Skip to main content

Module configurable_account

Module configurable_account 

Source
Expand description

Tempo configurable accounts (T14: TIP-1107, TIP-1113).

Configurations are never stored locally. They are rebuilt from the chain: the latest ConfigurableAccountConfigUpdated or AccountUpgraded event of an account carries its full configuration, and its commitment must match getConfigCommitment. A 1-of-1, salt-0 account is recomputed from its owner key instead, which also covers accounts that have not sent their first transaction yet.

cast wallet reads and updates configurations with these helpers and combines owner approvals, including WebAuthn assertions made in a browser, into 0x05 signatures.

detect_configurable_account tells whether a sender is a configurable account, and ConfigurableAccountSigner signs its transactions with 0x05 signatures from local owner keys.

Re-exportsΒ§

use crate::FoundryTransactionBuilder; πŸ”’
use alloy_consensus::BlockHeader; πŸ”’
use alloy_network::BlockResponse; πŸ”’
use alloy_network::Network; πŸ”’
use alloy_network::TransactionBuilder; πŸ”’
use alloy_primitives::Address; πŸ”’
use alloy_primitives::B256; πŸ”’
use alloy_primitives::Bytes; πŸ”’
use alloy_primitives::U256; πŸ”’
use alloy_primitives::hex; πŸ”’
use alloy_primitives::hex; πŸ”’
use alloy_provider::Provider; πŸ”’
use alloy_rpc_types::BlockId; πŸ”’
use alloy_rpc_types::BlockNumberOrTag; πŸ”’
use alloy_rpc_types::Filter; πŸ”’
use alloy_rpc_types::Log; πŸ”’
use alloy_signer::Signer; πŸ”’
use alloy_sol_types::SolCall; πŸ”’
use alloy_sol_types::SolEvent; πŸ”’
use base64::Engine; πŸ”’
use base64::alphabet::URL_SAFE; πŸ”’
use base64::engine::DecodePaddingMode; πŸ”’
use base64::engine::GeneralPurpose; πŸ”’
use base64::engine::GeneralPurposeConfig; πŸ”’
use eyre::Context; πŸ”’
use eyre::Result; πŸ”’
use foundry_wallets::WalletSigner; πŸ”’
use p256::ecdsa::signature::hazmat::PrehashSigner; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Serialize; πŸ”’
use serde::Serialize; πŸ”’
use serde_json::Value; πŸ”’
use std::collections::BTreeMap; πŸ”’
use std::ffi::OsString; πŸ”’
use std::path::Path; πŸ”’
use std::path::PathBuf; πŸ”’
use std::sync::Arc; πŸ”’
use tempo_alloy::TempoNetwork; πŸ”’
use tempo_alloy::accounts::TempoAccessKey; πŸ”’
use tempo_alloy::accounts::TempoAccountsStore; πŸ”’
use tempo_alloy::accounts::TempoAccountsWallet; πŸ”’
use tempo_alloy::contracts::precompiles::CONFIGURABLE_ACCOUNT_ADDRESS; πŸ”’
use tempo_alloy::contracts::precompiles::IConfigurableAccount; πŸ”’
use tempo_alloy::contracts::precompiles::IConfigurableAccount::AccountUpgraded; πŸ”’
use tempo_alloy::contracts::precompiles::IConfigurableAccount::ConfigurableAccountConfigUpdated; πŸ”’
use tempo_alloy::contracts::precompiles::IConfigurableAccount::ConfigurableAccountOwner as AbiOwner; πŸ”’
use tempo_alloy::rpc::ConfigurableAccountSimulationApproval; πŸ”’
use tempo_alloy::rpc::ConfigurableAccountSimulationSpec; πŸ”’
use tempo_alloy::rpc::PrimitiveSignatureType; πŸ”’
use tempo_alloy::rpc::TempoTransactionRequest; πŸ”’
use tempo_primitives::SignatureType; πŸ”’
use tempo_primitives::TempoTxEnvelope; πŸ”’
use tempo_primitives::transaction::ConfigurableAccountConfig; πŸ”’
use tempo_primitives::transaction::ConfigurableAccountOwner; πŸ”’
use tempo_primitives::transaction::ConfigurableAccountSignature; πŸ”’
use tempo_primitives::transaction::KeychainSignature; πŸ”’
use tempo_primitives::transaction::MAX_CONFIGURABLE_ACCOUNT_SIGNATURES; πŸ”’
use tempo_primitives::transaction::PrimitiveSignature; πŸ”’
use tempo_primitives::transaction::TEMPO_TX_TYPE_ID; πŸ”’
use tempo_primitives::transaction::TempoSignature; πŸ”’
use tempo_primitives::transaction::TempoTransaction; πŸ”’
use tempo_primitives::transaction::configurable_account_digest; πŸ”’
use tempo_primitives::transaction::tt_signature::P256SignatureWithPreHash; πŸ”’
use tempo_primitives::transaction::tt_signature::WebAuthnSignature; πŸ”’

StructsΒ§

ConfigJson
A configuration as cast wallet owners --json prints it, and as forge script saves it for owners on other machines.
ConfigurableAccountSigner
Signs the transactions of a configurable account with 0x05 signatures from local owner keys, or, as an access key of another account (TIP-1111), with keychain V2 signatures that wrap them.
LinkedAccountFile πŸ”’
A keystore’s linked account sidecar.

EnumsΒ§

ConfigurableAccountOwnerKey
A local key that approves the transactions of the configurable accounts it owns.
LinkedAccountFileState
What the file at a linked account sidecar path holds.

ConstantsΒ§

LINKED_ACCOUNT_SUFFIX
Suffix of the sidecar file that links a keystore to the 1-of-1, salt-0 configurable account its key owns, next to the keystore as <keystore>.tempo-account.
LINKED_ACCOUNT_VERSION πŸ”’
The only linked account sidecar version this release writes and reads.
LOG_LOOKUP_WINDOW πŸ”’
Blocks per eth_getLogs request when a configuration lookup starts. The window is halved whenever the RPC rejects a request, which covers providers that cap the block range or the number of results.
T14_REQUIRED πŸ”’
The error for a configurable account operation on a chain before T14.

FunctionsΒ§

abi_owners
Returns config’s owners as IConfigurableAccount encodes them.
ca_error
Converts a Tempo configurable account error, which is not a std::error::Error.
check_config πŸ”’
Checks that config is the current configuration of account, whose stored commitment is commitment.
combine_approvals
Combines owner approvals of inner into a 0x05 signature for account.
config_commitment
Returns the configuration commitment of account at block, or None when the configurable account precompile is not active there: before T14 a call to it returns no data.
config_for_commitment πŸ”’
Returns the configuration of account that matches its commitment stored at block.
config_from_log πŸ”’
Rebuilds the configuration that a configuration event announces.
config_from_logs
Scans the configurable account precompile’s logs backwards from block for the latest configuration event of account, which must match commitment.
current_config
Returns the current configuration of account, rebuilt from the chain.
decode_unsigned_tx
Decodes an unsigned Tempo transaction as cast mktx --raw-unsigned encodes it.
detect_configurable_account
Tells whether account is a configurable account at block, and returns its configuration there.
ensure_link_available
Fails unless the linked account sidecar path of keystore is free or holds a link, which link_keystore may replace.
has_config
Tells whether config is still the configuration of account at the latest block. Fails when the commitment cannot be read, so that a failing RPC is not taken for a changed configuration.
link_keystore
Links keystore, whose key is owner, to the 1-of-1, salt-0 configurable account of owner, and returns that account. Fails when the sidecar path holds another file.
linked_account
Returns the configurable account linked to keystore and its owner key, or None when the keystore has no link. A keystore at the sidecar path is not a link.
linked_account_file_state
Returns what the file at path, a linked account sidecar path, holds.
linked_account_path
Returns the path of the linked account sidecar of keystore.
p256_public_key
Returns the affine coordinates of the public key of the P-256 key.
parse_config
Parses a configuration given as JSON, or as the path of a JSON file: salt, version, threshold and owners (each an owner and a weight), as cast wallet owners --json prints it, with or without its JSON envelope.
parse_owner_signature
Parses an owner approval: a hex Tempo primitive signature (65-byte secp256k1, 0x01 P-256 or 0x02 WebAuthn), a JSON signature, or a WebAuthn assertion made in a browser. A value naming an existing file is read from it.
parse_p256_key
Parses a hex P-256 private key.
parse_webauthn_assertion πŸ”’
Parses a browser WebAuthn assertion: authenticatorData, clientDataJSON and signature (an AuthenticatorAssertionResponse, at the top level or under response as PublicKeyCredential.toJSON() writes it), plus the credential’s P-256 publicKey. Binary fields are base64url or 0x-prefixed hex; the signature is DER or raw r || s.
prepare_request
Makes tx a Tempo transaction from account, whose gas estimate models the owner quorum of spec. A 0x05 signature only signs Tempo (0x76) transactions.
quorum
Returns the largest owner quorum among owners, or the smallest one unless largest is set, that the node accepts: at most [MAX_CONFIGURABLE_ACCOUNT_SIGNATURES] owners that, in address order, reach threshold only on the last one. owners are sorted by address. Returns an empty list when no quorum exists.
reaches_threshold
Tells whether owners among keys can approve for an account with config, as ConfigurableAccountSigner::new selects them.
sign_p256
Signs digest with the P-256 key as the 0x01 approval of a raw P-256 owner. The signature covers digest itself, without the SHA-256 pre-hash of WebCrypto keys.
sign_p256_low_s
Signs the prehash message with the P-256 key and returns a low-s (r, s), which Tempo’s verifier requires and about half of raw ECDSA signatures are not.
simulation_spec
Returns the owner quorum that gas estimation models for account: the owners in approvals with their key types or, when it is empty, the most approvals any valid signing set can need, as maximum-size WebAuthn approvals.
single_owner_account
Returns the account address of the 1-of-1, salt-0 configuration for owner.
single_owner_config
Returns the 1-of-1, salt-0 configuration that cast wallet new creates for owner.
stored_owner_keys
Returns the locally signable keys of the Tempo Accounts store on chain_id that own config. A missing or unreadable store has none.
unlink_keystore
Removes the link of keystore, and leaves any other file at its sidecar path alone.
updates_config
Tells whether a call to to with input updates the configuration of the account that sends it.