Skip to content

Commit b0cd538

Browse files
committed
wip
1 parent eaf7222 commit b0cd538

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/wallet.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,32 +2749,34 @@ pub fn encode_usdc_paymaster_data(
27492749
}
27502750

27512751
/// Encode paymaster data for Circle's USDC paymaster
2752-
/// Format: abi.encode(uint256 verificationGasLimit, uint256 callGasLimit)
2753-
/// Note: The paymaster address is NOT included here - it goes in the separate paymaster field
2752+
/// Format: abi.encode(address paymaster, uint256 verificationGasLimit, uint256 callGasLimit)
2753+
/// Returns the complete ABI encoding that the paymaster expects to receive
27542754
pub fn encode_circle_paymaster_data(
27552755
paymaster: EthAddress,
27562756
verification_gas_limit: u128,
27572757
call_gas_limit: u128,
27582758
) -> Vec<u8> {
27592759
let mut data = Vec::new();
27602760

2761-
// First, add the paymaster address (20 bytes) - this will be extracted by the bundler
2762-
data.extend_from_slice(paymaster.as_slice());
2761+
// ABI encoding includes the paymaster address as the first parameter
2762+
// This matches the developer's example:
2763+
// encode(["address", "uint256", "uint256"], ['0x0578cFB241215b77442a541325d6A4E6dFE700Ec', 500000, 300000])
27632764

2764-
// Then add the ABI-encoded gas limits (what the paymaster actually expects)
2765+
// First parameter: paymaster address as uint256 (padded to 32 bytes)
2766+
let mut padded_address = vec![0u8; 12]; // 12 zero bytes for padding
2767+
padded_address.extend_from_slice(paymaster.as_slice()); // 20 bytes of address
2768+
data.extend_from_slice(&padded_address);
27652769

2766-
// Verification gas limit as uint256 (32 bytes)
2770+
// Second parameter: verification gas limit as uint256 (32 bytes)
27672771
let verification_gas_u256 = U256::from(verification_gas_limit);
27682772
data.extend_from_slice(&verification_gas_u256.to_be_bytes::<32>());
27692773

2770-
// Call gas limit as uint256 (32 bytes)
2774+
// Third parameter: call gas limit as uint256 (32 bytes)
27712775
let call_gas_u256 = U256::from(call_gas_limit);
27722776
data.extend_from_slice(&call_gas_u256.to_be_bytes::<32>());
27732777

2774-
// Total: 84 bytes (20 + 32 + 32)
2775-
// The bundler will split this into:
2776-
// - paymaster: first 20 bytes
2777-
// - paymasterData: remaining 64 bytes (the ABI-encoded gas limits)
2778+
// Total: 96 bytes (32 + 32 + 32)
2779+
// This is the complete ABI encoding the paymaster expects
27782780
data
27792781
}
27802782

0 commit comments

Comments
 (0)