@safe-global/relay-kit 2.0.3 → 2.1.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 (51) hide show
  1. package/dist/src/RelayKitBasePack.d.ts +51 -20
  2. package/dist/src/RelayKitBasePack.js +13 -2
  3. package/dist/src/RelayKitBasePack.js.map +1 -1
  4. package/dist/src/index.d.ts +3 -1
  5. package/dist/src/index.js +3 -1
  6. package/dist/src/index.js.map +1 -1
  7. package/dist/src/packs/gelato/GelatoRelayPack.d.ts +46 -9
  8. package/dist/src/packs/gelato/GelatoRelayPack.js +49 -10
  9. package/dist/src/packs/gelato/GelatoRelayPack.js.map +1 -1
  10. package/dist/src/packs/gelato/GelatoRelayPack.test.js +26 -20
  11. package/dist/src/packs/gelato/GelatoRelayPack.test.js.map +1 -1
  12. package/dist/src/packs/gelato/types.d.ts +18 -0
  13. package/dist/src/packs/safe-4337/Safe4337Pack.d.ts +99 -0
  14. package/dist/src/packs/safe-4337/Safe4337Pack.js +499 -0
  15. package/dist/src/packs/safe-4337/Safe4337Pack.js.map +1 -0
  16. package/dist/src/packs/safe-4337/Safe4337Pack.test.d.ts +1 -0
  17. package/dist/src/packs/safe-4337/Safe4337Pack.test.js +542 -0
  18. package/dist/src/packs/safe-4337/Safe4337Pack.test.js.map +1 -0
  19. package/dist/src/packs/safe-4337/SafeOperation.d.ts +18 -0
  20. package/dist/src/packs/safe-4337/SafeOperation.js +62 -0
  21. package/dist/src/packs/safe-4337/SafeOperation.js.map +1 -0
  22. package/dist/src/packs/safe-4337/SafeOperation.test.d.ts +1 -0
  23. package/dist/src/packs/safe-4337/SafeOperation.test.js +124 -0
  24. package/dist/src/packs/safe-4337/SafeOperation.test.js.map +1 -0
  25. package/dist/src/packs/safe-4337/constants.d.ts +19 -0
  26. package/dist/src/packs/safe-4337/constants.js +39 -0
  27. package/dist/src/packs/safe-4337/constants.js.map +1 -0
  28. package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.d.ts +7 -0
  29. package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.js +41 -0
  30. package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.js.map +1 -0
  31. package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.test.d.ts +1 -0
  32. package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.test.js +75 -0
  33. package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.test.js.map +1 -0
  34. package/dist/src/packs/safe-4337/estimators/index.d.ts +2 -0
  35. package/dist/src/packs/safe-4337/estimators/index.js +6 -0
  36. package/dist/src/packs/safe-4337/estimators/index.js.map +1 -0
  37. package/dist/src/packs/safe-4337/testing-utils/fixtures.d.ts +100 -0
  38. package/dist/src/packs/safe-4337/testing-utils/fixtures.js +90 -0
  39. package/dist/src/packs/safe-4337/testing-utils/fixtures.js.map +1 -0
  40. package/dist/src/packs/safe-4337/testing-utils/helpers.d.ts +4 -0
  41. package/dist/src/packs/safe-4337/testing-utils/helpers.js +56 -0
  42. package/dist/src/packs/safe-4337/testing-utils/helpers.js.map +1 -0
  43. package/dist/src/packs/safe-4337/types.d.ts +158 -0
  44. package/dist/src/{types.js.map → packs/safe-4337/types.js.map} +1 -1
  45. package/dist/src/packs/safe-4337/utils.d.ts +35 -0
  46. package/dist/src/packs/safe-4337/utils.js +50 -0
  47. package/dist/src/packs/safe-4337/utils.js.map +1 -0
  48. package/dist/tsconfig.build.tsbuildinfo +1 -1
  49. package/package.json +5 -3
  50. package/dist/src/types.d.ts +0 -9
  51. /package/dist/src/{types.js → packs/safe-4337/types.js} +0 -0
@@ -0,0 +1,158 @@
1
+ import Safe, { EthersAdapter } from '@safe-global/protocol-kit';
2
+ import { MetaTransactionData, SafeVersion } from '@safe-global/safe-core-sdk-types';
3
+ import { ethers } from 'ethers';
4
+ import SafeOperation from './SafeOperation';
5
+ type ExistingSafeOptions = {
6
+ safeAddress: string;
7
+ };
8
+ type PredictedSafeOptions = {
9
+ owners: string[];
10
+ threshold: number;
11
+ safeVersion?: SafeVersion;
12
+ saltNonce?: string;
13
+ };
14
+ export type PaymasterOptions = {
15
+ paymasterUrl?: string;
16
+ isSponsored?: boolean;
17
+ sponsorshipPolicyId?: string;
18
+ paymasterAddress: string;
19
+ paymasterTokenAddress?: string;
20
+ amountToApprove?: bigint;
21
+ };
22
+ export type Safe4337InitOptions = {
23
+ ethersAdapter: EthersAdapter;
24
+ bundlerUrl: string;
25
+ rpcUrl: string;
26
+ safeModulesVersion?: string;
27
+ customContracts?: {
28
+ entryPointAddress?: string;
29
+ safe4337ModuleAddress?: string;
30
+ addModulesLibAddress?: string;
31
+ };
32
+ options: ExistingSafeOptions | PredictedSafeOptions;
33
+ paymasterOptions?: PaymasterOptions;
34
+ };
35
+ export type Safe4337Options = {
36
+ protocolKit: Safe;
37
+ bundlerUrl: string;
38
+ paymasterOptions?: PaymasterOptions;
39
+ bundlerClient: ethers.JsonRpcProvider;
40
+ publicClient: ethers.JsonRpcProvider;
41
+ entryPointAddress: string;
42
+ safe4337ModuleAddress: string;
43
+ };
44
+ export type Safe4337CreateTransactionProps = {
45
+ transactions: MetaTransactionData[];
46
+ options?: {
47
+ amountToApprove?: bigint;
48
+ validUntil?: number;
49
+ validAfter?: number;
50
+ feeEstimator?: IFeeEstimator;
51
+ };
52
+ };
53
+ export type Safe4337ExecutableProps = {
54
+ executable: SafeOperation;
55
+ };
56
+ export type SafeUserOperation = {
57
+ safe: string;
58
+ nonce: bigint;
59
+ initCode: string;
60
+ callData: string;
61
+ callGasLimit: bigint;
62
+ verificationGasLimit: bigint;
63
+ preVerificationGas: bigint;
64
+ maxFeePerGas: bigint;
65
+ maxPriorityFeePerGas: bigint;
66
+ paymasterAndData: string;
67
+ validAfter: number;
68
+ validUntil: number;
69
+ entryPoint: string;
70
+ };
71
+ export type UserOperation = {
72
+ sender: string;
73
+ nonce: string;
74
+ initCode: string;
75
+ callData: string;
76
+ callGasLimit: bigint;
77
+ verificationGasLimit: bigint;
78
+ preVerificationGas: bigint;
79
+ maxFeePerGas: bigint;
80
+ maxPriorityFeePerGas: bigint;
81
+ paymasterAndData: string;
82
+ signature: string;
83
+ };
84
+ export type EstimateGasData = {
85
+ maxFeePerGas?: bigint;
86
+ maxPriorityFeePerGas?: bigint;
87
+ preVerificationGas?: bigint;
88
+ verificationGasLimit?: bigint;
89
+ callGasLimit?: bigint;
90
+ };
91
+ export type EstimateSponsoredGasData = {
92
+ paymasterAndData: string;
93
+ } & EstimateGasData;
94
+ type Log = {
95
+ logIndex: string;
96
+ transactionIndex: string;
97
+ transactionHash: string;
98
+ blockHash: string;
99
+ blockNumber: string;
100
+ address: string;
101
+ data: string;
102
+ topics: string[];
103
+ };
104
+ type Receipt = {
105
+ transactionHash: string;
106
+ transactionIndex: string;
107
+ blockHash: string;
108
+ blockNumber: string;
109
+ from: string;
110
+ to: string;
111
+ cumulativeGasUsed: string;
112
+ gasUsed: string;
113
+ contractAddress: null;
114
+ logs: Log[];
115
+ logsBloom: string;
116
+ status: string;
117
+ effectiveGasPrice: string;
118
+ };
119
+ export type UserOperationReceipt = {
120
+ userOpHash: string;
121
+ sender: string;
122
+ nonce: string;
123
+ actualGasUsed: string;
124
+ actualGasCost: string;
125
+ success: boolean;
126
+ logs: Log[];
127
+ receipt: Receipt;
128
+ };
129
+ export type UserOperationWithPayload = {
130
+ userOperation: UserOperation;
131
+ entryPoint: string;
132
+ transactionHash: string;
133
+ blockHash: string;
134
+ blockNumber: string;
135
+ };
136
+ export type EstimateFeeFunctionProps = {
137
+ userOperation: UserOperation;
138
+ bundlerUrl: string;
139
+ entryPoint: string;
140
+ };
141
+ export type EstimateFeeFunction = ({ userOperation, bundlerUrl, entryPoint }: EstimateFeeFunctionProps) => Promise<EstimateGasData>;
142
+ export type EstimateSponsoredFeeFunctionProps = {
143
+ userOperation: UserOperation;
144
+ paymasterUrl: string;
145
+ entryPoint: string;
146
+ sponsorshipPolicyId?: string;
147
+ };
148
+ export type EstimateSponsoredFeeFunction = ({ userOperation, paymasterUrl, entryPoint }: EstimateSponsoredFeeFunctionProps) => Promise<EstimateSponsoredGasData>;
149
+ export interface IFeeEstimator {
150
+ setupEstimation?: EstimateFeeFunction;
151
+ adjustEstimation?: EstimateFeeFunction;
152
+ getPaymasterEstimation?: EstimateSponsoredFeeFunction;
153
+ }
154
+ export type EstimateFeeProps = {
155
+ safeOperation: SafeOperation;
156
+ feeEstimator?: IFeeEstimator;
157
+ };
158
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/packs/safe-4337/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { ethers } from 'ethers';
2
+ import { UserOperation } from './types';
3
+ /**
4
+ * Gets the EIP-4337 bundler provider.
5
+ *
6
+ * @param {string} bundlerUrl The EIP-4337 bundler URL.
7
+ * @return {Provider} The EIP-4337 bundler provider.
8
+ */
9
+ export declare function getEip4337BundlerProvider(bundlerUrl: string): ethers.JsonRpcProvider;
10
+ /**
11
+ * Gets the EIP-1193 provider from the bundler url.
12
+ *
13
+ * @param {string} rpcUrl The RPC URL.
14
+ * @return {Provider} The EIP-1193 provider.
15
+ */
16
+ export declare function getEip1193Provider(rpcUrl: string): ethers.JsonRpcProvider;
17
+ /**
18
+ * Converts various bigint values from a UserOperation to their hexadecimal representation.
19
+ *
20
+ * @param {UserOperation} userOperation - The UserOperation object whose values are to be converted.
21
+ * @returns {UserOperation} A new UserOperation object with the values converted to hexadecimal.
22
+ */
23
+ export declare function userOperationToHexValues(userOperation: UserOperation): {
24
+ nonce: string;
25
+ callGasLimit: string;
26
+ verificationGasLimit: string;
27
+ preVerificationGas: string;
28
+ maxFeePerGas: string;
29
+ maxPriorityFeePerGas: string;
30
+ sender: string;
31
+ initCode: string;
32
+ callData: string;
33
+ paymasterAndData: string;
34
+ signature: string;
35
+ };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.userOperationToHexValues = exports.getEip1193Provider = exports.getEip4337BundlerProvider = void 0;
4
+ const ethers_1 = require("ethers");
5
+ /**
6
+ * Gets the EIP-4337 bundler provider.
7
+ *
8
+ * @param {string} bundlerUrl The EIP-4337 bundler URL.
9
+ * @return {Provider} The EIP-4337 bundler provider.
10
+ */
11
+ function getEip4337BundlerProvider(bundlerUrl) {
12
+ const provider = new ethers_1.ethers.JsonRpcProvider(bundlerUrl, undefined, {
13
+ batchMaxCount: 1
14
+ });
15
+ return provider;
16
+ }
17
+ exports.getEip4337BundlerProvider = getEip4337BundlerProvider;
18
+ /**
19
+ * Gets the EIP-1193 provider from the bundler url.
20
+ *
21
+ * @param {string} rpcUrl The RPC URL.
22
+ * @return {Provider} The EIP-1193 provider.
23
+ */
24
+ function getEip1193Provider(rpcUrl) {
25
+ const provider = new ethers_1.ethers.JsonRpcProvider(rpcUrl, undefined, {
26
+ batchMaxCount: 1
27
+ });
28
+ return provider;
29
+ }
30
+ exports.getEip1193Provider = getEip1193Provider;
31
+ /**
32
+ * Converts various bigint values from a UserOperation to their hexadecimal representation.
33
+ *
34
+ * @param {UserOperation} userOperation - The UserOperation object whose values are to be converted.
35
+ * @returns {UserOperation} A new UserOperation object with the values converted to hexadecimal.
36
+ */
37
+ function userOperationToHexValues(userOperation) {
38
+ const userOperationWithHexValues = {
39
+ ...userOperation,
40
+ nonce: ethers_1.ethers.toBeHex(userOperation.nonce),
41
+ callGasLimit: ethers_1.ethers.toBeHex(userOperation.callGasLimit),
42
+ verificationGasLimit: ethers_1.ethers.toBeHex(userOperation.verificationGasLimit),
43
+ preVerificationGas: ethers_1.ethers.toBeHex(userOperation.preVerificationGas),
44
+ maxFeePerGas: ethers_1.ethers.toBeHex(userOperation.maxFeePerGas),
45
+ maxPriorityFeePerGas: ethers_1.ethers.toBeHex(userOperation.maxPriorityFeePerGas)
46
+ };
47
+ return userOperationWithHexValues;
48
+ }
49
+ exports.userOperationToHexValues = userOperationToHexValues;
50
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/packs/safe-4337/utils.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAG/B;;;;;GAKG;AACH,SAAgB,yBAAyB,CAAC,UAAkB;IAC1D,MAAM,QAAQ,GAAG,IAAI,eAAM,CAAC,eAAe,CAAC,UAAU,EAAE,SAAS,EAAE;QACjE,aAAa,EAAE,CAAC;KACjB,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAA;AACjB,CAAC;AAND,8DAMC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,MAAM,QAAQ,GAAG,IAAI,eAAM,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE;QAC7D,aAAa,EAAE,CAAC;KACjB,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAA;AACjB,CAAC;AAND,gDAMC;AAED;;;;;GAKG;AACH,SAAgB,wBAAwB,CAAC,aAA4B;IACnE,MAAM,0BAA0B,GAAG;QACjC,GAAG,aAAa;QAChB,KAAK,EAAE,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC;QAC1C,YAAY,EAAE,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC;QACxD,oBAAoB,EAAE,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,oBAAoB,CAAC;QACxE,kBAAkB,EAAE,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC;QACpE,YAAY,EAAE,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC;QACxD,oBAAoB,EAAE,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,oBAAoB,CAAC;KACzE,CAAA;IAED,OAAO,0BAA0B,CAAA;AACnC,CAAC;AAZD,4DAYC"}