Skip to content

Commit ca26d85

Browse files
committed
wip
1 parent e6ba986 commit ca26d85

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

src/wallet.rs

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,33 +2744,29 @@ pub fn encode_usdc_paymaster_data(
27442744
token_address: EthAddress,
27452745
max_cost: U256,
27462746
) -> Vec<u8> {
2747-
// Start with paymaster address (20 bytes)
2747+
// Use the new Circle format with default gas limits
2748+
encode_circle_paymaster_data(paymaster, 500_000, 300_000)
2749+
}
2750+
2751+
/// Encode paymaster data for Circle's USDC paymaster
2752+
/// Format: abi.encodePacked(address paymaster, uint128 verificationGasLimit, uint128 callGasLimit)
2753+
pub fn encode_circle_paymaster_data(
2754+
paymaster: EthAddress,
2755+
verification_gas_limit: u128,
2756+
call_gas_limit: u128,
2757+
) -> Vec<u8> {
27482758
let mut data = Vec::new();
2759+
2760+
// Paymaster address (20 bytes)
27492761
data.extend_from_slice(paymaster.as_slice());
2750-
2751-
// Add paymaster-specific data for Circle's TokenPaymaster v0.8
2752-
// Format: encodePacked([uint8, address, uint256, bytes])
2753-
// - uint8: mode (0 for permit mode)
2754-
// - address: USDC token address
2755-
// - uint256: permit amount
2756-
// - bytes: permit signature (dummy for now)
2757-
2758-
// Mode byte (0 for permit mode)
2759-
data.push(0u8);
2760-
2761-
// Token address (USDC)
2762-
data.extend_from_slice(token_address.as_slice());
2763-
2764-
// Permit amount - use a reasonable amount for gas payment
2765-
// 10 USDC should be more than enough for any transaction
2766-
let permit_amount = U256::from(10_000_000u64); // 10 USDC in 6 decimal units
2767-
data.extend_from_slice(&permit_amount.to_be_bytes::<32>());
2768-
2769-
// Permit signature - DUMMY SIGNATURE
2770-
// In production, this needs to be a real EIP-2612 permit signature
2771-
let dummy_signature = vec![0u8; 65]; // r (32) + s (32) + v (1)
2772-
data.extend_from_slice(&dummy_signature);
2773-
2762+
2763+
// Verification gas limit as uint128 (16 bytes)
2764+
data.extend_from_slice(&verification_gas_limit.to_be_bytes());
2765+
2766+
// Call gas limit as uint128 (16 bytes)
2767+
data.extend_from_slice(&call_gas_limit.to_be_bytes());
2768+
2769+
// Total: 52 bytes (20 + 16 + 16)
27742770
data
27752771
}
27762772

0 commit comments

Comments
 (0)