abstractionkit 0.1.3 → 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 -10
  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 -43
  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":"AAAA,OAAO,EAMN,SAAS,EAGT,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,eAAe,EAAE,kCAAkC,EAAE,MAAM,SAAS,CAAC;AAG/H,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,qBAAa,WAAY,SAAQ,YAAY;IAC5C,MAAM,CAAC,QAAQ,CAAC,0BAA0B,gDAA+C;IACzF,MAAM,CAAC,QAAQ,CAAC,gCAAgC,gDAA+C;IAC/F,MAAM,CAAC,QAAQ,CAAC,yBAAyB,gDAA+C;IACxF,MAAM,CAAC,QAAQ,CAAC,8BAA8B,gDAA+C;IAC7F,MAAM,CAAC,QAAQ,CAAC,kCAAkC,gDAA+C;IAEjG,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAo9B;IAC5/B,MAAM,CAAC,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAgB;IACnE,MAAM,CAAC,QAAQ,CAAC,2BAA2B,EAAE,MAAM,EAAE,CASnD;IAEF,MAAM,CAAC,QAAQ,CAAC,kCAAkC,mEAAkE;IACpH,MAAM,CAAC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,EAAE,CAKhD;IAEF,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;gBAGtC,cAAc,EAAC,MAAM,EACrB,iBAAiB,GAAC,MAA+C,EACjE,qBAAqB,GAAC,MAAqD;WAO9D,+BAA+B,CAC5C,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,GAAC,iBAAsB,GAC/B,CAAC,MAAM,EAAE,SAAS,CAAC;WA8CP,yBAAyB,CACtC,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,EAAE,MAAM,EACjB,qBAAqB,GAAE,MAAqD,EAC5E,mBAAmB,GAAE,MAAmD,GACvE,SAAS;WAqCG,cAAc,CAC3B,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,GAAE,MAAU,EACrB,OAAO,GAAE,MAAW,EACpB,gBAAgB,GAAE,MAA8C,EAChE,kBAAkB,GAAE,kBAA6C,EACjE,qBAAqB,GAAE,MAAqD,EAC5E,mBAAmB,GAAE,MAAmD,GACtE,SAAS;WAsCE,kBAAkB,CAC/B,mBAAmB,EAAE,SAAS,EAC9B,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,MAAM,EAC1B,gBAAgB,EAAE,MAAM,GACtB,MAAM;WAyBK,sCAAsC,CACnD,EAAE,EAAE,eAAe,GACjB,SAAS;WAaE,sCAAsC,CACnD,gBAAgB,EAAE,eAAe,EAAE,EACnC,wBAAwB,GAAE,MAAuD,GAC/E,SAAS;WAwBE,qBAAqB,CAClC,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,EACpB,kCAAkC,GAAE,kCAAmF,GACrH,SAAS;WAeQ,wBAAwB,CAC3C,cAAc,EAAC,aAAa,EAC5B,iBAAiB,EAAE,MAAM,EACzB,UAAU,EAAC,MAAM,GAChB,OAAO,CAAC,CAAC,MAAM,EAAC,MAAM,EAAC,MAAM,CAAC,GAAG,mBAAmB,CAAC;IAkBhD,iBAAiB,CACvB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,EAAE,MAAM,EACf,UAAU,GAAE,MAAW,EACvB,UAAU,GAAE,MAAW,GACrB,MAAM;IAqEI,mBAAmB,CAC/B,YAAY,EAAE,eAAe,EAAE,EAC/B,WAAW,EAAC,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAC,4BAAgC,GACvC,OAAO,CAAC,aAAa,GAAG,YAAY,GAAG,mBAAmB,CAAC;IAqHjD,iBAAiB,CAC7B,cAAc,EAAE,aAAa,EAC7B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,yBAAyB,GAAG,mBAAmB,CAAC;CAe1D"}
@@ -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,20 +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
- callGasLimitPercentageMultiplier?: number;
12
- verificationGasLimitPercentageMultiplier?: number;
13
- preVerificationGasPercentageMultiplier?: number;
14
- maxFeePerGasPercentageMultiplier?: number;
15
- maxPriorityFeePerGasPercentageMultiplier?: number;
16
- numberOfSigners?: number;
17
- state_override_set?: StateOverrideSet;
18
24
  }
19
25
  export interface InitCodeOverrides {
20
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;IAG9B,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAE1C,wCAAwC,CAAC,EAAE,MAAM,CAAC;IAElD,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAEhD,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAE1C,wCAAwC,CAAC,EAAE,MAAM,CAAC;IAKlD,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}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 p={"-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"},h=/*#__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 v(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 m=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:P(g("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(y(e,"eth_call",i)).then(function(e){if("string"!=typeof e)throw new h("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=v(e);throw new h("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=v(e);throw new h("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},y=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 h(n in p?p[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(a)}})})})}catch(e){return Promise.reject(e)}};function A(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 g(t){return e.id(t).slice(0,10)}function E(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var D,b="0x0000000000000000000000000000000000000000",O={sender:b,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}(),R=/*#__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}(G);function x(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"}(D||(D={}));var S=/*#__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(y(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new h("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=v(e);throw new h("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(y(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=v(e);throw new h("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(y(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){a=e}):Promise.resolve(y(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){a=e});return o&&o.then?o.then(i):i()},function(e){var t=v(e);throw new h("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(y(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=v(e);throw new h("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(y(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=v(t);throw new h("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(y(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=v(t);throw new h("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function U(e,t,r){if(!e.s){if(r instanceof T){if(!r.s)return void(r.o=U.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(U.bind(null,e,t),U.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var T=/*#__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{U(n,1,a(this.v))}catch(e){U(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?U(n,1,t?t(i):i):r?U(n,1,r(i)):U(n,2,i)}catch(e){U(n,2,e)}},n},e}();function F(e){return e instanceof T&&1&e.s}var w=/*#__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 h("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(F(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!F(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!F(o)){n=2;break}}}var s=new T,f=U.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&&!F(o))return void o.then(l).then(void 0,f);if(!(i=e())||F(i)&&!i.v)return void U(s,1,a);if(i.then)return void i.then(u).then(void 0,f);F(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):U(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):U(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}(),L=/*#__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 R;null!=t.safeAccountFactoryAddress&&(p=new R(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=P("0x8d0dc49f",["address[]"],[[n]]);return P(r.initializerFunctionSelector,r.initializerFunctionInputAbi,[e,t,i,a,n,b,0,b])},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 R),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=P("0x8d80ff0a",["bytes"],[x(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),P(a,r.executorFunctionInputAbi,[e,t,n,i])};var i=r.prototype;return i.decodeAccountCallData=function(t){if(t.startsWith(D.executeUserOpWithErrorString)||t.startsWith(D.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 h("BAD_DATA","Invalid calldata, should start with "+D.executeUserOpWithErrorString+" or "+D.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=x([{to:n,value:0n,data:P(g("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=x([{to:f,value:c,data:u,operation:l}])+p.slice(2);var y=P(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 S(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,r,n;function i(){var e,t,r,n,i,a;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 f.preVerificationGas=null!=(e=o.preVerificationGas)?e:l*BigInt(Math.floor(((null!=(t=o.preVerificationGasPercentageMultiplier)?t:0)+100)/100)),f.verificationGasLimit=null!=(r=o.verificationGasLimit)?r:m*BigInt(Math.floor(((null!=(n=o.verificationGasLimitPercentageMultiplier)?n:0)+100)/100)),f.callGasLimit=null!=(i=o.callGasLimit)?i:y*BigInt(Math.floor(((null!=(a=o.callGasLimitPercentageMultiplier)?a:0)+100)/100)),f}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*BigInt(Math.floor(((null!=(t=o.maxFeePerGasPercentageMultiplier)?t:0)+100)/100)),v=null!=(r=o.maxPriorityFeePerGas)?r:v*BigInt(Math.floor(((null!=(n=o.maxPriorityFeePerGasPercentageMultiplier)?n:0)+100)/100));var f=s({},O,{sender:c.accountAddress,nonce:u,initCode:d,callData:p,maxFeePerGas:h,maxPriorityFeePerGas:v}),l=O.preVerificationGas,m=O.verificationGasLimit,y=O.callGasLimit,A=function(){if(null==o.preVerificationGas||null==o.verificationGasLimit||null==o.callGasLimit)return Promise.resolve(c.estimateUserOperationGas(f,a,o.state_override_set,o.numberOfSigners)).then(function(e){l=e[0],m=e[1],y=e[2]})}();return A&&A.then?A.then(i):i()}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=O.maxFeePerGas,v=O.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(m(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=[],u=[],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 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.")}(n);!(s=l()).done;){var p=new e.Wallet(s.value),h=p.signingKey.sign(e.TypedDataEncoder.hash({chainId:i,verifyingContract:this.safe4337ModuleAddress},r.EIP712_SAFE_OPERATION_TYPE,f)).serialized;c.push(p.address),u.push(h)}return r.formatEip712SignaturesToUseroperationSignature(c,u,a,o)},r.formatEip712SignaturesToUseroperationSignature=function(t,r,n,i){if(void 0===n&&(n=0n),void 0===i&&(i=0n),t.length!=r.length)throw RangeError("signersAddresses and signatures arrays should be the same length");if(n<0n)throw RangeError("validAfter can't be negative");if(i<0n)throw RangeError("validUntil can't be negative");var a=new Map;t.forEach(function(e,t){a.set(e.toLocaleLowerCase(),r[t])});var o=new Map(Array.from(a).sort()),s="0x"+Array.from(o.values()).reduce(function(e,t){return e+t.slice(2)},"");return e.solidityPacked(["uint48","uint48","bytes"],[n,i,s])},i.sendUserOperation=function(e,t){try{var r=this,n=new S(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new w(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}L.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",L.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",L.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",L.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",L.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",L.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",L.initializerFunctionSelector="0xb63e800d",L.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],L.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=D.executeUserOpWithErrorString,L.executorFunctionInputAbi=["address","uint256","bytes","uint8"],L.EIP712_SAFE_OPERATION_TYPE={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"}]};var C=/*#__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=v(e);throw new h("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(y(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}})},function(e){var t=v(e);throw new h("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(y(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=v(e);throw new h("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 S(t);return Promise.resolve(i.estimateUserOperationGas(e,a.entrypointAddress,n)).then(function(t){return e.preVerificationGas=t.preVerificationGas+100n,e.verificationGasLimit=t.verificationGasLimit+10000n,e.callGasLimit=t.callGasLimit,Promise.resolve(y(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=v(e);throw new h("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=v(e);throw new h("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 h("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e)}})});var i=E(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})},function(e){var t=v(e);throw new h("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),M={__proto__:null,SmartAccount:a,SafeAccountV0_2_0:L,SendUseroperationResponse:w,SmartAccountFactory:G,SafeAccountFactory:R,Bundler:S,CandidePaymaster:C,createUserOperationHash:A,createCallData:P,getFunctionSelector:g,fetchAccountNonce:m,calculateUserOperationMaxGasCost:E,get Operation(){return exports.Operation}};exports.Bundler=S,exports.CandidePaymaster=C,exports.SafeAccountFactory=R,exports.SafeAccountV0_2_0=L,exports.SendUseroperationResponse=w,exports.SmartAccount=a,exports.SmartAccountFactory=G,exports.abstractionkit=M,exports.calculateUserOperationMaxGasCost=E,exports.createCallData=P,exports.createUserOperationHash=A,exports.fetchAccountNonce=m,exports.getFunctionSelector=g;
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 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}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 P={"-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"},E=/*#__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 D(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 b=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:O(_("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 E("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=D(e);throw new E("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=D(e);throw new E("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},G=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 E(n in P?P[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(i)}})})})}catch(e){return Promise.reject(e)}};function R(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 O(e,r,n){return e+t.defaultAbiCoder().encode(r,n).slice(2)}function _(e){return r(e).slice(0,10)}function S(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var T,U="0x0000000000000000000000000000000000000000",x={sender:U,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},F=/*#__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=O(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),w=/*#__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}(F);function L(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 I(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 C=/*#__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(I(function(){return Promise.resolve(G(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new E("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=D(e);throw new E("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(I(function(){return Promise.resolve(G(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=D(e);throw new E("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(I(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=D(e);throw new E("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(I(function(){return Promise.resolve(G(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=D(e);throw new E("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(I(function(){return Promise.resolve(G(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=D(t);throw new E("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(I(function(){return Promise.resolve(G(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=D(t);throw new E("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function M(e,t,r){if(!e.s){if(r instanceof B){if(!r.s)return void(r.o=M.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(M.bind(null,e,t),M.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var B=/*#__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{M(n,1,a(this.v))}catch(e){M(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?M(n,1,t?t(i):i):r?M(n,1,r(i)):M(n,2,i)}catch(e){M(n,2,e)}},n},e}();function N(e){return e instanceof B&&1&e.s}var j=/*#__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 E("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(N(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!N(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!N(o)){n=2;break}}}var s=new B,f=M.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&&!N(o))return void o.then(l).then(void 0,f);if(!(i=e())||N(i)&&!i.v)return void M(s,1,a);if(i.then)return void i.then(u).then(void 0,f);N(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):M(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):M(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}(),k=/*#__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 w;null!=t.safeAccountFactoryAddress&&(p=new w(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=O("0x8d0dc49f",["address[]"],[[r]]);return O(i.initializerFunctionSelector,i.initializerFunctionInputAbi,[e,t,n,a,r,U,0,U])},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 w),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=O("0x8d80ff0a",["bytes"],[L(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),O(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 E("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=L([{to:r,value:0n,data:O(_("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=L([{to:f,value:c,data:l,operation:d}])+h.slice(2);var A=O(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 C(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,n,i;function o(){var e,t,r,n,i,o;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 c.preVerificationGas=null!=(e=a.preVerificationGas)?e:l*BigInt(Math.floor(((null!=(t=a.preVerificationGasPercentageMultiplier)?t:0)+100)/100)),c.verificationGasLimit=null!=(r=a.verificationGasLimit)?r:m*BigInt(Math.floor(((null!=(n=a.verificationGasLimitPercentageMultiplier)?n:0)+100)/100)),c.callGasLimit=null!=(i=a.callGasLimit)?i:y*BigInt(Math.floor(((null!=(o=a.callGasLimitPercentageMultiplier)?o:0)+100)/100)),c}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*BigInt(Math.floor(((null!=(t=a.maxFeePerGasPercentageMultiplier)?t:0)+100)/100)),v=null!=(n=a.maxPriorityFeePerGas)?n:v*BigInt(Math.floor(((null!=(i=a.maxPriorityFeePerGasPercentageMultiplier)?i:0)+100)/100));var c=h({},x,{sender:s.accountAddress,nonce:f,initCode:u,callData:d,maxFeePerGas:p,maxPriorityFeePerGas:v}),l=x.preVerificationGas,m=x.verificationGasLimit,y=x.callGasLimit,A=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return Promise.resolve(s.estimateUserOperationGas(c,r,a.state_override_set,a.numberOfSigners)).then(function(e){l=e[0],m=e[1],y=e[2]})}();return A&&A.then?A.then(o):o()}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=x.maxFeePerGas,v=x.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(b(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=[],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);!(o=d()).done;){var p=new s(o.value),h=p.signingKey.sign(f.hash({chainId:r,verifyingContract:this.safe4337ModuleAddress},i.EIP712_SAFE_OPERATION_TYPE,c)).serialized;u.push(p.address),l.push(h)}return i.formatEip712SignaturesToUseroperationSignature(u,l,n,a)},i.formatEip712SignaturesToUseroperationSignature=function(e,t,r,n){if(void 0===r&&(r=0n),void 0===n&&(n=0n),e.length!=t.length)throw RangeError("signersAddresses and signatures arrays should be the same length");if(r<0n)throw RangeError("validAfter can't be negative");if(n<0n)throw RangeError("validUntil can't be negative");var i=new Map;e.forEach(function(e,r){i.set(e.toLocaleLowerCase(),t[r])});var o=new Map(Array.from(i).sort()),s="0x"+Array.from(o.values()).reduce(function(e,t){return e+t.slice(2)},"");return a(["uint48","uint48","bytes"],[r,n,s])},c.sendUserOperation=function(e,t){try{var r=this,n=new C(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new j(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},i}(d);function V(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}k.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",k.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",k.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",k.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",k.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",k.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",k.initializerFunctionSelector="0xb63e800d",k.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],k.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=T.executeUserOpWithErrorString,k.executorFunctionInputAbi=["address","uint256","bytes","uint8"],k.EIP712_SAFE_OPERATION_TYPE={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"}]};var z=/*#__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(V(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=D(e);throw new E("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?V(function(){return Promise.resolve(G(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}})},function(e){var t=D(e);throw new E("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?V(function(){return Promise.resolve(G(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=D(e);throw new E("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 V(function(){e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var i=new C(t);return Promise.resolve(i.estimateUserOperationGas(e,a.entrypointAddress,n)).then(function(t){return e.preVerificationGas=t.preVerificationGas+100n,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=D(e);throw new E("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(V(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=D(e);throw new E("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}))}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(V(function(){return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new E("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e)}})});var i=S(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})},function(e){var t=D(e);throw new E("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),Y={__proto__:null,SmartAccount:d,SafeAccountV0_2_0:k,SendUseroperationResponse:j,SmartAccountFactory:F,SafeAccountFactory:w,Bundler:C,CandidePaymaster:z,createUserOperationHash:R,createCallData:O,getFunctionSelector:_,fetchAccountNonce:b,calculateUserOperationMaxGasCost:S,get Operation(){return u}};export{C as Bundler,z as CandidePaymaster,u as Operation,w as SafeAccountFactory,k as SafeAccountV0_2_0,j as SendUseroperationResponse,d as SmartAccount,F as SmartAccountFactory,Y as abstractionkit,S as calculateUserOperationMaxGasCost,O as createCallData,R as createUserOperationHash,b as fetchAccountNonce,_ 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};