Skip to content

Commit

Permalink
Paymaster_Bug_Fixes (#22)
Browse files Browse the repository at this point in the history
* Paymaster_Bug_Fixes

* updated package version
  • Loading branch information
vignesha22 authored Aug 24, 2023
1 parent 54de301 commit cc224d9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
## [1.1.6] - 2023-08-24
### Bug Fixes
- Fixes on User hash was created before initialising the paymaster response if given which leads to "Invalid signature or paymaster signature"

## [1.1.4] - 2023-08-21
### Breaking Changes
- Changed the way of initialising the Paymaster url to string as before it was unreachable code to get VerifyingPaymasterApi class to pass on to the Prime-Sdk
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@etherspot/prime-sdk",
"version": "1.1.5",
"version": "1.1.6",
"description": "Etherspot Prime (Account Abstraction) SDK",
"keywords": [
"ether",
Expand Down
3 changes: 2 additions & 1 deletion src/sdk/base/BaseAccountAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,13 @@ export abstract class BaseAccountAPI {
* @param userOp the UserOperation to sign (with signature field ignored)
*/
async signUserOp(userOp: UserOperationStruct): Promise<UserOperationStruct> {
const userOpHash = await this.getUserOpHash(userOp);
if (this.paymasterAPI != null) {
const paymasterAndData = await this.paymasterAPI.getPaymasterAndData(userOp);
userOp.paymasterAndData = paymasterAndData.paymasterAndData;
userOp.verificationGasLimit = BigNumber.from(paymasterAndData.verificationGasLimit);
userOp.preVerificationGas = paymasterAndData.preVerificationGas;
}
const userOpHash = await this.getUserOpHash(userOp);
const signature = await this.signUserOpHash(userOpHash);
return {
...userOp,
Expand Down
5 changes: 3 additions & 2 deletions src/sdk/base/VerifyingPaymasterAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const DUMMY_PAYMASTER_AND_DATA =
export interface paymasterResponse {
paymasterAndData: string;
verificationGasLimit: string;
preVerificationGas?: string;
}

export class VerifyingPaymasterAPI extends PaymasterAPI {
Expand Down Expand Up @@ -49,7 +50,7 @@ export class VerifyingPaymasterAPI extends PaymasterAPI {
op.preVerificationGas = calcPreVerificationGas(op);

// Ask the paymaster to sign the transaction and return a valid paymasterAndData value.
const paymasterAndData = axios
const paymasterAndData = await axios
.post<paymasterResponse>(this.paymasterUrl, {
jsonrpc: '2.0',
id: 1,
Expand All @@ -60,7 +61,7 @@ export class VerifyingPaymasterAPI extends PaymasterAPI {
return res.data
});

return paymasterAndData;
return {paymasterAndData: paymasterAndData.paymasterAndData, verificationGasLimit: paymasterAndData.verificationGasLimit, preVerificationGas: op.preVerificationGas.toString()};
}
}

Expand Down

0 comments on commit cc224d9

Please sign in to comment.