@zerodev/sdk 4.2.2 → 4.3.0

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 (65) hide show
  1. package/dist/cjs/kernel-zerodev/abis/SessionKeyValidatorAbi.d.ts +58 -4
  2. package/dist/cjs/kernel-zerodev/abis/SessionKeyValidatorAbi.js +75 -4
  3. package/dist/cjs/kernel-zerodev/abis/SessionKeyValidatorAbi.js.map +1 -1
  4. package/dist/cjs/kernel-zerodev/client/create-client.js +1 -0
  5. package/dist/cjs/kernel-zerodev/client/create-client.js.map +1 -1
  6. package/dist/cjs/kernel-zerodev/constants.d.ts +1 -1
  7. package/dist/cjs/kernel-zerodev/constants.js +2 -2
  8. package/dist/cjs/kernel-zerodev/constants.js.map +1 -1
  9. package/dist/cjs/kernel-zerodev/middleware/gas-estimator.d.ts +4 -0
  10. package/dist/cjs/kernel-zerodev/middleware/gas-estimator.js +15 -7
  11. package/dist/cjs/kernel-zerodev/middleware/gas-estimator.js.map +1 -1
  12. package/dist/cjs/kernel-zerodev/validator/base.d.ts +1 -1
  13. package/dist/cjs/kernel-zerodev/validator/base.js +3 -3
  14. package/dist/cjs/kernel-zerodev/validator/base.js.map +1 -1
  15. package/dist/cjs/kernel-zerodev/validator/session-key-validator.d.ts +18 -7
  16. package/dist/cjs/kernel-zerodev/validator/session-key-validator.js +117 -63
  17. package/dist/cjs/kernel-zerodev/validator/session-key-validator.js.map +1 -1
  18. package/dist/cjs/kernel-zerodev/validator/types.d.ts +1 -1
  19. package/dist/cjs/kernel-zerodev/validator/types.js.map +1 -1
  20. package/dist/cjs/kernel-zerodev/validator-provider/base.js +9 -0
  21. package/dist/cjs/kernel-zerodev/validator-provider/base.js.map +1 -1
  22. package/dist/esm/kernel-zerodev/abis/SessionKeyValidatorAbi.d.ts +58 -4
  23. package/dist/esm/kernel-zerodev/abis/SessionKeyValidatorAbi.js +75 -4
  24. package/dist/esm/kernel-zerodev/abis/SessionKeyValidatorAbi.js.map +1 -1
  25. package/dist/esm/kernel-zerodev/client/create-client.js +1 -0
  26. package/dist/esm/kernel-zerodev/client/create-client.js.map +1 -1
  27. package/dist/esm/kernel-zerodev/constants.d.ts +1 -1
  28. package/dist/esm/kernel-zerodev/constants.js +2 -2
  29. package/dist/esm/kernel-zerodev/constants.js.map +1 -1
  30. package/dist/esm/kernel-zerodev/middleware/gas-estimator.d.ts +4 -0
  31. package/dist/esm/kernel-zerodev/middleware/gas-estimator.js +15 -6
  32. package/dist/esm/kernel-zerodev/middleware/gas-estimator.js.map +1 -1
  33. package/dist/esm/kernel-zerodev/validator/base.d.ts +1 -1
  34. package/dist/esm/kernel-zerodev/validator/base.js +3 -3
  35. package/dist/esm/kernel-zerodev/validator/base.js.map +1 -1
  36. package/dist/esm/kernel-zerodev/validator/session-key-validator.d.ts +18 -7
  37. package/dist/esm/kernel-zerodev/validator/session-key-validator.js +118 -64
  38. package/dist/esm/kernel-zerodev/validator/session-key-validator.js.map +1 -1
  39. package/dist/esm/kernel-zerodev/validator/types.d.ts +1 -1
  40. package/dist/esm/kernel-zerodev/validator/types.js.map +1 -1
  41. package/dist/esm/kernel-zerodev/validator-provider/base.js +9 -0
  42. package/dist/esm/kernel-zerodev/validator-provider/base.js.map +1 -1
  43. package/dist/types/kernel-zerodev/abis/SessionKeyValidatorAbi.d.ts +58 -4
  44. package/dist/types/kernel-zerodev/abis/SessionKeyValidatorAbi.d.ts.map +1 -1
  45. package/dist/types/kernel-zerodev/client/create-client.d.ts.map +1 -1
  46. package/dist/types/kernel-zerodev/constants.d.ts +1 -1
  47. package/dist/types/kernel-zerodev/middleware/gas-estimator.d.ts +4 -0
  48. package/dist/types/kernel-zerodev/middleware/gas-estimator.d.ts.map +1 -1
  49. package/dist/types/kernel-zerodev/validator/base.d.ts +1 -1
  50. package/dist/types/kernel-zerodev/validator/base.d.ts.map +1 -1
  51. package/dist/types/kernel-zerodev/validator/session-key-validator.d.ts +18 -7
  52. package/dist/types/kernel-zerodev/validator/session-key-validator.d.ts.map +1 -1
  53. package/dist/types/kernel-zerodev/validator/types.d.ts +1 -1
  54. package/dist/types/kernel-zerodev/validator/types.d.ts.map +1 -1
  55. package/dist/types/kernel-zerodev/validator-provider/base.d.ts.map +1 -1
  56. package/package.json +5 -4
  57. package/src/kernel-zerodev/__tests__/config/index.ts +18 -0
  58. package/src/kernel-zerodev/abis/SessionKeyValidatorAbi.ts +75 -4
  59. package/src/kernel-zerodev/client/create-client.ts +1 -0
  60. package/src/kernel-zerodev/constants.ts +2 -2
  61. package/src/kernel-zerodev/middleware/gas-estimator.ts +21 -7
  62. package/src/kernel-zerodev/validator/base.ts +4 -4
  63. package/src/kernel-zerodev/validator/session-key-validator.ts +159 -88
  64. package/src/kernel-zerodev/validator/types.ts +1 -1
  65. package/src/kernel-zerodev/validator-provider/base.ts +13 -0
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/validator-provider/base.ts"],"names":[],"mappings":";;;AACA,gDAA6E;AAU7E,8CAIuB;AACvB,wCAA4C;AAC5C,6DAAyE;AA8BzE,MAAsB,iBAGpB,SAAQ,6BAAe;IAKvB,YACE,MAA0C,EAC1C,SAA8B;QAE9B,IAAI,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;QAC7C,MAAM,kBAAkB,GACtB,MAAM,CAAC,YAAY,KAAK,SAAS,IAAI,MAAM,CAAC,YAAY,CAAC;QAC3D,IACE,MAAM,CAAC,IAAI,EAAE,eAAe;YAC5B,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,KAAK,iBAAiB;YACzD,kBAAkB,EAClB;YACA,eAAe,GAAG,SAAS,CAAC;SAC7B;QACD,KAAK,CAAC;YACJ,GAAG,MAAM,CAAC,IAAI,EAAE,cAAc;YAC9B,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,IAAI,sBAAa;YAC1D,MAAM,EAAE,MAAM,CAAC,IAAI,EAA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,aAAa;SAC9B,CAAC,CACL,CAAC;QACF,IAAI,kBAAkB,EAAE;YACtB,IAAI,eAAe,GAAG,MAAM,CAAC,IAAI,EAAE,eAAe,IAAI;gBACpD,MAAM,EAAE,qBAAqB;aAC9B,CAAC;YACF,eAAe,GAAG;gBAChB,GAAG,eAAe;gBAClB,iBAAiB,EACf,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,iBAAiB,IAAI,eAAe;aACrE,CAAC;YACF,IAAA,0CAA2B,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC;SACpD;IACH,CAAC;CA+DF;AApHD,8CAoHC","sourcesContent":["import { type Hex, type SendUserOperationResult } from \"@alchemy/aa-core\";\nimport { ZeroDevProvider, type ZeroDevProviderConfig } from \"../provider.js\";\nimport type {\n KernelBaseValidator,\n KernelBaseValidatorParams,\n} from \"../validator/base.js\";\nimport type {\n PaymasterAndBundlerProviders,\n PaymasterConfig,\n PaymasterPolicy,\n} from \"../paymaster/types.js\";\nimport {\n KernelSmartContractAccount,\n type KernelSmartAccountParams,\n isKernelAccount,\n} from \"../account.js\";\nimport { polygonMumbai } from \"viem/chains\";\nimport { withZeroDevPaymasterAndData } from \"../middleware/paymaster.js\";\nimport type { RequiredProps } from \"../types.js\";\n\nexport type ValidatorProviderParamsOpts<P extends KernelBaseValidatorParams> = {\n paymasterConfig?: PaymasterConfig<PaymasterPolicy>;\n providerConfig?: Partial<ZeroDevProviderConfig>;\n accountConfig?: Omit<\n KernelSmartAccountParams,\n keyof ExtendedValidatorProviderParams<P>\n >;\n validatorConfig?: Omit<P, keyof ExtendedValidatorProviderParams<P>>;\n};\n\nexport interface ValidatorProviderParams<P extends KernelBaseValidatorParams> {\n projectId: string;\n bundlerProvider?: PaymasterAndBundlerProviders;\n opts?: ValidatorProviderParamsOpts<P>;\n usePaymaster?: boolean;\n defaultProvider?: ValidatorProvider<\n KernelBaseValidator,\n KernelBaseValidatorParams\n >;\n}\n\nexport type ExtendedValidatorProviderParams<\n P extends KernelBaseValidatorParams\n> = ValidatorProviderParams<P> & RequiredProps<P>;\n\n// A simple facade abstraction for validator related provider operations\n// Needs to be implemented for each validator plugin\nexport abstract class ValidatorProvider<\n V extends KernelBaseValidator,\n P extends KernelBaseValidatorParams\n> extends ZeroDevProvider {\n protected defaultProvider?: ValidatorProvider<\n KernelBaseValidator,\n KernelBaseValidatorParams\n >;\n constructor(\n params: ExtendedValidatorProviderParams<P>,\n validator: KernelBaseValidator\n ) {\n let bundlerProvider = params.bundlerProvider;\n const shouldUsePaymaster =\n params.usePaymaster === undefined || params.usePaymaster;\n if (\n params.opts?.paymasterConfig &&\n params.opts?.paymasterConfig.policy === \"TOKEN_PAYMASTER\" &&\n shouldUsePaymaster\n ) {\n bundlerProvider = \"STACKUP\";\n }\n super({\n ...params.opts?.providerConfig,\n chain: params.opts?.providerConfig?.chain ?? polygonMumbai,\n rpcUrl: params.opts?.providerConfig?.rpcUrl,\n projectId: params.projectId,\n bundlerProvider,\n });\n this.defaultProvider = params.defaultProvider;\n this.connect(\n () =>\n new KernelSmartContractAccount({\n projectId: params.projectId,\n validator,\n defaultValidator: params.defaultProvider?.getValidator(),\n rpcClient: this.rpcClient,\n bundlerProvider,\n index: params.defaultProvider?.getAccount().getIndex(),\n ...params.opts?.accountConfig,\n })\n );\n if (shouldUsePaymaster) {\n let paymasterConfig = params.opts?.paymasterConfig ?? {\n policy: \"VERIFYING_PAYMASTER\",\n };\n paymasterConfig = {\n ...paymasterConfig,\n paymasterProvider:\n params.opts?.paymasterConfig?.paymasterProvider ?? bundlerProvider,\n };\n withZeroDevPaymasterAndData(this, paymasterConfig);\n }\n }\n\n getValidator = (): V => {\n if (!isKernelAccount(this.account) || !this.account.validator) {\n throw new Error(\n \"ValidatorProvider: account with validator is not set, did you call all connects first?\"\n );\n }\n return this.account.getValidator() as unknown as V;\n };\n\n getEncodedEnableData = async (enableData: Hex): Promise<Hex> => {\n if (!isKernelAccount(this.account) || !this.account.validator) {\n throw new Error(\n \"ValidatorProvider: account with validator is not set, did you call all connects first?\"\n );\n }\n return await this.account.validator.encodeEnable(enableData);\n };\n\n getEncodedDisableData = async (disableData: Hex = \"0x\"): Promise<Hex> => {\n if (!isKernelAccount(this.account) || !this.account.validator) {\n throw new Error(\n \"ValidatorProvider: account with validator is not set, did you call all connects first?\"\n );\n }\n return await this.account.validator.encodeDisable(disableData);\n };\n\n sendEnableUserOperation = async (\n enableData: Hex\n ): Promise<SendUserOperationResult> => {\n const encodedEnableData = await this.getEncodedEnableData(enableData);\n if (!isKernelAccount(this.account) || !this.account.validator) {\n throw new Error(\n \"ValidatorProvider: account with validator is not set, did you call all connects first?\"\n );\n }\n\n return await this.sendUserOperation({\n target: this.account.validator.validatorAddress,\n data: encodedEnableData,\n });\n };\n\n sendDisableUserOperation = async (\n disableData: Hex = \"0x\"\n ): Promise<SendUserOperationResult> => {\n const encodedDisableData = await this.getEncodedDisableData(disableData);\n if (!isKernelAccount(this.account) || !this.account.validator) {\n throw new Error(\n \"ValidatorProvider: account with validator is not set, did you call all connects first?\"\n );\n }\n if (!this.defaultProvider) {\n throw Error(\"Default Validator provider unintialized\");\n }\n\n return await this.defaultProvider.sendUserOperation({\n target: this.account.validator.validatorAddress,\n data: encodedDisableData,\n });\n };\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/validator-provider/base.ts"],"names":[],"mappings":";;;AACA,gDAA6E;AAU7E,8CAIuB;AACvB,wCAA4C;AAC5C,6DAAyE;AA8BzE,MAAsB,iBAGpB,SAAQ,6BAAe;IAKvB,YACE,MAA0C,EAC1C,SAA8B;QAE9B,IAAI,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;QAC7C,MAAM,kBAAkB,GACtB,MAAM,CAAC,YAAY,KAAK,SAAS,IAAI,MAAM,CAAC,YAAY,CAAC;QAC3D,IACE,MAAM,CAAC,IAAI,EAAE,eAAe;YAC5B,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,KAAK,i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,MAAM,CAAC,eAAe,EAAE,KAAK,KAAK,QAAQ;YACjD,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,KAAK,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC;YACvE,CAAC,OAAO,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,KAAK,QAAQ;gBACrD,OAAO,MAAM,CAAC,eAAe,EAAE,KAAK,KAAK,QAAQ;gBACjD,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE;oBACnC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,EACrC;YACA,MAAM,IAAI,KAAK,CACb,mFAAmF,CACpF,CAAC;SACH;QACD,IAAI,CAAC,OAAO,CACV,GAAG,EAAE,CACH,IAAI,uCAA0B,CAAC;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,SAAS;YACT,gBAAgB,EAAE,MAAM,CAAC,eAAe,EAAE,YAAY,EAAE;YACxD,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe;YACf,KAAK,EAAE,MAAM,CAAC,eAAe,EAAE,UAAU,EAAE,CAAC,QAAQ,EAAE;YACtD,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa;SAC9B,CAAC,CACL,CAAC;QACF,IAAI,kBAAkB,EAAE;YACtB,IAAI,eAAe,GAAG,MAAM,CAAC,IAAI,EAAE,eAAe,IAAI;gBACpD,MAAM,EAAE,qBAAqB;aAC9B,CAAC;YACF,eAAe,GAAG;gBAChB,GAAG,eAAe;gBAClB,iBAAiB,EACf,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,iBAAiB,IAAI,eAAe;aACrE,CAAC;YACF,IAAA,0CAA2B,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC;SACpD;IACH,CAAC;CA+DF;AAjID,8CAiIC","sourcesContent":["import { type Hex, type SendUserOperationResult } from \"@alchemy/aa-core\";\nimport { ZeroDevProvider, type ZeroDevProviderConfig } from \"../provider.js\";\nimport type {\n KernelBaseValidator,\n KernelBaseValidatorParams,\n} from \"../validator/base.js\";\nimport type {\n PaymasterAndBundlerProviders,\n PaymasterConfig,\n PaymasterPolicy,\n} from \"../paymaster/types.js\";\nimport {\n KernelSmartContractAccount,\n type KernelSmartAccountParams,\n isKernelAccount,\n} from \"../account.js\";\nimport { polygonMumbai } from \"viem/chains\";\nimport { withZeroDevPaymasterAndData } from \"../middleware/paymaster.js\";\nimport type { RequiredProps } from \"../types.js\";\n\nexport type ValidatorProviderParamsOpts<P extends KernelBaseValidatorParams> = {\n paymasterConfig?: PaymasterConfig<PaymasterPolicy>;\n providerConfig?: Partial<ZeroDevProviderConfig>;\n accountConfig?: Omit<\n KernelSmartAccountParams,\n keyof ExtendedValidatorProviderParams<P>\n >;\n validatorConfig?: Omit<P, keyof ExtendedValidatorProviderParams<P>>;\n};\n\nexport interface ValidatorProviderParams<P extends KernelBaseValidatorParams> {\n projectId: string;\n bundlerProvider?: PaymasterAndBundlerProviders;\n opts?: ValidatorProviderParamsOpts<P>;\n usePaymaster?: boolean;\n defaultProvider?: ValidatorProvider<\n KernelBaseValidator,\n KernelBaseValidatorParams\n >;\n}\n\nexport type ExtendedValidatorProviderParams<\n P extends KernelBaseValidatorParams\n> = ValidatorProviderParams<P> & RequiredProps<P>;\n\n// A simple facade abstraction for validator related provider operations\n// Needs to be implemented for each validator plugin\nexport abstract class ValidatorProvider<\n V extends KernelBaseValidator,\n P extends KernelBaseValidatorParams\n> extends ZeroDevProvider {\n protected defaultProvider?: ValidatorProvider<\n KernelBaseValidator,\n KernelBaseValidatorParams\n >;\n constructor(\n params: ExtendedValidatorProviderParams<P>,\n validator: KernelBaseValidator\n ) {\n let bundlerProvider = params.bundlerProvider;\n const shouldUsePaymaster =\n params.usePaymaster === undefined || params.usePaymaster;\n if (\n params.opts?.paymasterConfig &&\n params.opts?.paymasterConfig.policy === \"TOKEN_PAYMASTER\" &&\n shouldUsePaymaster\n ) {\n bundlerProvider = \"STACKUP\";\n }\n super({\n ...params.opts?.providerConfig,\n chain: params.opts?.providerConfig?.chain ?? polygonMumbai,\n rpcUrl: params.opts?.providerConfig?.rpcUrl,\n projectId: params.projectId,\n bundlerProvider,\n });\n this.defaultProvider = params.defaultProvider;\n if (\n (typeof params.opts?.providerConfig?.chain === \"number\" &&\n typeof params.defaultProvider?.chain === \"number\" &&\n params.opts?.providerConfig?.chain !== params.defaultProvider?.chain) ||\n (typeof params.opts?.providerConfig?.chain === \"object\" &&\n typeof params.defaultProvider?.chain === \"object\" &&\n params.opts?.providerConfig?.chain.id !==\n params.defaultProvider?.chain.id)\n ) {\n throw new Error(\n \"chainId mismatch between default provider and current provider - check projectIds\"\n );\n }\n this.connect(\n () =>\n new KernelSmartContractAccount({\n projectId: params.projectId,\n validator,\n defaultValidator: params.defaultProvider?.getValidator(),\n rpcClient: this.rpcClient,\n bundlerProvider,\n index: params.defaultProvider?.getAccount().getIndex(),\n ...params.opts?.accountConfig,\n })\n );\n if (shouldUsePaymaster) {\n let paymasterConfig = params.opts?.paymasterConfig ?? {\n policy: \"VERIFYING_PAYMASTER\",\n };\n paymasterConfig = {\n ...paymasterConfig,\n paymasterProvider:\n params.opts?.paymasterConfig?.paymasterProvider ?? bundlerProvider,\n };\n withZeroDevPaymasterAndData(this, paymasterConfig);\n }\n }\n\n getValidator = (): V => {\n if (!isKernelAccount(this.account) || !this.account.validator) {\n throw new Error(\n \"ValidatorProvider: account with validator is not set, did you call all connects first?\"\n );\n }\n return this.account.getValidator() as unknown as V;\n };\n\n getEncodedEnableData = async (enableData: Hex): Promise<Hex> => {\n if (!isKernelAccount(this.account) || !this.account.validator) {\n throw new Error(\n \"ValidatorProvider: account with validator is not set, did you call all connects first?\"\n );\n }\n return await this.account.validator.encodeEnable(enableData);\n };\n\n getEncodedDisableData = async (disableData: Hex = \"0x\"): Promise<Hex> => {\n if (!isKernelAccount(this.account) || !this.account.validator) {\n throw new Error(\n \"ValidatorProvider: account with validator is not set, did you call all connects first?\"\n );\n }\n return await this.account.validator.encodeDisable(disableData);\n };\n\n sendEnableUserOperation = async (\n enableData: Hex\n ): Promise<SendUserOperationResult> => {\n const encodedEnableData = await this.getEncodedEnableData(enableData);\n if (!isKernelAccount(this.account) || !this.account.validator) {\n throw new Error(\n \"ValidatorProvider: account with validator is not set, did you call all connects first?\"\n );\n }\n\n return await this.sendUserOperation({\n target: this.account.validator.validatorAddress,\n data: encodedEnableData,\n });\n };\n\n sendDisableUserOperation = async (\n disableData: Hex = \"0x\"\n ): Promise<SendUserOperationResult> => {\n const encodedDisableData = await this.getEncodedDisableData(disableData);\n if (!isKernelAccount(this.account) || !this.account.validator) {\n throw new Error(\n \"ValidatorProvider: account with validator is not set, did you call all connects first?\"\n );\n }\n if (!this.defaultProvider) {\n throw Error(\"Default Validator provider unintialized\");\n }\n\n return await this.defaultProvider.sendUserOperation({\n target: this.account.validator.validatorAddress,\n data: encodedDisableData,\n });\n };\n}\n"]}
@@ -1,4 +1,8 @@
1
1
  export declare const SessionKeyValidatorAbi: readonly [{
2
+ readonly inputs: readonly [];
3
+ readonly name: "NotImplemented";
4
+ readonly type: "error";
5
+ }, {
2
6
  readonly inputs: readonly [{
3
7
  readonly internalType: "bytes";
4
8
  readonly name: "_data";
@@ -18,6 +22,56 @@ export declare const SessionKeyValidatorAbi: readonly [{
18
22
  readonly outputs: readonly [];
19
23
  readonly stateMutability: "payable";
20
24
  readonly type: "function";
25
+ }, {
26
+ readonly inputs: readonly [{
27
+ readonly internalType: "bytes32";
28
+ readonly name: "permissionKey";
29
+ readonly type: "bytes32";
30
+ }, {
31
+ readonly internalType: "address";
32
+ readonly name: "kernel";
33
+ readonly type: "address";
34
+ }];
35
+ readonly name: "executionStatus";
36
+ readonly outputs: readonly [{
37
+ readonly internalType: "ValidAfter";
38
+ readonly name: "validAfter";
39
+ readonly type: "uint48";
40
+ }, {
41
+ readonly internalType: "uint48";
42
+ readonly name: "runs";
43
+ readonly type: "uint48";
44
+ }];
45
+ readonly stateMutability: "view";
46
+ readonly type: "function";
47
+ }, {
48
+ readonly inputs: readonly [{
49
+ readonly internalType: "uint128";
50
+ readonly name: "nonce";
51
+ readonly type: "uint128";
52
+ }];
53
+ readonly name: "invalidateNonce";
54
+ readonly outputs: readonly [];
55
+ readonly stateMutability: "nonpayable";
56
+ readonly type: "function";
57
+ }, {
58
+ readonly inputs: readonly [{
59
+ readonly internalType: "address";
60
+ readonly name: "kernel";
61
+ readonly type: "address";
62
+ }];
63
+ readonly name: "nonces";
64
+ readonly outputs: readonly [{
65
+ readonly internalType: "uint128";
66
+ readonly name: "lastNonce";
67
+ readonly type: "uint128";
68
+ }, {
69
+ readonly internalType: "uint128";
70
+ readonly name: "invalidNonce";
71
+ readonly type: "uint128";
72
+ }];
73
+ readonly stateMutability: "view";
74
+ readonly type: "function";
21
75
  }, {
22
76
  readonly inputs: readonly [{
23
77
  readonly internalType: "address";
@@ -46,9 +100,9 @@ export declare const SessionKeyValidatorAbi: readonly [{
46
100
  readonly name: "paymaster";
47
101
  readonly type: "address";
48
102
  }, {
49
- readonly internalType: "bool";
50
- readonly name: "enabled";
51
- readonly type: "bool";
103
+ readonly internalType: "uint256";
104
+ readonly name: "nonce";
105
+ readonly type: "uint256";
52
106
  }];
53
107
  readonly stateMutability: "view";
54
108
  readonly type: "function";
@@ -140,7 +194,7 @@ export declare const SessionKeyValidatorAbi: readonly [{
140
194
  readonly type: "tuple";
141
195
  }, {
142
196
  readonly internalType: "bytes32";
143
- readonly name: "userOpHash";
197
+ readonly name: "";
144
198
  readonly type: "bytes32";
145
199
  }, {
146
200
  readonly internalType: "uint256";
@@ -1,4 +1,9 @@
1
1
  export const SessionKeyValidatorAbi = [
2
+ {
3
+ inputs: [],
4
+ name: "NotImplemented",
5
+ type: "error",
6
+ },
2
7
  {
3
8
  inputs: [
4
9
  {
@@ -25,6 +30,72 @@ export const SessionKeyValidatorAbi = [
25
30
  stateMutability: "payable",
26
31
  type: "function",
27
32
  },
33
+ {
34
+ inputs: [
35
+ {
36
+ internalType: "bytes32",
37
+ name: "permissionKey",
38
+ type: "bytes32",
39
+ },
40
+ {
41
+ internalType: "address",
42
+ name: "kernel",
43
+ type: "address",
44
+ },
45
+ ],
46
+ name: "executionStatus",
47
+ outputs: [
48
+ {
49
+ internalType: "ValidAfter",
50
+ name: "validAfter",
51
+ type: "uint48",
52
+ },
53
+ {
54
+ internalType: "uint48",
55
+ name: "runs",
56
+ type: "uint48",
57
+ },
58
+ ],
59
+ stateMutability: "view",
60
+ type: "function",
61
+ },
62
+ {
63
+ inputs: [
64
+ {
65
+ internalType: "uint128",
66
+ name: "nonce",
67
+ type: "uint128",
68
+ },
69
+ ],
70
+ name: "invalidateNonce",
71
+ outputs: [],
72
+ stateMutability: "nonpayable",
73
+ type: "function",
74
+ },
75
+ {
76
+ inputs: [
77
+ {
78
+ internalType: "address",
79
+ name: "kernel",
80
+ type: "address",
81
+ },
82
+ ],
83
+ name: "nonces",
84
+ outputs: [
85
+ {
86
+ internalType: "uint128",
87
+ name: "lastNonce",
88
+ type: "uint128",
89
+ },
90
+ {
91
+ internalType: "uint128",
92
+ name: "invalidNonce",
93
+ type: "uint128",
94
+ },
95
+ ],
96
+ stateMutability: "view",
97
+ type: "function",
98
+ },
28
99
  {
29
100
  inputs: [
30
101
  {
@@ -61,9 +132,9 @@ export const SessionKeyValidatorAbi = [
61
132
  type: "address",
62
133
  },
63
134
  {
64
- internalType: "bool",
65
- name: "enabled",
66
- type: "bool",
135
+ internalType: "uint256",
136
+ name: "nonce",
137
+ type: "uint256",
67
138
  },
68
139
  ],
69
140
  stateMutability: "view",
@@ -183,7 +254,7 @@ export const SessionKeyValidatorAbi = [
183
254
  },
184
255
  {
185
256
  internalType: "bytes32",
186
- name: "userOpHash",
257
+ name: "",
187
258
  type: "bytes32",
188
259
  },
189
260
  {
@@ -1 +1 @@
1
- {"version":3,"file":"SessionKeyValidatorAbi.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/abis/SessionKeyValidatorAbi.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AS;wBACvB,IAAI,EAAE,sBAAsB;wBAC5B,IAAI,EAAE,SAAS;qBAChB;oBACD;wBACE,YAAY,EAAE,SAAS;wBACvB,IAAI,EAAE,oBAAoB;wBAC1B,IAAI,EAAE,SAAS;qBAChB;oBACD;wBACE,YAAY,EAAE,SAAS;wBACvB,IAAI,EAAE,cAAc;wBACpB,IAAI,EAAE,SAAS;qBAChB;oBACD;wBACE,YAAY,EAAE,SAAS;wBACvB,IAAI,EAAE,sBAAsB;wBAC5B,IAAI,EAAE,SAAS;qBAChB;oBACD;wBACE,YAAY,EAAE,OAAO;wBACrB,IAAI,EAAE,kBAAkB;wBACxB,IAAI,EAAE,OAAO;qBACd;oBACD;wBACE,YAAY,EAAE,OAAO;wBACrB,IAAI,EAAE,WAAW;wBACjB,IAAI,EAAE,OAAO;qBACd;iBACF;gBACD,YAAY,EAAE,sBAAsB;gBACpC,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,OAAO;aACd;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,gBAAgB;gBAC9B,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,SAAS;QAC1B,IAAI,EAAE,UAAU;KACjB;CACO,CAAC","sourcesContent":["export const SessionKeyValidatorAbi = [\n {\n inputs: [\n {\n internalType: \"bytes\",\n name: \"_data\",\n type: \"bytes\",\n },\n ],\n name: \"disable\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"bytes\",\n name: \"_data\",\n type: \"bytes\",\n },\n ],\n name: \"enable\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"sessionKey\",\n type: \"address\",\n },\n {\n internalType: \"address\",\n name: \"kernel\",\n type: \"address\",\n },\n ],\n name: \"sessionData\",\n outputs: [\n {\n internalType: \"bytes32\",\n name: \"merkleRoot\",\n type: \"bytes32\",\n },\n {\n internalType: \"ValidAfter\",\n name: \"validAfter\",\n type: \"uint48\",\n },\n {\n internalType: \"ValidUntil\",\n name: \"validUntil\",\n type: \"uint48\",\n },\n {\n internalType: \"address\",\n name: \"paymaster\",\n type: \"address\",\n },\n {\n internalType: \"bool\",\n name: \"enabled\",\n type: \"bool\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\",\n },\n {\n internalType: \"bytes\",\n name: \"\",\n type: \"bytes\",\n },\n ],\n name: \"validCaller\",\n outputs: [\n {\n internalType: \"bool\",\n name: \"\",\n type: \"bool\",\n },\n ],\n stateMutability: \"pure\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"bytes32\",\n name: \"\",\n type: \"bytes32\",\n },\n {\n internalType: \"bytes\",\n name: \"\",\n type: \"bytes\",\n },\n ],\n name: \"validateSignature\",\n outputs: [\n {\n internalType: \"ValidationData\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"pure\",\n type: \"function\",\n },\n {\n inputs: [\n {\n components: [\n {\n internalType: \"address\",\n name: \"sender\",\n type: \"address\",\n },\n {\n internalType: \"uint256\",\n name: \"nonce\",\n type: \"uint256\",\n },\n {\n internalType: \"bytes\",\n name: \"initCode\",\n type: \"bytes\",\n },\n {\n internalType: \"bytes\",\n name: \"callData\",\n type: \"bytes\",\n },\n {\n internalType: \"uint256\",\n name: \"callGasLimit\",\n type: \"uint256\",\n },\n {\n internalType: \"uint256\",\n name: \"verificationGasLimit\",\n type: \"uint256\",\n },\n {\n internalType: \"uint256\",\n name: \"preVerificationGas\",\n type: \"uint256\",\n },\n {\n internalType: \"uint256\",\n name: \"maxFeePerGas\",\n type: \"uint256\",\n },\n {\n internalType: \"uint256\",\n name: \"maxPriorityFeePerGas\",\n type: \"uint256\",\n },\n {\n internalType: \"bytes\",\n name: \"paymasterAndData\",\n type: \"bytes\",\n },\n {\n internalType: \"bytes\",\n name: \"signature\",\n type: \"bytes\",\n },\n ],\n internalType: \"struct UserOperation\",\n name: \"userOp\",\n type: \"tuple\",\n },\n {\n internalType: \"bytes32\",\n name: \"userOpHash\",\n type: \"bytes32\",\n },\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n name: \"validateUserOp\",\n outputs: [\n {\n internalType: \"ValidationData\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"payable\",\n type: \"function\",\n },\n] as const;\n"]}
1
+ {"version":3,"file":"SessionKeyValidatorAbi.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/abis/SessionKeyValidatorAbi.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,OAAO;KACd;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,OAAO;aACd;SACF;QACD,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,SAAS;QAC1B,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,OAAO;aACd;SACF;QACD,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,SAAS;QAC1B,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,eAAe;gBACrB,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I,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,gBAAgB;gBAC9B,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,SAAS;QAC1B,IAAI,EAAE,UAAU;KACjB;CACO,CAAC","sourcesContent":["export const SessionKeyValidatorAbi = [\n {\n inputs: [],\n name: \"NotImplemented\",\n type: \"error\",\n },\n {\n inputs: [\n {\n internalType: \"bytes\",\n name: \"_data\",\n type: \"bytes\",\n },\n ],\n name: \"disable\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"bytes\",\n name: \"_data\",\n type: \"bytes\",\n },\n ],\n name: \"enable\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"bytes32\",\n name: \"permissionKey\",\n type: \"bytes32\",\n },\n {\n internalType: \"address\",\n name: \"kernel\",\n type: \"address\",\n },\n ],\n name: \"executionStatus\",\n outputs: [\n {\n internalType: \"ValidAfter\",\n name: \"validAfter\",\n type: \"uint48\",\n },\n {\n internalType: \"uint48\",\n name: \"runs\",\n type: \"uint48\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"uint128\",\n name: \"nonce\",\n type: \"uint128\",\n },\n ],\n name: \"invalidateNonce\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"kernel\",\n type: \"address\",\n },\n ],\n name: \"nonces\",\n outputs: [\n {\n internalType: \"uint128\",\n name: \"lastNonce\",\n type: \"uint128\",\n },\n {\n internalType: \"uint128\",\n name: \"invalidNonce\",\n type: \"uint128\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"sessionKey\",\n type: \"address\",\n },\n {\n internalType: \"address\",\n name: \"kernel\",\n type: \"address\",\n },\n ],\n name: \"sessionData\",\n outputs: [\n {\n internalType: \"bytes32\",\n name: \"merkleRoot\",\n type: \"bytes32\",\n },\n {\n internalType: \"ValidAfter\",\n name: \"validAfter\",\n type: \"uint48\",\n },\n {\n internalType: \"ValidUntil\",\n name: \"validUntil\",\n type: \"uint48\",\n },\n {\n internalType: \"address\",\n name: \"paymaster\",\n type: \"address\",\n },\n {\n internalType: \"uint256\",\n name: \"nonce\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\",\n },\n {\n internalType: \"bytes\",\n name: \"\",\n type: \"bytes\",\n },\n ],\n name: \"validCaller\",\n outputs: [\n {\n internalType: \"bool\",\n name: \"\",\n type: \"bool\",\n },\n ],\n stateMutability: \"pure\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"bytes32\",\n name: \"\",\n type: \"bytes32\",\n },\n {\n internalType: \"bytes\",\n name: \"\",\n type: \"bytes\",\n },\n ],\n name: \"validateSignature\",\n outputs: [\n {\n internalType: \"ValidationData\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"pure\",\n type: \"function\",\n },\n {\n inputs: [\n {\n components: [\n {\n internalType: \"address\",\n name: \"sender\",\n type: \"address\",\n },\n {\n internalType: \"uint256\",\n name: \"nonce\",\n type: \"uint256\",\n },\n {\n internalType: \"bytes\",\n name: \"initCode\",\n type: \"bytes\",\n },\n {\n internalType: \"bytes\",\n name: \"callData\",\n type: \"bytes\",\n },\n {\n internalType: \"uint256\",\n name: \"callGasLimit\",\n type: \"uint256\",\n },\n {\n internalType: \"uint256\",\n name: \"verificationGasLimit\",\n type: \"uint256\",\n },\n {\n internalType: \"uint256\",\n name: \"preVerificationGas\",\n type: \"uint256\",\n },\n {\n internalType: \"uint256\",\n name: \"maxFeePerGas\",\n type: \"uint256\",\n },\n {\n internalType: \"uint256\",\n name: \"maxPriorityFeePerGas\",\n type: \"uint256\",\n },\n {\n internalType: \"bytes\",\n name: \"paymasterAndData\",\n type: \"bytes\",\n },\n {\n internalType: \"bytes\",\n name: \"signature\",\n type: \"bytes\",\n },\n ],\n internalType: \"struct UserOperation\",\n name: \"userOp\",\n type: \"tuple\",\n },\n {\n internalType: \"bytes32\",\n name: \"\",\n type: \"bytes32\",\n },\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n name: \"validateUserOp\",\n outputs: [\n {\n internalType: \"ValidationData\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"payable\",\n type: \"function\",\n },\n] as const;\n"]}
@@ -10,6 +10,7 @@ function isMethodInErc4337RpcSchema(variable) {
10
10
  "eth_supportedEntryPoints",
11
11
  "eth_maxPriorityFeePerGas",
12
12
  "rundler_maxPriorityFeePerGas",
13
+ "pimlico_getUserOperationGasPrice",
13
14
  ].includes(variable);
14
15
  }
15
16
  export const createZeroDevPublicErc4337Client = ({ chain, rpcUrl, projectId, bundlerProvider, }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"create-client.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/client/create-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAI9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAc,MAAM,EAAE,MAAM,MAAM,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAYhE,SAAS,0BAA0B,CACjC,QAAgB;IAEhB,OACE;QACE,uBAAuB;QACvB,8BAA8B;QAC9B,6BAA6B;QAC7B,4BAA4B;QAC5B,0BAA0B;QAC1B,0BAA0B;QAC1B,8BAA8B;KAEjC,CAAC,QAAQ,CAAC,QAAqC,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,EAC/C,KAAK,EACL,MAAM,EACN,SAAS,EACT,eAAe,GACK,EAAsC,EAAE;IAC5D,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE;QACpC,YAAY,EAAE;YAEZ,OAAO,EAAE,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE;SACtE;QACD,IAAI,EAAE,2BAA2B;QACjC,GAAG,EAAE,2BAA2B;QAChC,UAAU,EAAE,CAAC;QACb,OAAO,EAAE,KAAK;KACf,CAAC,CAAC;IACH,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,IAAI,MAAM,GAAG,6BAA6B,CACxC,kBAAkB,CAAC;QACjB,KAAK;QACL,SAAS,EAAE,MAAM,CAAC;YAChB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;gBAC9B,IAAI,QAAQ,CAAC;gBACb,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAE;oBACtC,QAAQ,GAAG,MAAM,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC;wBACnD,MAAM;wBACN,MAAM;qBACA,CAAC,CAAC;iBACX;qBAAM;oBACL,QAAQ,GAAG,MAAM,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC;wBAClD,MAAM;wBACN,MAAM;qBACA,CAAC,CAAC;iBACX;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;KACH,CAAC,CACH,CAAC;IAEF,OAAO,MAAuD,CAAC;AACjE,CAAC,CAAC","sourcesContent":["import {\n createPublicErc4337FromClient,\n type PublicErc4337Client,\n type Erc337RpcSchema,\n type HttpTransport,\n} from \"@alchemy/aa-core\";\nimport { http, createPublicClient, type Chain, custom } from \"viem\";\nimport { BUNDLER_URL, CHAIN_ID_TO_NODE } from \"../constants.js\";\nimport type { PaymasterAndBundlerProviders } from \"../paymaster/types.js\";\n\ninterface ZeroDevClientConfig {\n chain: Chain;\n projectId: string;\n rpcUrl?: string;\n bundlerProvider?: PaymasterAndBundlerProviders;\n}\n\ntype MethodsOfErc4337RpcSchema = Erc337RpcSchema[number][\"Method\"];\n\nfunction isMethodInErc4337RpcSchema(\n variable: string\n): variable is MethodsOfErc4337RpcSchema {\n return (\n [\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationReceipt\",\n \"eth_getUserOperationByHash\",\n \"eth_supportedEntryPoints\",\n \"eth_maxPriorityFeePerGas\",\n \"rundler_maxPriorityFeePerGas\",\n ] as const\n ).includes(variable as MethodsOfErc4337RpcSchema);\n}\n\nexport const createZeroDevPublicErc4337Client = ({\n chain,\n rpcUrl,\n projectId,\n bundlerProvider,\n}: ZeroDevClientConfig): PublicErc4337Client<HttpTransport> => {\n const erc4337Transport = http(rpcUrl, {\n fetchOptions: {\n // @ts-ignore\n headers: rpcUrl === BUNDLER_URL ? { projectId, bundlerProvider } : {},\n },\n name: \"Connected bundler network\",\n key: \"connected-bundler-network\",\n retryCount: 0,\n timeout: 35000,\n });\n const publicTransport = http(CHAIN_ID_TO_NODE[chain.id]);\n let client = createPublicErc4337FromClient(\n createPublicClient({\n chain,\n transport: custom({\n async request({ method, params }) {\n let response;\n if (isMethodInErc4337RpcSchema(method)) {\n response = await erc4337Transport({ chain }).request({\n method,\n params,\n } as any);\n } else {\n response = await publicTransport({ chain }).request({\n method,\n params,\n } as any);\n }\n return response;\n },\n }),\n })\n );\n\n return client as unknown as PublicErc4337Client<HttpTransport>;\n};\n"]}
1
+ {"version":3,"file":"create-client.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/client/create-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAI9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAc,MAAM,EAAE,MAAM,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O,CAAC;wBAClD,MAAM;wBACN,MAAM;qBACA,CAAC,CAAC;iBACX;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;KACH,CAAC,CACH,CAAC;IAEF,OAAO,MAAuD,CAAC;AACjE,CAAC,CAAC","sourcesContent":["import {\n createPublicErc4337FromClient,\n type PublicErc4337Client,\n type Erc337RpcSchema,\n type HttpTransport,\n} from \"@alchemy/aa-core\";\nimport { http, createPublicClient, type Chain, custom } from \"viem\";\nimport { BUNDLER_URL, CHAIN_ID_TO_NODE } from \"../constants.js\";\nimport type { PaymasterAndBundlerProviders } from \"../paymaster/types.js\";\n\ninterface ZeroDevClientConfig {\n chain: Chain;\n projectId: string;\n rpcUrl?: string;\n bundlerProvider?: PaymasterAndBundlerProviders;\n}\n\ntype MethodsOfErc4337RpcSchema = Erc337RpcSchema[number][\"Method\"];\n\nfunction isMethodInErc4337RpcSchema(\n variable: string\n): variable is MethodsOfErc4337RpcSchema {\n return (\n [\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationReceipt\",\n \"eth_getUserOperationByHash\",\n \"eth_supportedEntryPoints\",\n \"eth_maxPriorityFeePerGas\",\n \"rundler_maxPriorityFeePerGas\",\n \"pimlico_getUserOperationGasPrice\",\n ] as const\n ).includes(variable as MethodsOfErc4337RpcSchema);\n}\n\nexport const createZeroDevPublicErc4337Client = ({\n chain,\n rpcUrl,\n projectId,\n bundlerProvider,\n}: ZeroDevClientConfig): PublicErc4337Client<HttpTransport> => {\n const erc4337Transport = http(rpcUrl, {\n fetchOptions: {\n // @ts-ignore\n headers: rpcUrl === BUNDLER_URL ? { projectId, bundlerProvider } : {},\n },\n name: \"Connected bundler network\",\n key: \"connected-bundler-network\",\n retryCount: 0,\n timeout: 35000,\n });\n const publicTransport = http(CHAIN_ID_TO_NODE[chain.id]);\n let client = createPublicErc4337FromClient(\n createPublicClient({\n chain,\n transport: custom({\n async request({ method, params }) {\n let response;\n if (isMethodInErc4337RpcSchema(method)) {\n response = await erc4337Transport({ chain }).request({\n method,\n params,\n } as any);\n } else {\n response = await publicTransport({ chain }).request({\n method,\n params,\n } as any);\n }\n return response;\n },\n }),\n })\n );\n\n return client as unknown as PublicErc4337Client<HttpTransport>;\n};\n"]}
@@ -16,7 +16,7 @@ export declare const KILL_SWITCH_ACTION = "0x3f38e479304c7F18F988269a1bDa7d646bd
16
16
  export declare const DUMMY_ECDSA_SIG = "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
17
17
  export declare const ERC165_SESSION_KEY_VALIDATOR_ADDRESS = "0xe149290800De29D4b0BF9dB82c508255D81902E6";
18
18
  export declare const TOKEN_ACTION = "0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1";
19
- export declare const SESSION_KEY_VALIDATOR_ADDRESS = "0x1C1D5b70aD6e0c04366aab100261A6Bcc251EA3f";
19
+ export declare const SESSION_KEY_VALIDATOR_ADDRESS = "0xB8E3c4bEaACAd06f6092793012DA4a8cB23D6123";
20
20
  export declare const RECOVERY_VALIDATOR_ADDRESS = "0x4fd47D861c349bD49DC61341a922cb72F9dF7E8d";
21
21
  export declare const RECOVERY_ACTION = "0x2f65dB8039fe5CAEE0a8680D2879deB800F31Ae1";
22
22
  export declare const oneAddress = "0x0000000000000000000000000000000000000001";
@@ -16,7 +16,7 @@ export const KILL_SWITCH_ACTION = "0x3f38e479304c7F18F988269a1bDa7d646bd48243";
16
16
  export const DUMMY_ECDSA_SIG = "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
17
17
  export const ERC165_SESSION_KEY_VALIDATOR_ADDRESS = "0xe149290800De29D4b0BF9dB82c508255D81902E6";
18
18
  export const TOKEN_ACTION = "0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1";
19
- export const SESSION_KEY_VALIDATOR_ADDRESS = "0x1C1D5b70aD6e0c04366aab100261A6Bcc251EA3f";
19
+ export const SESSION_KEY_VALIDATOR_ADDRESS = "0xB8E3c4bEaACAd06f6092793012DA4a8cB23D6123";
20
20
  export const RECOVERY_VALIDATOR_ADDRESS = "0x4fd47D861c349bD49DC61341a922cb72F9dF7E8d";
21
21
  export const RECOVERY_ACTION = "0x2f65dB8039fe5CAEE0a8680D2879deB800F31Ae1";
22
22
  export const oneAddress = "0x0000000000000000000000000000000000000001";
@@ -65,6 +65,6 @@ export const CHAIN_ID_TO_NODE = {
65
65
  10200: "https://nd-810-853-201.p2pify.com/e828b09f0d43591de96c297b3f36fffd",
66
66
  59144: `https://linea-mainnet.infura.io/v3/${INFURA_API_KEY}`,
67
67
  59140: `https://linea-goerli.infura.io/v3/${INFURA_API_KEY}`,
68
- 204: 'https://opbnb.rpc.thirdweb.com/eed98c1f30120c0508f17c1f01d3102b',
68
+ 204: "https://opbnb.rpc.thirdweb.com/eed98c1f30120c0508f17c1f01d3102b",
69
69
  };
70
70
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/kernel-zerodev/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,MAAM,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,iCAAiC,GAAG,KAAK,CAAC;AACvD,MAAM,CAAC,MAAM,WAAW,GAAG,wCAAwC,CAAC;AACpE,MAAM,CAAC,MAAM,aAAa,GACxB,wDAAwD,CAAC;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAC7B,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAQ,4CAA4C,CAAC;AAChF,MAAM,CAAC,MA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;IACrG,KAAK,EACH,8FAA8F;IAChG,GAAG,EAAE,2FAA2F;IAChG,KAAK,EAAE,oEAAoE;IAC3E,KAAK,EAAE,sCAAsC,cAAc,EAAE;IAC7D,KAAK,EAAE,qCAAqC,cAAc,EAAE;IAC5D,GAAG,EAAE,iEAAiE;CAEvE,CAAC","sourcesContent":["import { parseUnits, type Hex } from \"viem\";\nimport type { IGasTokenAddresses } from \"./paymaster/types.js\";\nimport { polygon } from \"viem/chains\";\n\nexport const DEFAULT_SEND_TX_MAX_RETRIES = 3;\nexport const DEFAULT_SEND_TX_RETRY_INTERVAL_MS = 60000; // 1 minutes\nexport const BUNDLER_URL = \"https://v0-6-meta-bundler.onrender.com\";\nexport const PAYMASTER_URL =\n \"https://meta-aa-provider.onrender.com/api/v1/paymaster\";\nexport const ENTRYPOINT_ADDRESS: Hex =\n \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\";\nexport const MULTISEND_ADDR: Hex = \"0x8ae01fcf7c655655ff2c6ef907b8b4718ab4e17c\";\nexport const BACKEND_URL = \"https://backend-vikp.onrender.com\";\nexport const API_URL = \"https://prod-api.zerodev.app\";\nexport const ECDSA_VALIDATOR_ADDRESS =\n \"0xd9AB5096a832b9ce79914329DAEE236f8Eea0390\";\nexport const KERNEL_FACTORY_ADDRESS =\n \"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3\";\nexport const KERNEL_IMPL_ADDRESS = \"0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5\";\nexport const KILL_SWITCH_VALIDATOR_ADDRESS =\n \"0x7393A7dA58CCfFb78f52adb09705BE6E20F704BC\";\nexport const KILL_SWITCH_ACTION = \"0x3f38e479304c7F18F988269a1bDa7d646bd48243\";\nexport const DUMMY_ECDSA_SIG =\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\nexport const ERC165_SESSION_KEY_VALIDATOR_ADDRESS =\n \"0xe149290800De29D4b0BF9dB82c508255D81902E6\";\nexport const TOKEN_ACTION = \"0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1\";\nexport const SESSION_KEY_VALIDATOR_ADDRESS =\n \"0x1C1D5b70aD6e0c04366aab100261A6Bcc251EA3f\";\nexport const RECOVERY_VALIDATOR_ADDRESS =\n \"0x4fd47D861c349bD49DC61341a922cb72F9dF7E8d\";\nexport const RECOVERY_ACTION = \"0x2f65dB8039fe5CAEE0a8680D2879deB800F31Ae1\";\nexport const oneAddress = \"0x0000000000000000000000000000000000000001\";\n\nexport const gasTokenChainAddresses: IGasTokenAddresses = {\n USDC: {\n 1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n // 5: \"0x2f3A40A3db8a7e3D09B0adfEfbCe4f6F81927557\",\n 137: \"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\",\n // 80001: \"\",\n // 420: \"0x7F5c764cBc14f9669B88837ca1490cCa17c31607\",\n 42161: \"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8\",\n // 421613: \"\",\n 43114: \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\",\n // 43113: \"\",\n // 56: \"\",\n // 97: \"\"\n },\n PEPE: {\n 1: \"0x6982508145454Ce325dDbE47a25d4ec3d2311933\",\n },\n};\n\nexport const ERC20_APPROVAL_AMOUNT: { [key: string]: bigint } = {\n // ETH\n [gasTokenChainAddresses[\"USDC\"][1]]: parseUnits(\"100\", 6),\n\n // Goerli\n [gasTokenChainAddresses[\"USDC\"][5]]: parseUnits(\"100\", 6),\n\n // Polygon\n [gasTokenChainAddresses[\"USDC\"][137]]: parseUnits(\"10\", 6),\n\n // Arbitrum\n [gasTokenChainAddresses[\"USDC\"][42161]]: parseUnits(\"10\", 6),\n\n // Avalanche\n [gasTokenChainAddresses[\"USDC\"][43114]]: parseUnits(\"10\", 6),\n\n // ETH\n [gasTokenChainAddresses[\"PEPE\"][1]]: parseUnits(\"50000000\", 18),\n\n \"0x3870419Ba2BBf0127060bCB37f69A1b1C090992B\": parseUnits(\"100\", 18),\n};\n\nexport const minPriorityFeePerBidDefaults = new Map<number, bigint>([\n [polygon.id, 30_000_000_000n],\n]);\n\nexport const INFURA_API_KEY = \"f36f7f706a58477884ce6fe89165666c\";\nexport const CHAIN_ID_TO_NODE: { [key: number]: string } = {\n 1: `https://mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 5: `https://goerli.infura.io/v3/${INFURA_API_KEY}`,\n 11155111:\n \"https://fittest-ultra-aura.ethereum-sepolia.quiknode.pro/3893d01b1dd411fdfa9b6dd372dd2b4f69fcf1ea/\",\n 137: `https://polygon-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 80001: `https://polygon-mumbai.infura.io/v3/${INFURA_API_KEY}`,\n 10: `https://optimism-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 420: `https://optimism-goerli.infura.io/v3/${INFURA_API_KEY}`,\n 42161: `https://arbitrum-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n // 42161: 'https://evocative-stylish-dinghy.arbitrum-mainnet.discover.quiknode.pro/80b526d14fa9fd9a8b0db1e65554acaf00c6a1ab/',\n 421613: `https://arbitrum-goerli.infura.io/v3/${INFURA_API_KEY}`,\n 43114: `https://avalanche-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 43113: `https://avalanche-fuji.infura.io/v3/${INFURA_API_KEY}`,\n 1313161554: `https://aurora-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 1313161555: `https://aurora-testnet.infura.io/v3/${INFURA_API_KEY}`,\n 56: \"https://neat-greatest-layer.bsc.quiknode.pro/9405a499ceee314e5f2f68c9d47518d3537fce6a/\",\n 8453: \"https://twilight-red-tree.base-mainnet.quiknode.pro/dc6eb27bf0f917df215922488dd97f4de7d9b08e/\",\n 84531:\n \"https://icy-long-mountain.base-goerli.quiknode.pro/5b80d93e97cc9412a63c10a30841869abbef9596/\",\n 100: \"https://thrilling-fluent-film.xdai.quiknode.pro/305955cffb9868cdd95b5e3dc9775f20678ad9ac/\",\n 10200: \"https://nd-810-853-201.p2pify.com/e828b09f0d43591de96c297b3f36fffd\",\n 59144: `https://linea-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 59140: `https://linea-goerli.infura.io/v3/${INFURA_API_KEY}`,\n 204: 'https://opbnb.rpc.thirdweb.com/eed98c1f30120c0508f17c1f01d3102b',\n // 5611: 'opBnb-testnet',\n};\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/kernel-zerodev/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,MAAM,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,iCAAiC,GAAG,KAAK,CAAC;AACvD,MAAM,CAAC,MAAM,WAAW,GAAG,wCAAwC,CAAC;AACpE,MAAM,CAAC,MAAM,aAAa,GACxB,wDAAwD,CAAC;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAC7B,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAQ,4CAA4C,CAAC;AAChF,MAAM,CAAC,MAAM,WAAW,GAAG,mCAAmC,CAAC;AAC/D,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,uBAAuB,GAClC,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,sBAAsB,GACjC,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,4CAA4C,CAAC;AAChF,MAAM,CAAC,MAAM,6BAA6B,GACxC,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,4CAA4C,CAAC;AAC/E,MAAM,CAAC,MAAM,eAAe,GAC1B,sIAAsI,CAAC;AACzI,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A4C,EAAE,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC;CACpE,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAAiB;IAClE,CAAC,OAAO,CAAC,EAAE,EAAE,YAAe,CAAC;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,kCAAkC,CAAC;AACjE,MAAM,CAAC,MAAM,gBAAgB,GAA8B;IACzD,CAAC,EAAE,gCAAgC,cAAc,EAAE;IACnD,CAAC,EAAE,+BAA+B,cAAc,EAAE;IAClD,QAAQ,EACN,oGAAoG;IACtG,GAAG,EAAE,wCAAwC,cAAc,EAAE;IAC7D,KAAK,EAAE,uCAAuC,cAAc,EAAE;IAC9D,EAAE,EAAE,yCAAyC,cAAc,EAAE;IAC7D,GAAG,EAAE,wCAAwC,cAAc,EAAE;IAC7D,KAAK,EAAE,yCAAyC,cAAc,EAAE;IAEhE,MAAM,EAAE,wCAAwC,cAAc,EAAE;IAChE,KAAK,EAAE,0CAA0C,cAAc,EAAE;IACjE,KAAK,EAAE,uCAAuC,cAAc,EAAE;IAC9D,UAAU,EAAE,uCAAuC,cAAc,EAAE;IACnE,UAAU,EAAE,uCAAuC,cAAc,EAAE;IACnE,EAAE,EAAE,wFAAwF;IAC5F,IAAI,EAAE,+FAA+F;IACrG,KAAK,EACH,8FAA8F;IAChG,GAAG,EAAE,2FAA2F;IAChG,KAAK,EAAE,oEAAoE;IAC3E,KAAK,EAAE,sCAAsC,cAAc,EAAE;IAC7D,KAAK,EAAE,qCAAqC,cAAc,EAAE;IAC5D,GAAG,EAAE,iEAAiE;CAEvE,CAAC","sourcesContent":["import { parseUnits, type Hex } from \"viem\";\nimport type { IGasTokenAddresses } from \"./paymaster/types.js\";\nimport { polygon } from \"viem/chains\";\n\nexport const DEFAULT_SEND_TX_MAX_RETRIES = 3;\nexport const DEFAULT_SEND_TX_RETRY_INTERVAL_MS = 60000; // 1 minutes\nexport const BUNDLER_URL = \"https://v0-6-meta-bundler.onrender.com\";\nexport const PAYMASTER_URL =\n \"https://meta-aa-provider.onrender.com/api/v1/paymaster\";\nexport const ENTRYPOINT_ADDRESS: Hex =\n \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\";\nexport const MULTISEND_ADDR: Hex = \"0x8ae01fcf7c655655ff2c6ef907b8b4718ab4e17c\";\nexport const BACKEND_URL = \"https://backend-vikp.onrender.com\";\nexport const API_URL = \"https://prod-api.zerodev.app\";\nexport const ECDSA_VALIDATOR_ADDRESS =\n \"0xd9AB5096a832b9ce79914329DAEE236f8Eea0390\";\nexport const KERNEL_FACTORY_ADDRESS =\n \"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3\";\nexport const KERNEL_IMPL_ADDRESS = \"0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5\";\nexport const KILL_SWITCH_VALIDATOR_ADDRESS =\n \"0x7393A7dA58CCfFb78f52adb09705BE6E20F704BC\";\nexport const KILL_SWITCH_ACTION = \"0x3f38e479304c7F18F988269a1bDa7d646bd48243\";\nexport const DUMMY_ECDSA_SIG =\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\nexport const ERC165_SESSION_KEY_VALIDATOR_ADDRESS =\n \"0xe149290800De29D4b0BF9dB82c508255D81902E6\";\nexport const TOKEN_ACTION = \"0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1\";\nexport const SESSION_KEY_VALIDATOR_ADDRESS =\n \"0xB8E3c4bEaACAd06f6092793012DA4a8cB23D6123\";\nexport const RECOVERY_VALIDATOR_ADDRESS =\n \"0x4fd47D861c349bD49DC61341a922cb72F9dF7E8d\";\nexport const RECOVERY_ACTION = \"0x2f65dB8039fe5CAEE0a8680D2879deB800F31Ae1\";\nexport const oneAddress = \"0x0000000000000000000000000000000000000001\";\n\nexport const gasTokenChainAddresses: IGasTokenAddresses = {\n USDC: {\n 1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n // 5: \"0x2f3A40A3db8a7e3D09B0adfEfbCe4f6F81927557\",\n 137: \"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\",\n // 80001: \"\",\n // 420: \"0x7F5c764cBc14f9669B88837ca1490cCa17c31607\",\n 42161: \"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8\",\n // 421613: \"\",\n 43114: \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\",\n // 43113: \"\",\n // 56: \"\",\n // 97: \"\"\n },\n PEPE: {\n 1: \"0x6982508145454Ce325dDbE47a25d4ec3d2311933\",\n },\n};\n\nexport const ERC20_APPROVAL_AMOUNT: { [key: string]: bigint } = {\n // ETH\n [gasTokenChainAddresses[\"USDC\"][1]]: parseUnits(\"100\", 6),\n\n // Goerli\n [gasTokenChainAddresses[\"USDC\"][5]]: parseUnits(\"100\", 6),\n\n // Polygon\n [gasTokenChainAddresses[\"USDC\"][137]]: parseUnits(\"10\", 6),\n\n // Arbitrum\n [gasTokenChainAddresses[\"USDC\"][42161]]: parseUnits(\"10\", 6),\n\n // Avalanche\n [gasTokenChainAddresses[\"USDC\"][43114]]: parseUnits(\"10\", 6),\n\n // ETH\n [gasTokenChainAddresses[\"PEPE\"][1]]: parseUnits(\"50000000\", 18),\n\n \"0x3870419Ba2BBf0127060bCB37f69A1b1C090992B\": parseUnits(\"100\", 18),\n};\n\nexport const minPriorityFeePerBidDefaults = new Map<number, bigint>([\n [polygon.id, 30_000_000_000n],\n]);\n\nexport const INFURA_API_KEY = \"f36f7f706a58477884ce6fe89165666c\";\nexport const CHAIN_ID_TO_NODE: { [key: number]: string } = {\n 1: `https://mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 5: `https://goerli.infura.io/v3/${INFURA_API_KEY}`,\n 11155111:\n \"https://fittest-ultra-aura.ethereum-sepolia.quiknode.pro/3893d01b1dd411fdfa9b6dd372dd2b4f69fcf1ea/\",\n 137: `https://polygon-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 80001: `https://polygon-mumbai.infura.io/v3/${INFURA_API_KEY}`,\n 10: `https://optimism-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 420: `https://optimism-goerli.infura.io/v3/${INFURA_API_KEY}`,\n 42161: `https://arbitrum-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n // 42161: 'https://evocative-stylish-dinghy.arbitrum-mainnet.discover.quiknode.pro/80b526d14fa9fd9a8b0db1e65554acaf00c6a1ab/',\n 421613: `https://arbitrum-goerli.infura.io/v3/${INFURA_API_KEY}`,\n 43114: `https://avalanche-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 43113: `https://avalanche-fuji.infura.io/v3/${INFURA_API_KEY}`,\n 1313161554: `https://aurora-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 1313161555: `https://aurora-testnet.infura.io/v3/${INFURA_API_KEY}`,\n 56: \"https://neat-greatest-layer.bsc.quiknode.pro/9405a499ceee314e5f2f68c9d47518d3537fce6a/\",\n 8453: \"https://twilight-red-tree.base-mainnet.quiknode.pro/dc6eb27bf0f917df215922488dd97f4de7d9b08e/\",\n 84531:\n \"https://icy-long-mountain.base-goerli.quiknode.pro/5b80d93e97cc9412a63c10a30841869abbef9596/\",\n 100: \"https://thrilling-fluent-film.xdai.quiknode.pro/305955cffb9868cdd95b5e3dc9775f20678ad9ac/\",\n 10200: \"https://nd-810-853-201.p2pify.com/e828b09f0d43591de96c297b3f36fffd\",\n 59144: `https://linea-mainnet.infura.io/v3/${INFURA_API_KEY}`,\n 59140: `https://linea-goerli.infura.io/v3/${INFURA_API_KEY}`,\n 204: \"https://opbnb.rpc.thirdweb.com/eed98c1f30120c0508f17c1f01d3102b\",\n // 5611: 'opBnb-testnet',\n};\n"]}
@@ -1,8 +1,12 @@
1
1
  import type { ZeroDevProvider } from "../provider.js";
2
2
  import { type UserOperationStruct, type BigNumberish } from "@alchemy/aa-core";
3
+ import { type PaymasterAndBundlerProviders } from "../paymaster/types.js";
3
4
  export declare const withZeroDevGasEstimator: (provider: ZeroDevProvider) => ZeroDevProvider;
4
5
  export declare const estimateCreationGas: (provider: ZeroDevProvider, initCode?: string) => Promise<bigint>;
5
6
  export declare const getPreVerificationGas: (userOp: Partial<UserOperationStruct>) => Promise<number>;
7
+ export declare const GAS_PRICE_RPC_METHODS_BY_BUNDLER: {
8
+ [K in PaymasterAndBundlerProviders]: string;
9
+ };
6
10
  export declare const eip1559GasPrice: (provider: ZeroDevProvider) => Promise<{
7
11
  maxFeePerGas: bigint;
8
12
  maxPriorityFeePerGas: bigint;
@@ -1,6 +1,7 @@
1
1
  import { deepHexlify, resolveProperties, } from "@alchemy/aa-core";
2
2
  import { ENTRYPOINT_ADDRESS } from "../constants.js";
3
3
  import { calcPreVerificationGas } from "../utils/calc-pre-verification-gas.js";
4
+ import {} from "../paymaster/types.js";
4
5
  export const withZeroDevGasEstimator = (provider) => {
5
6
  provider.withFeeDataGetter(async (struct) => {
6
7
  let overrides = await resolveProperties({
@@ -76,15 +77,23 @@ export const getPreVerificationGas = async (userOp) => {
76
77
  const p = await resolveProperties(userOp);
77
78
  return calcPreVerificationGas(p);
78
79
  };
80
+ export const GAS_PRICE_RPC_METHODS_BY_BUNDLER = {
81
+ STACKUP: "eth_maxPriorityFeePerGas",
82
+ ALCHEMY: "rundler_maxPriorityFeePerGas",
83
+ PIMLICO: "pimlico_getUserOperationGasPrice",
84
+ };
79
85
  export const eip1559GasPrice = async (provider) => {
80
- const [fee, block] = await Promise.all([
81
- provider.bundlerProvider === "ALCHEMY"
82
- ? provider.rpcClient.request({
83
- method: "rundler_maxPriorityFeePerGas",
84
- })
85
- : provider.rpcClient.getMaxPriorityFeePerGas(),
86
+ let [fee, block] = await Promise.all([
87
+ provider.rpcClient.request({
88
+ method: GAS_PRICE_RPC_METHODS_BY_BUNDLER[provider.bundlerProvider] ??
89
+ "eth_maxPriorityFeePerGas",
90
+ params: [],
91
+ }),
86
92
  provider.rpcClient.getBlock({ blockTag: "latest" }),
87
93
  ]);
94
+ if (provider.bundlerProvider === "PIMLICO") {
95
+ fee = fee.standard.maxPriorityFeePerGas;
96
+ }
88
97
  const tip = BigInt(fee);
89
98
  const buffer = (tip / 100n) * 13n;
90
99
  let maxPriorityFeePerGas = tip + buffer;
@@ -1 +1 @@
1
- {"version":3,"file":"gas-estimator.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/middleware/gas-estimator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EAGX,iBAAiB,GAGlB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,QAAyB,EACR,EAAE;IACnB,QAAQ,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC1C,IAAI,SAAS,GAAG,MAAM,iBAAiB,CAAC;YACtC,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE;YACvC,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,IAAI,EAAE;SACxD,CAAC,CAAC;QAEH,IAAI,YAAY,EAAE,oBAAoB,CAAC;QAEvC,IAAI;YACF,CAAC,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,MAAM,eAAe,CAC7D,QAAQ,CACT,CAAC,CAAC;SACJ;QAAC,OAAO,KAAU,EAAE;YACnB,OAAO,CAAC,IAAI,CACV,4EAA4E,CAC7E,CAAC;SACH;QAED,IAAI,YAAY,KAAK,SAAS,IAAI,oBAAoB,KAAK,SAAS,EAAE;YACpE,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC3C,YAAY,GAAG,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,CA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,EAAE,GAAG,MAAM,iBAAiB,CAAC;QAClD,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QAC1D,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACzD,OAAO,CAAC,IAAI,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;KACH,CAAC,CAAC;IAEH,IAAI,YAAY,GAAG,IAAI,CAAC;IACxB,IAAI,oBAAoB,GAAG,IAAI,CAAC;IAEhC,IAAI,KAAK,IAAI,KAAK,CAAC,aAAa,IAAI,IAAI,EAAE;QAExC,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QACxC,oBAAoB,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;QACxE,IACE,oBAAoB,IAAI,IAAI;YAC5B,oBAAoB,GAAG,MAAM,CAAC,CAAC,CAAC;YAChC,oBAAoB,GAAG,UAAU,EACjC;YACA,oBAAoB,GAAG,UAAU,CAAC;SACnC;QACD,oBAAoB;YAClB,oBAAoB,GAAG,QAAQ,CAAC,oBAAoB;gBAClD,CAAC,CAAC,QAAQ,CAAC,oBAAoB;gBAC/B,CAAC,CAAC,oBAAoB,CAAC;QAC3B,YAAY;YACV,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,oBAAoB,IAAI,CAAC,CAAC,CAAC;KACjE;IAED,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import type { ZeroDevProvider } from \"../provider.js\";\nimport {\n deepHexlify,\n type Hex,\n type UserOperationStruct,\n resolveProperties,\n type BigNumberish,\n type UserOperationEstimateGasResponse,\n} from \"@alchemy/aa-core\";\nimport { ENTRYPOINT_ADDRESS } from \"../constants.js\";\nimport { calcPreVerificationGas } from \"../utils/calc-pre-verification-gas.js\";\n\nexport const withZeroDevGasEstimator = (\n provider: ZeroDevProvider\n): ZeroDevProvider => {\n provider.withFeeDataGetter(async (struct) => {\n let overrides = await resolveProperties({\n maxFeePerGas: struct.maxFeePerGas ?? 0n,\n maxPriorityFeePerGas: struct.maxPriorityFeePerGas ?? 0n,\n });\n\n let maxFeePerGas, maxPriorityFeePerGas;\n\n try {\n ({ maxFeePerGas, maxPriorityFeePerGas } = await eip1559GasPrice(\n provider\n ));\n } catch (error: any) {\n console.warn(\n \"getGas: eth_maxPriorityFeePerGas failed, falling back to legacy gas price.\"\n );\n }\n\n if (maxFeePerGas === undefined || maxPriorityFeePerGas === undefined) {\n const feeData = await getFeeData(provider);\n maxFeePerGas = feeData?.maxFeePerGas ? BigInt(feeData?.maxFeePerGas) : 0n;\n maxPriorityFeePerGas = feeData.maxPriorityFeePerGas\n ? BigInt(feeData.maxPriorityFeePerGas)\n : 0n;\n }\n\n if (\n maxFeePerGas < BigInt(overrides.maxFeePerGas) ||\n maxPriorityFeePerGas < BigInt(overrides.maxPriorityFeePerGas)\n ) {\n return overrides;\n }\n return { maxFeePerGas, maxPriorityFeePerGas };\n });\n\n provider.withGasEstimator(async (struct) => {\n if (\n struct.callGasLimit !== undefined &&\n struct.verificationGasLimit !== undefined &&\n struct.preVerificationGas !== undefined\n ) {\n return struct;\n }\n const initCode = await provider.account?.getInitCode();\n const initGas = await estimateCreationGas(provider, initCode);\n const partialStruct: UserOperationStruct = {\n ...struct,\n callGasLimit:\n initCode !== undefined && initCode.length > 2\n ? BigInt(\"1000000\")\n : BigInt(55000),\n verificationGasLimit: BigInt(110000) + initGas,\n preVerificationGas: BigInt(100000),\n };\n\n partialStruct.preVerificationGas = await getPreVerificationGas(\n partialStruct\n );\n\n const request = deepHexlify(await resolveProperties(partialStruct));\n let userOpGasEstimates: UserOperationEstimateGasResponse | undefined;\n userOpGasEstimates = await provider.rpcClient.estimateUserOperationGas(\n request,\n ENTRYPOINT_ADDRESS\n );\n const { preVerificationGas, verificationGasLimit, callGasLimit } =\n userOpGasEstimates;\n request.preVerificationGas =\n (BigInt(preVerificationGas) * 12n) / 10n ?? request.preVerificationGas;\n request.verificationGasLimit =\n BigInt(verificationGasLimit) ?? request.verificationGasLimit;\n request.callGasLimit =\n (BigInt(callGasLimit) * 12n) / 10n ?? request.callGasLimit;\n\n return {\n ...struct,\n ...request,\n };\n });\n\n return provider;\n};\n\nexport const estimateCreationGas = async (\n provider: ZeroDevProvider,\n initCode?: string\n): Promise<bigint> => {\n if (initCode == null || initCode === \"0x\") return BigInt(0);\n const deployerAddress = initCode.substring(0, 42) as Hex;\n const deployerCallData = (\"0x\" + initCode.substring(42)) as Hex;\n return await provider.rpcClient.estimateGas({\n account: ENTRYPOINT_ADDRESS,\n to: deployerAddress,\n data: deployerCallData,\n });\n};\n\n/**\n * should cover cost of putting calldata on-chain, and some overhead.\n * actual overhead depends on the expected bundle size\n */\nexport const getPreVerificationGas = async (\n userOp: Partial<UserOperationStruct>\n): Promise<number> => {\n const p = await resolveProperties(userOp);\n return calcPreVerificationGas(p);\n};\n\nexport const eip1559GasPrice = async (provider: ZeroDevProvider) => {\n const [fee, block] = await Promise.all([\n provider.bundlerProvider === \"ALCHEMY\"\n ? (provider.rpcClient.request({\n // @ts-expect-error\n method: \"rundler_maxPriorityFeePerGas\",\n }) as Promise<Hex>)\n : provider.rpcClient.getMaxPriorityFeePerGas(),\n provider.rpcClient.getBlock({ blockTag: \"latest\" }),\n ]);\n\n const tip = BigInt(fee);\n const buffer = (tip / 100n) * 13n;\n let maxPriorityFeePerGas = tip + buffer;\n maxPriorityFeePerGas =\n maxPriorityFeePerGas < provider.minPriorityFeePerBid\n ? provider.minPriorityFeePerBid\n : maxPriorityFeePerGas;\n const maxFeePerGas = block.baseFeePerGas\n ? BigInt(block.baseFeePerGas) * 2n + maxPriorityFeePerGas\n : maxPriorityFeePerGas;\n\n return { maxFeePerGas, maxPriorityFeePerGas };\n};\ninterface FeeData {\n maxFeePerGas: BigNumberish | null;\n maxPriorityFeePerGas: BigNumberish | null;\n}\n\nexport const getFeeData = async (\n provider: ZeroDevProvider\n): Promise<FeeData> => {\n const { block, gasPrice } = await resolveProperties({\n block: provider.rpcClient.getBlock({ blockTag: \"latest\" }),\n gasPrice: provider.rpcClient.getGasPrice().catch((error) => {\n console.warn(\"Legacy: Failed to get gas price\", error);\n return null;\n }),\n });\n\n let maxFeePerGas = null;\n let maxPriorityFeePerGas = null;\n\n if (block && block.baseFeePerGas != null) {\n // Set the tip to the min of the tip for the last block and 1.5 gwei\n const minimumTip = BigInt(\"1500000000\");\n maxPriorityFeePerGas = gasPrice ? gasPrice - block.baseFeePerGas : null;\n if (\n maxPriorityFeePerGas == null ||\n maxPriorityFeePerGas - BigInt(0) ||\n maxPriorityFeePerGas > minimumTip\n ) {\n maxPriorityFeePerGas = minimumTip;\n }\n maxPriorityFeePerGas =\n maxPriorityFeePerGas < provider.minPriorityFeePerBid\n ? provider.minPriorityFeePerBid\n : maxPriorityFeePerGas;\n maxFeePerGas =\n block.baseFeePerGas * BigInt(2) + (maxPriorityFeePerGas ?? 0);\n }\n\n return { maxFeePerGas, maxPriorityFeePerGas };\n};\n"]}
1
+ {"version":3,"file":"gas-estimator.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/middleware/gas-estimator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EAGX,iBAAiB,GAGlB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAqC,MAAM,uBAAuB,CAAC;AAE1E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,QAAyB,EACR,EAAE;IACnB,QAAQ,CAAC,iBAAiB,CAAC,KA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ACxB,IAAI,oBAAoB,GAAG,IAAI,CAAC;IAEhC,IAAI,KAAK,IAAI,KAAK,CAAC,aAAa,IAAI,IAAI,EAAE;QAExC,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QACxC,oBAAoB,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;QACxE,IACE,oBAAoB,IAAI,IAAI;YAC5B,oBAAoB,GAAG,MAAM,CAAC,CAAC,CAAC;YAChC,oBAAoB,GAAG,UAAU,EACjC;YACA,oBAAoB,GAAG,UAAU,CAAC;SACnC;QACD,oBAAoB;YAClB,oBAAoB,GAAG,QAAQ,CAAC,oBAAoB;gBAClD,CAAC,CAAC,QAAQ,CAAC,oBAAoB;gBAC/B,CAAC,CAAC,oBAAoB,CAAC;QAC3B,YAAY;YACV,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,oBAAoB,IAAI,CAAC,CAAC,CAAC;KACjE;IAED,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import type { ZeroDevProvider } from \"../provider.js\";\nimport {\n deepHexlify,\n type Hex,\n type UserOperationStruct,\n resolveProperties,\n type BigNumberish,\n type UserOperationEstimateGasResponse,\n} from \"@alchemy/aa-core\";\nimport { ENTRYPOINT_ADDRESS } from \"../constants.js\";\nimport { calcPreVerificationGas } from \"../utils/calc-pre-verification-gas.js\";\nimport { type PaymasterAndBundlerProviders } from \"../paymaster/types.js\";\n\nexport const withZeroDevGasEstimator = (\n provider: ZeroDevProvider\n): ZeroDevProvider => {\n provider.withFeeDataGetter(async (struct) => {\n let overrides = await resolveProperties({\n maxFeePerGas: struct.maxFeePerGas ?? 0n,\n maxPriorityFeePerGas: struct.maxPriorityFeePerGas ?? 0n,\n });\n\n let maxFeePerGas, maxPriorityFeePerGas;\n\n try {\n ({ maxFeePerGas, maxPriorityFeePerGas } = await eip1559GasPrice(\n provider\n ));\n } catch (error: any) {\n console.warn(\n \"getGas: eth_maxPriorityFeePerGas failed, falling back to legacy gas price.\"\n );\n }\n\n if (maxFeePerGas === undefined || maxPriorityFeePerGas === undefined) {\n const feeData = await getFeeData(provider);\n maxFeePerGas = feeData?.maxFeePerGas ? BigInt(feeData?.maxFeePerGas) : 0n;\n maxPriorityFeePerGas = feeData.maxPriorityFeePerGas\n ? BigInt(feeData.maxPriorityFeePerGas)\n : 0n;\n }\n\n if (\n maxFeePerGas < BigInt(overrides.maxFeePerGas) ||\n maxPriorityFeePerGas < BigInt(overrides.maxPriorityFeePerGas)\n ) {\n return overrides;\n }\n return { maxFeePerGas, maxPriorityFeePerGas };\n });\n\n provider.withGasEstimator(async (struct) => {\n if (\n struct.callGasLimit !== undefined &&\n struct.verificationGasLimit !== undefined &&\n struct.preVerificationGas !== undefined\n ) {\n return struct;\n }\n const initCode = await provider.account?.getInitCode();\n const initGas = await estimateCreationGas(provider, initCode);\n const partialStruct: UserOperationStruct = {\n ...struct,\n callGasLimit:\n initCode !== undefined && initCode.length > 2\n ? BigInt(\"1000000\")\n : BigInt(55000),\n verificationGasLimit: BigInt(110000) + initGas,\n preVerificationGas: BigInt(100000),\n };\n\n partialStruct.preVerificationGas = await getPreVerificationGas(\n partialStruct\n );\n\n const request = deepHexlify(await resolveProperties(partialStruct));\n let userOpGasEstimates: UserOperationEstimateGasResponse | undefined;\n userOpGasEstimates = await provider.rpcClient.estimateUserOperationGas(\n request,\n ENTRYPOINT_ADDRESS\n );\n const { preVerificationGas, verificationGasLimit, callGasLimit } =\n userOpGasEstimates;\n request.preVerificationGas =\n (BigInt(preVerificationGas) * 12n) / 10n ?? request.preVerificationGas;\n request.verificationGasLimit =\n BigInt(verificationGasLimit) ?? request.verificationGasLimit;\n request.callGasLimit =\n (BigInt(callGasLimit) * 12n) / 10n ?? request.callGasLimit;\n\n return {\n ...struct,\n ...request,\n };\n });\n\n return provider;\n};\n\nexport const estimateCreationGas = async (\n provider: ZeroDevProvider,\n initCode?: string\n): Promise<bigint> => {\n if (initCode == null || initCode === \"0x\") return BigInt(0);\n const deployerAddress = initCode.substring(0, 42) as Hex;\n const deployerCallData = (\"0x\" + initCode.substring(42)) as Hex;\n return await provider.rpcClient.estimateGas({\n account: ENTRYPOINT_ADDRESS,\n to: deployerAddress,\n data: deployerCallData,\n });\n};\n\n/**\n * should cover cost of putting calldata on-chain, and some overhead.\n * actual overhead depends on the expected bundle size\n */\nexport const getPreVerificationGas = async (\n userOp: Partial<UserOperationStruct>\n): Promise<number> => {\n const p = await resolveProperties(userOp);\n return calcPreVerificationGas(p);\n};\n\nexport const GAS_PRICE_RPC_METHODS_BY_BUNDLER: {\n [K in PaymasterAndBundlerProviders]: string;\n} = {\n STACKUP: \"eth_maxPriorityFeePerGas\",\n ALCHEMY: \"rundler_maxPriorityFeePerGas\",\n PIMLICO: \"pimlico_getUserOperationGasPrice\",\n};\n\nexport const eip1559GasPrice = async (provider: ZeroDevProvider) => {\n let [fee, block] = await Promise.all([\n provider.rpcClient.request({\n method:\n // @ts-expect-error\n GAS_PRICE_RPC_METHODS_BY_BUNDLER[provider.bundlerProvider] ??\n \"eth_maxPriorityFeePerGas\",\n params: [],\n }) as any,\n provider.rpcClient.getBlock({ blockTag: \"latest\" }),\n ]);\n\n if (provider.bundlerProvider === \"PIMLICO\") {\n fee = fee.standard.maxPriorityFeePerGas;\n }\n\n const tip = BigInt(fee);\n const buffer = (tip / 100n) * 13n;\n let maxPriorityFeePerGas = tip + buffer;\n maxPriorityFeePerGas =\n maxPriorityFeePerGas < provider.minPriorityFeePerBid\n ? provider.minPriorityFeePerBid\n : maxPriorityFeePerGas;\n const maxFeePerGas = block.baseFeePerGas\n ? BigInt(block.baseFeePerGas) * 2n + maxPriorityFeePerGas\n : maxPriorityFeePerGas;\n\n return { maxFeePerGas, maxPriorityFeePerGas };\n};\ninterface FeeData {\n maxFeePerGas: BigNumberish | null;\n maxPriorityFeePerGas: BigNumberish | null;\n}\n\nexport const getFeeData = async (\n provider: ZeroDevProvider\n): Promise<FeeData> => {\n const { block, gasPrice } = await resolveProperties({\n block: provider.rpcClient.getBlock({ blockTag: \"latest\" }),\n gasPrice: provider.rpcClient.getGasPrice().catch((error) => {\n console.warn(\"Legacy: Failed to get gas price\", error);\n return null;\n }),\n });\n\n let maxFeePerGas = null;\n let maxPriorityFeePerGas = null;\n\n if (block && block.baseFeePerGas != null) {\n // Set the tip to the min of the tip for the last block and 1.5 gwei\n const minimumTip = BigInt(\"1500000000\");\n maxPriorityFeePerGas = gasPrice ? gasPrice - block.baseFeePerGas : null;\n if (\n maxPriorityFeePerGas == null ||\n maxPriorityFeePerGas - BigInt(0) ||\n maxPriorityFeePerGas > minimumTip\n ) {\n maxPriorityFeePerGas = minimumTip;\n }\n maxPriorityFeePerGas =\n maxPriorityFeePerGas < provider.minPriorityFeePerBid\n ? provider.minPriorityFeePerBid\n : maxPriorityFeePerGas;\n maxFeePerGas =\n block.baseFeePerGas * BigInt(2) + (maxPriorityFeePerGas ?? 0);\n }\n\n return { maxFeePerGas, maxPriorityFeePerGas };\n};\n"]}
@@ -35,7 +35,7 @@ export declare abstract class KernelBaseValidator {
35
35
  constructor(params: KernelBaseValidatorParams);
36
36
  abstract encodeEnable(enableData: Hex): Hex;
37
37
  abstract encodeDisable(enableData: Hex): Hex;
38
- abstract getEnableData(): Promise<Hex>;
38
+ abstract getEnableData(kernelAccountAddress?: Address): Promise<Hex>;
39
39
  abstract signMessage(message: Uint8Array | string | Hex): Promise<Hex>;
40
40
  abstract signTypedData(params: SignTypedDataParams): Promise<Hex>;
41
41
  abstract signUserOp(userOp: UserOperationRequest): Promise<Hex>;
@@ -120,7 +120,7 @@ export class KernelBaseValidator {
120
120
  const dummyECDSASig = "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
121
121
  const validatorMode = await this.resolveValidatorMode(kernelAccountAddress, calldata);
122
122
  if (validatorMode === ValidatorMode.enable) {
123
- const enableData = await this.getEnableData();
123
+ const enableData = await this.getEnableData(kernelAccountAddress);
124
124
  const enableDataLength = enableData.length / 2 - 1;
125
125
  const enableSigLength = 65;
126
126
  const staticDummySig = concatHex([
@@ -204,7 +204,7 @@ export class KernelBaseValidator {
204
204
  validator.getAddress(),
205
205
  ]), { size: 32 }),
206
206
  executor: executor,
207
- enableData: await validator.getEnableData(),
207
+ enableData: await validator.getEnableData(kernel),
208
208
  },
209
209
  primaryType: "ValidatorApproved",
210
210
  });
@@ -249,7 +249,7 @@ export class KernelBaseValidator {
249
249
  return concatHex([this.mode, await this.signUserOp(userOp)]);
250
250
  }
251
251
  else {
252
- const enableData = await this.getEnableData();
252
+ const enableData = await this.getEnableData(userOp.sender);
253
253
  const enableDataLength = enableData.length / 2 - 1;
254
254
  const enableSignature = this.getEnableSignature();
255
255
  if (!enableSignature) {