@safe-global/relay-kit 2.0.2 → 2.1.0-alpha.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.
- package/dist/src/RelayKitBasePack.d.ts +51 -20
- package/dist/src/RelayKitBasePack.js +13 -2
- package/dist/src/RelayKitBasePack.js.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/packs/gelato/GelatoRelayPack.d.ts +46 -9
- package/dist/src/packs/gelato/GelatoRelayPack.js +49 -10
- package/dist/src/packs/gelato/GelatoRelayPack.js.map +1 -1
- package/dist/src/packs/gelato/GelatoRelayPack.test.js +26 -20
- package/dist/src/packs/gelato/GelatoRelayPack.test.js.map +1 -1
- package/dist/src/packs/gelato/types.d.ts +18 -0
- package/dist/src/packs/safe-4337/Safe4337Pack.d.ts +106 -0
- package/dist/src/packs/safe-4337/Safe4337Pack.js +501 -0
- package/dist/src/packs/safe-4337/Safe4337Pack.js.map +1 -0
- package/dist/src/packs/safe-4337/SafeOperation.d.ts +18 -0
- package/dist/src/packs/safe-4337/SafeOperation.js +62 -0
- package/dist/src/packs/safe-4337/SafeOperation.js.map +1 -0
- package/dist/src/packs/safe-4337/constants.d.ts +17 -0
- package/dist/src/packs/safe-4337/constants.js +37 -0
- package/dist/src/packs/safe-4337/constants.js.map +1 -0
- package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.d.ts +7 -0
- package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.js +46 -0
- package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.js.map +1 -0
- package/dist/src/packs/safe-4337/estimators/index.d.ts +2 -0
- package/dist/src/packs/safe-4337/estimators/index.js +6 -0
- package/dist/src/packs/safe-4337/estimators/index.js.map +1 -0
- package/dist/src/packs/safe-4337/types.d.ts +158 -0
- package/dist/src/{types.js.map → packs/safe-4337/types.js.map} +1 -1
- package/dist/src/packs/safe-4337/utils.d.ts +35 -0
- package/dist/src/packs/safe-4337/utils.js +50 -0
- package/dist/src/packs/safe-4337/utils.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/dist/src/types.d.ts +0 -9
- /package/dist/src/{types.js → packs/safe-4337/types.js} +0 -0
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import Safe from '@safe-global/protocol-kit';
|
|
2
|
+
import { MetaTransactionData, MetaTransactionOptions, SafeTransaction } from '@safe-global/safe-core-sdk-types';
|
|
2
3
|
export type GelatoOptions = {
|
|
3
4
|
apiKey?: string;
|
|
4
5
|
protocolKit: Safe;
|
|
5
6
|
};
|
|
7
|
+
export type GelatoEstimateFeeProps = {
|
|
8
|
+
chainId: bigint;
|
|
9
|
+
gasLimit: string;
|
|
10
|
+
gasToken?: string;
|
|
11
|
+
};
|
|
12
|
+
export type GelatoEstimateFeeResult = string;
|
|
13
|
+
export type GelatoCreateTransactionProps = {
|
|
14
|
+
transactions: MetaTransactionData[];
|
|
15
|
+
/** options - The transaction array optional properties */
|
|
16
|
+
options?: MetaTransactionOptions;
|
|
17
|
+
/** onlyCalls - Forces the execution of the transaction array with MultiSendCallOnly contract */
|
|
18
|
+
onlyCalls?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type GelatoExecuteTransactionProps = {
|
|
21
|
+
executable: SafeTransaction;
|
|
22
|
+
options?: MetaTransactionOptions;
|
|
23
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { SigningMethod } from '@safe-global/protocol-kit';
|
|
2
|
+
import { RelayKitBasePack } from '../../RelayKitBasePack';
|
|
3
|
+
import SafeOperation from './SafeOperation';
|
|
4
|
+
import { EstimateFeeProps, Safe4337CreateTransactionProps, Safe4337ExecutableProps, Safe4337InitOptions, Safe4337Options, UserOperation, UserOperationReceipt, UserOperationWithPayload } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Safe4337Pack class that extends RelayKitBasePack.
|
|
7
|
+
* This class provides an implementation of the ERC-4337 that enables Safe accounts to wrk with UserOperations.
|
|
8
|
+
* It allows to create, sign and execute transactions using the Safe 4337 Module.
|
|
9
|
+
*
|
|
10
|
+
* @class
|
|
11
|
+
* @link https://github.com/safe-global/safe-modules/blob/main/modules/4337/contracts/Safe4337Module.sol
|
|
12
|
+
* @link https://eips.ethereum.org/EIPS/eip-4337
|
|
13
|
+
*/
|
|
14
|
+
export declare class Safe4337Pack extends RelayKitBasePack<{
|
|
15
|
+
EstimateFeeProps: EstimateFeeProps;
|
|
16
|
+
EstimateFeeResult: SafeOperation;
|
|
17
|
+
CreateTransactionProps: Safe4337CreateTransactionProps;
|
|
18
|
+
CreateTransactionResult: SafeOperation;
|
|
19
|
+
ExecuteTransactionProps: Safe4337ExecutableProps;
|
|
20
|
+
ExecuteTransactionResult: string;
|
|
21
|
+
}> {
|
|
22
|
+
#private;
|
|
23
|
+
/**
|
|
24
|
+
* Creates an instance of the Safe4337Pack.
|
|
25
|
+
*
|
|
26
|
+
* @param {Safe4337Options} options - The initialization parameters.
|
|
27
|
+
*/
|
|
28
|
+
constructor({ protocolKit, bundlerClient, publicClient, bundlerUrl, paymasterOptions, entryPointAddress, safe4337ModuleAddress }: Safe4337Options);
|
|
29
|
+
/**
|
|
30
|
+
* Initializes a Safe4337Pack class.
|
|
31
|
+
* This method creates the protocolKit instance based on the input parameters.
|
|
32
|
+
* When the Safe address is provided, it will use the existing Safe.
|
|
33
|
+
* When the Safe address is not provided, it will use the predictedSafe feature with the provided owners and threshold.
|
|
34
|
+
* It will use the correct contract addresses for the fallbackHandler and the module and will add the data to enable the 4337 module.
|
|
35
|
+
*
|
|
36
|
+
* @param {Safe4337InitOptions} initOptions - The initialization parameters.
|
|
37
|
+
* @return {Promise<Safe4337Pack>} The Promise object that will be resolved into an instance of Safe4337Pack.
|
|
38
|
+
*/
|
|
39
|
+
static init(initOptions: Safe4337InitOptions): Promise<Safe4337Pack>;
|
|
40
|
+
/**
|
|
41
|
+
* Estimates gas for the SafeOperation.
|
|
42
|
+
*
|
|
43
|
+
* @param {EstimateFeeProps} props - The parameters for the gas estimation.
|
|
44
|
+
* @param {SafeOperation} props.safeOperation - The SafeOperation to estimate the gas.
|
|
45
|
+
* @param {IFeeEstimator} props.feeEstimator - The function to estimate the gas.
|
|
46
|
+
* @return {Promise<SafeOperation>} The Promise object that will be resolved into the gas estimation.
|
|
47
|
+
*/
|
|
48
|
+
getEstimateFee({ safeOperation, feeEstimator }: EstimateFeeProps): Promise<SafeOperation>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a relayed transaction based on the provided parameters.
|
|
51
|
+
*
|
|
52
|
+
* @param {MetaTransactionData[]} transactions - The transactions to batch in a SafeOperation.
|
|
53
|
+
* @param options - Optional configuration options for the transaction creation.
|
|
54
|
+
* @return {Promise<SafeOperation>} The Promise object will resolve a SafeOperation.
|
|
55
|
+
*/
|
|
56
|
+
createTransaction({ transactions, options }: Safe4337CreateTransactionProps): Promise<SafeOperation>;
|
|
57
|
+
/**
|
|
58
|
+
* Signs a safe operation.
|
|
59
|
+
*
|
|
60
|
+
* @param {SafeOperation} safeOperation - The SafeOperation to sign.
|
|
61
|
+
* @param {SigningMethod} signingMethod - The signing method to use.
|
|
62
|
+
* @return {Promise<SafeOperation>} The Promise object will resolve to the signed SafeOperation.
|
|
63
|
+
*/
|
|
64
|
+
signSafeOperation(safeOperation: SafeOperation, signingMethod?: SigningMethod): Promise<SafeOperation>;
|
|
65
|
+
/**
|
|
66
|
+
* Executes the relay transaction.
|
|
67
|
+
*
|
|
68
|
+
* @param {SafeOperation} safeOperation - The SafeOperation to execute.
|
|
69
|
+
* @return {Promise<string>} The user operation hash.
|
|
70
|
+
*/
|
|
71
|
+
executeTransaction({ executable: safeOperation }: Safe4337ExecutableProps): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Return a UserOperation based on a hash (userOpHash) returned by eth_sendUserOperation
|
|
74
|
+
*
|
|
75
|
+
* @param {string} userOpHash - The hash of the user operation to fetch. Returned from the sendUserOperation method
|
|
76
|
+
* @returns {UserOperation} - null in case the UserOperation is not yet included in a block, or a full UserOperation, with the addition of entryPoint, blockNumber, blockHash and transactionHash
|
|
77
|
+
*/
|
|
78
|
+
getUserOperationByHash(userOpHash: string): Promise<UserOperationWithPayload>;
|
|
79
|
+
/**
|
|
80
|
+
* Return a UserOperation receipt based on a hash (userOpHash) returned by eth_sendUserOperation
|
|
81
|
+
*
|
|
82
|
+
* @param {string} userOpHash - The hash of the user operation to fetch. Returned from the sendUserOperation method
|
|
83
|
+
* @returns {UserOperationReceipt} - null in case the UserOperation is not yet included in a block, or UserOperationReceipt object
|
|
84
|
+
*/
|
|
85
|
+
getUserOperationReceipt(userOpHash: string): Promise<UserOperationReceipt | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Returns an array of the entryPoint addresses supported by the client.
|
|
88
|
+
* The first element of the array SHOULD be the entryPoint addressed preferred by the client.
|
|
89
|
+
*
|
|
90
|
+
* @returns {string[]} - The supported entry points.
|
|
91
|
+
*/
|
|
92
|
+
getSupportedEntryPoints(): Promise<string[]>;
|
|
93
|
+
/**
|
|
94
|
+
* Returns EIP-155 Chain ID.
|
|
95
|
+
*
|
|
96
|
+
* @returns {string} - The chain id.
|
|
97
|
+
*/
|
|
98
|
+
getChainId(): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Send the UserOperation to the bundler.
|
|
101
|
+
*
|
|
102
|
+
* @param {UserOperation} userOpWithSignature - The signed UserOperation to send to the bundler.
|
|
103
|
+
* @return {Promise<string>} The hash.
|
|
104
|
+
*/
|
|
105
|
+
sendUserOperation(userOpWithSignature: UserOperation): Promise<string>;
|
|
106
|
+
}
|
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
26
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
27
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
28
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
29
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
30
|
+
};
|
|
31
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
32
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
33
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
var _Safe4337Pack_instances, _Safe4337Pack_BUNDLER_URL, _Safe4337Pack_ENTRYPOINT_ADDRESS, _Safe4337Pack_SAFE_4337_MODULE_ADDRESS, _Safe4337Pack_bundlerClient, _Safe4337Pack_publicClient, _Safe4337Pack_paymasterOptions, _Safe4337Pack_getSafeUserOperationHash, _Safe4337Pack_signTypedData, _Safe4337Pack_getAccountNonce, _Safe4337Pack_encodeExecuteUserOpCallData, _Safe4337Pack_encodeMultiSendCallData;
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.Safe4337Pack = void 0;
|
|
42
|
+
const ethers_1 = require("ethers");
|
|
43
|
+
const satisfies_1 = __importDefault(require("semver/functions/satisfies"));
|
|
44
|
+
const protocol_kit_1 = __importStar(require("@safe-global/protocol-kit"));
|
|
45
|
+
const RelayKitBasePack_1 = require("../../RelayKitBasePack");
|
|
46
|
+
const safe_core_sdk_types_1 = require("@safe-global/safe-core-sdk-types");
|
|
47
|
+
const safe_modules_deployments_1 = require("@safe-global/safe-modules-deployments");
|
|
48
|
+
const SafeOperation_1 = __importDefault(require("./SafeOperation"));
|
|
49
|
+
const constants_1 = require("./constants");
|
|
50
|
+
const utils_1 = require("./utils");
|
|
51
|
+
const PimlicoFeeEstimator_1 = require("./estimators/PimlicoFeeEstimator");
|
|
52
|
+
const DEFAULT_SAFE_VERSION = '1.4.1';
|
|
53
|
+
const DEFAULT_SAFE_MODULES_VERSION = '0.2.0';
|
|
54
|
+
const MAX_ERC20_AMOUNT_TO_APPROVE = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn;
|
|
55
|
+
/**
|
|
56
|
+
* Safe4337Pack class that extends RelayKitBasePack.
|
|
57
|
+
* This class provides an implementation of the ERC-4337 that enables Safe accounts to wrk with UserOperations.
|
|
58
|
+
* It allows to create, sign and execute transactions using the Safe 4337 Module.
|
|
59
|
+
*
|
|
60
|
+
* @class
|
|
61
|
+
* @link https://github.com/safe-global/safe-modules/blob/main/modules/4337/contracts/Safe4337Module.sol
|
|
62
|
+
* @link https://eips.ethereum.org/EIPS/eip-4337
|
|
63
|
+
*/
|
|
64
|
+
class Safe4337Pack extends RelayKitBasePack_1.RelayKitBasePack {
|
|
65
|
+
/**
|
|
66
|
+
* Creates an instance of the Safe4337Pack.
|
|
67
|
+
*
|
|
68
|
+
* @param {Safe4337Options} options - The initialization parameters.
|
|
69
|
+
*/
|
|
70
|
+
constructor({ protocolKit, bundlerClient, publicClient, bundlerUrl, paymasterOptions, entryPointAddress, safe4337ModuleAddress }) {
|
|
71
|
+
super(protocolKit);
|
|
72
|
+
_Safe4337Pack_instances.add(this);
|
|
73
|
+
_Safe4337Pack_BUNDLER_URL.set(this, void 0);
|
|
74
|
+
_Safe4337Pack_ENTRYPOINT_ADDRESS.set(this, void 0);
|
|
75
|
+
_Safe4337Pack_SAFE_4337_MODULE_ADDRESS.set(this, '0x');
|
|
76
|
+
_Safe4337Pack_bundlerClient.set(this, void 0);
|
|
77
|
+
_Safe4337Pack_publicClient.set(this, void 0);
|
|
78
|
+
_Safe4337Pack_paymasterOptions.set(this, void 0);
|
|
79
|
+
__classPrivateFieldSet(this, _Safe4337Pack_BUNDLER_URL, bundlerUrl, "f");
|
|
80
|
+
__classPrivateFieldSet(this, _Safe4337Pack_bundlerClient, bundlerClient, "f");
|
|
81
|
+
__classPrivateFieldSet(this, _Safe4337Pack_publicClient, publicClient, "f");
|
|
82
|
+
__classPrivateFieldSet(this, _Safe4337Pack_paymasterOptions, paymasterOptions, "f");
|
|
83
|
+
__classPrivateFieldSet(this, _Safe4337Pack_ENTRYPOINT_ADDRESS, entryPointAddress, "f");
|
|
84
|
+
__classPrivateFieldSet(this, _Safe4337Pack_SAFE_4337_MODULE_ADDRESS, safe4337ModuleAddress, "f");
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Initializes a Safe4337Pack class.
|
|
88
|
+
* This method creates the protocolKit instance based on the input parameters.
|
|
89
|
+
* When the Safe address is provided, it will use the existing Safe.
|
|
90
|
+
* When the Safe address is not provided, it will use the predictedSafe feature with the provided owners and threshold.
|
|
91
|
+
* It will use the correct contract addresses for the fallbackHandler and the module and will add the data to enable the 4337 module.
|
|
92
|
+
*
|
|
93
|
+
* @param {Safe4337InitOptions} initOptions - The initialization parameters.
|
|
94
|
+
* @return {Promise<Safe4337Pack>} The Promise object that will be resolved into an instance of Safe4337Pack.
|
|
95
|
+
*/
|
|
96
|
+
static async init(initOptions) {
|
|
97
|
+
const { ethersAdapter, options, bundlerUrl, rpcUrl, customContracts, paymasterOptions } = initOptions;
|
|
98
|
+
let protocolKit;
|
|
99
|
+
const bundlerClient = (0, utils_1.getEip4337BundlerProvider)(bundlerUrl);
|
|
100
|
+
const publicClient = (0, utils_1.getEip1193Provider)(rpcUrl);
|
|
101
|
+
const chainId = await bundlerClient.send(constants_1.RPC_4337_CALLS.CHAIN_ID, []);
|
|
102
|
+
let addModulesLibAddress = customContracts?.addModulesLibAddress;
|
|
103
|
+
const network = parseInt(chainId, 16).toString();
|
|
104
|
+
if (!addModulesLibAddress) {
|
|
105
|
+
const addModulesDeployment = (0, safe_modules_deployments_1.getAddModulesLibDeployment)({
|
|
106
|
+
released: true,
|
|
107
|
+
version: initOptions.safeModulesVersion || DEFAULT_SAFE_MODULES_VERSION,
|
|
108
|
+
network
|
|
109
|
+
});
|
|
110
|
+
addModulesLibAddress = addModulesDeployment?.networkAddresses[network];
|
|
111
|
+
}
|
|
112
|
+
let safe4337ModuleAddress = customContracts?.safe4337ModuleAddress;
|
|
113
|
+
if (!safe4337ModuleAddress) {
|
|
114
|
+
const safe4337ModuleDeployment = (0, safe_modules_deployments_1.getSafe4337ModuleDeployment)({
|
|
115
|
+
released: true,
|
|
116
|
+
version: initOptions.safeModulesVersion || DEFAULT_SAFE_MODULES_VERSION,
|
|
117
|
+
network
|
|
118
|
+
});
|
|
119
|
+
safe4337ModuleAddress = safe4337ModuleDeployment?.networkAddresses[network];
|
|
120
|
+
}
|
|
121
|
+
if (!addModulesLibAddress || !safe4337ModuleAddress) {
|
|
122
|
+
throw new Error(`Safe4337Module and/or AddModulesLib not available for chain ${network} and modules version ${DEFAULT_SAFE_MODULES_VERSION}`);
|
|
123
|
+
}
|
|
124
|
+
// Existing Safe
|
|
125
|
+
if ('safeAddress' in options) {
|
|
126
|
+
protocolKit = await protocol_kit_1.default.create({
|
|
127
|
+
ethAdapter: ethersAdapter,
|
|
128
|
+
safeAddress: options.safeAddress
|
|
129
|
+
});
|
|
130
|
+
const safeVersion = await protocolKit.getContractVersion();
|
|
131
|
+
const isSafeVersion4337Compatible = (0, satisfies_1.default)(safeVersion, '>=1.4.1');
|
|
132
|
+
if (!isSafeVersion4337Compatible) {
|
|
133
|
+
throw new Error(`Incompatibility detected: The current Safe Account version (${safeVersion}) is not supported. EIP-4337 requires the Safe to use at least v1.4.1.`);
|
|
134
|
+
}
|
|
135
|
+
const safeModules = (await protocolKit.getModules());
|
|
136
|
+
const is4337ModulePresent = safeModules.some((module) => module === safe4337ModuleAddress);
|
|
137
|
+
if (!is4337ModulePresent) {
|
|
138
|
+
throw new Error(`Incompatibility detected: The EIP-4337 module is not enabled in the provided Safe Account. Enable this module (address: ${safe4337ModuleAddress}) to add compatibility.`);
|
|
139
|
+
}
|
|
140
|
+
const safeFallbackhandler = await protocolKit.getFallbackHandler();
|
|
141
|
+
const is4337FallbackhandlerPresent = safeFallbackhandler === safe4337ModuleAddress;
|
|
142
|
+
if (!is4337FallbackhandlerPresent) {
|
|
143
|
+
throw new Error(`Incompatibility detected: The EIP-4337 fallbackhandler is not attached to the Safe Account. Attach this fallbackhandler (address: ${safe4337ModuleAddress}) to ensure compatibility.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// New Safe will be created based on the provided configuration when bundling a new UserOperation
|
|
148
|
+
if (!options.owners || !options.threshold) {
|
|
149
|
+
throw new Error('Owners and threshold are required to deploy a new Safe');
|
|
150
|
+
}
|
|
151
|
+
let deploymentTo = addModulesLibAddress;
|
|
152
|
+
let deploymentData = constants_1.INTERFACES.encodeFunctionData('enableModules', [[safe4337ModuleAddress]]);
|
|
153
|
+
const { isSponsored, paymasterTokenAddress } = paymasterOptions || {};
|
|
154
|
+
const isApproveTransactionRequired = !!paymasterOptions && !isSponsored && !!paymasterTokenAddress;
|
|
155
|
+
if (isApproveTransactionRequired) {
|
|
156
|
+
const { paymasterAddress, amountToApprove = MAX_ERC20_AMOUNT_TO_APPROVE } = paymasterOptions;
|
|
157
|
+
const enable4337ModulesTransaction = {
|
|
158
|
+
to: addModulesLibAddress,
|
|
159
|
+
value: '0',
|
|
160
|
+
data: constants_1.INTERFACES.encodeFunctionData('enableModules', [[safe4337ModuleAddress]]),
|
|
161
|
+
operation: safe_core_sdk_types_1.OperationType.DelegateCall // DelegateCall required for enabling the 4337 module
|
|
162
|
+
};
|
|
163
|
+
const approveToPaymasterTransaction = {
|
|
164
|
+
to: paymasterTokenAddress,
|
|
165
|
+
data: constants_1.INTERFACES.encodeFunctionData('approve', [paymasterAddress, amountToApprove]),
|
|
166
|
+
value: '0',
|
|
167
|
+
operation: safe_core_sdk_types_1.OperationType.Call // Call for approve
|
|
168
|
+
};
|
|
169
|
+
const setupBatch = [enable4337ModulesTransaction, approveToPaymasterTransaction];
|
|
170
|
+
const batchData = constants_1.INTERFACES.encodeFunctionData('multiSend', [
|
|
171
|
+
(0, protocol_kit_1.encodeMultiSendData)(setupBatch)
|
|
172
|
+
]);
|
|
173
|
+
const multiSendContract = await (0, protocol_kit_1.getMultiSendContract)({
|
|
174
|
+
ethAdapter: ethersAdapter,
|
|
175
|
+
safeVersion: options.safeVersion || DEFAULT_SAFE_VERSION
|
|
176
|
+
});
|
|
177
|
+
deploymentTo = await multiSendContract.getAddress();
|
|
178
|
+
deploymentData = batchData;
|
|
179
|
+
}
|
|
180
|
+
protocolKit = await protocol_kit_1.default.create({
|
|
181
|
+
ethAdapter: ethersAdapter,
|
|
182
|
+
predictedSafe: {
|
|
183
|
+
safeDeploymentConfig: {
|
|
184
|
+
safeVersion: options.safeVersion || DEFAULT_SAFE_VERSION,
|
|
185
|
+
saltNonce: options.saltNonce || undefined
|
|
186
|
+
},
|
|
187
|
+
safeAccountConfig: {
|
|
188
|
+
owners: options.owners,
|
|
189
|
+
threshold: options.threshold,
|
|
190
|
+
to: deploymentTo,
|
|
191
|
+
data: deploymentData,
|
|
192
|
+
fallbackHandler: safe4337ModuleAddress,
|
|
193
|
+
paymentToken: ethers_1.ethers.ZeroAddress,
|
|
194
|
+
payment: 0,
|
|
195
|
+
paymentReceiver: ethers_1.ethers.ZeroAddress
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
let supportedEntryPoints;
|
|
201
|
+
if (!customContracts?.entryPointAddress) {
|
|
202
|
+
supportedEntryPoints = await bundlerClient.send(constants_1.RPC_4337_CALLS.SUPPORTED_ENTRY_POINTS, []);
|
|
203
|
+
if (!supportedEntryPoints.length) {
|
|
204
|
+
throw new Error('No entrypoint provided or available through the bundler');
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return new Safe4337Pack({
|
|
208
|
+
protocolKit,
|
|
209
|
+
bundlerClient,
|
|
210
|
+
publicClient,
|
|
211
|
+
paymasterOptions,
|
|
212
|
+
bundlerUrl,
|
|
213
|
+
entryPointAddress: customContracts?.entryPointAddress || supportedEntryPoints[0],
|
|
214
|
+
safe4337ModuleAddress
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Estimates gas for the SafeOperation.
|
|
219
|
+
*
|
|
220
|
+
* @param {EstimateFeeProps} props - The parameters for the gas estimation.
|
|
221
|
+
* @param {SafeOperation} props.safeOperation - The SafeOperation to estimate the gas.
|
|
222
|
+
* @param {IFeeEstimator} props.feeEstimator - The function to estimate the gas.
|
|
223
|
+
* @return {Promise<SafeOperation>} The Promise object that will be resolved into the gas estimation.
|
|
224
|
+
*/
|
|
225
|
+
async getEstimateFee({ safeOperation, feeEstimator = new PimlicoFeeEstimator_1.PimlicoFeeEstimator() }) {
|
|
226
|
+
const userOperation = safeOperation.toUserOperation();
|
|
227
|
+
const setupEstimationData = await feeEstimator?.setupEstimation?.({
|
|
228
|
+
bundlerUrl: __classPrivateFieldGet(this, _Safe4337Pack_BUNDLER_URL, "f"),
|
|
229
|
+
entryPoint: __classPrivateFieldGet(this, _Safe4337Pack_ENTRYPOINT_ADDRESS, "f"),
|
|
230
|
+
userOperation: safeOperation.toUserOperation()
|
|
231
|
+
});
|
|
232
|
+
if (setupEstimationData) {
|
|
233
|
+
safeOperation.addEstimations(setupEstimationData);
|
|
234
|
+
}
|
|
235
|
+
const estimateUserOperationGas = await __classPrivateFieldGet(this, _Safe4337Pack_bundlerClient, "f").send(constants_1.RPC_4337_CALLS.ESTIMATE_USER_OPERATION_GAS, [(0, utils_1.userOperationToHexValues)(userOperation), __classPrivateFieldGet(this, _Safe4337Pack_ENTRYPOINT_ADDRESS, "f")]);
|
|
236
|
+
if (estimateUserOperationGas) {
|
|
237
|
+
safeOperation.addEstimations({
|
|
238
|
+
preVerificationGas: BigInt(estimateUserOperationGas.preVerificationGas),
|
|
239
|
+
verificationGasLimit: BigInt(estimateUserOperationGas.verificationGasLimit),
|
|
240
|
+
callGasLimit: BigInt(estimateUserOperationGas.callGasLimit)
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
const adjustEstimationData = await feeEstimator?.adjustEstimation?.({
|
|
244
|
+
bundlerUrl: __classPrivateFieldGet(this, _Safe4337Pack_BUNDLER_URL, "f"),
|
|
245
|
+
entryPoint: __classPrivateFieldGet(this, _Safe4337Pack_ENTRYPOINT_ADDRESS, "f"),
|
|
246
|
+
userOperation: safeOperation.toUserOperation()
|
|
247
|
+
});
|
|
248
|
+
if (adjustEstimationData) {
|
|
249
|
+
safeOperation.addEstimations(adjustEstimationData);
|
|
250
|
+
}
|
|
251
|
+
if (__classPrivateFieldGet(this, _Safe4337Pack_paymasterOptions, "f")?.isSponsored) {
|
|
252
|
+
if (!__classPrivateFieldGet(this, _Safe4337Pack_paymasterOptions, "f").paymasterUrl) {
|
|
253
|
+
throw new Error('No paymaster url provided for a sponsored transaction');
|
|
254
|
+
}
|
|
255
|
+
const paymasterEstimation = await feeEstimator?.getPaymasterEstimation?.({
|
|
256
|
+
userOperation: safeOperation.toUserOperation(),
|
|
257
|
+
paymasterUrl: __classPrivateFieldGet(this, _Safe4337Pack_paymasterOptions, "f").paymasterUrl,
|
|
258
|
+
entryPoint: __classPrivateFieldGet(this, _Safe4337Pack_ENTRYPOINT_ADDRESS, "f"),
|
|
259
|
+
sponsorshipPolicyId: __classPrivateFieldGet(this, _Safe4337Pack_paymasterOptions, "f").sponsorshipPolicyId
|
|
260
|
+
});
|
|
261
|
+
safeOperation.data.paymasterAndData =
|
|
262
|
+
paymasterEstimation?.paymasterAndData || safeOperation.data.paymasterAndData;
|
|
263
|
+
if (paymasterEstimation) {
|
|
264
|
+
safeOperation.addEstimations(paymasterEstimation);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return safeOperation;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Creates a relayed transaction based on the provided parameters.
|
|
271
|
+
*
|
|
272
|
+
* @param {MetaTransactionData[]} transactions - The transactions to batch in a SafeOperation.
|
|
273
|
+
* @param options - Optional configuration options for the transaction creation.
|
|
274
|
+
* @return {Promise<SafeOperation>} The Promise object will resolve a SafeOperation.
|
|
275
|
+
*/
|
|
276
|
+
async createTransaction({ transactions, options = {} }) {
|
|
277
|
+
const safeAddress = await this.protocolKit.getAddress();
|
|
278
|
+
const nonce = await __classPrivateFieldGet(this, _Safe4337Pack_instances, "m", _Safe4337Pack_getAccountNonce).call(this, safeAddress);
|
|
279
|
+
const { amountToApprove, validUntil, validAfter, feeEstimator } = options;
|
|
280
|
+
if (amountToApprove) {
|
|
281
|
+
if (!__classPrivateFieldGet(this, _Safe4337Pack_paymasterOptions, "f") || !__classPrivateFieldGet(this, _Safe4337Pack_paymasterOptions, "f").paymasterTokenAddress) {
|
|
282
|
+
throw new Error('Paymaster must be initialized');
|
|
283
|
+
}
|
|
284
|
+
const paymasterAddress = __classPrivateFieldGet(this, _Safe4337Pack_paymasterOptions, "f").paymasterAddress;
|
|
285
|
+
const paymasterTokenAddress = __classPrivateFieldGet(this, _Safe4337Pack_paymasterOptions, "f").paymasterTokenAddress;
|
|
286
|
+
const approveToPaymasterTransaction = {
|
|
287
|
+
to: paymasterTokenAddress,
|
|
288
|
+
data: constants_1.INTERFACES.encodeFunctionData('approve', [paymasterAddress, amountToApprove]),
|
|
289
|
+
value: '0',
|
|
290
|
+
operation: safe_core_sdk_types_1.OperationType.Call // Call for approve
|
|
291
|
+
};
|
|
292
|
+
transactions.push(approveToPaymasterTransaction);
|
|
293
|
+
}
|
|
294
|
+
const isBatch = transactions.length > 1;
|
|
295
|
+
const multiSendAddress = await this.protocolKit.getMultiSendAddress();
|
|
296
|
+
const callData = isBatch
|
|
297
|
+
? __classPrivateFieldGet(this, _Safe4337Pack_instances, "m", _Safe4337Pack_encodeExecuteUserOpCallData).call(this, {
|
|
298
|
+
to: multiSendAddress,
|
|
299
|
+
value: '0',
|
|
300
|
+
data: __classPrivateFieldGet(this, _Safe4337Pack_instances, "m", _Safe4337Pack_encodeMultiSendCallData).call(this, transactions),
|
|
301
|
+
operation: safe_core_sdk_types_1.OperationType.DelegateCall
|
|
302
|
+
})
|
|
303
|
+
: __classPrivateFieldGet(this, _Safe4337Pack_instances, "m", _Safe4337Pack_encodeExecuteUserOpCallData).call(this, transactions[0]);
|
|
304
|
+
const paymasterAndData = __classPrivateFieldGet(this, _Safe4337Pack_paymasterOptions, "f")?.paymasterAddress || '0x';
|
|
305
|
+
const userOperation = {
|
|
306
|
+
sender: safeAddress,
|
|
307
|
+
nonce: nonce,
|
|
308
|
+
initCode: '0x',
|
|
309
|
+
callData,
|
|
310
|
+
callGasLimit: 1n,
|
|
311
|
+
verificationGasLimit: 1n,
|
|
312
|
+
preVerificationGas: 1n,
|
|
313
|
+
maxFeePerGas: 1n,
|
|
314
|
+
maxPriorityFeePerGas: 1n,
|
|
315
|
+
paymasterAndData,
|
|
316
|
+
signature: '0x'
|
|
317
|
+
};
|
|
318
|
+
const isSafeDeployed = await this.protocolKit.isSafeDeployed();
|
|
319
|
+
if (!isSafeDeployed) {
|
|
320
|
+
userOperation.initCode = await this.protocolKit.getInitCode();
|
|
321
|
+
}
|
|
322
|
+
const safeOperation = new SafeOperation_1.default(userOperation, {
|
|
323
|
+
entryPoint: __classPrivateFieldGet(this, _Safe4337Pack_ENTRYPOINT_ADDRESS, "f"),
|
|
324
|
+
validUntil,
|
|
325
|
+
validAfter
|
|
326
|
+
});
|
|
327
|
+
return await this.getEstimateFee({
|
|
328
|
+
safeOperation,
|
|
329
|
+
feeEstimator
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Signs a safe operation.
|
|
334
|
+
*
|
|
335
|
+
* @param {SafeOperation} safeOperation - The SafeOperation to sign.
|
|
336
|
+
* @param {SigningMethod} signingMethod - The signing method to use.
|
|
337
|
+
* @return {Promise<SafeOperation>} The Promise object will resolve to the signed SafeOperation.
|
|
338
|
+
*/
|
|
339
|
+
async signSafeOperation(safeOperation, signingMethod = protocol_kit_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4) {
|
|
340
|
+
const owners = await this.protocolKit.getOwners();
|
|
341
|
+
const signerAddress = await this.protocolKit.getEthAdapter().getSignerAddress();
|
|
342
|
+
if (!signerAddress) {
|
|
343
|
+
throw new Error('EthAdapter must be initialized with a signer to use this method');
|
|
344
|
+
}
|
|
345
|
+
const addressIsOwner = owners.some((owner) => signerAddress && owner.toLowerCase() === signerAddress.toLowerCase());
|
|
346
|
+
if (!addressIsOwner) {
|
|
347
|
+
throw new Error('UserOperations can only be signed by Safe owners');
|
|
348
|
+
}
|
|
349
|
+
let signature;
|
|
350
|
+
if (signingMethod === protocol_kit_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4 ||
|
|
351
|
+
signingMethod === protocol_kit_1.SigningMethod.ETH_SIGN_TYPED_DATA_V3 ||
|
|
352
|
+
signingMethod === protocol_kit_1.SigningMethod.ETH_SIGN_TYPED_DATA) {
|
|
353
|
+
signature = await __classPrivateFieldGet(this, _Safe4337Pack_instances, "m", _Safe4337Pack_signTypedData).call(this, safeOperation.data);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
const chainId = await this.protocolKit.getEthAdapter().getChainId();
|
|
357
|
+
const safeOpHash = __classPrivateFieldGet(this, _Safe4337Pack_instances, "m", _Safe4337Pack_getSafeUserOperationHash).call(this, safeOperation.data, chainId);
|
|
358
|
+
signature = await this.protocolKit.signHash(safeOpHash);
|
|
359
|
+
}
|
|
360
|
+
const signedSafeOperation = new SafeOperation_1.default(safeOperation.toUserOperation(), {
|
|
361
|
+
entryPoint: __classPrivateFieldGet(this, _Safe4337Pack_ENTRYPOINT_ADDRESS, "f"),
|
|
362
|
+
validUntil: safeOperation.data.validUntil,
|
|
363
|
+
validAfter: safeOperation.data.validAfter
|
|
364
|
+
});
|
|
365
|
+
signedSafeOperation.signatures.forEach((signature) => {
|
|
366
|
+
signedSafeOperation.addSignature(signature);
|
|
367
|
+
});
|
|
368
|
+
signedSafeOperation.addSignature(signature);
|
|
369
|
+
return signedSafeOperation;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Executes the relay transaction.
|
|
373
|
+
*
|
|
374
|
+
* @param {SafeOperation} safeOperation - The SafeOperation to execute.
|
|
375
|
+
* @return {Promise<string>} The user operation hash.
|
|
376
|
+
*/
|
|
377
|
+
async executeTransaction({ executable: safeOperation }) {
|
|
378
|
+
const userOperation = safeOperation.toUserOperation();
|
|
379
|
+
return this.sendUserOperation(userOperation);
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Return a UserOperation based on a hash (userOpHash) returned by eth_sendUserOperation
|
|
383
|
+
*
|
|
384
|
+
* @param {string} userOpHash - The hash of the user operation to fetch. Returned from the sendUserOperation method
|
|
385
|
+
* @returns {UserOperation} - null in case the UserOperation is not yet included in a block, or a full UserOperation, with the addition of entryPoint, blockNumber, blockHash and transactionHash
|
|
386
|
+
*/
|
|
387
|
+
async getUserOperationByHash(userOpHash) {
|
|
388
|
+
const userOperation = await __classPrivateFieldGet(this, _Safe4337Pack_bundlerClient, "f").send(constants_1.RPC_4337_CALLS.GET_USER_OPERATION_BY_HASH, [userOpHash]);
|
|
389
|
+
return userOperation;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Return a UserOperation receipt based on a hash (userOpHash) returned by eth_sendUserOperation
|
|
393
|
+
*
|
|
394
|
+
* @param {string} userOpHash - The hash of the user operation to fetch. Returned from the sendUserOperation method
|
|
395
|
+
* @returns {UserOperationReceipt} - null in case the UserOperation is not yet included in a block, or UserOperationReceipt object
|
|
396
|
+
*/
|
|
397
|
+
async getUserOperationReceipt(userOpHash) {
|
|
398
|
+
const userOperationReceipt = await __classPrivateFieldGet(this, _Safe4337Pack_bundlerClient, "f").send(constants_1.RPC_4337_CALLS.GET_USER_OPERATION_RECEIPT, [userOpHash]);
|
|
399
|
+
return userOperationReceipt;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Returns an array of the entryPoint addresses supported by the client.
|
|
403
|
+
* The first element of the array SHOULD be the entryPoint addressed preferred by the client.
|
|
404
|
+
*
|
|
405
|
+
* @returns {string[]} - The supported entry points.
|
|
406
|
+
*/
|
|
407
|
+
async getSupportedEntryPoints() {
|
|
408
|
+
const supportedEntryPoints = await __classPrivateFieldGet(this, _Safe4337Pack_bundlerClient, "f").send(constants_1.RPC_4337_CALLS.SUPPORTED_ENTRY_POINTS, []);
|
|
409
|
+
return supportedEntryPoints;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Returns EIP-155 Chain ID.
|
|
413
|
+
*
|
|
414
|
+
* @returns {string} - The chain id.
|
|
415
|
+
*/
|
|
416
|
+
async getChainId() {
|
|
417
|
+
const chainId = await __classPrivateFieldGet(this, _Safe4337Pack_bundlerClient, "f").send(constants_1.RPC_4337_CALLS.CHAIN_ID, []);
|
|
418
|
+
return chainId;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Send the UserOperation to the bundler.
|
|
422
|
+
*
|
|
423
|
+
* @param {UserOperation} userOpWithSignature - The signed UserOperation to send to the bundler.
|
|
424
|
+
* @return {Promise<string>} The hash.
|
|
425
|
+
*/
|
|
426
|
+
async sendUserOperation(userOpWithSignature) {
|
|
427
|
+
return await __classPrivateFieldGet(this, _Safe4337Pack_bundlerClient, "f").send(constants_1.RPC_4337_CALLS.SEND_USER_OPERATION, [
|
|
428
|
+
(0, utils_1.userOperationToHexValues)(userOpWithSignature),
|
|
429
|
+
__classPrivateFieldGet(this, _Safe4337Pack_ENTRYPOINT_ADDRESS, "f")
|
|
430
|
+
]);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
exports.Safe4337Pack = Safe4337Pack;
|
|
434
|
+
_Safe4337Pack_BUNDLER_URL = new WeakMap(), _Safe4337Pack_ENTRYPOINT_ADDRESS = new WeakMap(), _Safe4337Pack_SAFE_4337_MODULE_ADDRESS = new WeakMap(), _Safe4337Pack_bundlerClient = new WeakMap(), _Safe4337Pack_publicClient = new WeakMap(), _Safe4337Pack_paymasterOptions = new WeakMap(), _Safe4337Pack_instances = new WeakSet(), _Safe4337Pack_getSafeUserOperationHash = function _Safe4337Pack_getSafeUserOperationHash(safeUserOperation, chainId) {
|
|
435
|
+
return ethers_1.ethers.TypedDataEncoder.hash({
|
|
436
|
+
chainId,
|
|
437
|
+
verifyingContract: __classPrivateFieldGet(this, _Safe4337Pack_SAFE_4337_MODULE_ADDRESS, "f")
|
|
438
|
+
}, constants_1.EIP712_SAFE_OPERATION_TYPE, safeUserOperation);
|
|
439
|
+
}, _Safe4337Pack_signTypedData =
|
|
440
|
+
/**
|
|
441
|
+
* Signs typed data.
|
|
442
|
+
* This is currently only EthersAdapter compatible (Reflected in the init() props). If I want to make it compatible with any EthAdapter I need to either:
|
|
443
|
+
* - Add a SafeOp type to the protocol-kit (createSafeOperation, signSafeOperation, etc)
|
|
444
|
+
* - Allow to pass the data types (SafeOp, SafeMessage, SafeTx) to the signTypedData method and refactor the protocol-kit to allow any kind of data signing from outside (Currently only SafeTx and SafeMessage)
|
|
445
|
+
*
|
|
446
|
+
* @param {SafeUserOperation} safeUserOperation - Safe user operation to sign.
|
|
447
|
+
* @return {Promise<SafeSignature>} The SafeSignature object containing the data and the signatures.
|
|
448
|
+
*/
|
|
449
|
+
async function _Safe4337Pack_signTypedData(safeUserOperation) {
|
|
450
|
+
const ethAdapter = this.protocolKit.getEthAdapter();
|
|
451
|
+
const signer = ethAdapter.getSigner();
|
|
452
|
+
const chainId = await ethAdapter.getChainId();
|
|
453
|
+
const signerAddress = await signer.getAddress();
|
|
454
|
+
const signature = await signer.signTypedData({
|
|
455
|
+
chainId,
|
|
456
|
+
verifyingContract: __classPrivateFieldGet(this, _Safe4337Pack_SAFE_4337_MODULE_ADDRESS, "f")
|
|
457
|
+
}, constants_1.EIP712_SAFE_OPERATION_TYPE, {
|
|
458
|
+
...safeUserOperation,
|
|
459
|
+
nonce: ethers_1.ethers.toBeHex(safeUserOperation.nonce),
|
|
460
|
+
validAfter: ethers_1.ethers.toBeHex(safeUserOperation.validAfter),
|
|
461
|
+
validUntil: ethers_1.ethers.toBeHex(safeUserOperation.validUntil),
|
|
462
|
+
maxFeePerGas: ethers_1.ethers.toBeHex(safeUserOperation.maxFeePerGas),
|
|
463
|
+
maxPriorityFeePerGas: ethers_1.ethers.toBeHex(safeUserOperation.maxPriorityFeePerGas)
|
|
464
|
+
});
|
|
465
|
+
return new protocol_kit_1.EthSafeSignature(signerAddress, signature);
|
|
466
|
+
}, _Safe4337Pack_getAccountNonce =
|
|
467
|
+
/**
|
|
468
|
+
* Gets account nonce from the bundler.
|
|
469
|
+
*
|
|
470
|
+
* @param {string} sender - Account address for which the nonce is to be fetched.
|
|
471
|
+
* @returns {Promise<string>} The Promise object will resolve to the account nonce.
|
|
472
|
+
*/
|
|
473
|
+
async function _Safe4337Pack_getAccountNonce(sender) {
|
|
474
|
+
const abi = [
|
|
475
|
+
{
|
|
476
|
+
inputs: [
|
|
477
|
+
{ name: 'sender', type: 'address' },
|
|
478
|
+
{ name: 'key', type: 'uint192' }
|
|
479
|
+
],
|
|
480
|
+
name: 'getNonce',
|
|
481
|
+
outputs: [{ name: 'nonce', type: 'uint256' }],
|
|
482
|
+
stateMutability: 'view',
|
|
483
|
+
type: 'function'
|
|
484
|
+
}
|
|
485
|
+
];
|
|
486
|
+
const contract = new ethers_1.ethers.Contract(__classPrivateFieldGet(this, _Safe4337Pack_ENTRYPOINT_ADDRESS, "f") || '0x', abi, __classPrivateFieldGet(this, _Safe4337Pack_publicClient, "f"));
|
|
487
|
+
const newNonce = await contract.getNonce(sender, BigInt(0));
|
|
488
|
+
return newNonce.toString();
|
|
489
|
+
}, _Safe4337Pack_encodeExecuteUserOpCallData = function _Safe4337Pack_encodeExecuteUserOpCallData(transaction) {
|
|
490
|
+
return constants_1.INTERFACES.encodeFunctionData('executeUserOp', [
|
|
491
|
+
transaction.to,
|
|
492
|
+
transaction.value,
|
|
493
|
+
transaction.data,
|
|
494
|
+
transaction.operation || safe_core_sdk_types_1.OperationType.Call
|
|
495
|
+
]);
|
|
496
|
+
}, _Safe4337Pack_encodeMultiSendCallData = function _Safe4337Pack_encodeMultiSendCallData(transactions) {
|
|
497
|
+
return constants_1.INTERFACES.encodeFunctionData('multiSend', [
|
|
498
|
+
(0, protocol_kit_1.encodeMultiSendData)(transactions.map((tx) => ({ ...tx, operation: tx.operation ?? safe_core_sdk_types_1.OperationType.Call })))
|
|
499
|
+
]);
|
|
500
|
+
};
|
|
501
|
+
//# sourceMappingURL=Safe4337Pack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Safe4337Pack.js","sourceRoot":"","sources":["../../../../src/packs/safe-4337/Safe4337Pack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA+B;AAC/B,2EAAwD;AACxD,0EAMkC;AAClC,8EAA0E;AAC1E,0EAAoG;AACpG,oFAG8C;AAE9C,oEAA2C;AAa3C,2CAAoF;AACpF,mCAAiG;AACjG,0EAAsE;AAEtE,MAAM,oBAAoB,GAAG,OAAO,CAAA;AACpC,MAAM,4BAA4B,GAAG,OAAO,CAAA;AAE5C,MAAM,2BAA2B,GAC/B,mEAAmE,CAAA;AAErE;;;;;;;;GAQG;AACH,MAAa,YAAa,SAAQ,mCAOhC;IAWA;;;;OAIG;IACH,YAAY,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACL;QAChB,KAAK,CAAC,WAAW,CAAC,CAAA;;QAxBpB,4CAAoB;QAEpB,mDAA2B;QAC3B,iDAAoC,IAAI,EAAA;QAExC,8CAAsC;QACtC,6CAAqC;QAErC,iDAAoC;QAkBlC,uBAAA,IAAI,6BAAgB,UAAU,MAAA,CAAA;QAE9B,uBAAA,IAAI,+BAAkB,aAAa,MAAA,CAAA;QACnC,uBAAA,IAAI,8BAAiB,YAAY,MAAA,CAAA;QAEjC,uBAAA,IAAI,kCAAqB,gBAAgB,MAAA,CAAA;QAEzC,uBAAA,IAAI,oCAAuB,iBAAiB,MAAA,CAAA;QAC5C,uBAAA,IAAI,0CAA6B,qBAAqB,MAAA,CAAA;IACxD,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,WAAgC;QAChD,MAAM,EAA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