11
11
use crate :: eth:: { BlockNumberOrTag , EthError , Provider } ;
12
12
use crate :: hypermap;
13
13
use crate :: hypermap:: { namehash, valid_fact, valid_name, valid_note} ;
14
- use crate :: signer:: { EncryptedSignerData , LocalSigner , Signer , SignerError , TransactionData } ;
15
14
use crate :: println as kiprintln;
15
+ use crate :: signer:: { EncryptedSignerData , LocalSigner , Signer , SignerError , TransactionData } ;
16
16
17
17
use alloy:: rpc:: types:: {
18
- request:: TransactionRequest , Filter , FilterBlockOption , FilterSet ,
19
- TransactionReceipt ,
18
+ request:: TransactionRequest , Filter , FilterBlockOption , FilterSet , TransactionReceipt ,
20
19
} ;
21
20
use alloy_primitives:: TxKind ;
22
- use alloy_primitives:: { Address as EthAddress , Bytes , TxHash , U256 , B256 } ;
21
+ use alloy_primitives:: { Address as EthAddress , Bytes , TxHash , B256 , U256 } ;
23
22
use alloy_sol_types:: { sol, SolCall } ;
24
23
use serde:: { Deserialize , Serialize } ;
25
24
use std:: str:: FromStr ;
@@ -1499,14 +1498,14 @@ pub fn set_gene<S: Signer>(
1499
1498
/// (e.g., via Hypermap notes like ~access-list) rather than the direct owner of the underlying NFT.
1500
1499
/// The TBA's own `execute` implementation is responsible for verifying the signer's authorization.
1501
1500
pub fn execute_via_tba_with_signer < S : Signer > (
1502
- tba_address_or_name : & str , // Address or name of the TBA to execute through
1503
- hot_wallet_signer : & S , // The signer (e.g., hot wallet) authorized to call execute
1501
+ tba_address_or_name : & str , // Address or name of the TBA to execute through
1502
+ hot_wallet_signer : & S , // The signer (e.g., hot wallet) authorized to call execute
1504
1503
target_address_or_name : & str , // Address or name of the contract to call via the TBA
1505
- call_data : Vec < u8 > , // ABI-encoded data for the call to the target contract
1506
- value : U256 , // ETH value to send with the call to the target contract
1504
+ call_data : Vec < u8 > , // ABI-encoded data for the call to the target contract
1505
+ value : U256 , // ETH value to send with the call to the target contract
1507
1506
provider : & Provider ,
1508
- operation : Option < u8 > , // ERC-6551 operation type (0=CALL, 1=DELEGATECALL, etc.). Defaults to 0.
1509
- gas_limit : Option < u64 > , // Optional gas limit override. Defaults to 500,000.
1507
+ operation : Option < u8 > , // ERC-6551 operation type (0=CALL, 1=DELEGATECALL, etc.). Defaults to 0.
1508
+ gas_limit : Option < u64 > , // Optional gas limit override. Defaults to 500,000.
1510
1509
) -> Result < TxReceipt , WalletError > {
1511
1510
// Resolve addresses
1512
1511
let tba = resolve_name ( tba_address_or_name, provider. chain_id ) ?;
@@ -1522,7 +1521,6 @@ pub fn execute_via_tba_with_signer<S: Signer>(
1522
1521
value
1523
1522
) ;
1524
1523
1525
-
1526
1524
// Create the outer execute call directed at the TBA
1527
1525
let execute_call = IERC6551Account :: executeCall {
1528
1526
to : target,
@@ -1536,25 +1534,26 @@ pub fn execute_via_tba_with_signer<S: Signer>(
1536
1534
let format_receipt = move |_| {
1537
1535
format ! (
1538
1536
"Execute via TBA {} to target {} (Signer: {})" ,
1539
- tba_address_or_name, target_address_or_name, hot_wallet_signer. address( )
1537
+ tba_address_or_name,
1538
+ target_address_or_name,
1539
+ hot_wallet_signer. address( )
1540
1540
)
1541
1541
} ;
1542
1542
1543
1543
// Prepare and send the transaction *to* the TBA, signed by the hot_wallet_signer.
1544
1544
// The `value` field in `prepare_and_send_tx` is U256::ZERO because the ETH transfer
1545
1545
// happens *inside* the TBA's execution context, funded by the TBA itself.
1546
1546
prepare_and_send_tx (
1547
- tba, // Transaction is sent TO the TBA address
1548
- execute_call_data, // Data is the ABI-encoded `execute` call
1549
- U256 :: ZERO , // Outer transaction sends no ETH directly to the TBA
1547
+ tba, // Transaction is sent TO the TBA address
1548
+ execute_call_data, // Data is the ABI-encoded `execute` call
1549
+ U256 :: ZERO , // Outer transaction sends no ETH directly to the TBA
1550
1550
provider,
1551
- hot_wallet_signer, // Signed by the provided (potentially delegated) signer
1551
+ hot_wallet_signer, // Signed by the provided (potentially delegated) signer
1552
1552
gas_limit. or ( Some ( 500_000 ) ) , // Default gas limit for TBA executions
1553
1553
format_receipt,
1554
1554
)
1555
1555
}
1556
1556
1557
-
1558
1557
/// Executes a call through a Token Bound Account (TBA)
1559
1558
/// Assumes the provided signer is the owner/controller authorized by the standard ERC6551 implementation.
1560
1559
pub fn tba_execute < S : Signer > (
@@ -1700,7 +1699,7 @@ pub fn tba_set_signer_data_key<S: Signer>(
1700
1699
/// and then configures the entry's TBA to use this note for alternative signature validation.
1701
1700
/// Requires the signature of the *owner* of the Hypermap entry.
1702
1701
pub fn setup_alternative_signer < S : Signer > (
1703
- entry_name : & str , // e.g., "username.hypr"
1702
+ entry_name : & str , // e.g., "username.hypr"
1704
1703
alt_signer_address : EthAddress , // The address allowed to sign alternatively
1705
1704
provider : & Provider ,
1706
1705
owner_signer : & S , // Signer holding the key that owns 'entry_name'
0 commit comments