@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SafeSignature } from '@safe-global/safe-core-sdk-types';
|
|
2
|
+
import { EstimateGasData, SafeUserOperation, UserOperation } from './types';
|
|
3
|
+
type SafeOperationOptions = {
|
|
4
|
+
entryPoint: string;
|
|
5
|
+
validAfter?: number;
|
|
6
|
+
validUntil?: number;
|
|
7
|
+
};
|
|
8
|
+
declare class SafeOperation {
|
|
9
|
+
data: SafeUserOperation;
|
|
10
|
+
signatures: Map<string, SafeSignature>;
|
|
11
|
+
constructor(userOperation: UserOperation, { entryPoint, validAfter, validUntil }: SafeOperationOptions);
|
|
12
|
+
getSignature(signer: string): SafeSignature | undefined;
|
|
13
|
+
addSignature(signature: SafeSignature): void;
|
|
14
|
+
encodedSignatures(): string;
|
|
15
|
+
addEstimations(estimations: EstimateGasData): void;
|
|
16
|
+
toUserOperation(): UserOperation;
|
|
17
|
+
}
|
|
18
|
+
export default SafeOperation;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const protocol_kit_1 = require("@safe-global/protocol-kit");
|
|
5
|
+
class SafeOperation {
|
|
6
|
+
constructor(userOperation, { entryPoint, validAfter, validUntil }) {
|
|
7
|
+
this.signatures = new Map();
|
|
8
|
+
this.data = {
|
|
9
|
+
safe: userOperation.sender,
|
|
10
|
+
nonce: BigInt(userOperation.nonce),
|
|
11
|
+
initCode: userOperation.initCode,
|
|
12
|
+
callData: userOperation.callData,
|
|
13
|
+
callGasLimit: userOperation.callGasLimit,
|
|
14
|
+
verificationGasLimit: userOperation.verificationGasLimit,
|
|
15
|
+
preVerificationGas: userOperation.preVerificationGas,
|
|
16
|
+
maxFeePerGas: userOperation.maxFeePerGas,
|
|
17
|
+
maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas,
|
|
18
|
+
paymasterAndData: userOperation.paymasterAndData,
|
|
19
|
+
validAfter: validAfter || 0,
|
|
20
|
+
validUntil: validUntil || 0,
|
|
21
|
+
entryPoint
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
getSignature(signer) {
|
|
25
|
+
return this.signatures.get(signer.toLowerCase());
|
|
26
|
+
}
|
|
27
|
+
addSignature(signature) {
|
|
28
|
+
this.signatures.set(signature.signer.toLowerCase(), signature);
|
|
29
|
+
}
|
|
30
|
+
encodedSignatures() {
|
|
31
|
+
return (0, protocol_kit_1.buildSignatureBytes)(Array.from(this.signatures.values()));
|
|
32
|
+
}
|
|
33
|
+
addEstimations(estimations) {
|
|
34
|
+
const keys = [
|
|
35
|
+
'maxFeePerGas',
|
|
36
|
+
'maxPriorityFeePerGas',
|
|
37
|
+
'verificationGasLimit',
|
|
38
|
+
'preVerificationGas',
|
|
39
|
+
'callGasLimit'
|
|
40
|
+
];
|
|
41
|
+
for (const key of keys) {
|
|
42
|
+
this.data[key] = BigInt(estimations[key] || this.data[key]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
toUserOperation() {
|
|
46
|
+
return {
|
|
47
|
+
sender: this.data.safe,
|
|
48
|
+
nonce: ethers_1.ethers.toBeHex(this.data.nonce),
|
|
49
|
+
initCode: this.data.initCode,
|
|
50
|
+
callData: this.data.callData,
|
|
51
|
+
callGasLimit: this.data.callGasLimit,
|
|
52
|
+
verificationGasLimit: this.data.verificationGasLimit,
|
|
53
|
+
preVerificationGas: this.data.preVerificationGas,
|
|
54
|
+
maxFeePerGas: this.data.maxFeePerGas,
|
|
55
|
+
maxPriorityFeePerGas: this.data.maxPriorityFeePerGas,
|
|
56
|
+
paymasterAndData: this.data.paymasterAndData,
|
|
57
|
+
signature: ethers_1.ethers.solidityPacked(['uint48', 'uint48', 'bytes'], [this.data.validAfter, this.data.validUntil, this.encodedSignatures()])
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = SafeOperation;
|
|
62
|
+
//# sourceMappingURL=SafeOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SafeOperation.js","sourceRoot":"","sources":["../../../../src/packs/safe-4337/SafeOperation.ts"],"names":[],"mappings":";;AAAA,mCAA+B;AAE/B,4DAA+D;AAM/D,MAAM,aAAa;IAIjB,YACE,aAA4B,EAC5B,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAwB;QAJ9D,eAAU,GAA+B,IAAI,GAAG,EAAE,CAAA;QAMhD,IAAI,CAAC,IAAI,GAAG;YACV,IAAI,EAAE,aAAa,CAAC,MAAM;YAC1B,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;YAClC,QAAQ,EAAE,aAAa,CAAC,QAAQ;YAChC,QAAQ,EAAE,aAAa,CAAC,QAAQ;YAChC,YAAY,EAAE,aAAa,CAAC,YAAY;YACxC,oBAAoB,EAAE,aAAa,CAAC,oBAAoB;YACxD,kBAAkB,EAAE,aAAa,CAAC,kBAAkB;YACpD,YAAY,EAAE,aAAa,CAAC,YAAY;YACxC,oBAAoB,EAAE,aAAa,CAAC,oBAAoB;YACxD,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;YAChD,UAAU,EAAE,UAAU,IAAI,CAAC;YAC3B,UAAU,EAAE,UAAU,IAAI,CAAC;YAC3B,UAAU;SACX,CAAA;IACH,CAAC;IAED,YAAY,CAAC,MAAc;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;IAClD,CAAC;IAED,YAAY,CAAC,SAAwB;QACnC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAA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AI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CACvE;SACF,CAAA;IACH,CAAC;CACF;AAED,kBAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
export declare const EIP712_SAFE_OPERATION_TYPE: {
|
|
3
|
+
SafeOp: {
|
|
4
|
+
type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}[];
|
|
7
|
+
};
|
|
8
|
+
export declare const INTERFACES: ethers.Interface;
|
|
9
|
+
export declare const RPC_4337_CALLS: {
|
|
10
|
+
ESTIMATE_USER_OPERATION_GAS: string;
|
|
11
|
+
SEND_USER_OPERATION: string;
|
|
12
|
+
GET_USER_OPERATION_BY_HASH: string;
|
|
13
|
+
GET_USER_OPERATION_RECEIPT: string;
|
|
14
|
+
SUPPORTED_ENTRY_POINTS: string;
|
|
15
|
+
CHAIN_ID: string;
|
|
16
|
+
SPONSOR_USER_OPERATION: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RPC_4337_CALLS = exports.INTERFACES = exports.EIP712_SAFE_OPERATION_TYPE = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
exports.EIP712_SAFE_OPERATION_TYPE = {
|
|
6
|
+
SafeOp: [
|
|
7
|
+
{ type: 'address', name: 'safe' },
|
|
8
|
+
{ type: 'uint256', name: 'nonce' },
|
|
9
|
+
{ type: 'bytes', name: 'initCode' },
|
|
10
|
+
{ type: 'bytes', name: 'callData' },
|
|
11
|
+
{ type: 'uint256', name: 'callGasLimit' },
|
|
12
|
+
{ type: 'uint256', name: 'verificationGasLimit' },
|
|
13
|
+
{ type: 'uint256', name: 'preVerificationGas' },
|
|
14
|
+
{ type: 'uint256', name: 'maxFeePerGas' },
|
|
15
|
+
{ type: 'uint256', name: 'maxPriorityFeePerGas' },
|
|
16
|
+
{ type: 'bytes', name: 'paymasterAndData' },
|
|
17
|
+
{ type: 'uint48', name: 'validAfter' },
|
|
18
|
+
{ type: 'uint48', name: 'validUntil' },
|
|
19
|
+
{ type: 'address', name: 'entryPoint' }
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
exports.INTERFACES = new ethers_1.ethers.Interface([
|
|
23
|
+
'function enableModules(address[])',
|
|
24
|
+
'function multiSend(bytes memory transactions) public payable',
|
|
25
|
+
'function executeUserOp(address to, uint256 value, bytes data, uint8 operation)',
|
|
26
|
+
'function approve(address _spender, uint256 _value)'
|
|
27
|
+
]);
|
|
28
|
+
exports.RPC_4337_CALLS = {
|
|
29
|
+
ESTIMATE_USER_OPERATION_GAS: 'eth_estimateUserOperationGas',
|
|
30
|
+
SEND_USER_OPERATION: 'eth_sendUserOperation',
|
|
31
|
+
GET_USER_OPERATION_BY_HASH: 'eth_getUserOperationByHash',
|
|
32
|
+
GET_USER_OPERATION_RECEIPT: 'eth_getUserOperationReceipt',
|
|
33
|
+
SUPPORTED_ENTRY_POINTS: 'eth_supportedEntryPoints',
|
|
34
|
+
CHAIN_ID: 'eth_chainId',
|
|
35
|
+
SPONSOR_USER_OPERATION: 'pm_sponsorUserOperation'
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/packs/safe-4337/constants.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAElB,QAAA,0BAA0B,GAAG;IACxC,MAAM,EAAE;QACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE;QACjC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE;QAClC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE;QACnC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE;QACnC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE;QACzC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,sBAAsB,EAAE;QACjD,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,EAAE;QAC/C,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE;QACzC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,sBAAsB,EAAE;QACjD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE;QAC3C,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE;QACtC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE;QACtC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE;KACxC;CACF,CAAA;AAEY,QAAA,UAAU,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC;IAC7C,mCAAmC;IACnC,8DAA8D;IAC9D,gFAAgF;IAChF,oDAAoD;CACrD,CAAC,CAAA;AAEW,QAAA,cAAc,GAAG;IAC5B,2BAA2B,EAAE,8BAA8B;IAC3D,mBAAmB,EAAE,uBAAuB;IAC5C,0BAA0B,EAAE,4BAA4B;IACxD,0BAA0B,EAAE,6BAA6B;IACzD,sBAAsB,EAAE,0BAA0B;IAClD,QAAQ,EAAE,aAAa;IACvB,sBAAsB,EAAE,yBAAyB;CAClD,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EstimateFeeFunctionProps, EstimateGasData, EstimateSponsoredFeeFunctionProps, EstimateSponsoredGasData, IFeeEstimator } from '../types';
|
|
2
|
+
export declare class PimlicoFeeEstimator implements IFeeEstimator {
|
|
3
|
+
#private;
|
|
4
|
+
setupEstimation({ bundlerUrl }: EstimateFeeFunctionProps): Promise<EstimateGasData>;
|
|
5
|
+
adjustEstimation({ userOperation }: EstimateFeeFunctionProps): Promise<EstimateGasData>;
|
|
6
|
+
getPaymasterEstimation({ userOperation, paymasterUrl, entryPoint, sponsorshipPolicyId }: EstimateSponsoredFeeFunctionProps): Promise<EstimateSponsoredGasData>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
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");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _PimlicoFeeEstimator_instances, _PimlicoFeeEstimator_getFeeData;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PimlicoFeeEstimator = void 0;
|
|
10
|
+
const ethers_1 = require("ethers");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
const constants_1 = require("../constants");
|
|
13
|
+
class PimlicoFeeEstimator {
|
|
14
|
+
constructor() {
|
|
15
|
+
_PimlicoFeeEstimator_instances.add(this);
|
|
16
|
+
}
|
|
17
|
+
async setupEstimation({ bundlerUrl }) {
|
|
18
|
+
const bundlerClient = new ethers_1.ethers.JsonRpcProvider(bundlerUrl, undefined, {
|
|
19
|
+
batchMaxCount: 1
|
|
20
|
+
});
|
|
21
|
+
const feeData = await __classPrivateFieldGet(this, _PimlicoFeeEstimator_instances, "m", _PimlicoFeeEstimator_getFeeData).call(this, bundlerClient);
|
|
22
|
+
return feeData;
|
|
23
|
+
}
|
|
24
|
+
async adjustEstimation({ userOperation }) {
|
|
25
|
+
return {
|
|
26
|
+
callGasLimit: userOperation.callGasLimit + userOperation.callGasLimit / 2n,
|
|
27
|
+
verificationGasLimit: userOperation.verificationGasLimit + userOperation.verificationGasLimit / 2n
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async getPaymasterEstimation({ userOperation, paymasterUrl, entryPoint, sponsorshipPolicyId }) {
|
|
31
|
+
const paymasterClient = new ethers_1.ethers.JsonRpcProvider(paymasterUrl, undefined, {
|
|
32
|
+
batchMaxCount: 1
|
|
33
|
+
});
|
|
34
|
+
const params = sponsorshipPolicyId
|
|
35
|
+
? [(0, utils_1.userOperationToHexValues)(userOperation), entryPoint, { sponsorshipPolicyId }]
|
|
36
|
+
: [(0, utils_1.userOperationToHexValues)(userOperation), entryPoint];
|
|
37
|
+
const gasEstimate = await paymasterClient.send(constants_1.RPC_4337_CALLS.SPONSOR_USER_OPERATION, params);
|
|
38
|
+
return gasEstimate;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.PimlicoFeeEstimator = PimlicoFeeEstimator;
|
|
42
|
+
_PimlicoFeeEstimator_instances = new WeakSet(), _PimlicoFeeEstimator_getFeeData = async function _PimlicoFeeEstimator_getFeeData(bundlerClient) {
|
|
43
|
+
const { fast } = await bundlerClient.send('pimlico_getUserOperationGasPrice', []);
|
|
44
|
+
return fast;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=PimlicoFeeEstimator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PimlicoFeeEstimator.js","sourceRoot":"","sources":["../../../../../src/packs/safe-4337/estimators/PimlicoFeeEstimator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAA+B;AAQ/B,oCAAmD;AACnD,4CAA6C;AAE7C,MAAa,mBAAmB;IAAhC;;IA6CA,CAAC;IA5CC,KAAK,CAAC,eAAe,CAAC,EAAE,UAAU,EAA4B;QAC5D,MAAM,aAAa,GAAG,IAAI,eAAM,CAAC,eAAe,CAAC,UAAU,EAAE,SAAS,EAAE;YACtE,aAAa,EAAE,CAAC;SACjB,CAAC,CAAA;QAEF,MAAM,OA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icoFeeEstimator_1 = require("./PimlicoFeeEstimator");
|
|
5
|
+
Object.defineProperty(exports, "PimlicoFeeEstimator", { enumerable: true, get: function () { return PimlicoFeeEstimator_1.PimlicoFeeEstimator; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/packs/safe-4337/estimators/index.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAElD,oGAFA,yCAAmB,OAEA"}
|
|
@@ -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":["
|
|
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"}
|