MCPcopy
hub / github.com/eth-infinitism/account-abstraction / encodeUserOp

Function encodeUserOp

test/UserOp.ts:116–140  ·  view source on GitHub ↗
(userOp: UserOperation, forSignature = true)

Source from the content-addressed store, hash-verified

114}
115
116export function encodeUserOp (userOp: UserOperation, forSignature = true): string {
117 const packedUserOp = packUserOp(userOp)
118 if (forSignature) {
119 return defaultAbiCoder.encode(
120 ['bytes32',
121 'address', 'uint256', 'bytes32', 'bytes32',
122 'bytes32', 'uint256', 'bytes32',
123 'bytes32'],
124 [PACKED_USEROP_TYPEHASH,
125 packedUserOp.sender, packedUserOp.nonce, keccak256(packedUserOp.initCode), keccak256(packedUserOp.callData),
126 packedUserOp.accountGasLimits, packedUserOp.preVerificationGas, packedUserOp.gasFees,
127 keccakPaymasterAndData(hexlify(packedUserOp.paymasterAndData))])
128 } else {
129 // for the purpose of calculating gas cost encode also signature (and no keccak of bytes)
130 return defaultAbiCoder.encode(
131 ['bytes32',
132 'address', 'uint256', 'bytes', 'bytes',
133 'bytes32', 'uint256', 'bytes32',
134 'bytes', 'bytes'],
135 [PACKED_USEROP_TYPEHASH,
136 packedUserOp.sender, packedUserOp.nonce, packedUserOp.initCode, packedUserOp.callData,
137 packedUserOp.accountGasLimits, packedUserOp.preVerificationGas, packedUserOp.gasFees,
138 packedUserOp.paymasterAndData, packedUserOp.signature])
139 }
140}
141
142export function getUserOpHash (op: UserOperation, entryPoint: string, chainId: number): string {
143 const packed = encodeUserOp(op, true)

Callers 3

getUserOpHashFunction · 0.85
fillUserOpFunction · 0.85

Calls 2

packUserOpFunction · 0.85
keccakPaymasterAndDataFunction · 0.85

Tested by

no test coverage detected