Skip to content

Commit

Permalink
Dummy Signature (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
vignesha22 authored Mar 8, 2024
1 parent 54a63a7 commit a16ca24
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 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.6.0] - 2024-03-08
### Bug Fixes
- Passed the dummy signature based on the type of smart wallet account to the paymaster

## [1.5.4] - 2024-03-01
### New
- The `DataUtils` module has been updated to fetch data from REST APIs provided by the new backend
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.5.4",
"version": "1.6.0",
"description": "Etherspot Prime (Account Abstraction) SDK",
"keywords": [
"ether",
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/base/BaseAccountAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ export abstract class BaseAccountAPI {
return {
...partialUserOp,
preVerificationGas: this.getPreVerificationGas(partialUserOp),
signature: '0x',
signature: info.dummySignature ?? '0x',
};
}

Expand Down
1 change: 1 addition & 0 deletions src/sdk/base/TransactionDetailsForUserOp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface TransactionDetailsForUserOp {
gasLimit?: BigNumberish;
maxFeePerGas?: BigNumberish;
maxPriorityFeePerGas?: BigNumberish;
dummySignature?: string;
}

export interface TransactionGasInfoForUserOp {
Expand Down
4 changes: 1 addition & 3 deletions src/sdk/base/VerifyingPaymasterAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export class VerifyingPaymasterAPI extends PaymasterAPI {
private paymasterUrl: string;
private entryPoint: string;
private context: any;
private api_key: string;
private chainId: number;
constructor(paymasterUrl: string, entryPoint: string, context: any) {
super();
this.paymasterUrl = paymasterUrl;
Expand All @@ -50,7 +48,7 @@ export class VerifyingPaymasterAPI extends PaymasterAPI {
maxPriorityFeePerGas: userOp.maxPriorityFeePerGas,
// A dummy value here is required in order to calculate a correct preVerificationGas value.
paymasterAndData: DUMMY_PAYMASTER_AND_DATA,
signature: ethers.utils.hexlify(Buffer.alloc(SIG_SIZE, 1)),
signature: userOp.signature ?? '0x',
};
const op = await ethers.utils.resolveProperties(pmOp);
op.preVerificationGas = calcPreVerificationGas(op);
Expand Down
18 changes: 9 additions & 9 deletions src/sdk/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ export class PrimeSdk {
key?: number
} = {}) {
const { paymasterDetails, gasDetails, callGasLimit, key } = params;
let dummySignature = "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";

/**
* Dummy signature used only in the case of zeroDev factory contract
*/
if (this.factoryUsed === Factory.ZERO_DEV) {
dummySignature = "0x00000000870fe151d548a1c527c3804866fab30abf28ed17b79d5fc5149f19ca0819fefc3c57f3da4fdf9b10fab3f2f3dca536467ae44943b9dbb8433efe7760ddd72aaa1c"
}

if (this.userOpsBatch.to.length < 1) {
throw new ErrorHandler('cannot sign empty transaction batch', 1);
Expand All @@ -182,6 +190,7 @@ export class PrimeSdk {
target: this.userOpsBatch.to,
values: this.userOpsBatch.value,
data: this.userOpsBatch.data,
dummySignature: dummySignature,
...gasDetails,
}

Expand All @@ -197,15 +206,6 @@ export class PrimeSdk {
partialtx.callGasLimit = BigNumber.from(callGasLimit).toHexString();
}

partialtx.signature = "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";

/**
* Dummy signature used only in the case of zeroDev factory contract
*/
if (this.factoryUsed === Factory.ZERO_DEV) {
partialtx.signature = "0x00000000870fe151d548a1c527c3804866fab30abf28ed17b79d5fc5149f19ca0819fefc3c57f3da4fdf9b10fab3f2f3dca536467ae44943b9dbb8433efe7760ddd72aaa1c"
}

const bundlerGasEstimate = await this.bundler.getVerificationGasInfo(partialtx);

// if user has specified the gas prices then use them
Expand Down

0 comments on commit a16ca24

Please sign in to comment.