abstractionkit 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/Bundler.d.ts +8 -7
  2. package/dist/Bundler.d.ts.map +1 -1
  3. package/dist/abstractionkit.d.ts +8 -4
  4. package/dist/abstractionkit.d.ts.map +1 -1
  5. package/dist/account/Safe/SafeAccount.d.ts +33 -0
  6. package/dist/account/Safe/SafeAccount.d.ts.map +1 -0
  7. package/dist/account/Safe/multisend.d.ts +2 -3
  8. package/dist/account/Safe/multisend.d.ts.map +1 -1
  9. package/dist/account/Safe/types.d.ts +16 -5
  10. package/dist/account/Safe/types.d.ts.map +1 -1
  11. package/dist/account/SendUseroperationResponse.d.ts +2 -2
  12. package/dist/account/SendUseroperationResponse.d.ts.map +1 -1
  13. package/dist/account/SmartAccount.d.ts +3 -3
  14. package/dist/account/SmartAccount.d.ts.map +1 -1
  15. package/dist/constants.d.ts +2 -2
  16. package/dist/constants.d.ts.map +1 -1
  17. package/dist/factory/SimpleAccountFactory.d.ts +5 -0
  18. package/dist/factory/SimpleAccountFactory.d.ts.map +1 -0
  19. package/dist/factory/SmartAccountFactory.d.ts +2 -1
  20. package/dist/factory/SmartAccountFactory.d.ts.map +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/index.m.js +1 -1
  23. package/dist/index.modern.mjs +1 -1
  24. package/dist/index.umd.js +1 -1
  25. package/dist/paymaster/CandideValidationPaymaster.d.ts +13 -0
  26. package/dist/paymaster/CandideValidationPaymaster.d.ts.map +1 -0
  27. package/dist/paymaster/Paymaster.d.ts +6 -3
  28. package/dist/paymaster/Paymaster.d.ts.map +1 -1
  29. package/dist/types.d.ts +59 -49
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/utils.d.ts +7 -7
  32. package/dist/utils.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/account/Safe/SafeAccountV0_2_0.d.ts +0 -37
  35. package/dist/account/Safe/SafeAccountV0_2_0.d.ts.map +0 -1
  36. package/dist/errors.d.ts +0 -24
  37. package/dist/errors.d.ts.map +0 -1
  38. package/dist/paymaster/CandidePaymaster.d.ts +0 -22
  39. package/dist/paymaster/CandidePaymaster.d.ts.map +0 -1
  40. package/dist/paymaster/types.d.ts +0 -4
  41. package/dist/paymaster/types.d.ts.map +0 -1
package/dist/Bundler.d.ts CHANGED
@@ -1,12 +1,13 @@
1
- import type { UserOperation, GasEstimationResult, UserOperationByHashResult, UserOperationReceiptResult, StateOverrideSet } from "./types";
1
+ import type { UserOperation, BundlerJsonRpcError, GasEstimationResult, UserOperationByHashResult, UserOperationReceiptResult, StateOverrideSet } from "./types";
2
+ import { BytesLike } from "ethers";
2
3
  export declare class Bundler {
3
4
  readonly rpcUrl: string;
4
5
  constructor(rpcUrl: string);
5
- chainId(): Promise<string>;
6
- supportedEntryPoints(): Promise<string[]>;
7
- estimateUserOperationGas(useroperation: UserOperation, entrypointAddress: string, state_override_set?: StateOverrideSet): Promise<GasEstimationResult>;
8
- sendUserOperation(useroperation: UserOperation, entrypointAddress: string): Promise<string>;
9
- getUserOperationReceipt(useroperationhash: string): Promise<UserOperationReceiptResult>;
10
- getUserOperationByHash(useroperationhash: string): Promise<UserOperationByHashResult>;
6
+ chainId(): Promise<string | BundlerJsonRpcError>;
7
+ supportedEntryPoints(): Promise<string[] | BundlerJsonRpcError>;
8
+ estimateUserOperationGas(useroperation: UserOperation, entrypointAddress: string, state_override_set?: StateOverrideSet): Promise<GasEstimationResult | BundlerJsonRpcError>;
9
+ sendUserOperation(useroperation: UserOperation, entrypointAddress: string): Promise<string | BundlerJsonRpcError>;
10
+ getUserOperationReceipt(useroperationhash: BytesLike): Promise<UserOperationReceiptResult | BundlerJsonRpcError>;
11
+ getUserOperationByHash(useroperationhash: BytesLike): Promise<UserOperationByHashResult | BundlerJsonRpcError>;
11
12
  }
12
13
  //# sourceMappingURL=Bundler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Bundler.d.ts","sourceRoot":"","sources":["../src/Bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EAEzB,0BAA0B,EAC1B,gBAAgB,EAEhB,MAAM,SAAS,CAAC;AAIjB,qBAAa,OAAO;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;IAQpB,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAgC1B,oBAAoB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IA4BzC,wBAAwB,CAC7B,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,CAAC,EAAE,gBAAgB,GACnC,OAAO,CAAC,mBAAmB,CAAC;IA2CzB,iBAAiB,CACtB,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC;IA0BZ,uBAAuB,CAC5B,iBAAiB,EAAE,MAAM,GACvB,OAAO,CAAC,0BAA0B,CAAC;IAyDhC,sBAAsB,CAC3B,iBAAiB,EAAE,MAAM,GACvB,OAAO,CAAC,yBAAyB,CAAC;CA+BrC"}
1
+ {"version":3,"file":"Bundler.d.ts","sourceRoot":"","sources":["../src/Bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EAEzB,0BAA0B,EAC1B,gBAAgB,EAEhB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGnC,qBAAa,OAAO;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;IAIpB,OAAO,IAAI,OAAO,CAAC,MAAM,GAAE,mBAAmB,CAAC;IAa/C,oBAAoB,IAAI,OAAO,CACpC,MAAM,EAAE,GAAG,mBAAmB,CAC9B;IAcK,wBAAwB,CAC7B,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,CAAC,EAAE,gBAAgB,GACnC,OAAO,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IAsB/C,iBAAiB,CACtB,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,GAAG,mBAAmB,CAAC;IAclC,uBAAuB,CAC5B,iBAAiB,EAAE,SAAS,GAC1B,OAAO,CAAC,0BAA0B,GAAG,mBAAmB,CAAC;IAyBtD,sBAAsB,CAC3B,iBAAiB,EAAE,SAAS,GAC1B,OAAO,CAAC,yBAAyB,GAAG,mBAAmB,CAAC;CAa3D"}
@@ -1,10 +1,14 @@
1
1
  export { SmartAccount } from "./account/SmartAccount";
2
- export { SafeAccountV0_2_0 } from "./account/Safe/SafeAccountV0_2_0";
2
+ export { MetaTransaction } from "./account/Safe/types";
3
+ export { SafeAccount } from "./account/Safe/SafeAccount";
3
4
  export { SendUseroperationResponse } from "./account/SendUseroperationResponse";
4
5
  export { SmartAccountFactory } from "./factory/SmartAccountFactory";
5
6
  export { SafeAccountFactory } from "./factory/SafeAccountFactory";
7
+ export { SimpleAccountFactory } from "./factory/SimpleAccountFactory";
6
8
  export { Bundler } from "./Bundler";
7
- export { CandidePaymaster } from "./paymaster/CandidePaymaster";
8
- export { createUserOperationHash, createCallData, getFunctionSelector, fetchAccountNonce, calculateUserOperationMaxGasCost, } from "./utils";
9
- export { UserOperation, AbiInputValue, JsonRpcParam, JsonRpcResponse, JsonRpcResult, GasEstimationResult, UserOperationByHashResult, UserOperationReceipt, UserOperationReceiptResult, JsonRpcError, StateOverrideSet, Operation, MetaTransaction, } from "./types";
9
+ export { CandideValidationPaymaster } from "./paymaster/CandideValidationPaymaster";
10
+ export { createUserOperationHash, createCallData, getFunctionSelector, fetchAccountNonce } from "./utils";
11
+ export { UserOperationEmptyValues, UserOperationDummyValues } from "./constants";
12
+ export { Operation } from "./types";
13
+ export type { UserOperation, AbiInputValue, JsonRpcParam, JsonRpcResponse, JsonRpcResult, BundlerJsonRpcError, GasEstimationResult, UserOperationByHashResult, UserOperationReceipt, UserOperationReceiptResult, JsonRpcError, } from "./types";
10
14
  //# sourceMappingURL=abstractionkit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstractionkit.d.ts","sourceRoot":"","sources":["../src/abstractionkit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EACN,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,gCAAgC,GAChC,MAAM,SAAS,CAAC;AAEjB,OAAO,EACN,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,eAAe,GACf,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"abstractionkit.d.ts","sourceRoot":"","sources":["../src/abstractionkit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAA;AAEjF,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,YAAY,EACX,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,YAAY,GACZ,MAAM,SAAS,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { BytesLike } from "ethers";
2
+ import { SmartAccount } from "../SmartAccount";
3
+ import { BundlerJsonRpcError, JsonRpcError, Operation, UserOperation } from "../../types";
4
+ import { SafeAccountFactory } from "../../factory/SafeAccountFactory";
5
+ import { CreateUserOperationOverrides, InitCodeOverrides, MetaTransaction, SafeModuleExecutorFunctionSelector } from "./types";
6
+ import { SendUseroperationResponse } from "../SendUseroperationResponse";
7
+ export declare class SafeAccount extends SmartAccount {
8
+ static readonly DEFAULT_ENTRYPOINT_ADDRESS = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";
9
+ static readonly DEFAULT_SAFE_4337_MODULE_ADDRESS = "0xD556564bAcF6FEAC2E26ff70695f8250Cea8C29E";
10
+ static readonly DEFAULT_SINGLETON_ADDRESS = "0x41675C099F32341bf84BFc5382aF534df5C7461a";
11
+ static readonly DEFAULT_ADD_MODULE_LIB_ADDRESS = "0xea2B4251c7C1cDFFc04D35d990AF6Fd0309928B3";
12
+ static readonly DEFAULT_MULTISEND_CONTRACT_ADDRESS = "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526";
13
+ static readonly proxyByteCode: BytesLike;
14
+ static readonly initializerFunctionSelector: string;
15
+ static readonly initializerFunctionInputAbi: string[];
16
+ static readonly DEFAULT_EXECUTOR_FUCNTION_SELECTOR = SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString;
17
+ static readonly executorFunctionInputAbi: string[];
18
+ readonly entrypointAddress: string;
19
+ readonly safe4337ModuleAddress: string;
20
+ constructor(accountAddress: string, entrypointAddress?: string, safe4337ModuleAddress?: string);
21
+ static createAccountAddressAndInitCode(owners: string[], overrides?: InitCodeOverrides): [string, BytesLike];
22
+ static createInitializerCallData(owners: string[], threshold: number, safe4337ModuleAddress?: string, addModuleLibAddress?: string): BytesLike;
23
+ static createInitCode(owners: string[], threshold?: number, c2Nonce?: bigint, singletonAddress?: string, safeAccountFactory?: SafeAccountFactory, safe4337ModuleAddress?: string, addModuleLibAddress?: string): BytesLike;
24
+ static createProxyAddress(initializerCallData: BytesLike, c2Nonce: bigint, safeFactoryAddress: string, singletonAddress: string): string;
25
+ static createAccountCallDataSingleTransaction(tx: MetaTransaction): BytesLike;
26
+ static createAccountCallDataBatchTransactions(metaTransactions: MetaTransaction[], multisendContractAddress?: string): BytesLike;
27
+ static createAccountCallData(to: string, value: bigint, data: BytesLike, operation: Operation, safeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector): BytesLike;
28
+ static estimateUserOperationGas(user_operation: UserOperation, entrypointAddress: string, bundlerRpc: string): Promise<[bigint, bigint, bigint] | BundlerJsonRpcError>;
29
+ signUserOperation(useroperation: UserOperation, privateKeys: string[], chainId: bigint, validAfter?: bigint, validUntil?: bigint): string;
30
+ createUserOperation(transactions: MetaTransaction[], providerRpc: string, bundlerRpc: string, overrids?: CreateUserOperationOverrides): Promise<UserOperation | JsonRpcError | BundlerJsonRpcError>;
31
+ sendUserOperation(user_operation: UserOperation, bundlerRpc: string): Promise<SendUseroperationResponse | BundlerJsonRpcError>;
32
+ }
33
+ //# sourceMappingURL=SafeAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeAccount.d.ts","sourceRoot":"","sources":["../../../src/account/Safe/SafeAccount.ts"],"names":[],"mappings":"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"}
@@ -1,4 +1,3 @@
1
- import { MetaTransaction } from "src/types";
2
- export declare function encodeMultiSendCallData(metaTransactions: MetaTransaction[]): string;
3
- export declare function decodeMultiSendCallData(callData: string): string;
1
+ import { MetaTransaction } from "./types";
2
+ export declare function encodeMultiSendCallData(txs: MetaTransaction[]): string;
4
3
  //# sourceMappingURL=multisend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"multisend.d.ts","sourceRoot":"","sources":["../../../src/account/Safe/multisend.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAa,MAAM,WAAW,CAAC;AAuBvD,wBAAgB,uBAAuB,CACtC,gBAAgB,EAAE,eAAe,EAAE,GACjC,MAAM,CAIR;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIhE"}
1
+ {"version":3,"file":"multisend.d.ts","sourceRoot":"","sources":["../../../src/account/Safe/multisend.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAc1C,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,MAAM,CAEtE"}
@@ -1,15 +1,26 @@
1
- import type { StateOverrideSet } from "../../types";
1
+ import { BytesLike } from "ethers";
2
+ import type { Operation } from "../../types";
3
+ export interface MetaTransactionInput {
4
+ to: string;
5
+ value?: bigint;
6
+ data?: BytesLike;
7
+ operation?: Operation;
8
+ }
9
+ export interface MetaTransaction {
10
+ to: string;
11
+ value: bigint;
12
+ data: BytesLike;
13
+ operation?: Operation;
14
+ }
2
15
  export interface CreateUserOperationOverrides {
3
16
  nonce?: bigint;
4
- initCode?: string;
5
- callData?: string;
17
+ initCode?: BytesLike;
18
+ callData?: BytesLike;
6
19
  callGasLimit?: bigint;
7
20
  verificationGasLimit?: bigint;
8
21
  preVerificationGas?: bigint;
9
22
  maxFeePerGas?: bigint;
10
23
  maxPriorityFeePerGas?: bigint;
11
- numberOfSigners?: number;
12
- state_override_set?: StateOverrideSet;
13
24
  }
14
25
  export interface InitCodeOverrides {
15
26
  threshold?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/account/Safe/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpD,MAAM,WAAW,4BAA4B;IAE5C,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAI9B,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;CACtC;AAKD,MAAM,WAAW,iBAAiB;IAIjC,SAAS,CAAC,EAAE,MAAM,CAAC;IAInB,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAInC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAI/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAKD,oBAAY,kCAAkC;IAC7C,4BAA4B,eAAe;IAC3C,aAAa,eAAe;CAC5B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/account/Safe/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB;AAED,MAAM,WAAW,4BAA4B;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,oBAAY,kCAAkC;IAC7C,4BAA4B,eAAe;IAC3C,aAAa,eAAe;CAC5B"}
@@ -1,11 +1,11 @@
1
1
  import { Bundler } from "src/Bundler";
2
- import { UserOperationReceiptResult } from "src/types";
2
+ import { BundlerJsonRpcError, UserOperationReceiptResult } from "src/types";
3
3
  export declare class SendUseroperationResponse {
4
4
  readonly userOperationHash: string;
5
5
  readonly bundler: Bundler;
6
6
  readonly entrypointAddress: string;
7
7
  constructor(userOperationHash: string, bundler: Bundler, entrypointAddress: string);
8
8
  private delay;
9
- included(timeoutInSeconds?: number, requestIntervalInSeconds?: number): Promise<UserOperationReceiptResult>;
9
+ included(timeoutInSeconds?: number, requestIntervalInSeconds?: number): Promise<UserOperationReceiptResult | BundlerJsonRpcError>;
10
10
  }
11
11
  //# sourceMappingURL=SendUseroperationResponse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SendUseroperationResponse.d.ts","sourceRoot":"","sources":["../../src/account/SendUseroperationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAEvD,qBAAa,yBAAyB;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;gBAGlC,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,OAAO,EAChB,iBAAiB,EAAE,MAAM;IAO1B,OAAO,CAAC,KAAK;IAWP,QAAQ,CACb,gBAAgB,GAAE,MAAY,EAC9B,wBAAwB,GAAE,MAAU,GAClC,OAAO,CAAC,0BAA0B,CAAC;CA2BtC"}
1
+ {"version":3,"file":"SendUseroperationResponse.d.ts","sourceRoot":"","sources":["../../src/account/SendUseroperationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAEN,mBAAmB,EACnB,0BAA0B,EAC1B,MAAM,WAAW,CAAC;AAEnB,qBAAa,yBAAyB;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;gBAGlC,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,OAAO,EAChB,iBAAiB,EAAE,MAAM;IAO1B,OAAO,CAAC,KAAK;IAIP,QAAQ,CACb,gBAAgB,GAAE,MAAW,EAC7B,wBAAwB,GAAE,MAAU,GAClC,OAAO,CAAC,0BAA0B,GAAG,mBAAmB,CAAC;CAiC5D"}
@@ -1,11 +1,11 @@
1
- export declare abstract class SmartAccount {
1
+ import { BytesLike } from "ethers";
2
+ export declare class SmartAccount {
2
3
  readonly accountAddress: string;
3
- static readonly proxyByteCode: string;
4
+ static readonly proxyByteCode: BytesLike;
4
5
  static readonly initializerFunctionSelector: string;
5
6
  static readonly initializerFunctionInputAbi: string[];
6
7
  static readonly executorFunctionSelector: string;
7
8
  static readonly executorFunctionInputAbi: string[];
8
9
  constructor(accountAddress: string);
9
- abstract prependTokenPaymasterApproveToCallData(callData: string, tokenAddress: string, paymasterAddress: string, approveAmount: bigint): string;
10
10
  }
11
11
  //# sourceMappingURL=SmartAccount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SmartAccount.d.ts","sourceRoot":"","sources":["../../src/account/SmartAccount.ts"],"names":[],"mappings":"AAAA,8BAAsB,YAAY;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IACtC,MAAM,CAAC,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;IACpD,MAAM,CAAC,QAAQ,CAAC,2BAA2B,EAAE,MAAM,EAAE,CAAC;IACtD,MAAM,CAAC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IACjD,MAAM,CAAC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,EAAE,CAAC;gBAEvC,cAAc,EAAE,MAAM;IAGlC,QAAQ,CAAC,sCAAsC,CAC9C,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,MAAM,GACnB,MAAM;CACT"}
1
+ {"version":3,"file":"SmartAccount.d.ts","sourceRoot":"","sources":["../../src/account/SmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,qBAAa,YAAY;IACxB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC;IACzC,MAAM,CAAC,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;IACpD,MAAM,CAAC,QAAQ,CAAC,2BAA2B,EAAE,MAAM,EAAE,CAAC;IACtD,MAAM,CAAC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IACjD,MAAM,CAAC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,EAAE,CAAC;gBAEvC,cAAc,EAAE,MAAM;CAGlC"}
@@ -1,4 +1,4 @@
1
- import { type UserOperation } from "./types";
2
- export declare const ZeroAddress = "0x0000000000000000000000000000000000000000";
1
+ import type { UserOperation } from "./types";
2
+ export declare const UserOperationEmptyValues: UserOperation;
3
3
  export declare const UserOperationDummyValues: UserOperation;
4
4
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,WAAW,+CAA+C,CAAC;AAExE,eAAO,MAAM,wBAAwB,EAAE,aAatC,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,wBAAwB,EAAE,aAYtC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,aAYtC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { SmartAccountFactory } from "./SmartAccountFactory";
2
+ export declare class SimpleAccountFactory extends SmartAccountFactory {
3
+ constructor(address?: string);
4
+ }
5
+ //# sourceMappingURL=SimpleAccountFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleAccountFactory.d.ts","sourceRoot":"","sources":["../../src/factory/SimpleAccountFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,qBAAa,oBAAqB,SAAQ,mBAAmB;gBAChD,OAAO,GAAE,MAAqD;CAK1E"}
@@ -1,9 +1,10 @@
1
+ import type { BytesLike } from "ethers";
1
2
  import type { AbiInputValue } from "../types";
2
3
  export declare class SmartAccountFactory {
3
4
  readonly address: string;
4
5
  readonly generatorFunctionSelector: string;
5
6
  readonly generatorFunctionInputAbi: string[];
6
7
  constructor(address: string, generatorFunctionSelector: string, generatorFunctionInputAbi: string[]);
7
- getFactoryGeneratorFunctionCallData(generatorFunctionInputParameters: AbiInputValue[]): string;
8
+ getFactoryGeneratorFunctionCallData(generatorFunctionInputParameters: AbiInputValue[]): BytesLike;
8
9
  }
9
10
  //# sourceMappingURL=SmartAccountFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SmartAccountFactory.d.ts","sourceRoot":"","sources":["../../src/factory/SmartAccountFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,qBAAa,mBAAmB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAC3C,QAAQ,CAAC,yBAAyB,EAAE,MAAM,EAAE,CAAC;gBAG5C,OAAO,EAAE,MAAM,EACf,yBAAyB,EAAE,MAAM,EACjC,yBAAyB,EAAE,MAAM,EAAE;IAOpC,mCAAmC,CAClC,gCAAgC,EAAE,aAAa,EAAE,GAC/C,MAAM;CAUT"}
1
+ {"version":3,"file":"SmartAccountFactory.d.ts","sourceRoot":"","sources":["../../src/factory/SmartAccountFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,qBAAa,mBAAmB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAC3C,QAAQ,CAAC,yBAAyB,EAAE,MAAM,EAAE,CAAC;gBAG5C,OAAO,EAAE,MAAM,EACf,yBAAyB,EAAE,MAAM,EACjC,yBAAyB,EAAE,MAAM,EAAE;IAOpC,mCAAmC,CAClC,gCAAgC,EAAE,aAAa,EAAE,GAC/C,SAAS;CAUZ"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var e=require("ethers");function t(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var r,n,i=/*#__PURE__*/t(require("isomorphic-unfetch")),a=function(e){this.accountAddress=void 0,this.accountAddress=e};function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},s.apply(this,arguments)}function f(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,u(e,t)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function l(e){var t="function"==typeof Map?new Map:void 0;return l=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(o())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&u(i,r.prototype),i}(e,arguments,c(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,e)},l(e)}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}a.proxyByteCode=void 0,a.initializerFunctionSelector=void 0,a.initializerFunctionInputAbi=void 0,a.executorFunctionSelector=void 0,a.executorFunctionInputAbi=void 0,exports.Operation=void 0,(r=exports.Operation||(exports.Operation={}))[r.Call=0]="Call",r[r.Delegate=1]="Delegate",function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(n||(n={}));var h={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"},v=/*#__PURE__*/function(e){function t(t,r,n){var i;void 0===n&&(n={});var a=n.errno,o=n.context;return(i=e.call(this,r,{cause:n.cause})||this).code=void 0,i.context=void 0,i.errno=void 0,i.name=i.constructor.name,i.code=t,i.errno=a,i.context=o,i}return f(t,e),t}(/*#__PURE__*/l(Error));function m(e){if(e instanceof Error)return e;var t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch(e){}return new Error("This value was thrown as is, not through an Error: "+t)}var y=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:g(E("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(A(e,"eth_call",i)).then(function(e){if("string"!=typeof e)throw new v("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=m(e);throw new v("BAD_DATA","getNonce returned ill formed data",{cause:t})}})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=m(e);throw new v("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},A=function(e,t,r){try{var n=i.default||i,a={method:"POST",body:JSON.stringify({method:t,params:r,id:(new Date).getTime(),jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t}),redirect:"follow"};return Promise.resolve(n(e,a)).then(function(t){return Promise.resolve(t.json()).then(function(t){if("result"in t)return t.result;var r=t.error,n=String(r.code);throw new v(n in h?h[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(a)}})})})}catch(e){return Promise.reject(e)}};function P(t,r,n){var i=e.keccak256(function(t){var r=[t.sender,t.nonce,e.keccak256(t.initCode),e.keccak256(t.callData),t.callGasLimit,t.verificationGasLimit,t.preVerificationGas,t.maxFeePerGas,t.maxPriorityFeePerGas,e.keccak256(t.paymasterAndData)];return e.AbiCoder.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(t)),a=e.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,r,n]);return e.keccak256(a)}function g(t,r,n){return t+e.AbiCoder.defaultAbiCoder().encode(r,n).slice(2)}function E(t){return e.id(t).slice(0,10)}function D(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var b,O="0x0000000000000000000000000000000000000000",G={sender:O,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},R=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=g(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),x=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return f(t,e),t}(R);function S(t){return"0x"+t.map(function(t){return i=null!=(n=(r=t).operation)?n:exports.Operation.Call,a=e.getBytes(r.data),e.solidityPacked(["uint8","address","uint256","uint256","bytes"],[i,r.to,r.value,a.length,a]).slice(2);var r,n,i,a}).join("")}function _(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(b||(b={}));var U=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{var e=this;return Promise.resolve(_(function(){return Promise.resolve(A(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new v("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=m(e);throw new v("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{var e=this;return Promise.resolve(_(function(){return Promise.resolve(A(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=m(e);throw new v("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=this;return Promise.resolve(_(function(){function i(){var e=a;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var a={},o=void 0===r?Promise.resolve(A(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){a=e}):Promise.resolve(A(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){a=e});return o&&o.then?o.then(i):i()},function(e){var t=m(e);throw new v("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{var r=this;return Promise.resolve(_(function(){return Promise.resolve(A(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=m(e);throw new v("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{var t=this;return Promise.resolve(_(function(){return Promise.resolve(A(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=s({},t.receipt,{blockNumber:BigInt(t.receipt.blockNumber),cumulativeGasUsed:BigInt(t.receipt.cumulativeGasUsed),gasUsed:BigInt(t.receipt.gasUsed),transactionIndex:BigInt(t.receipt.transactionIndex),effectiveGasPrice:null==t.receipt.effectiveGasPrice?void 0:BigInt(t.receipt.effectiveGasPrice),logs:JSON.stringify(t.receipt.logs)});return s({},t,{nonce:BigInt(t.nonce),actualGasCost:BigInt(t.actualGasCost),actualGasUsed:BigInt(t.actualGasUsed),logs:JSON.stringify(t.logs),receipt:r})}return null})},function(t){var r=m(t);throw new v("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{var t=this;return Promise.resolve(_(function(){return Promise.resolve(A(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?s({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=m(t);throw new v("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function T(e,t,r){if(!e.s){if(r instanceof F){if(!r.s)return void(r.o=T.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(T.bind(null,e,t),T.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var F=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{T(n,1,a(this.v))}catch(e){T(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?T(n,1,t?t(i):i):r?T(n,1,r(i)):T(n,2,i)}catch(e){T(n,2,e)}},n},e}();function w(e){return e instanceof F&&1&e.s}var L=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=180),void 0===t&&(t=2);try{var r,n=function(e){if(r)return e;throw new v("TIMEOUT","can't find useroperation",{context:i.userOperationHash})},i=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var a=0,o=function(e,t,r){for(var n;;){var i=e();if(w(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!w(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!w(o)){n=2;break}}}var s=new F,f=T.bind(null,s,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,f),s;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!w(o))return void o.then(l).then(void 0,f);if(!(i=e())||w(i)&&!i.v)return void T(s,1,a);if(i.then)return void i.then(u).then(void 0,f);w(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,f)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,f):c(a):T(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):T(s,1,a)}}(function(){return!r&&a<=e},void 0,function(){return Promise.resolve(i.delay(1e3*t)).then(function(){return Promise.resolve(i.bundler.getUserOperationReceipt(i.userOperationHash)).then(function(e){if(null!=e)return r=1,e;a++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),C=/*#__PURE__*/function(t){function r(e,n,i){var a;return void 0===n&&(n=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=r.DEFAULT_ENTRYPOINT_ADDRESS),(a=t.call(this,e)||this).entrypointAddress=void 0,a.safe4337ModuleAddress=void 0,a.initCode=void 0,a.entrypointAddress=i,a.safe4337ModuleAddress=n,a.initCode=null,a}f(r,t),r.initializeNewAccount=function(e,t){void 0===t&&(t={});var n=r.createAccountAddressAndInitCode(e,t),i=n[1],a=new r(n[0]);return a.initCode=i,a},r.createAccountAddressAndInitCode=function(e,t){var n,i,a,o,s;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(n=t.threshold)?n:1,c=null!=(i=t.c2Nonce)?i:0n,u=null!=(a=t.singletonAddress)?a:r.DEFAULT_SINGLETON_ADDRESS,l=null!=(o=t.safe4337ModuleAddress)?o:r.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:r.DEFAULT_ADD_MODULE_LIB_ADDRESS,p=new x;null!=t.safeAccountFactoryAddress&&(p=new x(t.safeAccountFactoryAddress));var h=r.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(h,c,p.address,u),p.getFactoryGeneratorFunctionCallData([u,h,c])]},r.createInitializerCallData=function(e,t,n,i){if(void 0===n&&(n=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=r.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");var a=g("0x8d0dc49f",["address[]"],[[n]]);return g(r.initializerFunctionSelector,r.initializerFunctionInputAbi,[e,t,i,a,n,O,0,O])},r.createInitCode=function(e,t,n,i,a,o,s){if(void 0===t&&(t=1),void 0===n&&(n=0n),void 0===i&&(i=r.DEFAULT_SINGLETON_ADDRESS),void 0===a&&(a=new x),void 0===o&&(o=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=r.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(n<0n)throw RangeError("c2Nonce can't be negative");var f=r.createInitializerCallData(e,t,o,s);return a.getFactoryGeneratorFunctionCallData([i,f,n])},r.createProxyAddress=function(t,r,n,i){if(r<0n)throw RangeError("c2Nonce can't be negative");var a=e.AbiCoder.defaultAbiCoder(),o=e.keccak256(e.solidityPacked(["bytes32","uint256"],[e.keccak256(t),r])),s=a.encode(["uint256"],[i]),f=e.keccak256(e.solidityPacked(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+e.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,f]).slice(-40)},r.createAccountCallDataSingleTransaction=function(e){var t,n,i,a=null!=(t=e.value)?t:0,o=null!=(n=e.data)?n:"0x",s=null!=(i=e.operation)?i:exports.Operation.Call;return r.createAccountCallData(e.to,a,o,s)},r.createAccountCallDataBatchTransactions=function(e,t){if(void 0===t&&(t=r.DEFAULT_MULTISEND_CONTRACT_ADDRESS),e.length<1)throw RangeError("There should be at least one metaTransaction");var n=g("0x8d80ff0a",["bytes"],[S(e)]);return r.createAccountCallData(t,0n,n,exports.Operation.Delegate)},r.createAccountCallData=function(e,t,n,i,a){return void 0===a&&(a=r.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),g(a,r.executorFunctionInputAbi,[e,t,n,i])};var i=r.prototype;return i.decodeAccountCallData=function(t){if(t.startsWith(b.executeUserOpWithErrorString)||t.startsWith(b.executeUserOp)){var r=e.AbiCoder.defaultAbiCoder(),n="0x"+t.slice(10),i=r.decode(["address","uint256","bytes","uint8"],n);return[i[0],BigInt(i[1]),i[2],Number(i[3])]}throw new v("BAD_DATA","Invalid calldata, should start with "+b.executeUserOpWithErrorString+" or "+b.executeUserOp,{context:{callData:t}})},i.prependTokenPaymasterApproveToCallData=function(t,n,i,a,o){void 0===o&&(o=r.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var s=this.decodeAccountCallData(t),f=s[0],c=s[1],u=s[2],l=s[3],d="";d="string"!=typeof u?(new TextDecoder).decode(u):u;var p=S([{to:n,value:0n,data:g(E("approve(address,uint256)"),["address","uint256"],[i,a]),operation:exports.Operation.Call}]),h="",v="0x8d80ff0a";if(d.startsWith(v)){var m=function(t){return e.AbiCoder.defaultAbiCoder().decode(["bytes"],"0x"+t.slice(10))[0]}(d);h=m+p.slice(2)}else h=S([{to:f,value:c,data:u,operation:l}])+p.slice(2);var y=g(v,["bytes"],[h]);return r.createAccountCallData(o,0n,y,exports.Operation.Delegate)},i.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new U(t);return Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n*BigInt(n),BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},i.createUserOperation=function(t,i,a,o){void 0===o&&(o={});try{var f=function(){var f;function l(){var e,t;function r(){var e,t,r;if("bigint"==typeof o.preVerificationGas&&o.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof o.verificationGasLimit&&o.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof o.callGasLimit&&o.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return n.preVerificationGas=null!=(e=o.preVerificationGas)?e:i,n.verificationGasLimit=null!=(t=o.verificationGasLimit)?t:f,n.callGasLimit=null!=(r=o.callGasLimit)?r:l,n}if("bigint"==typeof o.maxFeePerGas&&o.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof o.maxPriorityFeePerGas&&o.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");h=null!=(e=o.maxFeePerGas)?e:h,v=null!=(t=o.maxPriorityFeePerGas)?t:v;var n=s({},G,{sender:c.accountAddress,nonce:u,initCode:d,callData:p,maxFeePerGas:h,maxPriorityFeePerGas:v}),i=G.preVerificationGas,f=G.verificationGasLimit,l=G.callGasLimit,m=function(){if(null==o.preVerificationGas||null==o.verificationGasLimit||null==o.callGasLimit)return Promise.resolve(c.estimateUserOperationGas(n,a,o.state_override_set,o.numberOfSigners)).then(function(e){i=e[0],f=e[1],l=e[2]})}();return m&&m.then?m.then(r):r()}var d=null!=(f=o.initCode)?f:c.initCode;if((null==d||u>0n)&&(d="0x"),u<0n)throw RangeError("nonce can't be negative");var p="0x";p=null==o.callData?1==t.length?r.createAccountCallDataSingleTransaction(t[0]):r.createAccountCallDataBatchTransactions(t):o.callData;var h=G.maxFeePerGas,v=G.maxPriorityFeePerGas,m=function(){if(null==o.maxFeePerGas||null==o.maxPriorityFeePerGas)return Promise.resolve(function(t,r){try{void 0===r&&(r=n.Medium);var i=new e.JsonRpcProvider(t);return Promise.resolve(i.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*r)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*r))]})}catch(e){return Promise.reject(e)}}(i)).then(function(e){h=e[0],v=e[1]})}();return m&&m.then?m.then(l):l()},c=this;if(t.length<1)throw RangeError("There should be at least one transaction");var u=0n,l=function(){if(null==o.nonce)return Promise.resolve(y(i,c.entrypointAddress,c.accountAddress)).then(function(e){u=e});u=o.nonce}();return Promise.resolve(l&&l.then?l.then(f):f())}catch(e){return Promise.reject(e)}},i.signUserOperation=function(t,n,i,a,o){if(void 0===a&&(a=0n),void 0===o&&(o=0n),n.length<1)throw RangeError("There should be at least one privateKey");if(i<0n)throw RangeError("chainId can't be negative");if(a<0n)throw RangeError("validAfter can't be negative");if(o<0n)throw RangeError("validUntil can't be negative");for(var s,f={safe:t.sender,nonce:t.nonce,initCode:t.initCode,callData:t.callData,callGasLimit:t.callGasLimit,verificationGasLimit:t.verificationGasLimit,preVerificationGas:t.preVerificationGas,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas,paymasterAndData:t.paymasterAndData,validAfter:a,validUntil:o,entryPoint:this.entrypointAddress},c={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},u=new Map,l=p(n);!(s=l()).done;){var d=new e.Wallet(s.value);u.set(d.address,d)}for(var h,v=[],m=p(Array.from(u.keys()).sort());!(h=m()).done;){var y=u.get(h.value).signingKey.sign(e.TypedDataEncoder.hash({chainId:i,verifyingContract:this.safe4337ModuleAddress},c,f)).serialized;v.push(y.slice(2))}return r.formatEip712SignaturesToUseroperationSignature(v,a,o)},r.formatEip712SignaturesToUseroperationSignature=function(t,r,n){void 0===r&&(r=0n),void 0===n&&(n=0n);var i="0x"+t.join("");return e.solidityPacked(["uint48","uint48","bytes"],[r,n,i])},i.sendUserOperation=function(e,t){try{var r=this,n=new U(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new L(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},r}(a);function I(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}C.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",C.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",C.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",C.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",C.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",C.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",C.initializerFunctionSelector="0xb63e800d",C.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],C.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=b.executeUserOpWithErrorString,C.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var N=/*#__PURE__*/function(e){function t(t){var r;return(r=e.call(this)||this).rpcUrl=void 0,r.entrypointAddress=void 0,r.supportedTokens=void 0,r.paymasterMetadata=void 0,r.rpcUrl=t,r}f(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(I(function(){return Promise.resolve(e.getSupportedEntrypoint()).then(function(t){return e.entrypointAddress=t,Promise.resolve(e.getSupportedERC20TokensAndPaymasterMetadata()).then(function(t){return e.supportedTokens=t.tokens,e.paymasterMetadata=t.paymasterMetadata,null})})},function(e){var t=m(e);throw new v("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}))}catch(e){return Promise.reject(e)}},r.getPaymasterMetaData=function(){try{var e=function(){return t.paymasterMetadata},t=this,r=function(){if(null==t.paymasterMetadata)return Promise.resolve(t.initialize()).then(function(){})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokensAndPaymasterMetadata=function(){try{var e=this;return Promise.resolve(null==e.supportedTokens||null==e.paymasterMetadata?I(function(){return Promise.resolve(A(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}})},function(e){var t=m(e);throw new v("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}):{tokens:e.supportedTokens,paymasterMetadata:e.paymasterMetadata})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{var e=this;return Promise.resolve(null==e.entrypointAddress?I(function(){return Promise.resolve(A(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=m(e);throw new v("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}):e.entrypointAddress)}catch(e){return Promise.reject(e)}},r.isSupportedERC20Token=function(e){try{var t=function(){return!!r.supportedTokens.find(function(t){return t.address===e.toLowerCase()})},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokenData=function(e){try{var t=function(){var t=r.supportedTokens.find(function(t){return t.address.toLowerCase()===e.toLowerCase()});return t?{symbol:t.symbol,address:t.address,decimal:Number(t.decimal),fee:BigInt(t.fee),exchangeRate:BigInt(t.exchangeRate)}:null},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.createPaymasterUserOperation=function(e,t,r,n){void 0===r&&(r={});try{var i=function(){return I(function(){e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var i=new U(t);return Promise.resolve(i.estimateUserOperationGas(e,a.entrypointAddress,n)).then(function(t){return e.preVerificationGas=t.preVerificationGas,e.verificationGasLimit=t.verificationGasLimit+10000n,e.callGasLimit=t.callGasLimit,Promise.resolve(A(a.rpcUrl,"pm_sponsorUserOperation",[e,a.entrypointAddress,r])).then(function(t){var r,n,i,a,o,s=t,f={paymasterAndData:s.paymasterAndData,callGasLimit:null==s.callGasLimit?void 0:BigInt(s.callGasLimit),preVerificationGas:null==s.preVerificationGas?void 0:BigInt(s.preVerificationGas),verificationGasLimit:null==s.verificationGasLimit?void 0:BigInt(s.verificationGasLimit),maxFeePerGas:null==s.maxFeePerGas?void 0:BigInt(s.maxFeePerGas),maxPriorityFeePerGas:null==s.maxPriorityFeePerGas?void 0:BigInt(s.maxPriorityFeePerGas)};return e.paymasterAndData=f.paymasterAndData,e.callGasLimit=null!=(r=f.callGasLimit)?r:e.callGasLimit,e.preVerificationGas=null!=(n=f.preVerificationGas)?n:e.preVerificationGas,e.verificationGasLimit=null!=(i=f.verificationGasLimit)?i:e.verificationGasLimit,e.maxFeePerGas=null!=(a=f.maxFeePerGas)?a:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})})},function(e){var t=m(e);throw new v("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},a=this,o=function(){if(null==a.entrypointAddress||null==a.supportedTokens||null==a.paymasterMetadata)return Promise.resolve(a.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(i):i())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,i){void 0===i&&(i={});try{var a=this;return Promise.resolve(I(function(){return Promise.resolve(a.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(a.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(a.createPaymasterUserOperation(t,n,{token:r},i))})})},function(e){var t=m(e);throw new v("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}))}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(I(function(){return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new v("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e)}})});var i=D(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})},function(e){var t=m(e);throw new v("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),B={__proto__:null,SmartAccount:a,SafeAccountV0_2_0:C,SendUseroperationResponse:L,SmartAccountFactory:R,SafeAccountFactory:x,Bundler:U,CandidePaymaster:N,createUserOperationHash:P,createCallData:g,getFunctionSelector:E,fetchAccountNonce:y,calculateUserOperationMaxGasCost:D,get Operation(){return exports.Operation}};exports.Bundler=U,exports.CandidePaymaster=N,exports.SafeAccountFactory=x,exports.SafeAccountV0_2_0=C,exports.SendUseroperationResponse=L,exports.SmartAccount=a,exports.SmartAccountFactory=R,exports.abstractionkit=B,exports.calculateUserOperationMaxGasCost=D,exports.createCallData=g,exports.createUserOperationHash=P,exports.fetchAccountNonce=y,exports.getFunctionSelector=E;
1
+ var e=require("ethers");function t(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var r,n,i,a=/*#__PURE__*/t(require("isomorphic-unfetch")),o=function(e){this.accountAddress=void 0,this.accountAddress=e};function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},f.apply(this,arguments)}function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}o.proxyByteCode=void 0,o.initializerFunctionSelector=void 0,o.initializerFunctionInputAbi=void 0,o.executorFunctionSelector=void 0,o.executorFunctionInputAbi=void 0,function(e){e[e.InvalidFields=-32602]="InvalidFields",e[e.SimulateValidation=-32500]="SimulateValidation",e[e.SimulatePaymasterValidation=-32501]="SimulatePaymasterValidation",e[e.OpcodeValidation=-32502]="OpcodeValidation",e[e.ExpiresShortly=-32503]="ExpiresShortly",e[e.Reputation=-32504]="Reputation",e[e.InsufficientStake=-32505]="InsufficientStake",e[e.UnsupportedSignatureAggregator=-32506]="UnsupportedSignatureAggregator",e[e.InvalidSignature=-32507]="InvalidSignature",e[e.InvalidUseroperationHash=-32601]="InvalidUseroperationHash",e[e.ExecutionReverted=-32521]="ExecutionReverted"}(r||(r={})),exports.Operation=void 0,(n=exports.Operation||(exports.Operation={}))[n.Call=0]="Call",n[n.Delegate=1]="Delegate",function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(i||(i={}));var l=function(e,t,r,n){void 0===n&&(n=0);try{var i=p(v("getNonce(address,uint192)"),["address","uint192"],[r,n]);return Promise.resolve(d(e,"eth_call",[{from:"0x0000000000000000000000000000000000000000",to:t,data:i},"latest"])).then(function(e){return"result"in e?BigInt(e.result):e.error})}catch(e){return Promise.reject(e)}},d=function(e,t,r){try{var n=a.default||a,i=JSON.stringify({method:t,params:r,id:1,jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t});return Promise.resolve(n(e,{method:"POST",body:i,redirect:"follow"})).then(function(e){return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function h(t,r,n){var i=e.keccak256(function(t){var r=[t.sender,t.nonce,e.keccak256(t.initCode),e.keccak256(t.callData),t.callGasLimit,t.verificationGasLimit,t.preVerificationGas,t.maxFeePerGas,t.maxPriorityFeePerGas,e.keccak256(t.paymasterAndData)];return e.AbiCoder.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(t)),a=e.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,r,n]);return e.keccak256(a)}function p(t,r,n){return t+e.AbiCoder.defaultAbiCoder().encode(r,n).slice(2)}function v(t){return e.id(t).slice(0,10)}var y,m={sender:e.ZeroAddress,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,paymasterAndData:"0x",signature:"0x"},A={sender:e.ZeroAddress,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},g=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=p(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),b=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return s(t,e),t}(g);!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(y||(y={}));var D=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{return Promise.resolve(d(this.rpcUrl,"eth_chainId",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{return Promise.resolve(d(this.rpcUrl,"eth_supportedEntryPoints",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=function(){return"result"in i?i.result:i.error},i={},a=void 0===r?Promise.resolve(d(this.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){i=e}):Promise.resolve(d(this.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){i=e});return Promise.resolve(a&&a.then?a.then(n):n())}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{return Promise.resolve(d(this.rpcUrl,"eth_sendUserOperation",[e,t])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{return Promise.resolve(d(this.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){if("result"in e){var t=e.result,r=f({},t.receipt,{logs:JSON.stringify(t.receipt.logs)});return f({},t,{logs:JSON.stringify(t.logs),receipt:r})}return e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{return Promise.resolve(d(this.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},e}();function P(e,t,r){if(!e.s){if(r instanceof E){if(!r.s)return void(r.o=P.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(P.bind(null,e,t),P.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var E=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{P(n,1,a(this.v))}catch(e){P(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?P(n,1,t?t(i):i):r?P(n,1,r(i)):P(n,2,i)}catch(e){P(n,2,e)}},n},e}();function x(e){return e instanceof E&&1&e.s}var F=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=60),void 0===t&&(t=1);try{var n,i=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var a=0,o={},f=function(e,t,r){for(var n;;){var i=e();if(x(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!x(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!x(o)){n=2;break}}}var f=new E,s=P.bind(null,f,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,s),f;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!x(o))return void o.then(l).then(void 0,s);if(!(i=e())||x(i)&&!i.v)return void P(f,1,a);if(i.then)return void i.then(u).then(void 0,s);x(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,s)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,s):c(a):P(f,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,s):u(i):P(f,1,a)}}(function(){return!n&&a<=e},void 0,function(){return Promise.resolve(i.delay(1e3*t)).then(function(){return Promise.resolve(i.bundler.getUserOperationReceipt(i.userOperationHash)).then(function(e){return"code"in e?e.code!=r.InvalidUseroperationHash?(n=1,e):(a++,void(o=e)):(n=1,e)})})});return Promise.resolve(f&&f.then?f.then(function(e){return n?e:o}):n?f:o)}catch(e){return Promise.reject(e)}},e}(),S=/*#__PURE__*/function(t){function r(e,n,i){var a;return void 0===n&&(n=r.DEFAULT_ENTRYPOINT_ADDRESS),void 0===i&&(i=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),(a=t.call(this,e)||this).entrypointAddress=void 0,a.safe4337ModuleAddress=void 0,a.entrypointAddress=n,a.safe4337ModuleAddress=i,a}s(r,t),r.createAccountAddressAndInitCode=function(e,t){var n,i,a,o,f;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var s=null!=(n=t.threshold)?n:1,c=null!=(i=t.c2Nonce)?i:0n,u=null!=(a=t.singletonAddress)?a:r.DEFAULT_SINGLETON_ADDRESS,l=null!=(o=t.safe4337ModuleAddress)?o:r.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(f=t.addModuleLibAddress)?f:r.DEFAULT_ADD_MODULE_LIB_ADDRESS,h=new b;null!=t.safeAccountFactoryAddress&&(h=new b(t.safeAccountFactoryAddress));var p=r.createInitializerCallData(e,s,l,d);return[this.createProxyAddress(p,c,h.address,u),r.createInitCode(e,s,c,u,h,l,d)]},r.createInitializerCallData=function(t,n,i,a){if(void 0===i&&(i=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=r.DEFAULT_ADD_MODULE_LIB_ADDRESS),t.length<1)throw RangeError("There should be at least one owner");if(n<1)throw RangeError("threshold should be at least one");if(n>t.length)throw RangeError("threshold can't be larger than number of owners");var o=p("0x8d0dc49f",["address[]"],[[i]]);return p(r.initializerFunctionSelector,r.initializerFunctionInputAbi,[t,n,a,o,i,e.ZeroAddress,0,e.ZeroAddress])},r.createInitCode=function(e,t,n,i,a,o,f){if(void 0===t&&(t=1),void 0===n&&(n=0n),void 0===i&&(i=r.DEFAULT_SINGLETON_ADDRESS),void 0===a&&(a=new b),void 0===o&&(o=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===f&&(f=r.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(n<0n)throw RangeError("c2Nonce can't be negative");var s=r.createInitializerCallData(e,t,o,f);return a.getFactoryGeneratorFunctionCallData([i,s,n])},r.createProxyAddress=function(t,r,n,i){if(r<0n)throw RangeError("c2Nonce can't be negative");var a=e.AbiCoder.defaultAbiCoder(),o=e.keccak256(e.solidityPacked(["bytes32","uint256"],[e.keccak256(t),r])),f=a.encode(["uint256"],[i]),s=e.keccak256(e.solidityPacked(["bytes","bytes"],[this.proxyByteCode,f]));return"0x"+e.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,s]).slice(-40)},r.createAccountCallDataSingleTransaction=function(e){var t,n,i,a=null!=(t=e.value)?t:0,o=null!=(n=e.data)?n:"0x",f=null!=(i=e.operation)?i:exports.Operation.Call;return r.createAccountCallData(e.to,a,o,f)},r.createAccountCallDataBatchTransactions=function(t,n){if(void 0===n&&(n=r.DEFAULT_MULTISEND_CONTRACT_ADDRESS),t.length<1)throw RangeError("There should be at least one metaTransaction");var i,a=p("0x8d80ff0a",["bytes"],[(i=t,"0x"+i.map(function(t){return function(t){var r,n=null!=(r=t.operation)?r:exports.Operation.Call,i=e.ethers.getBytes(t.data);return e.ethers.solidityPacked(["uint8","address","uint256","uint256","bytes"],[n,t.to,t.value,i.length,i]).slice(2)}(t)}).join(""))]);return r.createAccountCallData(n,0n,a,exports.Operation.Delegate)},r.createAccountCallData=function(e,t,n,i,a){return void 0===a&&(a=r.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),p(a,r.executorFunctionInputAbi,[e,t,n,i])},r.estimateUserOperationGas=function(e,t,r){try{e.signature="0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";var n=new D(r);return Promise.resolve(n.estimateUserOperationGas(e,t)).then(function(e){return"code"in e?e:[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n,BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}};var n=r.prototype;return n.signUserOperation=function(t,r,n,i,a){if(void 0===i&&(i=0n),void 0===a&&(a=0n),r.length<1)throw RangeError("There should be at least one privateKey");if(n<0n)throw RangeError("chainId can't be negative");if(i<0n)throw RangeError("validAfter can't be negative");if(a<0n)throw RangeError("validUntil can't be negative");for(var o,f={safe:t.sender,nonce:t.nonce,initCode:t.initCode,callData:t.callData,callGasLimit:t.callGasLimit,verificationGasLimit:t.verificationGasLimit,preVerificationGas:t.preVerificationGas,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas,paymasterAndData:t.paymasterAndData,validAfter:i,validUntil:a,entryPoint:this.entrypointAddress},s={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},c="",l=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(o=l()).done;)c+=new e.Wallet(o.value).signingKey.sign(e.TypedDataEncoder.hash({chainId:n,verifyingContract:this.safe4337ModuleAddress},s,f)).serialized;return e.solidityPacked(["uint48","uint48","bytes"],[i,a,c])},n.createUserOperation=function(t,n,a,o){void 0===o&&(o={});try{var s,c=function(c){var l;if(s)return c;function h(){var e,t,n;function i(e){var t,r,i;if(n)return e;if("bigint"==typeof o.preVerificationGas&&o.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof o.verificationGasLimit&&o.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof o.callGasLimit&&o.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return s.preVerificationGas=null!=(t=o.preVerificationGas)?t:c,s.verificationGasLimit=null!=(r=o.verificationGasLimit)?r:l,s.callGasLimit=null!=(i=o.callGasLimit)?i:h,s}if("bigint"==typeof o.maxFeePerGas&&o.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof o.maxPriorityFeePerGas&&o.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");y=null!=(e=o.maxFeePerGas)?e:y,m=null!=(t=o.maxPriorityFeePerGas)?t:m;var s=f({},A,{sender:u.accountAddress,nonce:d,initCode:p,callData:v,maxFeePerGas:y,maxPriorityFeePerGas:m}),c=A.preVerificationGas,l=A.verificationGasLimit,h=A.callGasLimit,g=function(){if(null==o.preVerificationGas||null==o.verificationGasLimit||null==o.callGasLimit)return Promise.resolve(r.estimateUserOperationGas(s,u.entrypointAddress,a)).then(function(e){if("code"in e)return n=1,e;c=e[0],l=e[1],h=e[2]})}();return g&&g.then?g.then(i):i(g)}var p=null!=(l=o.initCode)?l:"0x";if(d<0n)throw RangeError("nonce can't be negative");if("0x"!=p&&d>0n)throw RangeError("initCode is only allowed when the nonce is zero for the first transaction when the safe account is not deployed yet");var v="0x";v=null==o.callData?1==t.length?r.createAccountCallDataSingleTransaction(t[0]):r.createAccountCallDataBatchTransactions(t):o.callData;var y=A.maxFeePerGas,m=A.maxPriorityFeePerGas,g=function(){if(null==o.maxFeePerGas||null==o.maxPriorityFeePerGas)return Promise.resolve(function(t,r){try{void 0===r&&(r=i.Medium);var n=new e.JsonRpcProvider(t);return Promise.resolve(n.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*r)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*r))]})}catch(e){return Promise.reject(e)}}(n)).then(function(e){y=e[0],m=e[1]})}();return g&&g.then?g.then(h):h()},u=this;if(t.length<1)throw RangeError("There should be at least one transaction");var d=0n,h=function(){if(null==o.nonce)return Promise.resolve(l(n,u.entrypointAddress,u.accountAddress)).then(function(e){if("bigint"!=typeof e)return s=1,e;d=e});d=o.nonce}();return Promise.resolve(h&&h.then?h.then(c):c(h))}catch(e){return Promise.reject(e)}},n.sendUserOperation=function(e,t){try{var r=this,n=new D(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return"string"!=typeof e?e:new F(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},r}(o);S.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",S.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xD556564bAcF6FEAC2E26ff70695f8250Cea8C29E",S.DEFAULT_SINGLETON_ADDRESS="0x41675C099F32341bf84BFc5382aF534df5C7461a",S.DEFAULT_ADD_MODULE_LIB_ADDRESS="0xea2B4251c7C1cDFFc04D35d990AF6Fd0309928B3",S.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",S.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",S.initializerFunctionSelector="0xb63e800d",S.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],S.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=y.executeUserOpWithErrorString,S.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var U=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x9406Cc6185a346906296840746125a0E44976454"),e.call(this,t,"0x5fbfb9cf",["address","uint256"])||this}return s(t,e),t}(g),G=/*#__PURE__*/function(e){function t(t,r){var n;return(n=e.call(this)||this).rpcUrl=void 0,n.entrypointAddress=void 0,n.rpcUrl=r,n.entrypointAddress=t,n}s(t,e);var r=t.prototype;return r.getSupportedERC20Tokens=function(){try{return Promise.resolve(d(this.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){if("result"in e){var t=e.result;return{tokens:t.tokens,paymasterMetadata:t.paymasterMetadata}}return e.error})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{return Promise.resolve(d(this.rpcUrl,"pm_supportedEntryPoint",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForPayingGasWithErc20=function(e,t){try{var r=this;return Promise.resolve(r.getPaymasterCallData(e,[r.rpcUrl,r.entrypointAddress,t]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForGaslessTx=function(e){try{var t=this;return Promise.resolve(t.getPaymasterCallData(e,[t.rpcUrl,t.entrypointAddress]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallData=function(e,t){try{return Promise.resolve(d(t[0],"pm_sponsorUserOperation",[e,t[1],{token:t[2]}])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t}(function(){}),O={__proto__:null,SmartAccount:o,SafeAccount:S,SendUseroperationResponse:F,SmartAccountFactory:g,SafeAccountFactory:b,SimpleAccountFactory:U,Bundler:D,CandideValidationPaymaster:G,createUserOperationHash:h,createCallData:p,getFunctionSelector:v,fetchAccountNonce:l,UserOperationEmptyValues:m,UserOperationDummyValues:A,get Operation(){return exports.Operation}};exports.Bundler=D,exports.CandideValidationPaymaster=G,exports.SafeAccount=S,exports.SafeAccountFactory=b,exports.SendUseroperationResponse=F,exports.SimpleAccountFactory=U,exports.SmartAccount=o,exports.SmartAccountFactory=g,exports.UserOperationDummyValues=A,exports.UserOperationEmptyValues=m,exports.abstractionkit=O,exports.createCallData=p,exports.createUserOperationHash=h,exports.fetchAccountNonce=l,exports.getFunctionSelector=v;
package/dist/index.m.js CHANGED
@@ -1 +1 @@
1
- import{keccak256 as e,AbiCoder as t,id as r,JsonRpcProvider as n,getBytes as i,solidityPacked as a,solidityPackedKeccak256 as o,Wallet as s,TypedDataEncoder as f}from"ethers";import*as c from"isomorphic-unfetch";var u,l,d=function(e){this.accountAddress=void 0,this.accountAddress=e};function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},h.apply(this,arguments)}function v(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,y(e,t)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function A(e){var t="function"==typeof Map?new Map:void 0;return A=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(p())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&y(i,r.prototype),i}(e,arguments,m(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,e)},A(e)}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function g(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return P(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}d.proxyByteCode=void 0,d.initializerFunctionSelector=void 0,d.initializerFunctionInputAbi=void 0,d.executorFunctionSelector=void 0,d.executorFunctionInputAbi=void 0,function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(u||(u={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(l||(l={}));var E={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"},D=/*#__PURE__*/function(e){function t(t,r,n){var i;void 0===n&&(n={});var a=n.errno,o=n.context;return(i=e.call(this,r,{cause:n.cause})||this).code=void 0,i.context=void 0,i.errno=void 0,i.name=i.constructor.name,i.code=t,i.errno=a,i.context=o,i}return v(t,e),t}(/*#__PURE__*/A(Error));function b(e){if(e instanceof Error)return e;var t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch(e){}return new Error("This value was thrown as is, not through an Error: "+t)}var G=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:_(S("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(R(e,"eth_call",i)).then(function(e){if("string"!=typeof e)throw new D("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=b(e);throw new D("BAD_DATA","getNonce returned ill formed data",{cause:t})}})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=b(e);throw new D("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},R=function(e,t,r){try{var n=c.default||c,i={method:"POST",body:JSON.stringify({method:t,params:r,id:(new Date).getTime(),jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t}),redirect:"follow"};return Promise.resolve(n(e,i)).then(function(t){return Promise.resolve(t.json()).then(function(t){if("result"in t)return t.result;var r=t.error,n=String(r.code);throw new D(n in E?E[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(i)}})})})}catch(e){return Promise.reject(e)}};function O(r,n,i){var a=e(function(r){var n=[r.sender,r.nonce,e(r.initCode),e(r.callData),r.callGasLimit,r.verificationGasLimit,r.preVerificationGas,r.maxFeePerGas,r.maxPriorityFeePerGas,e(r.paymasterAndData)];return t.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],n)}(r)),o=t.defaultAbiCoder().encode(["bytes32","address","uint256"],[a,n,i]);return e(o)}function _(e,r,n){return e+t.defaultAbiCoder().encode(r,n).slice(2)}function S(e){return r(e).slice(0,10)}function U(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var T,x="0x0000000000000000000000000000000000000000",F={sender:x,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},w=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=_(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),L=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return v(t,e),t}(w);function I(e){return"0x"+e.map(function(e){return n=null!=(r=(t=e).operation)?r:u.Call,o=i(t.data),a(["uint8","address","uint256","uint256","bytes"],[n,t.to,t.value,o.length,o]).slice(2);var t,r,n,o}).join("")}function C(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(T||(T={}));var N=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{var e=this;return Promise.resolve(C(function(){return Promise.resolve(R(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new D("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=b(e);throw new D("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{var e=this;return Promise.resolve(C(function(){return Promise.resolve(R(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=b(e);throw new D("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=this;return Promise.resolve(C(function(){function i(){var e=a;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var a={},o=void 0===r?Promise.resolve(R(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){a=e}):Promise.resolve(R(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){a=e});return o&&o.then?o.then(i):i()},function(e){var t=b(e);throw new D("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{var r=this;return Promise.resolve(C(function(){return Promise.resolve(R(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=b(e);throw new D("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{var t=this;return Promise.resolve(C(function(){return Promise.resolve(R(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=h({},t.receipt,{blockNumber:BigInt(t.receipt.blockNumber),cumulativeGasUsed:BigInt(t.receipt.cumulativeGasUsed),gasUsed:BigInt(t.receipt.gasUsed),transactionIndex:BigInt(t.receipt.transactionIndex),effectiveGasPrice:null==t.receipt.effectiveGasPrice?void 0:BigInt(t.receipt.effectiveGasPrice),logs:JSON.stringify(t.receipt.logs)});return h({},t,{nonce:BigInt(t.nonce),actualGasCost:BigInt(t.actualGasCost),actualGasUsed:BigInt(t.actualGasUsed),logs:JSON.stringify(t.logs),receipt:r})}return null})},function(t){var r=b(t);throw new D("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{var t=this;return Promise.resolve(C(function(){return Promise.resolve(R(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?h({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=b(t);throw new D("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function B(e,t,r){if(!e.s){if(r instanceof M){if(!r.s)return void(r.o=B.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(B.bind(null,e,t),B.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var M=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{B(n,1,a(this.v))}catch(e){B(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?B(n,1,t?t(i):i):r?B(n,1,r(i)):B(n,2,i)}catch(e){B(n,2,e)}},n},e}();function j(e){return e instanceof M&&1&e.s}var k=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=180),void 0===t&&(t=2);try{var r,n=function(e){if(r)return e;throw new D("TIMEOUT","can't find useroperation",{context:i.userOperationHash})},i=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var a=0,o=function(e,t,r){for(var n;;){var i=e();if(j(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!j(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!j(o)){n=2;break}}}var s=new M,f=B.bind(null,s,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,f),s;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!j(o))return void o.then(l).then(void 0,f);if(!(i=e())||j(i)&&!i.v)return void B(s,1,a);if(i.then)return void i.then(u).then(void 0,f);j(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,f)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,f):c(a):B(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):B(s,1,a)}}(function(){return!r&&a<=e},void 0,function(){return Promise.resolve(i.delay(1e3*t)).then(function(){return Promise.resolve(i.bundler.getUserOperationReceipt(i.userOperationHash)).then(function(e){if(null!=e)return r=1,e;a++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),V=/*#__PURE__*/function(r){function i(e,t,n){var a;return void 0===t&&(t=i.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===n&&(n=i.DEFAULT_ENTRYPOINT_ADDRESS),(a=r.call(this,e)||this).entrypointAddress=void 0,a.safe4337ModuleAddress=void 0,a.initCode=void 0,a.entrypointAddress=n,a.safe4337ModuleAddress=t,a.initCode=null,a}v(i,r),i.initializeNewAccount=function(e,t){void 0===t&&(t={});var r=i.createAccountAddressAndInitCode(e,t),n=r[1],a=new i(r[0]);return a.initCode=n,a},i.createAccountAddressAndInitCode=function(e,t){var r,n,a,o,s;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(r=t.threshold)?r:1,c=null!=(n=t.c2Nonce)?n:0n,u=null!=(a=t.singletonAddress)?a:i.DEFAULT_SINGLETON_ADDRESS,l=null!=(o=t.safe4337ModuleAddress)?o:i.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:i.DEFAULT_ADD_MODULE_LIB_ADDRESS,p=new L;null!=t.safeAccountFactoryAddress&&(p=new L(t.safeAccountFactoryAddress));var h=i.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(h,c,p.address,u),p.getFactoryGeneratorFunctionCallData([u,h,c])]},i.createInitializerCallData=function(e,t,r,n){if(void 0===r&&(r=i.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===n&&(n=i.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");var a=_("0x8d0dc49f",["address[]"],[[r]]);return _(i.initializerFunctionSelector,i.initializerFunctionInputAbi,[e,t,n,a,r,x,0,x])},i.createInitCode=function(e,t,r,n,a,o,s){if(void 0===t&&(t=1),void 0===r&&(r=0n),void 0===n&&(n=i.DEFAULT_SINGLETON_ADDRESS),void 0===a&&(a=new L),void 0===o&&(o=i.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=i.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(r<0n)throw RangeError("c2Nonce can't be negative");var f=i.createInitializerCallData(e,t,o,s);return a.getFactoryGeneratorFunctionCallData([n,f,r])},i.createProxyAddress=function(r,n,i,s){if(n<0n)throw RangeError("c2Nonce can't be negative");var f=t.defaultAbiCoder(),c=e(a(["bytes32","uint256"],[e(r),n])),u=f.encode(["uint256"],[s]),l=e(a(["bytes","bytes"],[this.proxyByteCode,u]));return"0x"+o(["bytes1","address","bytes32","bytes32"],["0xff",i,c,l]).slice(-40)},i.createAccountCallDataSingleTransaction=function(e){var t,r,n,a=null!=(t=e.value)?t:0,o=null!=(r=e.data)?r:"0x",s=null!=(n=e.operation)?n:u.Call;return i.createAccountCallData(e.to,a,o,s)},i.createAccountCallDataBatchTransactions=function(e,t){if(void 0===t&&(t=i.DEFAULT_MULTISEND_CONTRACT_ADDRESS),e.length<1)throw RangeError("There should be at least one metaTransaction");var r=_("0x8d80ff0a",["bytes"],[I(e)]);return i.createAccountCallData(t,0n,r,u.Delegate)},i.createAccountCallData=function(e,t,r,n,a){return void 0===a&&(a=i.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),_(a,i.executorFunctionInputAbi,[e,t,r,n])};var c=i.prototype;return c.decodeAccountCallData=function(e){if(e.startsWith(T.executeUserOpWithErrorString)||e.startsWith(T.executeUserOp)){var r=t.defaultAbiCoder(),n="0x"+e.slice(10),i=r.decode(["address","uint256","bytes","uint8"],n);return[i[0],BigInt(i[1]),i[2],Number(i[3])]}throw new D("BAD_DATA","Invalid calldata, should start with "+T.executeUserOpWithErrorString+" or "+T.executeUserOp,{context:{callData:e}})},c.prependTokenPaymasterApproveToCallData=function(e,r,n,a,o){void 0===o&&(o=i.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var s=this.decodeAccountCallData(e),f=s[0],c=s[1],l=s[2],d=s[3],p="";p="string"!=typeof l?(new TextDecoder).decode(l):l;var h=I([{to:r,value:0n,data:_(S("approve(address,uint256)"),["address","uint256"],[n,a]),operation:u.Call}]),v="",m="0x8d80ff0a";if(p.startsWith(m)){var y=function(e){return t.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(p);v=y+h.slice(2)}else v=I([{to:f,value:c,data:l,operation:d}])+h.slice(2);var A=_(m,["bytes"],[v]);return i.createAccountCallData(o,0n,A,u.Delegate)},c.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new N(t);return Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n*BigInt(n),BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},c.createUserOperation=function(e,t,r,a){void 0===a&&(a={});try{var o=function(){var o;function c(){var e,t;function n(){var e,t,r;if("bigint"==typeof a.preVerificationGas&&a.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof a.verificationGasLimit&&a.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof a.callGasLimit&&a.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return i.preVerificationGas=null!=(e=a.preVerificationGas)?e:o,i.verificationGasLimit=null!=(t=a.verificationGasLimit)?t:c,i.callGasLimit=null!=(r=a.callGasLimit)?r:l,i}if("bigint"==typeof a.maxFeePerGas&&a.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof a.maxPriorityFeePerGas&&a.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");p=null!=(e=a.maxFeePerGas)?e:p,v=null!=(t=a.maxPriorityFeePerGas)?t:v;var i=h({},F,{sender:s.accountAddress,nonce:f,initCode:u,callData:d,maxFeePerGas:p,maxPriorityFeePerGas:v}),o=F.preVerificationGas,c=F.verificationGasLimit,l=F.callGasLimit,m=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return Promise.resolve(s.estimateUserOperationGas(i,r,a.state_override_set,a.numberOfSigners)).then(function(e){o=e[0],c=e[1],l=e[2]})}();return m&&m.then?m.then(n):n()}var u=null!=(o=a.initCode)?o:s.initCode;if((null==u||f>0n)&&(u="0x"),f<0n)throw RangeError("nonce can't be negative");var d="0x";d=null==a.callData?1==e.length?i.createAccountCallDataSingleTransaction(e[0]):i.createAccountCallDataBatchTransactions(e):a.callData;var p=F.maxFeePerGas,v=F.maxPriorityFeePerGas,m=function(){if(null==a.maxFeePerGas||null==a.maxPriorityFeePerGas)return Promise.resolve(function(e,t){try{void 0===t&&(t=l.Medium);var r=new n(e);return Promise.resolve(r.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*t)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*t))]})}catch(e){return Promise.reject(e)}}(t)).then(function(e){p=e[0],v=e[1]})}();return m&&m.then?m.then(c):c()},s=this;if(e.length<1)throw RangeError("There should be at least one transaction");var f=0n,c=function(){if(null==a.nonce)return Promise.resolve(G(t,s.entrypointAddress,s.accountAddress)).then(function(e){f=e});f=a.nonce}();return Promise.resolve(c&&c.then?c.then(o):o())}catch(e){return Promise.reject(e)}},c.signUserOperation=function(e,t,r,n,a){if(void 0===n&&(n=0n),void 0===a&&(a=0n),t.length<1)throw RangeError("There should be at least one privateKey");if(r<0n)throw RangeError("chainId can't be negative");if(n<0n)throw RangeError("validAfter can't be negative");if(a<0n)throw RangeError("validUntil can't be negative");for(var o,c={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:n,validUntil:a,entryPoint:this.entrypointAddress},u={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},l=new Map,d=g(t);!(o=d()).done;){var p=new s(o.value);l.set(p.address,p)}for(var h,v=[],m=g(Array.from(l.keys()).sort());!(h=m()).done;){var y=l.get(h.value).signingKey.sign(f.hash({chainId:r,verifyingContract:this.safe4337ModuleAddress},u,c)).serialized;v.push(y.slice(2))}return i.formatEip712SignaturesToUseroperationSignature(v,n,a)},i.formatEip712SignaturesToUseroperationSignature=function(e,t,r){void 0===t&&(t=0n),void 0===r&&(r=0n);var n="0x"+e.join("");return a(["uint48","uint48","bytes"],[t,r,n])},c.sendUserOperation=function(e,t){try{var r=this,n=new N(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new k(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},i}(d);function z(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}V.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",V.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",V.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",V.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",V.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",V.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",V.initializerFunctionSelector="0xb63e800d",V.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],V.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=T.executeUserOpWithErrorString,V.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var H=/*#__PURE__*/function(e){function t(t){var r;return(r=e.call(this)||this).rpcUrl=void 0,r.entrypointAddress=void 0,r.supportedTokens=void 0,r.paymasterMetadata=void 0,r.rpcUrl=t,r}v(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(z(function(){return Promise.resolve(e.getSupportedEntrypoint()).then(function(t){return e.entrypointAddress=t,Promise.resolve(e.getSupportedERC20TokensAndPaymasterMetadata()).then(function(t){return e.supportedTokens=t.tokens,e.paymasterMetadata=t.paymasterMetadata,null})})},function(e){var t=b(e);throw new D("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}))}catch(e){return Promise.reject(e)}},r.getPaymasterMetaData=function(){try{var e=function(){return t.paymasterMetadata},t=this,r=function(){if(null==t.paymasterMetadata)return Promise.resolve(t.initialize()).then(function(){})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokensAndPaymasterMetadata=function(){try{var e=this;return Promise.resolve(null==e.supportedTokens||null==e.paymasterMetadata?z(function(){return Promise.resolve(R(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}})},function(e){var t=b(e);throw new D("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}):{tokens:e.supportedTokens,paymasterMetadata:e.paymasterMetadata})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{var e=this;return Promise.resolve(null==e.entrypointAddress?z(function(){return Promise.resolve(R(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=b(e);throw new D("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}):e.entrypointAddress)}catch(e){return Promise.reject(e)}},r.isSupportedERC20Token=function(e){try{var t=function(){return!!r.supportedTokens.find(function(t){return t.address===e.toLowerCase()})},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokenData=function(e){try{var t=function(){var t=r.supportedTokens.find(function(t){return t.address.toLowerCase()===e.toLowerCase()});return t?{symbol:t.symbol,address:t.address,decimal:Number(t.decimal),fee:BigInt(t.fee),exchangeRate:BigInt(t.exchangeRate)}:null},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.createPaymasterUserOperation=function(e,t,r,n){void 0===r&&(r={});try{var i=function(){return z(function(){e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var i=new N(t);return Promise.resolve(i.estimateUserOperationGas(e,a.entrypointAddress,n)).then(function(t){return e.preVerificationGas=t.preVerificationGas,e.verificationGasLimit=t.verificationGasLimit+10000n,e.callGasLimit=t.callGasLimit,Promise.resolve(R(a.rpcUrl,"pm_sponsorUserOperation",[e,a.entrypointAddress,r])).then(function(t){var r,n,i,a,o,s=t,f={paymasterAndData:s.paymasterAndData,callGasLimit:null==s.callGasLimit?void 0:BigInt(s.callGasLimit),preVerificationGas:null==s.preVerificationGas?void 0:BigInt(s.preVerificationGas),verificationGasLimit:null==s.verificationGasLimit?void 0:BigInt(s.verificationGasLimit),maxFeePerGas:null==s.maxFeePerGas?void 0:BigInt(s.maxFeePerGas),maxPriorityFeePerGas:null==s.maxPriorityFeePerGas?void 0:BigInt(s.maxPriorityFeePerGas)};return e.paymasterAndData=f.paymasterAndData,e.callGasLimit=null!=(r=f.callGasLimit)?r:e.callGasLimit,e.preVerificationGas=null!=(n=f.preVerificationGas)?n:e.preVerificationGas,e.verificationGasLimit=null!=(i=f.verificationGasLimit)?i:e.verificationGasLimit,e.maxFeePerGas=null!=(a=f.maxFeePerGas)?a:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})})},function(e){var t=b(e);throw new D("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},a=this,o=function(){if(null==a.entrypointAddress||null==a.supportedTokens||null==a.paymasterMetadata)return Promise.resolve(a.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(i):i())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,i){void 0===i&&(i={});try{var a=this;return Promise.resolve(z(function(){return Promise.resolve(a.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(a.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(a.createPaymasterUserOperation(t,n,{token:r},i))})})},function(e){var t=b(e);throw new D("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}))}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(z(function(){return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new D("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e)}})});var i=U(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})},function(e){var t=b(e);throw new D("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),Y={__proto__:null,SmartAccount:d,SafeAccountV0_2_0:V,SendUseroperationResponse:k,SmartAccountFactory:w,SafeAccountFactory:L,Bundler:N,CandidePaymaster:H,createUserOperationHash:O,createCallData:_,getFunctionSelector:S,fetchAccountNonce:G,calculateUserOperationMaxGasCost:U,get Operation(){return u}};export{N as Bundler,H as CandidePaymaster,u as Operation,L as SafeAccountFactory,V as SafeAccountV0_2_0,k as SendUseroperationResponse,d as SmartAccount,w as SmartAccountFactory,Y as abstractionkit,U as calculateUserOperationMaxGasCost,_ as createCallData,O as createUserOperationHash,G as fetchAccountNonce,S as getFunctionSelector};
1
+ import{keccak256 as e,AbiCoder as t,id as r,JsonRpcProvider as n,ZeroAddress as i,ethers as a,solidityPacked as o,solidityPackedKeccak256 as f,Wallet as s,TypedDataEncoder as c}from"ethers";import*as u from"isomorphic-unfetch";var l,d,h,v=function(e){this.accountAddress=void 0,this.accountAddress=e};function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},p.apply(this,arguments)}function m(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,y(e,t)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}v.proxyByteCode=void 0,v.initializerFunctionSelector=void 0,v.initializerFunctionInputAbi=void 0,v.executorFunctionSelector=void 0,v.executorFunctionInputAbi=void 0,function(e){e[e.InvalidFields=-32602]="InvalidFields",e[e.SimulateValidation=-32500]="SimulateValidation",e[e.SimulatePaymasterValidation=-32501]="SimulatePaymasterValidation",e[e.OpcodeValidation=-32502]="OpcodeValidation",e[e.ExpiresShortly=-32503]="ExpiresShortly",e[e.Reputation=-32504]="Reputation",e[e.InsufficientStake=-32505]="InsufficientStake",e[e.UnsupportedSignatureAggregator=-32506]="UnsupportedSignatureAggregator",e[e.InvalidSignature=-32507]="InvalidSignature",e[e.InvalidUseroperationHash=-32601]="InvalidUseroperationHash",e[e.ExecutionReverted=-32521]="ExecutionReverted"}(l||(l={})),function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(d||(d={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(h||(h={}));var A=function(e,t,r,n){void 0===n&&(n=0);try{var i=P(E("getNonce(address,uint192)"),["address","uint192"],[r,n]);return Promise.resolve(D(e,"eth_call",[{from:"0x0000000000000000000000000000000000000000",to:t,data:i},"latest"])).then(function(e){return"result"in e?BigInt(e.result):e.error})}catch(e){return Promise.reject(e)}},D=function(e,t,r){try{var n=u.default||u,i=JSON.stringify({method:t,params:r,id:1,jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t});return Promise.resolve(n(e,{method:"POST",body:i,redirect:"follow"})).then(function(e){return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function b(r,n,i){var a=e(function(r){var n=[r.sender,r.nonce,e(r.initCode),e(r.callData),r.callGasLimit,r.verificationGasLimit,r.preVerificationGas,r.maxFeePerGas,r.maxPriorityFeePerGas,e(r.paymasterAndData)];return t.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],n)}(r)),o=t.defaultAbiCoder().encode(["bytes32","address","uint256"],[a,n,i]);return e(o)}function P(e,r,n){return e+t.defaultAbiCoder().encode(r,n).slice(2)}function E(e){return r(e).slice(0,10)}var F,S={sender:i,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,paymasterAndData:"0x",signature:"0x"},x={sender:i,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},G=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=P(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),U=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return m(t,e),t}(G);!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(F||(F={}));var _=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{return Promise.resolve(D(this.rpcUrl,"eth_chainId",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{return Promise.resolve(D(this.rpcUrl,"eth_supportedEntryPoints",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=function(){return"result"in i?i.result:i.error},i={},a=void 0===r?Promise.resolve(D(this.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){i=e}):Promise.resolve(D(this.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){i=e});return Promise.resolve(a&&a.then?a.then(n):n())}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{return Promise.resolve(D(this.rpcUrl,"eth_sendUserOperation",[e,t])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{return Promise.resolve(D(this.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){if("result"in e){var t=e.result,r=p({},t.receipt,{logs:JSON.stringify(t.receipt.logs)});return p({},t,{logs:JSON.stringify(t.logs),receipt:r})}return e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{return Promise.resolve(D(this.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},e}();function C(e,t,r){if(!e.s){if(r instanceof O){if(!r.s)return void(r.o=C.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(C.bind(null,e,t),C.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var O=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{C(n,1,a(this.v))}catch(e){C(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?C(n,1,t?t(i):i):r?C(n,1,r(i)):C(n,2,i)}catch(e){C(n,2,e)}},n},e}();function L(e){return e instanceof O&&1&e.s}var R=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=60),void 0===t&&(t=1);try{var r,n=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var i=0,a={},o=function(e,t,r){for(var n;;){var i=e();if(L(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!L(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!L(o)){n=2;break}}}var f=new O,s=C.bind(null,f,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,s),f;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!L(o))return void o.then(l).then(void 0,s);if(!(i=e())||L(i)&&!i.v)return void C(f,1,a);if(i.then)return void i.then(u).then(void 0,s);L(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,s)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,s):c(a):C(f,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,s):u(i):C(f,1,a)}}(function(){return!r&&i<=e},void 0,function(){return Promise.resolve(n.delay(1e3*t)).then(function(){return Promise.resolve(n.bundler.getUserOperationReceipt(n.userOperationHash)).then(function(e){return"code"in e?e.code!=l.InvalidUseroperationHash?(r=1,e):(i++,void(a=e)):(r=1,e)})})});return Promise.resolve(o&&o.then?o.then(function(e){return r?e:a}):r?o:a)}catch(e){return Promise.reject(e)}},e}(),I=/*#__PURE__*/function(r){function u(e,t,n){var i;return void 0===t&&(t=u.DEFAULT_ENTRYPOINT_ADDRESS),void 0===n&&(n=u.DEFAULT_SAFE_4337_MODULE_ADDRESS),(i=r.call(this,e)||this).entrypointAddress=void 0,i.safe4337ModuleAddress=void 0,i.entrypointAddress=t,i.safe4337ModuleAddress=n,i}m(u,r),u.createAccountAddressAndInitCode=function(e,t){var r,n,i,a,o;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(r=t.threshold)?r:1,s=null!=(n=t.c2Nonce)?n:0n,c=null!=(i=t.singletonAddress)?i:u.DEFAULT_SINGLETON_ADDRESS,l=null!=(a=t.safe4337ModuleAddress)?a:u.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(o=t.addModuleLibAddress)?o:u.DEFAULT_ADD_MODULE_LIB_ADDRESS,h=new U;null!=t.safeAccountFactoryAddress&&(h=new U(t.safeAccountFactoryAddress));var v=u.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(v,s,h.address,c),u.createInitCode(e,f,s,c,h,l,d)]},u.createInitializerCallData=function(e,t,r,n){if(void 0===r&&(r=u.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===n&&(n=u.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");var a=P("0x8d0dc49f",["address[]"],[[r]]);return P(u.initializerFunctionSelector,u.initializerFunctionInputAbi,[e,t,n,a,r,i,0,i])},u.createInitCode=function(e,t,r,n,i,a,o){if(void 0===t&&(t=1),void 0===r&&(r=0n),void 0===n&&(n=u.DEFAULT_SINGLETON_ADDRESS),void 0===i&&(i=new U),void 0===a&&(a=u.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===o&&(o=u.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(r<0n)throw RangeError("c2Nonce can't be negative");var f=u.createInitializerCallData(e,t,a,o);return i.getFactoryGeneratorFunctionCallData([n,f,r])},u.createProxyAddress=function(r,n,i,a){if(n<0n)throw RangeError("c2Nonce can't be negative");var s=t.defaultAbiCoder(),c=e(o(["bytes32","uint256"],[e(r),n])),u=s.encode(["uint256"],[a]),l=e(o(["bytes","bytes"],[this.proxyByteCode,u]));return"0x"+f(["bytes1","address","bytes32","bytes32"],["0xff",i,c,l]).slice(-40)},u.createAccountCallDataSingleTransaction=function(e){var t,r,n,i=null!=(t=e.value)?t:0,a=null!=(r=e.data)?r:"0x",o=null!=(n=e.operation)?n:d.Call;return u.createAccountCallData(e.to,i,a,o)},u.createAccountCallDataBatchTransactions=function(e,t){if(void 0===t&&(t=u.DEFAULT_MULTISEND_CONTRACT_ADDRESS),e.length<1)throw RangeError("There should be at least one metaTransaction");var r,n=P("0x8d80ff0a",["bytes"],[(r=e,"0x"+r.map(function(e){return function(e){var t,r=null!=(t=e.operation)?t:d.Call,n=a.getBytes(e.data);return a.solidityPacked(["uint8","address","uint256","uint256","bytes"],[r,e.to,e.value,n.length,n]).slice(2)}(e)}).join(""))]);return u.createAccountCallData(t,0n,n,d.Delegate)},u.createAccountCallData=function(e,t,r,n,i){return void 0===i&&(i=u.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),P(i,u.executorFunctionInputAbi,[e,t,r,n])},u.estimateUserOperationGas=function(e,t,r){try{e.signature="0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";var n=new _(r);return Promise.resolve(n.estimateUserOperationGas(e,t)).then(function(e){return"code"in e?e:[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n,BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}};var l=u.prototype;return l.signUserOperation=function(e,t,r,n,i){if(void 0===n&&(n=0n),void 0===i&&(i=0n),t.length<1)throw RangeError("There should be at least one privateKey");if(r<0n)throw RangeError("chainId can't be negative");if(n<0n)throw RangeError("validAfter can't be negative");if(i<0n)throw RangeError("validUntil can't be negative");for(var a,f={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:n,validUntil:i,entryPoint:this.entrypointAddress},u={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},l="",d=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(a=d()).done;)l+=new s(a.value).signingKey.sign(c.hash({chainId:r,verifyingContract:this.safe4337ModuleAddress},u,f)).serialized;return o(["uint48","uint48","bytes"],[n,i,l])},l.createUserOperation=function(e,t,r,i){void 0===i&&(i={});try{var a,o=function(o){var c;if(a)return o;function l(){var e,t,n;function a(e){var t,r,a;if(n)return e;if("bigint"==typeof i.preVerificationGas&&i.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof i.verificationGasLimit&&i.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof i.callGasLimit&&i.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return o.preVerificationGas=null!=(t=i.preVerificationGas)?t:c,o.verificationGasLimit=null!=(r=i.verificationGasLimit)?r:l,o.callGasLimit=null!=(a=i.callGasLimit)?a:h,o}if("bigint"==typeof i.maxFeePerGas&&i.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof i.maxPriorityFeePerGas&&i.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");m=null!=(e=i.maxFeePerGas)?e:m,y=null!=(t=i.maxPriorityFeePerGas)?t:y;var o=p({},x,{sender:f.accountAddress,nonce:s,initCode:d,callData:v,maxFeePerGas:m,maxPriorityFeePerGas:y}),c=x.preVerificationGas,l=x.verificationGasLimit,h=x.callGasLimit,g=function(){if(null==i.preVerificationGas||null==i.verificationGasLimit||null==i.callGasLimit)return Promise.resolve(u.estimateUserOperationGas(o,f.entrypointAddress,r)).then(function(e){if("code"in e)return n=1,e;c=e[0],l=e[1],h=e[2]})}();return g&&g.then?g.then(a):a(g)}var d=null!=(c=i.initCode)?c:"0x";if(s<0n)throw RangeError("nonce can't be negative");if("0x"!=d&&s>0n)throw RangeError("initCode is only allowed when the nonce is zero for the first transaction when the safe account is not deployed yet");var v="0x";v=null==i.callData?1==e.length?u.createAccountCallDataSingleTransaction(e[0]):u.createAccountCallDataBatchTransactions(e):i.callData;var m=x.maxFeePerGas,y=x.maxPriorityFeePerGas,g=function(){if(null==i.maxFeePerGas||null==i.maxPriorityFeePerGas)return Promise.resolve(function(e,t){try{void 0===t&&(t=h.Medium);var r=new n(e);return Promise.resolve(r.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*t)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*t))]})}catch(e){return Promise.reject(e)}}(t)).then(function(e){m=e[0],y=e[1]})}();return g&&g.then?g.then(l):l()},f=this;if(e.length<1)throw RangeError("There should be at least one transaction");var s=0n,c=function(){if(null==i.nonce)return Promise.resolve(A(t,f.entrypointAddress,f.accountAddress)).then(function(e){if("bigint"!=typeof e)return a=1,e;s=e});s=i.nonce}();return Promise.resolve(c&&c.then?c.then(o):o(c))}catch(e){return Promise.reject(e)}},l.sendUserOperation=function(e,t){try{var r=this,n=new _(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return"string"!=typeof e?e:new R(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},u}(v);I.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",I.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xD556564bAcF6FEAC2E26ff70695f8250Cea8C29E",I.DEFAULT_SINGLETON_ADDRESS="0x41675C099F32341bf84BFc5382aF534df5C7461a",I.DEFAULT_ADD_MODULE_LIB_ADDRESS="0xea2B4251c7C1cDFFc04D35d990AF6Fd0309928B3",I.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",I.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",I.initializerFunctionSelector="0xb63e800d",I.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],I.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=F.executeUserOpWithErrorString,I.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var T=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x9406Cc6185a346906296840746125a0E44976454"),e.call(this,t,"0x5fbfb9cf",["address","uint256"])||this}return m(t,e),t}(G),w=/*#__PURE__*/function(e){function t(t,r){var n;return(n=e.call(this)||this).rpcUrl=void 0,n.entrypointAddress=void 0,n.rpcUrl=r,n.entrypointAddress=t,n}m(t,e);var r=t.prototype;return r.getSupportedERC20Tokens=function(){try{return Promise.resolve(D(this.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){if("result"in e){var t=e.result;return{tokens:t.tokens,paymasterMetadata:t.paymasterMetadata}}return e.error})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{return Promise.resolve(D(this.rpcUrl,"pm_supportedEntryPoint",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForPayingGasWithErc20=function(e,t){try{var r=this;return Promise.resolve(r.getPaymasterCallData(e,[r.rpcUrl,r.entrypointAddress,t]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForGaslessTx=function(e){try{var t=this;return Promise.resolve(t.getPaymasterCallData(e,[t.rpcUrl,t.entrypointAddress]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallData=function(e,t){try{return Promise.resolve(D(t[0],"pm_sponsorUserOperation",[e,t[1],{token:t[2]}])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t}(function(){}),j={__proto__:null,SmartAccount:v,SafeAccount:I,SendUseroperationResponse:R,SmartAccountFactory:G,SafeAccountFactory:U,SimpleAccountFactory:T,Bundler:_,CandideValidationPaymaster:w,createUserOperationHash:b,createCallData:P,getFunctionSelector:E,fetchAccountNonce:A,UserOperationEmptyValues:S,UserOperationDummyValues:x,get Operation(){return d}};export{_ as Bundler,w as CandideValidationPaymaster,d as Operation,I as SafeAccount,U as SafeAccountFactory,R as SendUseroperationResponse,T as SimpleAccountFactory,v as SmartAccount,G as SmartAccountFactory,x as UserOperationDummyValues,S as UserOperationEmptyValues,j as abstractionkit,P as createCallData,b as createUserOperationHash,A as fetchAccountNonce,E as getFunctionSelector};
@@ -1 +1 @@
1
- import{keccak256 as e,AbiCoder as t,id as a,JsonRpcProvider as r,getBytes as n,solidityPacked as i,solidityPackedKeccak256 as s,Wallet as o,TypedDataEncoder as f}from"ethers";import*as c from"isomorphic-unfetch";class l{constructor(e){this.accountAddress=void 0,this.accountAddress=e}}function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},d.apply(this,arguments)}var u,p;l.proxyByteCode=void 0,l.initializerFunctionSelector=void 0,l.initializerFunctionInputAbi=void 0,l.executorFunctionSelector=void 0,l.executorFunctionInputAbi=void 0,function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(u||(u={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(p||(p={}));const h={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"};class y extends Error{constructor(e,t,a={}){const{cause:r,errno:n,context:i}=a;super(t,{cause:r}),this.code=void 0,this.context=void 0,this.errno=void 0,this.name=this.constructor.name,this.code=e,this.errno=n,this.context=i}}function m(e){if(e instanceof Error)return e;let t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch(e){}return new Error(`This value was thrown as is, not through an Error: ${t}`)}function A(a,r,n){const i=e(function(a){const r=[a.sender,a.nonce,e(a.initCode),e(a.callData),a.callGasLimit,a.verificationGasLimit,a.preVerificationGas,a.maxFeePerGas,a.maxPriorityFeePerGas,e(a.paymasterAndData)];return t.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(a)),s=t.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,r,n]);return e(s)}function E(e,a,r){return e+t.defaultAbiCoder().encode(a,r).slice(2)}async function g(e,t,a){const r=c.default||c,n={method:"POST",body:JSON.stringify({method:t,params:a,id:(new Date).getTime(),jsonrpc:"2.0"},(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t),redirect:"follow"},i=await r(e,n),s=await i.json();if("result"in s)return s.result;{const t=s.error,a=String(t.code);throw new y(a in h?h[a]:"UNKNOWN_ERROR",t.message,{errno:t.code,context:{url:e,requestOptions:JSON.stringify(n)}})}}function D(e){return a(e).slice(0,10)}async function G(e,t,a,r=0){const n=[{from:"0x0000000000000000000000000000000000000000",to:t,data:E(D("getNonce(address,uint192)"),["address","uint192"],[a,r])},"latest"];try{const t=await g(e,"eth_call",n);if("string"!=typeof t)throw new y("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(t)});try{return BigInt(t)}catch(e){const t=m(e);throw new y("BAD_DATA","getNonce returned ill formed data",{cause:t})}}catch(e){const t=m(e);throw new y("BAD_DATA","getNonce failed",{cause:t})}}function R(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}const w="0x0000000000000000000000000000000000000000",b={sender:w,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"};class U{constructor(e,t,a){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=a}getFactoryGeneratorFunctionCallData(e){const t=E(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)}}class _ extends U{constructor(e="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"){super(e,"0x1688f0b9",["address","bytes","uint256"])}}var S;function T(e){return"0x"+e.map(e=>function(e){var t;const a=null!=(t=e.operation)?t:u.Call,r=n(e.data);return i(["uint8","address","uint256","uint256","bytes"],[a,e.to,e.value,r.length,r]).slice(2)}(e)).join("")}!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(S||(S={}));class x{constructor(e){this.rpcUrl=void 0,this.rpcUrl=e}async chainId(){try{const e=await g(this.rpcUrl,"eth_chainId",[]);if("string"==typeof e)return e;throw new y("BAD_DATA","bundler eth_chainId rpc call failed")}catch(e){const t=m(e);throw new y("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}}async supportedEntryPoints(){try{return await g(this.rpcUrl,"eth_supportedEntryPoints",[])}catch(e){const t=m(e);throw new y("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}}async estimateUserOperationGas(e,t,a){try{let r={};r=void 0===a?await g(this.rpcUrl,"eth_estimateUserOperationGas",[e,t]):await g(this.rpcUrl,"eth_estimateUserOperationGas",[e,t,a]);const n=r;return{callGasLimit:BigInt(n.callGasLimit),preVerificationGas:BigInt(n.preVerificationGas),verificationGasLimit:BigInt(n.verificationGasLimit)}}catch(e){const t=m(e);throw new y("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}}async sendUserOperation(e,t){try{return await g(this.rpcUrl,"eth_sendUserOperation",[e,t])}catch(e){const t=m(e);throw new y("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}}async getUserOperationReceipt(e){try{const t=await g(this.rpcUrl,"eth_getUserOperationReceipt",[e]);if(null!=t){const e=d({},t.receipt,{blockNumber:BigInt(t.receipt.blockNumber),cumulativeGasUsed:BigInt(t.receipt.cumulativeGasUsed),gasUsed:BigInt(t.receipt.gasUsed),transactionIndex:BigInt(t.receipt.transactionIndex),effectiveGasPrice:null==t.receipt.effectiveGasPrice?void 0:BigInt(t.receipt.effectiveGasPrice),logs:JSON.stringify(t.receipt.logs)});return d({},t,{nonce:BigInt(t.nonce),actualGasCost:BigInt(t.actualGasCost),actualGasUsed:BigInt(t.actualGasUsed),logs:JSON.stringify(t.logs),receipt:e})}return null}catch(t){const a=m(t);throw new y("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:a,context:{useroperationhash:e}})}}async getUserOperationByHash(e){try{const t=await g(this.rpcUrl,"eth_getUserOperationByHash",[e]);return null!=t?d({},t,{blockNumber:null==t.blockNumber?null:BigInt(t.blockNumber)}):null}catch(t){const a=m(t);throw new y("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:a,context:{useroperationhash:e}})}}}class O{constructor(e,t,a){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=a}delay(e){return new Promise(t=>setTimeout(t,e))}async included(e=180,t=2){if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");let a=0;for(;a<=e;){await this.delay(1e3*t);const e=await this.bundler.getUserOperationReceipt(this.userOperationHash);if(null!=e)return e;a++}throw new y("TIMEOUT","can't find useroperation",{context:this.userOperationHash})}}class F extends l{constructor(e,t=F.DEFAULT_SAFE_4337_MODULE_ADDRESS,a=F.DEFAULT_ENTRYPOINT_ADDRESS){super(e),this.entrypointAddress=void 0,this.safe4337ModuleAddress=void 0,this.initCode=void 0,this.entrypointAddress=a,this.safe4337ModuleAddress=t,this.initCode=null}static initializeNewAccount(e,t={}){const[a,r]=F.createAccountAddressAndInitCode(e,t),n=new F(a);return n.initCode=r,n}static createAccountAddressAndInitCode(e,t={}){var a,r,n,i,s;if(e.length<1)throw RangeError("There should be at least one owner");const o=null!=(a=t.threshold)?a:1,f=null!=(r=t.c2Nonce)?r:0n,c=null!=(n=t.singletonAddress)?n:F.DEFAULT_SINGLETON_ADDRESS,l=null!=(i=t.safe4337ModuleAddress)?i:F.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:F.DEFAULT_ADD_MODULE_LIB_ADDRESS;let u=new _;null!=t.safeAccountFactoryAddress&&(u=new _(t.safeAccountFactoryAddress));const p=F.createInitializerCallData(e,o,l,d);return[this.createProxyAddress(p,f,u.address,c),u.getFactoryGeneratorFunctionCallData([c,p,f])]}static createInitializerCallData(e,t,a=F.DEFAULT_SAFE_4337_MODULE_ADDRESS,r=F.DEFAULT_ADD_MODULE_LIB_ADDRESS){if(e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");const n=E("0x8d0dc49f",["address[]"],[[a]]);return E(F.initializerFunctionSelector,F.initializerFunctionInputAbi,[e,t,r,n,a,w,0,w])}static createInitCode(e,t=1,a=0n,r=F.DEFAULT_SINGLETON_ADDRESS,n=new _,i=F.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=F.DEFAULT_ADD_MODULE_LIB_ADDRESS){if(e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(a<0n)throw RangeError("c2Nonce can't be negative");const o=F.createInitializerCallData(e,t,i,s);return n.getFactoryGeneratorFunctionCallData([r,o,a])}static createProxyAddress(a,r,n,o){if(r<0n)throw RangeError("c2Nonce can't be negative");const f=t.defaultAbiCoder(),c=e(i(["bytes32","uint256"],[e(a),r])),l=f.encode(["uint256"],[o]),d=e(i(["bytes","bytes"],[this.proxyByteCode,l]));return"0x"+s(["bytes1","address","bytes32","bytes32"],["0xff",n,c,d]).slice(-40)}static createAccountCallDataSingleTransaction(e){var t,a,r;const n=null!=(t=e.value)?t:0,i=null!=(a=e.data)?a:"0x",s=null!=(r=e.operation)?r:u.Call;return F.createAccountCallData(e.to,n,i,s)}static createAccountCallDataBatchTransactions(e,t=F.DEFAULT_MULTISEND_CONTRACT_ADDRESS){if(e.length<1)throw RangeError("There should be at least one metaTransaction");const a=E("0x8d80ff0a",["bytes"],[T(e)]);return F.createAccountCallData(t,0n,a,u.Delegate)}static createAccountCallData(e,t,a,r,n=F.DEFAULT_EXECUTOR_FUCNTION_SELECTOR){return E(n,F.executorFunctionInputAbi,[e,t,a,r])}decodeAccountCallData(e){if(e.startsWith(S.executeUserOpWithErrorString)||e.startsWith(S.executeUserOp)){const a=t.defaultAbiCoder(),r="0x"+e.slice(10),n=a.decode(["address","uint256","bytes","uint8"],r);return[n[0],BigInt(n[1]),n[2],Number(n[3])]}throw new y("BAD_DATA","Invalid calldata, should start with "+S.executeUserOpWithErrorString+" or "+S.executeUserOp,{context:{callData:e}})}prependTokenPaymasterApproveToCallData(e,a,r,n,i=F.DEFAULT_MULTISEND_CONTRACT_ADDRESS){const[s,o,f,c]=this.decodeAccountCallData(e);let l="";l="string"!=typeof f?(new TextDecoder).decode(f):f;const d=T([{to:a,value:0n,data:E(D("approve(address,uint256)"),["address","uint256"],[r,n]),operation:u.Call}]);let p="";const h="0x8d80ff0a";if(l.startsWith(h)){const e=function(e){return t.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(l);p=e+d.slice(2)}else p=T([{to:s,value:o,data:f,operation:c}])+d.slice(2);const y=E(h,["bytes"],[p]);return F.createAccountCallData(i,0n,y,u.Delegate)}async estimateUserOperationGas(e,t,a,r=1){if(r<1n)throw RangeError("numberOfSigners can't be less than 1");let n="";for(let e=0;e<r;e++)n+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+n;const i=new x(t),s=await i.estimateUserOperationGas(e,this.entrypointAddress,a);return[BigInt(s.preVerificationGas),BigInt(s.verificationGasLimit)+5000n*BigInt(r),BigInt(s.callGasLimit)]}async createUserOperation(e,t,a,n={}){var i,s,o,f,c,l;if(e.length<1)throw RangeError("There should be at least one transaction");let u=0n;u=null==n.nonce?await G(t,this.entrypointAddress,this.accountAddress):n.nonce;let h=null!=(i=n.initCode)?i:this.initCode;if((null==h||u>0n)&&(h="0x"),u<0n)throw RangeError("nonce can't be negative");let y="0x";y=null==n.callData?1==e.length?F.createAccountCallDataSingleTransaction(e[0]):F.createAccountCallDataBatchTransactions(e):n.callData;let m=b.maxFeePerGas,A=b.maxPriorityFeePerGas;if(null!=n.maxFeePerGas&&null!=n.maxPriorityFeePerGas||([m,A]=await async function(e,t=p.Medium){const a=new r(e),n=await a.getFeeData();return[BigInt(Math.ceil(Number(n.maxFeePerGas)*t)),BigInt(Math.ceil(Number(n.maxPriorityFeePerGas)*t))]}(t)),"bigint"==typeof n.maxFeePerGas&&n.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof n.maxPriorityFeePerGas&&n.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");m=null!=(s=n.maxFeePerGas)?s:m,A=null!=(o=n.maxPriorityFeePerGas)?o:A;const E=d({},b,{sender:this.accountAddress,nonce:u,initCode:h,callData:y,maxFeePerGas:m,maxPriorityFeePerGas:A});let g=b.preVerificationGas,D=b.verificationGasLimit,R=b.callGasLimit;if(null!=n.preVerificationGas&&null!=n.verificationGasLimit&&null!=n.callGasLimit||([g,D,R]=await this.estimateUserOperationGas(E,a,n.state_override_set,n.numberOfSigners)),"bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return E.preVerificationGas=null!=(f=n.preVerificationGas)?f:g,E.verificationGasLimit=null!=(c=n.verificationGasLimit)?c:D,E.callGasLimit=null!=(l=n.callGasLimit)?l:R,E}signUserOperation(e,t,a,r=0n,n=0n){if(t.length<1)throw RangeError("There should be at least one privateKey");if(a<0n)throw RangeError("chainId can't be negative");if(r<0n)throw RangeError("validAfter can't be negative");if(n<0n)throw RangeError("validUntil can't be negative");const i={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:r,validUntil:n,entryPoint:this.entrypointAddress},s={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},c=new Map;for(const e of t){const t=new o(e);c.set(t.address,t)}const l=Array.from(c.keys()).sort(),d=[];for(const e of l){const t=c.get(e).signingKey.sign(f.hash({chainId:a,verifyingContract:this.safe4337ModuleAddress},s,i)).serialized;d.push(t.slice(2))}return F.formatEip712SignaturesToUseroperationSignature(d,r,n)}static formatEip712SignaturesToUseroperationSignature(e,t=0n,a=0n){const r="0x"+e.join("");return i(["uint48","uint48","bytes"],[t,a,r])}async sendUserOperation(e,t){const a=new x(t),r=await a.sendUserOperation(e,this.entrypointAddress);return new O(r,a,this.entrypointAddress)}}F.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",F.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",F.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",F.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",F.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",F.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",F.initializerFunctionSelector="0xb63e800d",F.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],F.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=S.executeUserOpWithErrorString,F.executorFunctionInputAbi=["address","uint256","bytes","uint8"];class L{}class v extends L{constructor(e){super(),this.rpcUrl=void 0,this.entrypointAddress=void 0,this.supportedTokens=void 0,this.paymasterMetadata=void 0,this.rpcUrl=e}async initialize(){try{this.entrypointAddress=await this.getSupportedEntrypoint();const e=await this.getSupportedERC20TokensAndPaymasterMetadata();return this.supportedTokens=e.tokens,this.paymasterMetadata=e.paymasterMetadata,null}catch(e){const t=m(e);throw new y("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}}async getPaymasterMetaData(){return null==this.paymasterMetadata&&await this.initialize(),this.paymasterMetadata}async getSupportedERC20TokensAndPaymasterMetadata(){if(null!=this.supportedTokens&&null!=this.paymasterMetadata)return{tokens:this.supportedTokens,paymasterMetadata:this.paymasterMetadata};try{const e=await g(this.rpcUrl,"pm_supportedERC20Tokens",[]);return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}}catch(e){const t=m(e);throw new y("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}}async getSupportedEntrypoint(){if(null!=this.entrypointAddress)return this.entrypointAddress;try{return await g(this.rpcUrl,"pm_supportedEntryPoint",[])}catch(e){const t=m(e);throw new y("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}}async isSupportedERC20Token(e){return null!=this.entrypointAddress&&null!=this.supportedTokens&&null!=this.paymasterMetadata||await this.initialize(),!!this.supportedTokens.find(t=>t.address===e.toLowerCase())}async getSupportedERC20TokenData(e){null!=this.entrypointAddress&&null!=this.supportedTokens&&null!=this.paymasterMetadata||await this.initialize();const t=this.supportedTokens.find(t=>t.address.toLowerCase()===e.toLowerCase());return t?{symbol:t.symbol,address:t.address,decimal:Number(t.decimal),fee:BigInt(t.fee),exchangeRate:BigInt(t.exchangeRate)}:null}async createPaymasterUserOperation(e,t,a={},r){null!=this.entrypointAddress&&null!=this.supportedTokens&&null!=this.paymasterMetadata||await this.initialize();try{var n,i,s,o,f;e.paymasterAndData=this.paymasterMetadata.dummyPaymasterAndData;const c=new x(t),l=await c.estimateUserOperationGas(e,this.entrypointAddress,r);e.preVerificationGas=l.preVerificationGas,e.verificationGasLimit=l.verificationGasLimit+10000n,e.callGasLimit=l.callGasLimit;const d=await g(this.rpcUrl,"pm_sponsorUserOperation",[e,this.entrypointAddress,a]),u={paymasterAndData:d.paymasterAndData,callGasLimit:null==d.callGasLimit?void 0:BigInt(d.callGasLimit),preVerificationGas:null==d.preVerificationGas?void 0:BigInt(d.preVerificationGas),verificationGasLimit:null==d.verificationGasLimit?void 0:BigInt(d.verificationGasLimit),maxFeePerGas:null==d.maxFeePerGas?void 0:BigInt(d.maxFeePerGas),maxPriorityFeePerGas:null==d.maxPriorityFeePerGas?void 0:BigInt(d.maxPriorityFeePerGas)};return e.paymasterAndData=u.paymasterAndData,e.callGasLimit=null!=(n=u.callGasLimit)?n:e.callGasLimit,e.preVerificationGas=null!=(i=u.preVerificationGas)?i:e.preVerificationGas,e.verificationGasLimit=null!=(s=u.verificationGasLimit)?s:e.verificationGasLimit,e.maxFeePerGas=null!=(o=u.maxFeePerGas)?o:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(f=u.maxPriorityFeePerGas)?f:e.maxPriorityFeePerGas,e}catch(e){const t=m(e);throw new y("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})}}async createSponsorPaymasterUserOperation(e,t,a){return await this.createPaymasterUserOperation(e,t,{},a)}async createTokenPaymasterUserOperation(e,t,a,r,n={}){try{const i=2n*await this.calculateUserOperationErc20TokenMaxGasCost(t,a);let s=await this.getPaymasterMetaData();const o=e.prependTokenPaymasterApproveToCallData(t.callData,a,s.address,i);return t.callData=o,await this.createPaymasterUserOperation(t,r,{token:a},n)}catch(e){const t=m(e);throw new y("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}}async calculateUserOperationErc20TokenMaxGasCost(e,t){try{const a=await this.getSupportedERC20TokenData(t);if(null==a)throw new y("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(await this.getSupportedERC20TokensAndPaymasterMetadata())}});{const t=R(e);return a.exchangeRate*t/BigInt(10**18)}}catch(e){const t=m(e);throw new y("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}}}var P={__proto__:null,SmartAccount:l,SafeAccountV0_2_0:F,SendUseroperationResponse:O,SmartAccountFactory:U,SafeAccountFactory:_,Bundler:x,CandidePaymaster:v,createUserOperationHash:A,createCallData:E,getFunctionSelector:D,fetchAccountNonce:G,calculateUserOperationMaxGasCost:R,get Operation(){return u}};export{x as Bundler,v as CandidePaymaster,u as Operation,_ as SafeAccountFactory,F as SafeAccountV0_2_0,O as SendUseroperationResponse,l as SmartAccount,U as SmartAccountFactory,P as abstractionkit,R as calculateUserOperationMaxGasCost,E as createCallData,A as createUserOperationHash,G as fetchAccountNonce,D as getFunctionSelector};
1
+ import{keccak256 as e,AbiCoder as t,id as r,JsonRpcProvider as a,ZeroAddress as n,ethers as i,solidityPacked as s,solidityPackedKeccak256 as f,Wallet as o,TypedDataEncoder as c}from"ethers";import*as l from"isomorphic-unfetch";class d{constructor(e){this.accountAddress=void 0,this.accountAddress=e}}function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},u.apply(this,arguments)}var p,h,y;function g(r,a,n){const i=e(function(r){const a=[r.sender,r.nonce,e(r.initCode),e(r.callData),r.callGasLimit,r.verificationGasLimit,r.preVerificationGas,r.maxFeePerGas,r.maxPriorityFeePerGas,e(r.paymasterAndData)];return t.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],a)}(r)),s=t.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,a,n]);return e(s)}function m(e,r,a){return e+t.defaultAbiCoder().encode(r,a).slice(2)}async function A(e,t,r){const a=l.default||l,n={method:"POST",body:JSON.stringify({method:t,params:r,id:1,jsonrpc:"2.0"},(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t),redirect:"follow"},i=await a(e,n);return await i.json()}function D(e){return r(e).slice(0,10)}async function E(e,t,r,a=0){const n=[{from:"0x0000000000000000000000000000000000000000",to:t,data:m(D("getNonce(address,uint192)"),["address","uint192"],[r,a])},"latest"],i=await A(e,"eth_call",n);return"result"in i?BigInt(i.result):i.error}d.proxyByteCode=void 0,d.initializerFunctionSelector=void 0,d.initializerFunctionInputAbi=void 0,d.executorFunctionSelector=void 0,d.executorFunctionInputAbi=void 0,function(e){e[e.InvalidFields=-32602]="InvalidFields",e[e.SimulateValidation=-32500]="SimulateValidation",e[e.SimulatePaymasterValidation=-32501]="SimulatePaymasterValidation",e[e.OpcodeValidation=-32502]="OpcodeValidation",e[e.ExpiresShortly=-32503]="ExpiresShortly",e[e.Reputation=-32504]="Reputation",e[e.InsufficientStake=-32505]="InsufficientStake",e[e.UnsupportedSignatureAggregator=-32506]="UnsupportedSignatureAggregator",e[e.InvalidSignature=-32507]="InvalidSignature",e[e.InvalidUseroperationHash=-32601]="InvalidUseroperationHash",e[e.ExecutionReverted=-32521]="ExecutionReverted"}(p||(p={})),function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(h||(h={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(y||(y={}));const F={sender:n,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,paymasterAndData:"0x",signature:"0x"},b={sender:n,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"};class x{constructor(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}getFactoryGeneratorFunctionCallData(e){const t=m(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)}}class S extends x{constructor(e="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"){super(e,"0x1688f0b9",["address","bytes","uint256"])}}var G;!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(G||(G={}));class U{constructor(e){this.rpcUrl=void 0,this.rpcUrl=e}async chainId(){const e=await A(this.rpcUrl,"eth_chainId",[]);return"result"in e?e.result:e.error}async supportedEntryPoints(){const e=await A(this.rpcUrl,"eth_supportedEntryPoints",[]);return"result"in e?e.result:e.error}async estimateUserOperationGas(e,t,r){let a={};return a=void 0===r?await A(this.rpcUrl,"eth_estimateUserOperationGas",[e,t]):await A(this.rpcUrl,"eth_estimateUserOperationGas",[e,t,r]),"result"in a?a.result:a.error}async sendUserOperation(e,t){const r=await A(this.rpcUrl,"eth_sendUserOperation",[e,t]);return"result"in r?r.result:r.error}async getUserOperationReceipt(e){const t=await A(this.rpcUrl,"eth_getUserOperationReceipt",[e]);if("result"in t){const e=t.result,r=u({},e.receipt,{logs:JSON.stringify(e.receipt.logs)});return u({},e,{logs:JSON.stringify(e.logs),receipt:r})}return t.error}async getUserOperationByHash(e){const t=await A(this.rpcUrl,"eth_getUserOperationByHash",[e]);return"result"in t?t.result:t.error}}class v{constructor(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}delay(e){return new Promise(t=>setTimeout(t,e))}async included(e=60,t=1){if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");let r=0,a={};for(;r<=e;){await this.delay(1e3*t);const e=await this.bundler.getUserOperationReceipt(this.userOperationHash);if(!("code"in e))return e;if(e.code!=p.InvalidUseroperationHash)return e;r++,a=e}return a}}class _ extends d{constructor(e,t=_.DEFAULT_ENTRYPOINT_ADDRESS,r=_.DEFAULT_SAFE_4337_MODULE_ADDRESS){super(e),this.entrypointAddress=void 0,this.safe4337ModuleAddress=void 0,this.entrypointAddress=t,this.safe4337ModuleAddress=r}static createAccountAddressAndInitCode(e,t={}){var r,a,n,i,s;if(e.length<1)throw RangeError("There should be at least one owner");const f=null!=(r=t.threshold)?r:1,o=null!=(a=t.c2Nonce)?a:0n,c=null!=(n=t.singletonAddress)?n:_.DEFAULT_SINGLETON_ADDRESS,l=null!=(i=t.safe4337ModuleAddress)?i:_.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:_.DEFAULT_ADD_MODULE_LIB_ADDRESS;let u=new S;null!=t.safeAccountFactoryAddress&&(u=new S(t.safeAccountFactoryAddress));const p=_.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(p,o,u.address,c),_.createInitCode(e,f,o,c,u,l,d)]}static createInitializerCallData(e,t,r=_.DEFAULT_SAFE_4337_MODULE_ADDRESS,a=_.DEFAULT_ADD_MODULE_LIB_ADDRESS){if(e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");const i=m("0x8d0dc49f",["address[]"],[[r]]);return m(_.initializerFunctionSelector,_.initializerFunctionInputAbi,[e,t,a,i,r,n,0,n])}static createInitCode(e,t=1,r=0n,a=_.DEFAULT_SINGLETON_ADDRESS,n=new S,i=_.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=_.DEFAULT_ADD_MODULE_LIB_ADDRESS){if(e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(r<0n)throw RangeError("c2Nonce can't be negative");const f=_.createInitializerCallData(e,t,i,s);return n.getFactoryGeneratorFunctionCallData([a,f,r])}static createProxyAddress(r,a,n,i){if(a<0n)throw RangeError("c2Nonce can't be negative");const o=t.defaultAbiCoder(),c=e(s(["bytes32","uint256"],[e(r),a])),l=o.encode(["uint256"],[i]),d=e(s(["bytes","bytes"],[this.proxyByteCode,l]));return"0x"+f(["bytes1","address","bytes32","bytes32"],["0xff",n,c,d]).slice(-40)}static createAccountCallDataSingleTransaction(e){var t,r,a;const n=null!=(t=e.value)?t:0,i=null!=(r=e.data)?r:"0x",s=null!=(a=e.operation)?a:h.Call;return _.createAccountCallData(e.to,n,i,s)}static createAccountCallDataBatchTransactions(e,t=_.DEFAULT_MULTISEND_CONTRACT_ADDRESS){if(e.length<1)throw RangeError("There should be at least one metaTransaction");const r=m("0x8d80ff0a",["bytes"],[(a=e,"0x"+a.map(e=>function(e){var t;const r=null!=(t=e.operation)?t:h.Call,a=i.getBytes(e.data);return i.solidityPacked(["uint8","address","uint256","uint256","bytes"],[r,e.to,e.value,a.length,a]).slice(2)}(e)).join(""))]);var a;return _.createAccountCallData(t,0n,r,h.Delegate)}static createAccountCallData(e,t,r,a,n=_.DEFAULT_EXECUTOR_FUCNTION_SELECTOR){return m(n,_.executorFunctionInputAbi,[e,t,r,a])}static async estimateUserOperationGas(e,t,r){e.signature="0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";const a=new U(r),n=await a.estimateUserOperationGas(e,t);return"code"in n?n:[BigInt(n.preVerificationGas),BigInt(n.verificationGasLimit)+5000n,BigInt(n.callGasLimit)]}signUserOperation(e,t,r,a=0n,n=0n){if(t.length<1)throw RangeError("There should be at least one privateKey");if(r<0n)throw RangeError("chainId can't be negative");if(a<0n)throw RangeError("validAfter can't be negative");if(n<0n)throw RangeError("validUntil can't be negative");const i={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:a,validUntil:n,entryPoint:this.entrypointAddress},f={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]};let l="";for(const e of t)l+=new o(e).signingKey.sign(c.hash({chainId:r,verifyingContract:this.safe4337ModuleAddress},f,i)).serialized;return s(["uint48","uint48","bytes"],[a,n,l])}async createUserOperation(e,t,r,n={}){var i,s,f,o,c,l;if(e.length<1)throw RangeError("There should be at least one transaction");let d=0n;if(null==n.nonce){const e=await E(t,this.entrypointAddress,this.accountAddress);if("bigint"!=typeof e)return e;d=e}else d=n.nonce;const p=null!=(i=n.initCode)?i:"0x";if(d<0n)throw RangeError("nonce can't be negative");if("0x"!=p&&d>0n)throw RangeError("initCode is only allowed when the nonce is zero for the first transaction when the safe account is not deployed yet");let h="0x";h=null==n.callData?1==e.length?_.createAccountCallDataSingleTransaction(e[0]):_.createAccountCallDataBatchTransactions(e):n.callData;let g=b.maxFeePerGas,m=b.maxPriorityFeePerGas;if(null!=n.maxFeePerGas&&null!=n.maxPriorityFeePerGas||([g,m]=await async function(e,t=y.Medium){const r=new a(e),n=await r.getFeeData();return[BigInt(Math.ceil(Number(n.maxFeePerGas)*t)),BigInt(Math.ceil(Number(n.maxPriorityFeePerGas)*t))]}(t)),"bigint"==typeof n.maxFeePerGas&&n.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof n.maxPriorityFeePerGas&&n.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");g=null!=(s=n.maxFeePerGas)?s:g,m=null!=(f=n.maxPriorityFeePerGas)?f:m;const A=u({},b,{sender:this.accountAddress,nonce:d,initCode:p,callData:h,maxFeePerGas:g,maxPriorityFeePerGas:m});let D=b.preVerificationGas,F=b.verificationGasLimit,x=b.callGasLimit;if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit){const e=await _.estimateUserOperationGas(A,this.entrypointAddress,r);if("code"in e)return e;[D,F,x]=e}if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return A.preVerificationGas=null!=(o=n.preVerificationGas)?o:D,A.verificationGasLimit=null!=(c=n.verificationGasLimit)?c:F,A.callGasLimit=null!=(l=n.callGasLimit)?l:x,A}async sendUserOperation(e,t){const r=new U(t),a=await r.sendUserOperation(e,this.entrypointAddress);return"string"!=typeof a?a:new v(a,r,this.entrypointAddress)}}_.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",_.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xD556564bAcF6FEAC2E26ff70695f8250Cea8C29E",_.DEFAULT_SINGLETON_ADDRESS="0x41675C099F32341bf84BFc5382aF534df5C7461a",_.DEFAULT_ADD_MODULE_LIB_ADDRESS="0xea2B4251c7C1cDFFc04D35d990AF6Fd0309928B3",_.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",_.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",_.initializerFunctionSelector="0xb63e800d",_.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],_.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=G.executeUserOpWithErrorString,_.executorFunctionInputAbi=["address","uint256","bytes","uint8"];class C extends x{constructor(e="0x9406Cc6185a346906296840746125a0E44976454"){super(e,"0x5fbfb9cf",["address","uint256"])}}class L{}class w extends L{constructor(e,t){super(),this.rpcUrl=void 0,this.entrypointAddress=void 0,this.rpcUrl=t,this.entrypointAddress=e}async getSupportedERC20Tokens(){const e=await A(this.rpcUrl,"pm_supportedERC20Tokens",[]);if("result"in e){const t=e.result;return{tokens:t.tokens,paymasterMetadata:t.paymasterMetadata}}return e.error}async getSupportedEntrypoint(){const e=await A(this.rpcUrl,"pm_supportedEntryPoint",[]);return"result"in e?e.result:e.error}async getPaymasterCallDataForPayingGasWithErc20(e,t){return this.getPaymasterCallData(e,[this.rpcUrl,this.entrypointAddress,t])}async getPaymasterCallDataForGaslessTx(e){return this.getPaymasterCallData(e,[this.rpcUrl,this.entrypointAddress])}async getPaymasterCallData(e,t){const r=t[0],a=t[1],n=t[2],i=await A(r,"pm_sponsorUserOperation",[e,a,{token:n}]);return"result"in i?i.result:i.error}}var P={__proto__:null,SmartAccount:d,SafeAccount:_,SendUseroperationResponse:v,SmartAccountFactory:x,SafeAccountFactory:S,SimpleAccountFactory:C,Bundler:U,CandideValidationPaymaster:w,createUserOperationHash:g,createCallData:m,getFunctionSelector:D,fetchAccountNonce:E,UserOperationEmptyValues:F,UserOperationDummyValues:b,get Operation(){return h}};export{U as Bundler,w as CandideValidationPaymaster,h as Operation,_ as SafeAccount,S as SafeAccountFactory,v as SendUseroperationResponse,C as SimpleAccountFactory,d as SmartAccount,x as SmartAccountFactory,b as UserOperationDummyValues,F as UserOperationEmptyValues,P as abstractionkit,m as createCallData,g as createUserOperationHash,E as fetchAccountNonce,D as getFunctionSelector};
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ethers"),require("isomorphic-unfetch")):"function"==typeof define&&define.amd?define(["exports","ethers","isomorphic-unfetch"],t):t((e||self).abstractionkit={},e.ethers,e.isomorphicUnfetch)}(this,function(e,t,r){function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var i,a,o=/*#__PURE__*/n(r),s=function(e){this.accountAddress=void 0,this.accountAddress=e};function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c.apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,d(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function p(e){var t="function"==typeof Map?new Map:void 0;return p=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(f())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&d(i,r.prototype),i}(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},p(e)}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}s.proxyByteCode=void 0,s.initializerFunctionSelector=void 0,s.initializerFunctionInputAbi=void 0,s.executorFunctionSelector=void 0,s.executorFunctionInputAbi=void 0,e.Operation=void 0,(i=e.Operation||(e.Operation={}))[i.Call=0]="Call",i[i.Delegate=1]="Delegate",function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(a||(a={}));var m={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"},y=/*#__PURE__*/function(e){function t(t,r,n){var i;void 0===n&&(n={});var a=n.errno,o=n.context;return(i=e.call(this,r,{cause:n.cause})||this).code=void 0,i.context=void 0,i.errno=void 0,i.name=i.constructor.name,i.code=t,i.errno=a,i.context=o,i}return u(t,e),t}(/*#__PURE__*/p(Error));function A(e){if(e instanceof Error)return e;var t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch(e){}return new Error("This value was thrown as is, not through an Error: "+t)}var P=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:b(D("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(g(e,"eth_call",i)).then(function(e){if("string"!=typeof e)throw new y("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=A(e);throw new y("BAD_DATA","getNonce returned ill formed data",{cause:t})}})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=A(e);throw new y("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},g=function(e,t,r){try{var n=o.default||o,i={method:"POST",body:JSON.stringify({method:t,params:r,id:(new Date).getTime(),jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t}),redirect:"follow"};return Promise.resolve(n(e,i)).then(function(t){return Promise.resolve(t.json()).then(function(t){if("result"in t)return t.result;var r=t.error,n=String(r.code);throw new y(n in m?m[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(i)}})})})}catch(e){return Promise.reject(e)}};function E(e,r,n){var i=t.keccak256(function(e){var r=[e.sender,e.nonce,t.keccak256(e.initCode),t.keccak256(e.callData),e.callGasLimit,e.verificationGasLimit,e.preVerificationGas,e.maxFeePerGas,e.maxPriorityFeePerGas,t.keccak256(e.paymasterAndData)];return t.AbiCoder.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(e)),a=t.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,r,n]);return t.keccak256(a)}function b(e,r,n){return e+t.AbiCoder.defaultAbiCoder().encode(r,n).slice(2)}function D(e){return t.id(e).slice(0,10)}function O(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var G,R="0x0000000000000000000000000000000000000000",S={sender:R,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},_=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=b(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),U=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return u(t,e),t}(_);function T(r){return"0x"+r.map(function(r){return a=null!=(i=(n=r).operation)?i:e.Operation.Call,o=t.getBytes(n.data),t.solidityPacked(["uint8","address","uint256","uint256","bytes"],[a,n.to,n.value,o.length,o]).slice(2);var n,i,a,o}).join("")}function x(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(G||(G={}));var F=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{var e=this;return Promise.resolve(x(function(){return Promise.resolve(g(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new y("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=A(e);throw new y("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{var e=this;return Promise.resolve(x(function(){return Promise.resolve(g(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=A(e);throw new y("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=this;return Promise.resolve(x(function(){function i(){var e=a;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var a={},o=void 0===r?Promise.resolve(g(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){a=e}):Promise.resolve(g(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){a=e});return o&&o.then?o.then(i):i()},function(e){var t=A(e);throw new y("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{var r=this;return Promise.resolve(x(function(){return Promise.resolve(g(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=A(e);throw new y("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{var t=this;return Promise.resolve(x(function(){return Promise.resolve(g(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=c({},t.receipt,{blockNumber:BigInt(t.receipt.blockNumber),cumulativeGasUsed:BigInt(t.receipt.cumulativeGasUsed),gasUsed:BigInt(t.receipt.gasUsed),transactionIndex:BigInt(t.receipt.transactionIndex),effectiveGasPrice:null==t.receipt.effectiveGasPrice?void 0:BigInt(t.receipt.effectiveGasPrice),logs:JSON.stringify(t.receipt.logs)});return c({},t,{nonce:BigInt(t.nonce),actualGasCost:BigInt(t.actualGasCost),actualGasUsed:BigInt(t.actualGasUsed),logs:JSON.stringify(t.logs),receipt:r})}return null})},function(t){var r=A(t);throw new y("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{var t=this;return Promise.resolve(x(function(){return Promise.resolve(g(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?c({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=A(t);throw new y("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function w(e,t,r){if(!e.s){if(r instanceof L){if(!r.s)return void(r.o=w.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(w.bind(null,e,t),w.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var L=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{w(n,1,a(this.v))}catch(e){w(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?w(n,1,t?t(i):i):r?w(n,1,r(i)):w(n,2,i)}catch(e){w(n,2,e)}},n},e}();function C(e){return e instanceof L&&1&e.s}var I=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=180),void 0===t&&(t=2);try{var r,n=function(e){if(r)return e;throw new y("TIMEOUT","can't find useroperation",{context:i.userOperationHash})},i=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var a=0,o=function(e,t,r){for(var n;;){var i=e();if(C(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!C(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!C(o)){n=2;break}}}var s=new L,f=w.bind(null,s,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,f),s;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!C(o))return void o.then(l).then(void 0,f);if(!(i=e())||C(i)&&!i.v)return void w(s,1,a);if(i.then)return void i.then(u).then(void 0,f);C(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,f)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,f):c(a):w(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):w(s,1,a)}}(function(){return!r&&a<=e},void 0,function(){return Promise.resolve(i.delay(1e3*t)).then(function(){return Promise.resolve(i.bundler.getUserOperationReceipt(i.userOperationHash)).then(function(e){if(null!=e)return r=1,e;a++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),N=/*#__PURE__*/function(r){function n(e,t,i){var a;return void 0===t&&(t=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=n.DEFAULT_ENTRYPOINT_ADDRESS),(a=r.call(this,e)||this).entrypointAddress=void 0,a.safe4337ModuleAddress=void 0,a.initCode=void 0,a.entrypointAddress=i,a.safe4337ModuleAddress=t,a.initCode=null,a}u(n,r),n.initializeNewAccount=function(e,t){void 0===t&&(t={});var r=n.createAccountAddressAndInitCode(e,t),i=r[1],a=new n(r[0]);return a.initCode=i,a},n.createAccountAddressAndInitCode=function(e,t){var r,i,a,o,s;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(r=t.threshold)?r:1,c=null!=(i=t.c2Nonce)?i:0n,u=null!=(a=t.singletonAddress)?a:n.DEFAULT_SINGLETON_ADDRESS,l=null!=(o=t.safe4337ModuleAddress)?o:n.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:n.DEFAULT_ADD_MODULE_LIB_ADDRESS,p=new U;null!=t.safeAccountFactoryAddress&&(p=new U(t.safeAccountFactoryAddress));var h=n.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(h,c,p.address,u),p.getFactoryGeneratorFunctionCallData([u,h,c])]},n.createInitializerCallData=function(e,t,r,i){if(void 0===r&&(r=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=n.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");var a=b("0x8d0dc49f",["address[]"],[[r]]);return b(n.initializerFunctionSelector,n.initializerFunctionInputAbi,[e,t,i,a,r,R,0,R])},n.createInitCode=function(e,t,r,i,a,o,s){if(void 0===t&&(t=1),void 0===r&&(r=0n),void 0===i&&(i=n.DEFAULT_SINGLETON_ADDRESS),void 0===a&&(a=new U),void 0===o&&(o=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=n.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(r<0n)throw RangeError("c2Nonce can't be negative");var f=n.createInitializerCallData(e,t,o,s);return a.getFactoryGeneratorFunctionCallData([i,f,r])},n.createProxyAddress=function(e,r,n,i){if(r<0n)throw RangeError("c2Nonce can't be negative");var a=t.AbiCoder.defaultAbiCoder(),o=t.keccak256(t.solidityPacked(["bytes32","uint256"],[t.keccak256(e),r])),s=a.encode(["uint256"],[i]),f=t.keccak256(t.solidityPacked(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+t.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,f]).slice(-40)},n.createAccountCallDataSingleTransaction=function(t){var r,i,a,o=null!=(r=t.value)?r:0,s=null!=(i=t.data)?i:"0x",f=null!=(a=t.operation)?a:e.Operation.Call;return n.createAccountCallData(t.to,o,s,f)},n.createAccountCallDataBatchTransactions=function(t,r){if(void 0===r&&(r=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS),t.length<1)throw RangeError("There should be at least one metaTransaction");var i=b("0x8d80ff0a",["bytes"],[T(t)]);return n.createAccountCallData(r,0n,i,e.Operation.Delegate)},n.createAccountCallData=function(e,t,r,i,a){return void 0===a&&(a=n.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),b(a,n.executorFunctionInputAbi,[e,t,r,i])};var i=n.prototype;return i.decodeAccountCallData=function(e){if(e.startsWith(G.executeUserOpWithErrorString)||e.startsWith(G.executeUserOp)){var r=t.AbiCoder.defaultAbiCoder(),n="0x"+e.slice(10),i=r.decode(["address","uint256","bytes","uint8"],n);return[i[0],BigInt(i[1]),i[2],Number(i[3])]}throw new y("BAD_DATA","Invalid calldata, should start with "+G.executeUserOpWithErrorString+" or "+G.executeUserOp,{context:{callData:e}})},i.prependTokenPaymasterApproveToCallData=function(r,i,a,o,s){void 0===s&&(s=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var f=this.decodeAccountCallData(r),c=f[0],u=f[1],l=f[2],d=f[3],p="";p="string"!=typeof l?(new TextDecoder).decode(l):l;var h=T([{to:i,value:0n,data:b(D("approve(address,uint256)"),["address","uint256"],[a,o]),operation:e.Operation.Call}]),v="",m="0x8d80ff0a";if(p.startsWith(m)){var y=function(e){return t.AbiCoder.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(p);v=y+h.slice(2)}else v=T([{to:c,value:u,data:l,operation:d}])+h.slice(2);var A=b(m,["bytes"],[v]);return n.createAccountCallData(s,0n,A,e.Operation.Delegate)},i.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new F(t);return Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n*BigInt(n),BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},i.createUserOperation=function(e,r,i,o){void 0===o&&(o={});try{var s=function(){var s;function l(){var e,t;function r(){var e,t,r;if("bigint"==typeof o.preVerificationGas&&o.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof o.verificationGasLimit&&o.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof o.callGasLimit&&o.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return n.preVerificationGas=null!=(e=o.preVerificationGas)?e:a,n.verificationGasLimit=null!=(t=o.verificationGasLimit)?t:s,n.callGasLimit=null!=(r=o.callGasLimit)?r:l,n}if("bigint"==typeof o.maxFeePerGas&&o.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof o.maxPriorityFeePerGas&&o.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");h=null!=(e=o.maxFeePerGas)?e:h,v=null!=(t=o.maxPriorityFeePerGas)?t:v;var n=c({},S,{sender:f.accountAddress,nonce:u,initCode:d,callData:p,maxFeePerGas:h,maxPriorityFeePerGas:v}),a=S.preVerificationGas,s=S.verificationGasLimit,l=S.callGasLimit,m=function(){if(null==o.preVerificationGas||null==o.verificationGasLimit||null==o.callGasLimit)return Promise.resolve(f.estimateUserOperationGas(n,i,o.state_override_set,o.numberOfSigners)).then(function(e){a=e[0],s=e[1],l=e[2]})}();return m&&m.then?m.then(r):r()}var d=null!=(s=o.initCode)?s:f.initCode;if((null==d||u>0n)&&(d="0x"),u<0n)throw RangeError("nonce can't be negative");var p="0x";p=null==o.callData?1==e.length?n.createAccountCallDataSingleTransaction(e[0]):n.createAccountCallDataBatchTransactions(e):o.callData;var h=S.maxFeePerGas,v=S.maxPriorityFeePerGas,m=function(){if(null==o.maxFeePerGas||null==o.maxPriorityFeePerGas)return Promise.resolve(function(e,r){try{void 0===r&&(r=a.Medium);var n=new t.JsonRpcProvider(e);return Promise.resolve(n.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*r)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*r))]})}catch(e){return Promise.reject(e)}}(r)).then(function(e){h=e[0],v=e[1]})}();return m&&m.then?m.then(l):l()},f=this;if(e.length<1)throw RangeError("There should be at least one transaction");var u=0n,l=function(){if(null==o.nonce)return Promise.resolve(P(r,f.entrypointAddress,f.accountAddress)).then(function(e){u=e});u=o.nonce}();return Promise.resolve(l&&l.then?l.then(s):s())}catch(e){return Promise.reject(e)}},i.signUserOperation=function(e,r,i,a,o){if(void 0===a&&(a=0n),void 0===o&&(o=0n),r.length<1)throw RangeError("There should be at least one privateKey");if(i<0n)throw RangeError("chainId can't be negative");if(a<0n)throw RangeError("validAfter can't be negative");if(o<0n)throw RangeError("validUntil can't be negative");for(var s,f={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:a,validUntil:o,entryPoint:this.entrypointAddress},c={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},u=new Map,l=v(r);!(s=l()).done;){var d=new t.Wallet(s.value);u.set(d.address,d)}for(var p,h=[],m=v(Array.from(u.keys()).sort());!(p=m()).done;){var y=u.get(p.value).signingKey.sign(t.TypedDataEncoder.hash({chainId:i,verifyingContract:this.safe4337ModuleAddress},c,f)).serialized;h.push(y.slice(2))}return n.formatEip712SignaturesToUseroperationSignature(h,a,o)},n.formatEip712SignaturesToUseroperationSignature=function(e,r,n){void 0===r&&(r=0n),void 0===n&&(n=0n);var i="0x"+e.join("");return t.solidityPacked(["uint48","uint48","bytes"],[r,n,i])},i.sendUserOperation=function(e,t){try{var r=this,n=new F(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new I(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},n}(s);function B(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}N.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",N.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",N.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",N.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",N.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",N.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",N.initializerFunctionSelector="0xb63e800d",N.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],N.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=G.executeUserOpWithErrorString,N.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var k=/*#__PURE__*/function(e){function t(t){var r;return(r=e.call(this)||this).rpcUrl=void 0,r.entrypointAddress=void 0,r.supportedTokens=void 0,r.paymasterMetadata=void 0,r.rpcUrl=t,r}u(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(B(function(){return Promise.resolve(e.getSupportedEntrypoint()).then(function(t){return e.entrypointAddress=t,Promise.resolve(e.getSupportedERC20TokensAndPaymasterMetadata()).then(function(t){return e.supportedTokens=t.tokens,e.paymasterMetadata=t.paymasterMetadata,null})})},function(e){var t=A(e);throw new y("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}))}catch(e){return Promise.reject(e)}},r.getPaymasterMetaData=function(){try{var e=function(){return t.paymasterMetadata},t=this,r=function(){if(null==t.paymasterMetadata)return Promise.resolve(t.initialize()).then(function(){})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokensAndPaymasterMetadata=function(){try{var e=this;return Promise.resolve(null==e.supportedTokens||null==e.paymasterMetadata?B(function(){return Promise.resolve(g(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}})},function(e){var t=A(e);throw new y("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}):{tokens:e.supportedTokens,paymasterMetadata:e.paymasterMetadata})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{var e=this;return Promise.resolve(null==e.entrypointAddress?B(function(){return Promise.resolve(g(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=A(e);throw new y("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}):e.entrypointAddress)}catch(e){return Promise.reject(e)}},r.isSupportedERC20Token=function(e){try{var t=function(){return!!r.supportedTokens.find(function(t){return t.address===e.toLowerCase()})},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokenData=function(e){try{var t=function(){var t=r.supportedTokens.find(function(t){return t.address.toLowerCase()===e.toLowerCase()});return t?{symbol:t.symbol,address:t.address,decimal:Number(t.decimal),fee:BigInt(t.fee),exchangeRate:BigInt(t.exchangeRate)}:null},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.createPaymasterUserOperation=function(e,t,r,n){void 0===r&&(r={});try{var i=function(){return B(function(){e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var i=new F(t);return Promise.resolve(i.estimateUserOperationGas(e,a.entrypointAddress,n)).then(function(t){return e.preVerificationGas=t.preVerificationGas,e.verificationGasLimit=t.verificationGasLimit+10000n,e.callGasLimit=t.callGasLimit,Promise.resolve(g(a.rpcUrl,"pm_sponsorUserOperation",[e,a.entrypointAddress,r])).then(function(t){var r,n,i,a,o,s=t,f={paymasterAndData:s.paymasterAndData,callGasLimit:null==s.callGasLimit?void 0:BigInt(s.callGasLimit),preVerificationGas:null==s.preVerificationGas?void 0:BigInt(s.preVerificationGas),verificationGasLimit:null==s.verificationGasLimit?void 0:BigInt(s.verificationGasLimit),maxFeePerGas:null==s.maxFeePerGas?void 0:BigInt(s.maxFeePerGas),maxPriorityFeePerGas:null==s.maxPriorityFeePerGas?void 0:BigInt(s.maxPriorityFeePerGas)};return e.paymasterAndData=f.paymasterAndData,e.callGasLimit=null!=(r=f.callGasLimit)?r:e.callGasLimit,e.preVerificationGas=null!=(n=f.preVerificationGas)?n:e.preVerificationGas,e.verificationGasLimit=null!=(i=f.verificationGasLimit)?i:e.verificationGasLimit,e.maxFeePerGas=null!=(a=f.maxFeePerGas)?a:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})})},function(e){var t=A(e);throw new y("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},a=this,o=function(){if(null==a.entrypointAddress||null==a.supportedTokens||null==a.paymasterMetadata)return Promise.resolve(a.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(i):i())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,i){void 0===i&&(i={});try{var a=this;return Promise.resolve(B(function(){return Promise.resolve(a.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(a.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(a.createPaymasterUserOperation(t,n,{token:r},i))})})},function(e){var t=A(e);throw new y("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}))}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(B(function(){return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new y("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e)}})});var i=O(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})},function(e){var t=A(e);throw new y("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),M={__proto__:null,SmartAccount:s,SafeAccountV0_2_0:N,SendUseroperationResponse:I,SmartAccountFactory:_,SafeAccountFactory:U,Bundler:F,CandidePaymaster:k,createUserOperationHash:E,createCallData:b,getFunctionSelector:D,fetchAccountNonce:P,calculateUserOperationMaxGasCost:O,get Operation(){return e.Operation}};e.Bundler=F,e.CandidePaymaster=k,e.SafeAccountFactory=U,e.SafeAccountV0_2_0=N,e.SendUseroperationResponse=I,e.SmartAccount=s,e.SmartAccountFactory=_,e.abstractionkit=M,e.calculateUserOperationMaxGasCost=O,e.createCallData=b,e.createUserOperationHash=E,e.fetchAccountNonce=P,e.getFunctionSelector=D});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ethers"),require("isomorphic-unfetch")):"function"==typeof define&&define.amd?define(["exports","ethers","isomorphic-unfetch"],t):t((e||self).abstractionkit={},e.ethers,e.isomorphicUnfetch)}(this,function(e,t,r){function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var i,a,o,f=/*#__PURE__*/n(r),s=function(e){this.accountAddress=void 0,this.accountAddress=e};function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c.apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}s.proxyByteCode=void 0,s.initializerFunctionSelector=void 0,s.initializerFunctionInputAbi=void 0,s.executorFunctionSelector=void 0,s.executorFunctionInputAbi=void 0,function(e){e[e.InvalidFields=-32602]="InvalidFields",e[e.SimulateValidation=-32500]="SimulateValidation",e[e.SimulatePaymasterValidation=-32501]="SimulatePaymasterValidation",e[e.OpcodeValidation=-32502]="OpcodeValidation",e[e.ExpiresShortly=-32503]="ExpiresShortly",e[e.Reputation=-32504]="Reputation",e[e.InsufficientStake=-32505]="InsufficientStake",e[e.UnsupportedSignatureAggregator=-32506]="UnsupportedSignatureAggregator",e[e.InvalidSignature=-32507]="InvalidSignature",e[e.InvalidUseroperationHash=-32601]="InvalidUseroperationHash",e[e.ExecutionReverted=-32521]="ExecutionReverted"}(i||(i={})),e.Operation=void 0,(a=e.Operation||(e.Operation={}))[a.Call=0]="Call",a[a.Delegate=1]="Delegate",function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(o||(o={}));var h=function(e,t,r,n){void 0===n&&(n=0);try{var i=y(m("getNonce(address,uint192)"),["address","uint192"],[r,n]);return Promise.resolve(p(e,"eth_call",[{from:"0x0000000000000000000000000000000000000000",to:t,data:i},"latest"])).then(function(e){return"result"in e?BigInt(e.result):e.error})}catch(e){return Promise.reject(e)}},p=function(e,t,r){try{var n=f.default||f,i=JSON.stringify({method:t,params:r,id:1,jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t});return Promise.resolve(n(e,{method:"POST",body:i,redirect:"follow"})).then(function(e){return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function v(e,r,n){var i=t.keccak256(function(e){var r=[e.sender,e.nonce,t.keccak256(e.initCode),t.keccak256(e.callData),e.callGasLimit,e.verificationGasLimit,e.preVerificationGas,e.maxFeePerGas,e.maxPriorityFeePerGas,t.keccak256(e.paymasterAndData)];return t.AbiCoder.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(e)),a=t.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,r,n]);return t.keccak256(a)}function y(e,r,n){return e+t.AbiCoder.defaultAbiCoder().encode(r,n).slice(2)}function m(e){return t.id(e).slice(0,10)}var A,g={sender:t.ZeroAddress,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,paymasterAndData:"0x",signature:"0x"},b={sender:t.ZeroAddress,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},D=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=y(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),P=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return u(t,e),t}(D);!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(A||(A={}));var E=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{return Promise.resolve(p(this.rpcUrl,"eth_chainId",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{return Promise.resolve(p(this.rpcUrl,"eth_supportedEntryPoints",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=function(){return"result"in i?i.result:i.error},i={},a=void 0===r?Promise.resolve(p(this.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){i=e}):Promise.resolve(p(this.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){i=e});return Promise.resolve(a&&a.then?a.then(n):n())}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{return Promise.resolve(p(this.rpcUrl,"eth_sendUserOperation",[e,t])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{return Promise.resolve(p(this.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){if("result"in e){var t=e.result,r=c({},t.receipt,{logs:JSON.stringify(t.receipt.logs)});return c({},t,{logs:JSON.stringify(t.logs),receipt:r})}return e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{return Promise.resolve(p(this.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},e}();function F(e,t,r){if(!e.s){if(r instanceof S){if(!r.s)return void(r.o=F.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(F.bind(null,e,t),F.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var S=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{F(n,1,a(this.v))}catch(e){F(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?F(n,1,t?t(i):i):r?F(n,1,r(i)):F(n,2,i)}catch(e){F(n,2,e)}},n},e}();function x(e){return e instanceof S&&1&e.s}var U=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=60),void 0===t&&(t=1);try{var r,n=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var a=0,o={},f=function(e,t,r){for(var n;;){var i=e();if(x(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!x(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!x(o)){n=2;break}}}var f=new S,s=F.bind(null,f,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,s),f;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!x(o))return void o.then(l).then(void 0,s);if(!(i=e())||x(i)&&!i.v)return void F(f,1,a);if(i.then)return void i.then(u).then(void 0,s);x(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,s)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,s):c(a):F(f,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,s):u(i):F(f,1,a)}}(function(){return!r&&a<=e},void 0,function(){return Promise.resolve(n.delay(1e3*t)).then(function(){return Promise.resolve(n.bundler.getUserOperationReceipt(n.userOperationHash)).then(function(e){return"code"in e?e.code!=i.InvalidUseroperationHash?(r=1,e):(a++,void(o=e)):(r=1,e)})})});return Promise.resolve(f&&f.then?f.then(function(e){return r?e:o}):r?f:o)}catch(e){return Promise.reject(e)}},e}(),G=/*#__PURE__*/function(r){function n(e,t,i){var a;return void 0===t&&(t=n.DEFAULT_ENTRYPOINT_ADDRESS),void 0===i&&(i=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),(a=r.call(this,e)||this).entrypointAddress=void 0,a.safe4337ModuleAddress=void 0,a.entrypointAddress=t,a.safe4337ModuleAddress=i,a}u(n,r),n.createAccountAddressAndInitCode=function(e,t){var r,i,a,o,f;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var s=null!=(r=t.threshold)?r:1,c=null!=(i=t.c2Nonce)?i:0n,u=null!=(a=t.singletonAddress)?a:n.DEFAULT_SINGLETON_ADDRESS,l=null!=(o=t.safe4337ModuleAddress)?o:n.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(f=t.addModuleLibAddress)?f:n.DEFAULT_ADD_MODULE_LIB_ADDRESS,h=new P;null!=t.safeAccountFactoryAddress&&(h=new P(t.safeAccountFactoryAddress));var p=n.createInitializerCallData(e,s,l,d);return[this.createProxyAddress(p,c,h.address,u),n.createInitCode(e,s,c,u,h,l,d)]},n.createInitializerCallData=function(e,r,i,a){if(void 0===i&&(i=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=n.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(r<1)throw RangeError("threshold should be at least one");if(r>e.length)throw RangeError("threshold can't be larger than number of owners");var o=y("0x8d0dc49f",["address[]"],[[i]]);return y(n.initializerFunctionSelector,n.initializerFunctionInputAbi,[e,r,a,o,i,t.ZeroAddress,0,t.ZeroAddress])},n.createInitCode=function(e,t,r,i,a,o,f){if(void 0===t&&(t=1),void 0===r&&(r=0n),void 0===i&&(i=n.DEFAULT_SINGLETON_ADDRESS),void 0===a&&(a=new P),void 0===o&&(o=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===f&&(f=n.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(r<0n)throw RangeError("c2Nonce can't be negative");var s=n.createInitializerCallData(e,t,o,f);return a.getFactoryGeneratorFunctionCallData([i,s,r])},n.createProxyAddress=function(e,r,n,i){if(r<0n)throw RangeError("c2Nonce can't be negative");var a=t.AbiCoder.defaultAbiCoder(),o=t.keccak256(t.solidityPacked(["bytes32","uint256"],[t.keccak256(e),r])),f=a.encode(["uint256"],[i]),s=t.keccak256(t.solidityPacked(["bytes","bytes"],[this.proxyByteCode,f]));return"0x"+t.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,s]).slice(-40)},n.createAccountCallDataSingleTransaction=function(t){var r,i,a,o=null!=(r=t.value)?r:0,f=null!=(i=t.data)?i:"0x",s=null!=(a=t.operation)?a:e.Operation.Call;return n.createAccountCallData(t.to,o,f,s)},n.createAccountCallDataBatchTransactions=function(r,i){if(void 0===i&&(i=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS),r.length<1)throw RangeError("There should be at least one metaTransaction");var a,o=y("0x8d80ff0a",["bytes"],[(a=r,"0x"+a.map(function(r){return function(r){var n,i=null!=(n=r.operation)?n:e.Operation.Call,a=t.ethers.getBytes(r.data);return t.ethers.solidityPacked(["uint8","address","uint256","uint256","bytes"],[i,r.to,r.value,a.length,a]).slice(2)}(r)}).join(""))]);return n.createAccountCallData(i,0n,o,e.Operation.Delegate)},n.createAccountCallData=function(e,t,r,i,a){return void 0===a&&(a=n.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),y(a,n.executorFunctionInputAbi,[e,t,r,i])},n.estimateUserOperationGas=function(e,t,r){try{e.signature="0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";var n=new E(r);return Promise.resolve(n.estimateUserOperationGas(e,t)).then(function(e){return"code"in e?e:[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n,BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}};var i=n.prototype;return i.signUserOperation=function(e,r,n,i,a){if(void 0===i&&(i=0n),void 0===a&&(a=0n),r.length<1)throw RangeError("There should be at least one privateKey");if(n<0n)throw RangeError("chainId can't be negative");if(i<0n)throw RangeError("validAfter can't be negative");if(a<0n)throw RangeError("validUntil can't be negative");for(var o,f={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:i,validUntil:a,entryPoint:this.entrypointAddress},s={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},c="",u=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(o=u()).done;)c+=new t.Wallet(o.value).signingKey.sign(t.TypedDataEncoder.hash({chainId:n,verifyingContract:this.safe4337ModuleAddress},s,f)).serialized;return t.solidityPacked(["uint48","uint48","bytes"],[i,a,c])},i.createUserOperation=function(e,r,i,a){void 0===a&&(a={});try{var f,s=function(s){var d;if(f)return s;function h(){var e,t,r;function o(e){var t,n,i;if(r)return e;if("bigint"==typeof a.preVerificationGas&&a.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof a.verificationGasLimit&&a.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof a.callGasLimit&&a.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return f.preVerificationGas=null!=(t=a.preVerificationGas)?t:s,f.verificationGasLimit=null!=(n=a.verificationGasLimit)?n:d,f.callGasLimit=null!=(i=a.callGasLimit)?i:h,f}if("bigint"==typeof a.maxFeePerGas&&a.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof a.maxPriorityFeePerGas&&a.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");y=null!=(e=a.maxFeePerGas)?e:y,m=null!=(t=a.maxPriorityFeePerGas)?t:m;var f=c({},b,{sender:u.accountAddress,nonce:l,initCode:p,callData:v,maxFeePerGas:y,maxPriorityFeePerGas:m}),s=b.preVerificationGas,d=b.verificationGasLimit,h=b.callGasLimit,A=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return Promise.resolve(n.estimateUserOperationGas(f,u.entrypointAddress,i)).then(function(e){if("code"in e)return r=1,e;s=e[0],d=e[1],h=e[2]})}();return A&&A.then?A.then(o):o(A)}var p=null!=(d=a.initCode)?d:"0x";if(l<0n)throw RangeError("nonce can't be negative");if("0x"!=p&&l>0n)throw RangeError("initCode is only allowed when the nonce is zero for the first transaction when the safe account is not deployed yet");var v="0x";v=null==a.callData?1==e.length?n.createAccountCallDataSingleTransaction(e[0]):n.createAccountCallDataBatchTransactions(e):a.callData;var y=b.maxFeePerGas,m=b.maxPriorityFeePerGas,A=function(){if(null==a.maxFeePerGas||null==a.maxPriorityFeePerGas)return Promise.resolve(function(e,r){try{void 0===r&&(r=o.Medium);var n=new t.JsonRpcProvider(e);return Promise.resolve(n.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*r)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*r))]})}catch(e){return Promise.reject(e)}}(r)).then(function(e){y=e[0],m=e[1]})}();return A&&A.then?A.then(h):h()},u=this;if(e.length<1)throw RangeError("There should be at least one transaction");var l=0n,d=function(){if(null==a.nonce)return Promise.resolve(h(r,u.entrypointAddress,u.accountAddress)).then(function(e){if("bigint"!=typeof e)return f=1,e;l=e});l=a.nonce}();return Promise.resolve(d&&d.then?d.then(s):s(d))}catch(e){return Promise.reject(e)}},i.sendUserOperation=function(e,t){try{var r=this,n=new E(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return"string"!=typeof e?e:new U(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},n}(s);G.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",G.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xD556564bAcF6FEAC2E26ff70695f8250Cea8C29E",G.DEFAULT_SINGLETON_ADDRESS="0x41675C099F32341bf84BFc5382aF534df5C7461a",G.DEFAULT_ADD_MODULE_LIB_ADDRESS="0xea2B4251c7C1cDFFc04D35d990AF6Fd0309928B3",G.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",G.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",G.initializerFunctionSelector="0xb63e800d",G.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],G.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=A.executeUserOpWithErrorString,G.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var O=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x9406Cc6185a346906296840746125a0E44976454"),e.call(this,t,"0x5fbfb9cf",["address","uint256"])||this}return u(t,e),t}(D),_=/*#__PURE__*/function(e){function t(t,r){var n;return(n=e.call(this)||this).rpcUrl=void 0,n.entrypointAddress=void 0,n.rpcUrl=r,n.entrypointAddress=t,n}u(t,e);var r=t.prototype;return r.getSupportedERC20Tokens=function(){try{return Promise.resolve(p(this.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){if("result"in e){var t=e.result;return{tokens:t.tokens,paymasterMetadata:t.paymasterMetadata}}return e.error})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{return Promise.resolve(p(this.rpcUrl,"pm_supportedEntryPoint",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForPayingGasWithErc20=function(e,t){try{var r=this;return Promise.resolve(r.getPaymasterCallData(e,[r.rpcUrl,r.entrypointAddress,t]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForGaslessTx=function(e){try{var t=this;return Promise.resolve(t.getPaymasterCallData(e,[t.rpcUrl,t.entrypointAddress]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallData=function(e,t){try{return Promise.resolve(p(t[0],"pm_sponsorUserOperation",[e,t[1],{token:t[2]}])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t}(function(){}),C={__proto__:null,SmartAccount:s,SafeAccount:G,SendUseroperationResponse:U,SmartAccountFactory:D,SafeAccountFactory:P,SimpleAccountFactory:O,Bundler:E,CandideValidationPaymaster:_,createUserOperationHash:v,createCallData:y,getFunctionSelector:m,fetchAccountNonce:h,UserOperationEmptyValues:g,UserOperationDummyValues:b,get Operation(){return e.Operation}};e.Bundler=E,e.CandideValidationPaymaster=_,e.SafeAccount=G,e.SafeAccountFactory=P,e.SendUseroperationResponse=U,e.SimpleAccountFactory=O,e.SmartAccount=s,e.SmartAccountFactory=D,e.UserOperationDummyValues=b,e.UserOperationEmptyValues=g,e.abstractionkit=C,e.createCallData=y,e.createUserOperationHash=v,e.fetchAccountNonce=h,e.getFunctionSelector=m});
@@ -0,0 +1,13 @@
1
+ import { Paymaster } from "./Paymaster";
2
+ import { UserOperation, BundlerJsonRpcError, SupportedERC20Tokens, PmSponsorUserOperationResult } from "../types";
3
+ export declare class CandideValidationPaymaster extends Paymaster {
4
+ readonly rpcUrl: string;
5
+ readonly entrypointAddress: string;
6
+ constructor(entrypointAddress: string, rpcUrl: string);
7
+ getSupportedERC20Tokens(): Promise<SupportedERC20Tokens | BundlerJsonRpcError>;
8
+ getSupportedEntrypoint(): Promise<string | BundlerJsonRpcError>;
9
+ getPaymasterCallDataForPayingGasWithErc20(userOperation: UserOperation, erc20TokenAddress: string): Promise<PmSponsorUserOperationResult | BundlerJsonRpcError>;
10
+ getPaymasterCallDataForGaslessTx(userOperation: UserOperation): Promise<PmSponsorUserOperationResult | BundlerJsonRpcError>;
11
+ getPaymasterCallData(userOperation: UserOperation, config: string[]): Promise<PmSponsorUserOperationResult | BundlerJsonRpcError>;
12
+ }
13
+ //# sourceMappingURL=CandideValidationPaymaster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CandideValidationPaymaster.d.ts","sourceRoot":"","sources":["../../src/paymaster/CandideValidationPaymaster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EACN,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,MAAM,UAAU,CAAC;AAElB,qBAAa,0BAA2B,SAAQ,SAAS;IACxD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;gBAEvB,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAM/C,uBAAuB,IAAI,OAAO,CACvC,oBAAoB,GAAG,mBAAmB,CAC1C;IAeK,sBAAsB,IAAI,OAAO,CAAC,MAAM,GAAG,mBAAmB,CAAC;IAc/D,yCAAyC,CAC9C,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,MAAM,GACvB,OAAO,CAAC,4BAA4B,GAAG,mBAAmB,CAAC;IAMxD,gCAAgC,CACrC,aAAa,EAAE,aAAa,GAC1B,OAAO,CAAC,4BAA4B,GAAG,mBAAmB,CAAC;IAMxD,oBAAoB,CACzB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EAAE,GACd,OAAO,CAAC,4BAA4B,GAAG,mBAAmB,CAAC;CAiB9D"}
@@ -1,6 +1,9 @@
1
- import type { UserOperation, StateOverrideSet } from "../types";
2
- import { CandidePaymasterContext } from "./types";
1
+ import "ethers";
2
+ import type { BytesLike } from "ethers";
3
+ import type { UserOperation, BundlerJsonRpcError } from "../types";
3
4
  export declare abstract class Paymaster {
4
- abstract createPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, context: CandidePaymasterContext, state_override_set?: StateOverrideSet): Promise<UserOperation>;
5
+ abstract getPaymasterCallData(userOperation: UserOperation, config: string[]): Promise<{
6
+ paymasterAndData: BytesLike;
7
+ } | BundlerJsonRpcError>;
5
8
  }
6
9
  //# sourceMappingURL=Paymaster.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Paymaster.d.ts","sourceRoot":"","sources":["../../src/paymaster/Paymaster.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD,8BAAsB,SAAS;IAC9B,QAAQ,CAAC,4BAA4B,CACpC,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,uBAAuB,EAChC,kBAAkB,CAAC,EAAE,gBAAgB,GACnC,OAAO,CAAC,aAAa,CAAC;CACzB"}
1
+ {"version":3,"file":"Paymaster.d.ts","sourceRoot":"","sources":["../../src/paymaster/Paymaster.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEnE,8BAAsB,SAAS;IAC9B,QAAQ,CAAC,oBAAoB,CAC5B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EAAE,GACd,OAAO,CAAC;QAAE,gBAAgB,EAAE,SAAS,CAAA;KAAE,GAAG,mBAAmB,CAAC;CACjE"}
package/dist/types.d.ts CHANGED
@@ -1,92 +1,101 @@
1
+ import type { BytesLike } from "ethers";
1
2
  export type UserOperation = {
2
3
  sender: string;
3
4
  nonce: bigint;
4
- initCode: string;
5
- callData: string;
5
+ initCode: BytesLike;
6
+ callData: BytesLike;
6
7
  callGasLimit: bigint;
7
8
  verificationGasLimit: bigint;
8
9
  preVerificationGas: bigint;
9
10
  maxFeePerGas: bigint;
10
11
  maxPriorityFeePerGas: bigint;
11
- paymasterAndData: string;
12
- signature: string;
12
+ paymasterAndData: BytesLike;
13
+ signature: BytesLike;
13
14
  };
14
- export type AbiInputValue = string | bigint | number | boolean | AbiInputValue[];
15
- export type JsonRpcParam = string | bigint | boolean | object | JsonRpcParam[];
15
+ export type AbiInputValue = string | bigint | number | BytesLike | boolean | AbiInputValue[];
16
+ export type JsonRpcParam = string | bigint | BytesLike | boolean | object | JsonRpcParam[];
16
17
  export type JsonRpcResponse = {
17
- id: number | null;
18
- jsonrpc: string;
18
+ id: number;
19
19
  result?: JsonRpcResult;
20
- error?: JsonRpcError;
20
+ error?: BundlerJsonRpcError;
21
21
  };
22
22
  export type ChainIdResult = string;
23
23
  export type SupportedEntryPointsResult = string[];
24
- export type JsonRpcResult = ChainIdResult | SupportedEntryPointsResult | GasEstimationResult | UserOperationByHashResult | UserOperationReceipt | UserOperationReceiptResult | SupportedERC20TokensAndMetadata | PmUserOperationResult;
24
+ export type JsonRpcResult = ChainIdResult | SupportedEntryPointsResult | GasEstimationResult | UserOperationByHashResult | UserOperationReceipt | UserOperationReceiptResult | SupportedERC20Tokens | PmSponsorUserOperationResult;
25
+ export declare enum BundlerErrorCode {
26
+ InvalidFields = -32602,
27
+ SimulateValidation = -32500,
28
+ SimulatePaymasterValidation = -32501,
29
+ OpcodeValidation = -32502,
30
+ ExpiresShortly = -32503,
31
+ Reputation = -32504,
32
+ InsufficientStake = -32505,
33
+ UnsupportedSignatureAggregator = -32506,
34
+ InvalidSignature = -32507,
35
+ InvalidUseroperationHash = -32601,
36
+ ExecutionReverted = -32521
37
+ }
25
38
  export type JsonRpcError = {
26
39
  code: number;
27
40
  message: string;
28
- data: object;
41
+ };
42
+ export type BundlerJsonRpcError = {
43
+ code: BundlerErrorCode | number;
44
+ message: string;
29
45
  };
30
46
  export type GasEstimationResult = {
31
- callGasLimit: bigint;
32
- preVerificationGas: bigint;
33
- verificationGasLimit: bigint;
47
+ callGasLimit: string;
48
+ preVerificationGas: string;
49
+ verificationGasLimit: string;
34
50
  };
35
51
  export type UserOperationByHashResult = {
36
52
  userOperation: UserOperation;
37
53
  entryPoint: string;
38
- blockNumber: bigint | null;
39
- blockHash: string | null;
40
- transactionHash: string | null;
41
- } | null;
54
+ blockNumber: string;
55
+ blockHash: BytesLike;
56
+ transactionHash: BytesLike;
57
+ };
42
58
  export type UserOperationReceipt = {
43
- blockHash: string;
44
- blockNumber: bigint;
59
+ blockHash: BytesLike;
60
+ blockNumber: string;
45
61
  from: string;
46
- cumulativeGasUsed: bigint;
47
- gasUsed: bigint;
62
+ cumulativeGasUsed: string;
63
+ gasUsed: string;
48
64
  logs: string;
49
65
  logsBloom: string;
50
- transactionHash: string;
51
- transactionIndex: bigint;
52
- effectiveGasPrice?: bigint;
66
+ transactionHash: BytesLike;
67
+ transactionIndex: string;
53
68
  };
54
69
  export type UserOperationReceiptResult = {
55
- userOpHash: string;
70
+ userOpHash: BytesLike;
56
71
  entryPoint: string;
57
72
  sender: string;
58
- nonce: bigint;
73
+ nonce: string;
59
74
  paymaster: string;
60
- actualGasCost: bigint;
61
- actualGasUsed: bigint;
62
- success: boolean;
75
+ actualGasCost: string;
76
+ actualGasUsed: string;
77
+ success: string;
63
78
  logs: string;
64
79
  receipt: UserOperationReceipt;
65
- } | null;
66
- export type PmUserOperationResult = {
67
- paymasterAndData: string;
68
- callGasLimit?: bigint;
69
- preVerificationGas?: bigint;
70
- verificationGasLimit?: bigint;
71
- maxFeePerGas?: bigint;
72
- maxPriorityFeePerGas?: bigint;
80
+ };
81
+ export type PmSponsorUserOperationResult = {
82
+ paymasterAndData: BytesLike;
83
+ callGasLimit?: string;
84
+ preVerificationGas?: string;
85
+ verificationGasLimit?: string;
86
+ maxFeePerGas?: string;
87
+ maxPriorityFeePerGas?: string;
73
88
  };
74
89
  export declare enum Operation {
75
90
  Call = 0,
76
91
  Delegate = 1
77
92
  }
78
- export interface MetaTransaction {
79
- to: string;
80
- value: bigint;
81
- data: string;
82
- operation?: Operation;
83
- }
84
93
  export interface ERC20Token {
85
94
  symbol: string;
86
95
  address: string;
87
96
  decimal: number;
88
- fee: bigint;
89
- exchangeRate: bigint;
97
+ fee: number;
98
+ exchangeRate: string;
90
99
  }
91
100
  export interface PaymasterMetadata {
92
101
  name: string;
@@ -96,17 +105,17 @@ export interface PaymasterMetadata {
96
105
  sponsoredEventTopic: string;
97
106
  dummyPaymasterAndData: string;
98
107
  }
99
- export interface SupportedERC20TokensAndMetadata {
108
+ export interface SupportedERC20Tokens {
100
109
  paymasterMetadata: PaymasterMetadata;
101
110
  tokens: ERC20Token[];
102
111
  }
103
- export interface Dictionary<T> {
112
+ interface Dictionary<T> {
104
113
  [Key: string]: T;
105
114
  }
106
115
  export type AddressToState = {
107
116
  balance?: bigint;
108
117
  nonce?: bigint;
109
- code?: string;
118
+ code?: BytesLike;
110
119
  state?: Dictionary<string>;
111
120
  stateDiff?: Dictionary<string>;
112
121
  };
@@ -118,4 +127,5 @@ export declare enum GasOption {
118
127
  Medium = 1.2,
119
128
  Fast = 1.5
120
129
  }
130
+ export {};
121
131
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
package/dist/utils.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { AbiInputValue, UserOperation, JsonRpcParam, GasOption, JsonRpcResult } from "./types";
2
- export declare function createUserOperationHash(useroperation: UserOperation, entrypointAddress: string, chainId: bigint): string;
3
- export declare function createPackedUserOperation(useroperation: UserOperation): string;
4
- export declare function createCallData(functionSelector: string, functionInputAbi: string[], functionInputParameters: AbiInputValue[]): string;
5
- export declare function sendJsonRpcRequest(rpcUrl: string, method: string, params: JsonRpcParam): Promise<JsonRpcResult>;
1
+ import type { BytesLike } from "ethers";
2
+ import { AbiInputValue, UserOperation, JsonRpcResponse, JsonRpcParam, JsonRpcError, GasOption } from "./types";
3
+ export declare function createUserOperationHash(useroperation: UserOperation, entrypointAddress: string, chainId: bigint): BytesLike;
4
+ export declare function createPackedUserOperation(useroperation: UserOperation): BytesLike;
5
+ export declare function createCallData(functionSelector: string, functionInputAbi: string[], functionInputParameters: AbiInputValue[]): BytesLike;
6
+ export declare function sendJsonRpcRequest(rpcUrl: string, method: string, params: JsonRpcParam): Promise<JsonRpcResponse>;
6
7
  export declare function getFunctionSelector(functionSignature: string): string;
7
- export declare function fetchAccountNonce(rpcUrl: string, entryPoint: string, account: string, key?: number): Promise<bigint>;
8
+ export declare function fetchAccountNonce(rpcUrl: string, entryPoint: string, account: string, key?: number): Promise<bigint | JsonRpcError>;
8
9
  export declare function fetchGasPrice(provideRpc: string, gasLevel?: GasOption): Promise<[bigint, bigint]>;
9
- export declare function calculateUserOperationMaxGasCost(useroperation: UserOperation): bigint;
10
10
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,aAAa,EACb,aAAa,EAEb,YAAY,EAEZ,SAAS,EACT,aAAa,EACb,MAAM,SAAS,CAAC;AAcjB,wBAAgB,uBAAuB,CACtC,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM,GACb,MAAM,CAcR;AAOD,wBAAgB,yBAAyB,CACxC,aAAa,EAAE,aAAa,GAC1B,MAAM,CA+BR;AASD,wBAAgB,cAAc,CAC7B,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,EAAE,EAC1B,uBAAuB,EAAE,aAAa,EAAE,GACtC,MAAM,CASR;AAED,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,GAClB,OAAO,CAAC,aAAa,CAAC,CAmDxB;AAWD,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAErE;AAUD,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAU,GACb,OAAO,CAAC,MAAM,CAAC,CAqDjB;AAED,wBAAsB,aAAa,CAClC,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,SAA4B,GACpC,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAW3B;AAED,wBAAgB,gCAAgC,CAC/C,aAAa,EAAE,aAAa,GAC1B,MAAM,CAWR"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EACN,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,SAAS,EACR,MAAM,SAAS,CAAC;AAElB,wBAAgB,uBAAuB,CACtC,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM,GACb,SAAS,CAcX;AAED,wBAAgB,yBAAyB,CACxC,aAAa,EAAE,aAAa,GAC1B,SAAS,CA+BX;AAED,wBAAgB,cAAc,CAC7B,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,EAAE,EAC1B,uBAAuB,EAAE,aAAa,EAAE,GACtC,SAAS,CASX;AAED,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,GAClB,OAAO,CAAC,eAAe,CAAC,CAwB1B;AAGD,wBAAgB,mBAAmB,CAClC,iBAAiB,EAAE,MAAM,GACvB,MAAM,CAER;AAED,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,MAAM,EACd,UAAU,EAAC,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAQ,GACX,OAAO,CAAC,MAAM,GAAG,YAAY,CAAC,CA6BhC;AAED,wBAAsB,aAAa,CAClC,UAAU,EAAC,MAAM,EAAE,QAAQ,GAAE,SAA4B,GACxD,OAAO,CAAC,CAAC,MAAM,EAAC,MAAM,CAAC,CAAC,CASzB"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Candidelabs",
5
5
  "url": "https://candide.dev"
6
6
  },
7
- "version": "0.1.2",
7
+ "version": "0.1.4",
8
8
  "description": "Account Abstraction 4337 SDK by Candidelabs",
9
9
  "main": "dist/index.js",
10
10
  "module": "dist/index.m.js",
@@ -1,37 +0,0 @@
1
- import { SmartAccount } from "../SmartAccount";
2
- import { MetaTransaction, Operation, StateOverrideSet, UserOperation } from "../../types";
3
- import { SafeAccountFactory } from "../../factory/SafeAccountFactory";
4
- import { CreateUserOperationOverrides, InitCodeOverrides, SafeModuleExecutorFunctionSelector } from "./types";
5
- import { SendUseroperationResponse } from "../SendUseroperationResponse";
6
- export declare class SafeAccountV0_2_0 extends SmartAccount {
7
- static readonly DEFAULT_ENTRYPOINT_ADDRESS = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";
8
- static readonly DEFAULT_SAFE_4337_MODULE_ADDRESS = "0xa581c4A4DB7175302464fF3C06380BC3270b4037";
9
- static readonly DEFAULT_SINGLETON_ADDRESS = "0x29fcB43b46531BcA003ddC8FCB67FFE91900C762";
10
- static readonly DEFAULT_ADD_MODULE_LIB_ADDRESS = "0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb";
11
- static readonly DEFAULT_MULTISEND_CONTRACT_ADDRESS = "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526";
12
- static readonly proxyByteCode: string;
13
- static readonly initializerFunctionSelector: string;
14
- static readonly initializerFunctionInputAbi: string[];
15
- static readonly DEFAULT_EXECUTOR_FUCNTION_SELECTOR = SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString;
16
- static readonly executorFunctionInputAbi: string[];
17
- readonly entrypointAddress: string;
18
- readonly safe4337ModuleAddress: string;
19
- private initCode;
20
- constructor(accountAddress: string, safe4337ModuleAddress?: string, entrypointAddress?: string);
21
- static initializeNewAccount(owners: string[], overrides?: InitCodeOverrides): SafeAccountV0_2_0;
22
- static createAccountAddressAndInitCode(owners: string[], overrides?: InitCodeOverrides): [string, string];
23
- private static createInitializerCallData;
24
- static createInitCode(owners: string[], threshold?: number, c2Nonce?: bigint, singletonAddress?: string, safeAccountFactory?: SafeAccountFactory, safe4337ModuleAddress?: string, addModuleLibAddress?: string): string;
25
- static createProxyAddress(initializerCallData: string, c2Nonce: bigint, safeFactoryAddress: string, singletonAddress: string): string;
26
- static createAccountCallDataSingleTransaction(metaTransaction: MetaTransaction): string;
27
- static createAccountCallDataBatchTransactions(metaTransactions: MetaTransaction[], multisendContractAddress?: string): string;
28
- static createAccountCallData(to: string, value: bigint, data: string, operation: Operation, safeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector): string;
29
- decodeAccountCallData(callData: string): [string, bigint, string, number];
30
- prependTokenPaymasterApproveToCallData(callData: string, tokenAddress: string, paymasterAddress: string, approveAmount: bigint, multisendContractAddress?: string): string;
31
- estimateUserOperationGas(userOperation: UserOperation, bundlerRpc: string, state_override_set?: StateOverrideSet, numberOfSigners?: number): Promise<[bigint, bigint, bigint]>;
32
- createUserOperation(transactions: MetaTransaction[], providerRpc: string, bundlerRpc: string, overrids?: CreateUserOperationOverrides): Promise<UserOperation>;
33
- signUserOperation(useroperation: UserOperation, privateKeys: string[], chainId: bigint, validAfter?: bigint, validUntil?: bigint): string;
34
- static formatEip712SignaturesToUseroperationSignature(signatures: string[], validAfter?: bigint, validUntil?: bigint): string;
35
- sendUserOperation(userOperation: UserOperation, bundlerRpc: string): Promise<SendUseroperationResponse>;
36
- }
37
- //# sourceMappingURL=SafeAccountV0_2_0.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SafeAccountV0_2_0.d.ts","sourceRoot":"","sources":["../../../src/account/Safe/SafeAccountV0_2_0.ts"],"names":[],"mappings":"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"}
package/dist/errors.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import { Dictionary } from "./types";
2
- export type BasicErrorCode = "UNKNOWN_ERROR" | "TIMEOUT" | "BAD_DATA" | "BUNDLER_ERROR" | "PAYMASTER_ERROR";
3
- export type BundlerErrorCode = "INVALID_FIELDS" | "SIMULATE_VALIDATION" | "SIMULATE_PAYMASTER_VALIDATION" | "OPCODE_VALIDATION" | "EXPIRE_SHORTLY" | "REPUTATION" | "INSUFFICIENT_STAKE" | "UNSUPPORTED_SIGNATURE_AGGREGATOR" | "INVALID_SIGNATURE" | "INVALID_USEROPERATION_HASH" | "EXECUTION_REVERTED";
4
- export type JsonRpcErrorCode = "PARSE_ERROR" | "INVALID_REQUEST" | "METHOD_NOT_FOUND" | "INVALID_PARAMS" | "INTERNAL_ERROR" | "SERVER_ERROR";
5
- export declare const BundlerErrorCodeDict: Dictionary<BundlerErrorCode>;
6
- export declare const JsonRpcErrorDict: Dictionary<JsonRpcErrorCode>;
7
- type Jsonable = string | number | boolean | null | undefined | readonly Jsonable[] | {
8
- readonly [key: string]: Jsonable;
9
- } | {
10
- toJSON(): Jsonable;
11
- };
12
- export declare class AbstractionKitError extends Error {
13
- readonly code: BundlerErrorCode | BasicErrorCode | JsonRpcErrorCode;
14
- readonly context?: Jsonable;
15
- readonly errno?: number;
16
- constructor(code: BundlerErrorCode | BasicErrorCode | JsonRpcErrorCode, message: string, options?: {
17
- cause?: Error;
18
- errno?: number;
19
- context?: Jsonable;
20
- });
21
- }
22
- export declare function ensureError(value: unknown): Error;
23
- export {};
24
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,MAAM,cAAc,GACvB,eAAe,GACf,SAAS,GACT,UAAU,GACV,eAAe,GACf,iBAAiB,CAAC;AAErB,MAAM,MAAM,gBAAgB,GACzB,gBAAgB,GAChB,qBAAqB,GACrB,+BAA+B,GAC/B,mBAAmB,GACnB,gBAAgB,GAChB,YAAY,GACZ,oBAAoB,GACpB,kCAAkC,GAClC,mBAAmB,GACnB,4BAA4B,GAC5B,oBAAoB,CAAC;AAExB,MAAM,MAAM,gBAAgB,GACzB,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,CAAC;AAElB,eAAO,MAAM,oBAAoB,EAAE,UAAU,CAAC,gBAAgB,CAY7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,CAMzD,CAAC;AAEF,KAAK,QAAQ,GACV,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,SAAS,QAAQ,EAAE,GACnB;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,GACpC;IAAE,MAAM,IAAI,QAAQ,CAAA;CAAE,CAAC;AAE1B,qBAAa,mBAAoB,SAAQ,KAAK;IAC7C,SAAgB,IAAI,EAAE,gBAAgB,GAAG,cAAc,GAAG,gBAAgB,CAAC;IAC3E,SAAgB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnC,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAC;gBAG9B,IAAI,EAAE,gBAAgB,GAAG,cAAc,GAAG,gBAAgB,EAC1D,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,QAAQ,CAAA;KAAO;CAWpE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAcjD"}
@@ -1,22 +0,0 @@
1
- import { Paymaster } from "./Paymaster";
2
- import { UserOperation, SupportedERC20TokensAndMetadata, PaymasterMetadata, ERC20Token, StateOverrideSet } from "../types";
3
- import { CandidePaymasterContext } from "./types";
4
- import { SmartAccount } from "src/abstractionkit";
5
- export declare class CandidePaymaster extends Paymaster {
6
- readonly rpcUrl: string;
7
- private entrypointAddress;
8
- private supportedTokens;
9
- private paymasterMetadata;
10
- constructor(rpcUrl: string);
11
- initialize(): Promise<null>;
12
- getPaymasterMetaData(): Promise<PaymasterMetadata>;
13
- getSupportedERC20TokensAndPaymasterMetadata(): Promise<SupportedERC20TokensAndMetadata>;
14
- getSupportedEntrypoint(): Promise<string>;
15
- isSupportedERC20Token(erc20TokenAddress: string): Promise<boolean>;
16
- getSupportedERC20TokenData(erc20TokenAddress: string): Promise<ERC20Token | null>;
17
- createPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, context?: CandidePaymasterContext, state_override_set?: StateOverrideSet): Promise<UserOperation>;
18
- createSponsorPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, state_override_set?: StateOverrideSet): Promise<UserOperation>;
19
- createTokenPaymasterUserOperation(smartAccount: SmartAccount, userOperation: UserOperation, tokenAddress: string, bundlerRpc: string, state_override_set?: StateOverrideSet): Promise<UserOperation>;
20
- calculateUserOperationErc20TokenMaxGasCost(userOperation: UserOperation, erc20TokenAddress: string): Promise<bigint>;
21
- }
22
- //# sourceMappingURL=CandidePaymaster.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CandidePaymaster.d.ts","sourceRoot":"","sources":["../../src/paymaster/CandidePaymaster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EACN,aAAa,EACb,+BAA+B,EAE/B,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,qBAAa,gBAAiB,SAAQ,SAAS;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,iBAAiB,CAAgC;gBAE7C,MAAM,EAAE,MAAM;IAUpB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB3B,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAOlD,2CAA2C,IAAI,OAAO,CAAC,+BAA+B,CAAC;IAgCvF,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IA8BzC,qBAAqB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAyBlE,0BAA0B,CAC/B,iBAAiB,EAAE,MAAM,GACvB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAoCvB,4BAA4B,CACjC,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,uBAA4B,EACrC,kBAAkB,CAAC,EAAE,gBAAgB,GACnC,OAAO,CAAC,aAAa,CAAC;IAqFnB,mCAAmC,CACxC,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,MAAM,EAClB,kBAAkB,CAAC,EAAE,gBAAgB,GACnC,OAAO,CAAC,aAAa,CAAC;IAmBnB,iCAAiC,CACtC,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,kBAAkB,GAAE,gBAAqB,GACvC,OAAO,CAAC,aAAa,CAAC;IA4CnB,0CAA0C,CAC/C,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC;CAmClB"}
@@ -1,4 +0,0 @@
1
- export interface CandidePaymasterContext {
2
- token?: string;
3
- }
4
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/paymaster/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CACf"}