File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
apps/iframe/src/requests/utils Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -187,15 +187,16 @@ function safeParseSignature(validatorData?: Hex) {
187187}
188188
189189export async function boopFromTransaction ( account : Address , tx : ValidRpcTransactionRequest ) : Promise < Boop > {
190- // TODO bigint casts need validation
191-
192190 return {
193- account : tx . from ?? account , // Use provided account if tx.from is not available
191+ account : tx . from ?? account ,
194192 dest : tx . to ,
195193 payer : zeroAddress , // happyPaymaster, // TODO need to fund paymaster
196- value : tx . value ? BigInt ( tx . value ) : 0n ,
194+ value : tx . value !== undefined ? ( parseBigInt ( tx . value ) ?? 0n ) : 0n ,
197195 nonceTrack : 0n ,
198- nonceValue : tx . nonce ? BigInt ( tx . nonce ) : await getNextNonce ( account ) ,
196+ nonceValue :
197+ tx . nonce !== undefined
198+ ? ( parseBigInt ( tx . nonce ) ?? ( await getNextNonce ( account ) ) )
199+ : await getNextNonce ( account ) ,
199200 callData : tx . data ?? "0x" ,
200201 validatorData : "0x" , // we will fill after signing
201202 extraData : createValidatorExtraData ( account , tx . to ) ,
Original file line number Diff line number Diff line change @@ -28,20 +28,21 @@ export function checkAuthenticated() {
2828/**
2929 * Type of valid tx requests, use {@link checkedTx} to verify.
3030 */
31- export type ValidRpcTransactionRequest = RpcTransactionRequest & { from : Address ; to : Address }
31+ export type ValidRpcTransactionRequest = RpcTransactionRequest & { to : Address }
3232
3333/**
3434 * Asserts that the transaction has its destination defined, throws a {@link EIP1474InvalidInput}.
3535 * @throws EIP1474InvalidInput if the transaction is malformatted
3636 */
3737export function checkedTx ( tx : RpcTransactionRequest ) : ValidRpcTransactionRequest {
38+ // Check required fields
3839 if ( ! tx . to ) /****/ throw new EIP1474InvalidInput ( "missing 'to' field in transaction parameters" )
39- if ( ! tx . from ) /**/ throw new EIP1474InvalidInput ( "missing 'from' field in transaction parameters" )
4040
41+ // Validate addresses
4142 if ( ! isAddress ( tx . to ) ) /****/ throw new EIP1474InvalidInput ( `not an address: ${ tx . to } ` )
42- if ( ! isAddress ( tx . from ) ) /**/ throw new EIP1474InvalidInput ( `not an address: ${ tx . from } ` )
43+ if ( tx . from !== undefined && ! isAddress ( tx . from ) ) /**/ throw new EIP1474InvalidInput ( `not an address: ${ tx . from } ` )
4344
44- // Check if value exists and can be parsed as BigInt (allows zero values)
45+ // Check if the value and nonce exist, and can be parsed as BigInt (allows zero values)
4546 if ( tx . value !== undefined && parseBigInt ( tx . value ) === undefined )
4647 throw new EIP1474InvalidInput ( `value is not a number: ${ tx . value } ` )
4748 if ( tx . nonce !== undefined && parseBigInt ( tx . nonce ) === undefined )
You can’t perform that action at this time.
0 commit comments