Skip to content

Commit

Permalink
fix: resolves #2783
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Sep 30, 2024
1 parent 61120a7 commit be2298c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-suns-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

**Account Abstraction**: Allowed override of `signature` property in `prepareUserOperation`.
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,48 @@ describe('entryPointVersion: 0.7', async () => {
`)
})

test('args: signature', async () => {
const request = await prepareUserOperation(bundlerClient, {
account,
calls: [
{
to: '0x0000000000000000000000000000000000000000',
value: parseEther('1'),
},
{
to: wagmiContractConfig.address,
abi: wagmiContractConfig.abi,
functionName: 'mint',
},
],
signature: '0xdeadbeef',
...fees,
})

expect({
...request,
maxFeePerGas: undefined,
account: undefined,
}).toMatchInlineSnapshot(`
{
"account": undefined,
"callData": "0x34fcd5be00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fba3912ca04dd458c843e2ee08967fc04f3579c20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000041249c58b00000000000000000000000000000000000000000000000000000000",
"callGasLimit": 141653n,
"factory": "0xfb6dab6200b8958c2655c3747708f82243d3f32e",
"factoryData": "0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000",
"maxFeePerGas": undefined,
"maxPriorityFeePerGas": 2000000000n,
"nonce": 30902162761279602895850647322624n,
"paymasterPostOpGasLimit": 0n,
"paymasterVerificationGasLimit": 0n,
"preVerificationGas": 51246n,
"sender": "0xE911628bF8428C23f179a07b081325cAe376DE1f",
"signature": "0xdeadbeef",
"verificationGasLimit": 254502n,
}
`)
})

test('behavior: account.userOperation.estimateGas', async () => {
const request = await prepareUserOperation(bundlerClient, {
account: {
Expand Down Expand Up @@ -616,7 +658,7 @@ describe('entryPointVersion: 0.7', async () => {
"factoryData": "0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000",
"maxFeePerGas": 15000000000n,
"maxPriorityFeePerGas": 2000000000n,
"nonce": 30902162761279602895850647322624n,
"nonce": 30902162761298049639924356874240n,
"paymasterPostOpGasLimit": 0n,
"paymasterVerificationGasLimit": 0n,
"preVerificationGas": 53438n,
Expand Down Expand Up @@ -667,7 +709,7 @@ describe('entryPointVersion: 0.7', async () => {
"factoryData": "0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000",
"maxFeePerGas": 15000000000n,
"maxPriorityFeePerGas": 2000000000n,
"nonce": 30902162761298049639924356874240n,
"nonce": 30902162761316496383998066425856n,
"preVerificationGas": 1000000n,
"sender": "0xE911628bF8428C23f179a07b081325cAe376DE1f",
"signature": "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",
Expand Down Expand Up @@ -746,7 +788,7 @@ describe('entryPointVersion: 0.7', async () => {
"factoryData": "0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000",
"maxFeePerGas": 3000000n,
"maxPriorityFeePerGas": 1000000n,
"nonce": 30902162761334943128071775977472n,
"nonce": 30902162761353389872145485529088n,
"paymasterPostOpGasLimit": 0n,
"paymasterVerificationGasLimit": 0n,
"preVerificationGas": 53438n,
Expand Down Expand Up @@ -823,9 +865,9 @@ describe('entryPointVersion: 0.7', async () => {
"factoryData": "0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000",
"maxFeePerGas": 15000000000n,
"maxPriorityFeePerGas": 2000000000n,
"nonce": 30902162761371836616219195080704n,
"nonce": 30902162761390283360292904632320n,
"paymaster": "0x41219a0a9c0b86ed81933c788a6b63dfef8f17ee",
"paymasterData": "0x00000000000000000000000000000000000000000000000000000000deadbeef0000000000000000000000000000000000000000000000000000000000001234b2719774d995cd5fa330119925e62f9c76678b5bb1eed58d76872ee390e09f1c35f7facfbd4708e4b2bd673d97c228d4c06cc71b2ba516b1ebac5c8a41dcdd031c",
"paymasterData": "0x00000000000000000000000000000000000000000000000000000000deadbeef0000000000000000000000000000000000000000000000000000000000001234fc6dca78f243df7d59c299a92b566ac102011e79a5a72c21921be882d1d42bd10b8bd6cb743fe39c2bca82fac658a474fb273f1eeb2e4dbf056e62877b87fe7b1b",
"paymasterPostOpGasLimit": 1000000n,
"paymasterVerificationGasLimit": 1000000n,
"preVerificationGas": 59826n,
Expand Down Expand Up @@ -881,9 +923,9 @@ describe('entryPointVersion: 0.7', async () => {
"factoryData": "0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000",
"maxFeePerGas": 15000000000n,
"maxPriorityFeePerGas": 2000000000n,
"nonce": 30902162761390283360292904632320n,
"nonce": 30902162761408730104366614183936n,
"paymaster": "0x1d460d731bd5a0ff2ca07309daeb8641a7b175a1",
"paymasterData": "0x00000000000000000000000000000000000000000000000000000000deadbeef00000000000000000000000000000000000000000000000000000000000012347701ca0b1096ba1604f54a530cf69176938f882b58290c4238826eb034e898574adee6bf25406d3f5ffbfbae2cb438e9700e60590454a8aa4b5f68331ae2e5a31b",
"paymasterData": "0x00000000000000000000000000000000000000000000000000000000deadbeef0000000000000000000000000000000000000000000000000000000000001234382583762a2f2d8c5d57aab2ec3c7a899190e43c06114cab15b103da3e076c0330dcf7d93cc5cfdd95be5b81c3724d56576637c370f8a686591cfedffff3e06f1b",
"paymasterPostOpGasLimit": 1000000n,
"paymasterVerificationGasLimit": 1000000n,
"preVerificationGas": 59826n,
Expand Down Expand Up @@ -942,9 +984,9 @@ describe('entryPointVersion: 0.7', async () => {
"factoryData": "0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000",
"maxFeePerGas": 15000000000n,
"maxPriorityFeePerGas": 2000000000n,
"nonce": 30902162761408730104366614183936n,
"nonce": 30902162761427176848440323735552n,
"paymaster": "0xf67e26649037695ddfab19f4e22d5c9fd1564592",
"paymasterData": "0x00000000000000000000000000000000000000000000000000000000deadbeef000000000000000000000000000000000000000000000000000000000000123457a075b288aba9b1142feb8f64d2b91235482c499879d45a3bc30cae3226ce07089684444bfcd45ca3978261b97bc43a17b17486a2e4e6638e142db17eb2455c1b",
"paymasterData": "0x00000000000000000000000000000000000000000000000000000000deadbeef000000000000000000000000000000000000000000000000000000000000123481cad233167ea1d8ed383d4a460c9f9ea3853d8de80f3bbae3f7532c0bc3cd707ebf52eefb227b068f3c14dbf113cbbba5b3ff893d9bbeef622557f52fe2496e1b",
"paymasterPostOpGasLimit": 1000000n,
"paymasterVerificationGasLimit": 1000000n,
"preVerificationGas": 59826n,
Expand Down Expand Up @@ -997,9 +1039,9 @@ describe('entryPointVersion: 0.7', async () => {
"factoryData": "0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000",
"maxFeePerGas": 15000000000n,
"maxPriorityFeePerGas": 2000000000n,
"nonce": 30902162761427176848440323735552n,
"nonce": 30902162761445623592514033287168n,
"paymaster": "0xea8ae08513f8230caa8d031d28cb4ac8ce720c68",
"paymasterData": "0x00000000000000000000000000000000000000000000000000000000deadbf18000000000000000000000000000000000000000000000000000000000000123456fda50df3bba7b6286b8686ed97a70aa789a1a7b51052d8ae5f59db564c54db5d9ba52d54b4553c74d9872ed6fa96443ef6d1a7a0e77d458f7065f877295e071b",
"paymasterData": "0x00000000000000000000000000000000000000000000000000000000deadbf18000000000000000000000000000000000000000000000000000000000000123473e52a4667dd3ef6df23825f569d0902f5961bf96056008fd91d41513ef8eee467fffc20a829c697d364c1063c2b249fa87ea14430c89638052ce217a3ae34841b",
"paymasterPostOpGasLimit": 1000000n,
"paymasterVerificationGasLimit": 1000000n,
"preVerificationGas": 59826n,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ export async function prepareUserOperation<
})(),
(async () => {
if (!properties.includes('signature')) return undefined
if (typeof parameters.signature !== 'undefined')
return parameters.signature
return account.getStubSignature()
})(),
])
Expand Down

0 comments on commit be2298c

Please sign in to comment.