Skip to content

Commit

Permalink
fix: update smart contract account to return gas limits in updateUser…
Browse files Browse the repository at this point in the history
…Operation
  • Loading branch information
montelaidev committed Feb 27, 2024
1 parent fea01e0 commit 79e4cc5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ const PATCH_USER_OPERATION_RESPONSE_MOCK: Awaited<
ReturnType<KeyringController['patchUserOperation']>
> = {
paymasterAndData: '0x123',
callGasLimit: '0x444',
verificationGasLimit: '0x555',
preVerificationGas: '0x667',
};

const SIGN_USER_OPERATION_RESPONSE_MOCK: Awaited<
Expand Down Expand Up @@ -222,6 +225,11 @@ describe('SnapSmartContractAccount', () => {

expect(response).toStrictEqual<UpdateUserOperationResponse>({
paymasterAndData: PATCH_USER_OPERATION_RESPONSE_MOCK.paymasterAndData,
callGasLimit: PATCH_USER_OPERATION_RESPONSE_MOCK.callGasLimit,
preVerificationGas:
PATCH_USER_OPERATION_RESPONSE_MOCK.preVerificationGas,
verificationGasLimit:
PATCH_USER_OPERATION_RESPONSE_MOCK.verificationGasLimit,
});

expect(patchMock).toHaveBeenCalledTimes(1);
Expand All @@ -244,6 +252,9 @@ describe('SnapSmartContractAccount', () => {

expect(response).toStrictEqual<UpdateUserOperationResponse>({
paymasterAndData: undefined,
callGasLimit: undefined,
preVerificationGas: undefined,
verificationGasLimit: undefined,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ export class SnapSmartContractAccount implements SmartContractAccount {
const { userOperation } = request;
const { sender } = userOperation;

const { paymasterAndData: responsePaymasterAndData } =
await this.#messenger.call(
'KeyringController:patchUserOperation',
sender,
userOperation,
);
const {
paymasterAndData: responsePaymasterAndData,
verificationGasLimit,
preVerificationGas,
callGasLimit,
} = await this.#messenger.call(
'KeyringController:patchUserOperation',
sender,
userOperation,
);

const paymasterAndData =
responsePaymasterAndData === EMPTY_BYTES
Expand All @@ -79,6 +83,9 @@ export class SnapSmartContractAccount implements SmartContractAccount {

return {
paymasterAndData,
verificationGasLimit,
preVerificationGas,
callGasLimit,
};
}

Expand Down

0 comments on commit 79e4cc5

Please sign in to comment.