58
58
59
59
interface IERC6551Account {
60
60
function execute( address to, uint256 value, bytes calldata data, uint8 operation) external payable returns ( bytes memory) ;
61
+ function execute( address to, uint256 value, bytes calldata data, uint8 operation, uint256 txGas) external payable returns ( bytes memory) ;
61
62
function isValidSigner( address signer, bytes calldata data) external view returns ( bytes4 magicValue) ;
62
63
function token( ) external view returns ( uint256 chainId, address tokenContract, uint256 tokenId) ;
63
64
function setSignerDataKey( bytes32 signerDataKey) external;
@@ -492,7 +493,7 @@ where
492
493
}
493
494
494
495
// Create the ERC-6551 execute call
495
- let execute_call = IERC6551Account :: executeCall {
496
+ let execute_call = IERC6551Account :: execute_0Call {
496
497
to : * hypermap. address ( ) ,
497
498
value : U256 :: ZERO ,
498
499
data : hypermap_call_data,
@@ -1498,14 +1499,13 @@ pub fn set_gene<S: Signer>(
1498
1499
/// (e.g., via Hypermap notes like ~access-list) rather than the direct owner of the underlying NFT.
1499
1500
/// The TBA's own `execute` implementation is responsible for verifying the signer's authorization.
1500
1501
pub fn execute_via_tba_with_signer < S : Signer > (
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
1503
- target_address_or_name : & str , // Address or name of the contract to call via the TBA
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
1502
+ tba_address_or_name : & str ,
1503
+ hot_wallet_signer : & S ,
1504
+ target_address_or_name : & str ,
1505
+ call_data : Vec < u8 > ,
1506
+ value : U256 ,
1506
1507
provider : & Provider ,
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.
1508
+ operation : Option < u8 > ,
1509
1509
) -> Result < TxReceipt , WalletError > {
1510
1510
// Resolve addresses
1511
1511
let tba = resolve_name ( tba_address_or_name, provider. chain_id ) ?;
@@ -1521,35 +1521,40 @@ pub fn execute_via_tba_with_signer<S: Signer>(
1521
1521
value
1522
1522
) ;
1523
1523
1524
- // Create the outer execute call directed at the TBA
1525
- let execute_call = IERC6551Account :: executeCall {
1524
+ // Create the outer execute call (with txGas) directed at the TBA
1525
+ // Use the _1 suffix for the second defined execute function (5 args)
1526
+ let internal_gas_limit = U256 :: from ( 500_000 ) ; // Explicitly set gas for the internal call
1527
+ let execute_call = IERC6551Account :: execute_1Call { // <-- Using _1 suffix now
1526
1528
to : target,
1527
1529
value, // This value is sent from the TBA to the target
1528
1530
data : Bytes :: from ( call_data) ,
1529
1531
operation : op,
1532
+ txGas : internal_gas_limit, // Provide gas for the internal call
1530
1533
} ;
1531
1534
let execute_call_data = execute_call. abi_encode ( ) ;
1532
1535
1533
1536
// Format receipt message
1534
1537
let format_receipt = move |_| {
1535
1538
format ! (
1536
- "Execute via TBA {} to target {} (Signer: {})" ,
1539
+ "Execute via TBA {} to target {} (Signer: {}, Internal Gas: {} )" , // Updated log
1537
1540
tba_address_or_name,
1538
1541
target_address_or_name,
1539
- hot_wallet_signer. address( )
1542
+ hot_wallet_signer. address( ) ,
1543
+ internal_gas_limit // Log internal gas
1540
1544
)
1541
1545
} ;
1542
1546
1543
1547
// Prepare and send the transaction *to* the TBA, signed by the hot_wallet_signer.
1544
- // The `value` field in `prepare_and_send_tx` is U256::ZERO because the ETH transfer
1548
+ // The `value` field in the *outer* transaction is U256::ZERO because the ETH transfer
1545
1549
// happens *inside* the TBA's execution context, funded by the TBA itself.
1550
+ // prepare_and_send_tx will handle gas estimation for the outer transaction.
1546
1551
prepare_and_send_tx (
1547
1552
tba, // Transaction is sent TO the TBA address
1548
- execute_call_data, // Data is the ABI-encoded `execute` call
1553
+ execute_call_data, // Data is the ABI-encoded `execute` call with internal gas limit
1549
1554
U256 :: ZERO , // Outer transaction sends no ETH directly to the TBA
1550
1555
provider,
1551
1556
hot_wallet_signer, // Signed by the provided (potentially delegated) signer
1552
- gas_limit . or ( Some ( 500_000 ) ) , // Default gas limit for TBA executions
1557
+ None , // Let prepare_and_send_tx estimate outer gas limit
1553
1558
format_receipt,
1554
1559
)
1555
1560
}
@@ -1570,7 +1575,7 @@ pub fn tba_execute<S: Signer>(
1570
1575
let target = resolve_name ( target_address, provider. chain_id ) ?;
1571
1576
1572
1577
// Create the execute call
1573
- let execute_call = IERC6551Account :: executeCall {
1578
+ let execute_call = IERC6551Account :: execute_0Call {
1574
1579
to : target,
1575
1580
value,
1576
1581
data : Bytes :: from ( call_data) ,
0 commit comments