@safe-global/relay-kit 3.3.1 → 3.4.1-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/cjs/src/index.cjs +1323 -0
- package/dist/cjs/test-utils/index.cjs +1171 -0
- package/dist/esm/src/index.mjs +1326 -0
- package/dist/esm/test-utils/index.mjs +1172 -0
- package/dist/src/RelayKitBasePack.d.ts +1 -0
- package/dist/src/RelayKitBasePack.d.ts.map +1 -0
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/deprecated.d.ts +1 -0
- package/dist/src/deprecated.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/packs/gelato/GelatoRelayPack.d.ts +1 -0
- package/dist/src/packs/gelato/GelatoRelayPack.d.ts.map +1 -0
- package/dist/src/packs/gelato/types.d.ts +1 -0
- package/dist/src/packs/gelato/types.d.ts.map +1 -0
- package/dist/src/packs/safe-4337/Safe4337Pack.d.ts +3 -1
- package/dist/src/packs/safe-4337/Safe4337Pack.d.ts.map +1 -0
- package/dist/src/packs/safe-4337/SafeOperation.d.ts +1 -0
- package/dist/src/packs/safe-4337/SafeOperation.d.ts.map +1 -0
- package/dist/src/packs/safe-4337/constants.d.ts +1 -0
- package/dist/src/packs/safe-4337/constants.d.ts.map +1 -0
- package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.d.ts +1 -0
- package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.d.ts.map +1 -0
- package/dist/src/packs/safe-4337/estimators/index.d.ts +1 -0
- package/dist/src/packs/safe-4337/estimators/index.d.ts.map +1 -0
- package/dist/src/packs/safe-4337/types.d.ts +4 -1
- package/dist/src/packs/safe-4337/types.d.ts.map +1 -0
- package/dist/src/packs/safe-4337/utils/entrypoint.d.ts +1 -0
- package/dist/src/packs/safe-4337/utils/entrypoint.d.ts.map +1 -0
- package/dist/src/packs/safe-4337/utils/getRelayKitVersion.d.ts +2 -0
- package/dist/src/packs/safe-4337/utils/getRelayKitVersion.d.ts.map +1 -0
- package/dist/src/packs/safe-4337/utils.d.ts +1 -0
- package/dist/src/packs/safe-4337/utils.d.ts.map +1 -0
- package/dist/{src/packs/safe-4337/testing-utils → test-utils}/fixtures.d.ts +1 -0
- package/dist/test-utils/fixtures.d.ts.map +1 -0
- package/dist/{src/packs/safe-4337/testing-utils → test-utils}/helpers.d.ts +3 -2
- package/dist/test-utils/helpers.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +4 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +23 -6
- package/dist/src/RelayKitBasePack.js +0 -26
- package/dist/src/RelayKitBasePack.js.map +0 -1
- package/dist/src/constants.js +0 -12
- package/dist/src/constants.js.map +0 -1
- package/dist/src/deprecated.js +0 -3
- package/dist/src/deprecated.js.map +0 -1
- package/dist/src/index.js +0 -30
- package/dist/src/index.js.map +0 -1
- package/dist/src/packs/gelato/GelatoRelayPack.js +0 -327
- package/dist/src/packs/gelato/GelatoRelayPack.js.map +0 -1
- package/dist/src/packs/gelato/types.js +0 -3
- package/dist/src/packs/gelato/types.js.map +0 -1
- package/dist/src/packs/safe-4337/Safe4337Pack.js +0 -619
- package/dist/src/packs/safe-4337/Safe4337Pack.js.map +0 -1
- package/dist/src/packs/safe-4337/SafeOperation.js +0 -68
- package/dist/src/packs/safe-4337/SafeOperation.js.map +0 -1
- package/dist/src/packs/safe-4337/constants.js +0 -55
- package/dist/src/packs/safe-4337/constants.js.map +0 -1
- package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.js +0 -49
- package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.js.map +0 -1
- package/dist/src/packs/safe-4337/estimators/index.js +0 -6
- package/dist/src/packs/safe-4337/estimators/index.js.map +0 -1
- package/dist/src/packs/safe-4337/testing-utils/fixtures.js +0 -128
- package/dist/src/packs/safe-4337/testing-utils/fixtures.js.map +0 -1
- package/dist/src/packs/safe-4337/testing-utils/helpers.js +0 -58
- package/dist/src/packs/safe-4337/testing-utils/helpers.js.map +0 -1
- package/dist/src/packs/safe-4337/types.js +0 -3
- package/dist/src/packs/safe-4337/types.js.map +0 -1
- package/dist/src/packs/safe-4337/utils/entrypoint.js +0 -23
- package/dist/src/packs/safe-4337/utils/entrypoint.js.map +0 -1
- package/dist/src/packs/safe-4337/utils.js +0 -190
- package/dist/src/packs/safe-4337/utils.js.map +0 -1
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const viem_1 = require("viem");
|
|
4
|
-
const protocol_kit_1 = require("@safe-global/protocol-kit");
|
|
5
|
-
const utils_1 = require("./utils");
|
|
6
|
-
class EthSafeOperation {
|
|
7
|
-
constructor(userOperation, { chainId, entryPoint, validAfter, validUntil, moduleAddress }) {
|
|
8
|
-
this.signatures = new Map();
|
|
9
|
-
this.chainId = chainId;
|
|
10
|
-
this.moduleAddress = moduleAddress;
|
|
11
|
-
this.data = {
|
|
12
|
-
safe: userOperation.sender,
|
|
13
|
-
nonce: BigInt(userOperation.nonce),
|
|
14
|
-
initCode: userOperation.initCode,
|
|
15
|
-
callData: userOperation.callData,
|
|
16
|
-
callGasLimit: userOperation.callGasLimit,
|
|
17
|
-
verificationGasLimit: userOperation.verificationGasLimit,
|
|
18
|
-
preVerificationGas: userOperation.preVerificationGas,
|
|
19
|
-
maxFeePerGas: userOperation.maxFeePerGas,
|
|
20
|
-
maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas,
|
|
21
|
-
paymasterAndData: userOperation.paymasterAndData,
|
|
22
|
-
validAfter: validAfter || 0,
|
|
23
|
-
validUntil: validUntil || 0,
|
|
24
|
-
entryPoint
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
getSignature(signer) {
|
|
28
|
-
return this.signatures.get(signer.toLowerCase());
|
|
29
|
-
}
|
|
30
|
-
addSignature(signature) {
|
|
31
|
-
this.signatures.set(signature.signer.toLowerCase(), signature);
|
|
32
|
-
}
|
|
33
|
-
encodedSignatures() {
|
|
34
|
-
return (0, protocol_kit_1.buildSignatureBytes)(Array.from(this.signatures.values()));
|
|
35
|
-
}
|
|
36
|
-
addEstimations(estimations) {
|
|
37
|
-
const keys = [
|
|
38
|
-
'maxFeePerGas',
|
|
39
|
-
'maxPriorityFeePerGas',
|
|
40
|
-
'verificationGasLimit',
|
|
41
|
-
'preVerificationGas',
|
|
42
|
-
'callGasLimit'
|
|
43
|
-
];
|
|
44
|
-
for (const key of keys) {
|
|
45
|
-
this.data[key] = BigInt(estimations[key] || this.data[key]);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
toUserOperation() {
|
|
49
|
-
return {
|
|
50
|
-
sender: this.data.safe,
|
|
51
|
-
nonce: (0, viem_1.toHex)(this.data.nonce),
|
|
52
|
-
initCode: this.data.initCode,
|
|
53
|
-
callData: this.data.callData,
|
|
54
|
-
callGasLimit: this.data.callGasLimit,
|
|
55
|
-
verificationGasLimit: this.data.verificationGasLimit,
|
|
56
|
-
preVerificationGas: this.data.preVerificationGas,
|
|
57
|
-
maxFeePerGas: this.data.maxFeePerGas,
|
|
58
|
-
maxPriorityFeePerGas: this.data.maxPriorityFeePerGas,
|
|
59
|
-
paymasterAndData: this.data.paymasterAndData,
|
|
60
|
-
signature: (0, viem_1.encodePacked)(['uint48', 'uint48', 'bytes'], [this.data.validAfter, this.data.validUntil, this.encodedSignatures()])
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
getHash() {
|
|
64
|
-
return (0, utils_1.calculateSafeUserOperationHash)(this.data, this.chainId, this.moduleAddress);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.default = EthSafeOperation;
|
|
68
|
-
//# sourceMappingURL=SafeOperation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version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C,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;IACpF,CAAC;CACF;AAED,kBAAe,gBAAgB,CAAA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RPC_4337_CALLS = exports.ENTRYPOINT_ADDRESS_V07 = exports.ENTRYPOINT_ADDRESS_V06 = exports.ENTRYPOINT_ABI = exports.ABI = exports.EIP712_SAFE_OPERATION_TYPE = exports.DEFAULT_SAFE_MODULES_VERSION = exports.DEFAULT_SAFE_VERSION = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
exports.DEFAULT_SAFE_VERSION = '1.4.1';
|
|
6
|
-
exports.DEFAULT_SAFE_MODULES_VERSION = '0.2.0';
|
|
7
|
-
exports.EIP712_SAFE_OPERATION_TYPE = {
|
|
8
|
-
SafeOp: [
|
|
9
|
-
{ type: 'address', name: 'safe' },
|
|
10
|
-
{ type: 'uint256', name: 'nonce' },
|
|
11
|
-
{ type: 'bytes', name: 'initCode' },
|
|
12
|
-
{ type: 'bytes', name: 'callData' },
|
|
13
|
-
{ type: 'uint256', name: 'callGasLimit' },
|
|
14
|
-
{ type: 'uint256', name: 'verificationGasLimit' },
|
|
15
|
-
{ type: 'uint256', name: 'preVerificationGas' },
|
|
16
|
-
{ type: 'uint256', name: 'maxFeePerGas' },
|
|
17
|
-
{ type: 'uint256', name: 'maxPriorityFeePerGas' },
|
|
18
|
-
{ type: 'bytes', name: 'paymasterAndData' },
|
|
19
|
-
{ type: 'uint48', name: 'validAfter' },
|
|
20
|
-
{ type: 'uint48', name: 'validUntil' },
|
|
21
|
-
{ type: 'address', name: 'entryPoint' }
|
|
22
|
-
]
|
|
23
|
-
};
|
|
24
|
-
exports.ABI = (0, viem_1.parseAbi)([
|
|
25
|
-
'function enableModules(address[])',
|
|
26
|
-
'function multiSend(bytes memory transactions) public payable',
|
|
27
|
-
'function executeUserOp(address to, uint256 value, bytes data, uint8 operation)',
|
|
28
|
-
'function approve(address _spender, uint256 _value)',
|
|
29
|
-
'function configure((uint256 x, uint256 y, uint176 verifiers) signer)'
|
|
30
|
-
]);
|
|
31
|
-
exports.ENTRYPOINT_ABI = [
|
|
32
|
-
{
|
|
33
|
-
inputs: [
|
|
34
|
-
{ name: 'sender', type: 'address' },
|
|
35
|
-
{ name: 'key', type: 'uint192' }
|
|
36
|
-
],
|
|
37
|
-
name: 'getNonce',
|
|
38
|
-
outputs: [{ name: 'nonce', type: 'uint256' }],
|
|
39
|
-
stateMutability: 'view',
|
|
40
|
-
type: 'function'
|
|
41
|
-
}
|
|
42
|
-
];
|
|
43
|
-
exports.ENTRYPOINT_ADDRESS_V06 = '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789';
|
|
44
|
-
exports.ENTRYPOINT_ADDRESS_V07 = '0x0000000071727De22E5E9d8BAf0edAc6f37da032';
|
|
45
|
-
var RPC_4337_CALLS;
|
|
46
|
-
(function (RPC_4337_CALLS) {
|
|
47
|
-
RPC_4337_CALLS["ESTIMATE_USER_OPERATION_GAS"] = "eth_estimateUserOperationGas";
|
|
48
|
-
RPC_4337_CALLS["SEND_USER_OPERATION"] = "eth_sendUserOperation";
|
|
49
|
-
RPC_4337_CALLS["GET_USER_OPERATION_BY_HASH"] = "eth_getUserOperationByHash";
|
|
50
|
-
RPC_4337_CALLS["GET_USER_OPERATION_RECEIPT"] = "eth_getUserOperationReceipt";
|
|
51
|
-
RPC_4337_CALLS["SUPPORTED_ENTRY_POINTS"] = "eth_supportedEntryPoints";
|
|
52
|
-
RPC_4337_CALLS["CHAIN_ID"] = "eth_chainId";
|
|
53
|
-
RPC_4337_CALLS["SPONSOR_USER_OPERATION"] = "pm_sponsorUserOperation";
|
|
54
|
-
})(RPC_4337_CALLS || (exports.RPC_4337_CALLS = RPC_4337_CALLS = {}));
|
|
55
|
-
//# sourceMappingURL=constants.js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;QACE,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;YACnC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE;SACjC;QACD,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC7C,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;CACO,CAAA;AAEG,QAAA,sBAAsB,GAAG,4CAA4C,CAAA;AACrE,QAAA,sBAAsB,GAAG,4CAA4C,CAAA;AAElF,IAAY,cAQX;AARD,WAAY,cAAc;IACxB,8EAA4D,CAAA;IAC5D,+DAA6C,CAAA;IAC7C,2EAAyD,CAAA;IACzD,4EAA0D,CAAA;IAC1D,qEAAmD,CAAA;IACnD,0CAAwB,CAAA;IACxB,oEAAkD,CAAA;AACpD,CAAC,EARW,cAAc,8BAAd,cAAc,QAQzB"}
|
|
@@ -1,49 +0,0 @@
|
|
|
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 utils_1 = require("../utils");
|
|
11
|
-
const constants_1 = require("../constants");
|
|
12
|
-
class PimlicoFeeEstimator {
|
|
13
|
-
constructor() {
|
|
14
|
-
_PimlicoFeeEstimator_instances.add(this);
|
|
15
|
-
}
|
|
16
|
-
async setupEstimation({ bundlerUrl }) {
|
|
17
|
-
const bundlerClient = (0, utils_1.getEip4337BundlerProvider)(bundlerUrl);
|
|
18
|
-
const feeData = await __classPrivateFieldGet(this, _PimlicoFeeEstimator_instances, "m", _PimlicoFeeEstimator_getFeeData).call(this, bundlerClient);
|
|
19
|
-
return feeData;
|
|
20
|
-
}
|
|
21
|
-
async adjustEstimation({ userOperation }) {
|
|
22
|
-
return {
|
|
23
|
-
callGasLimit: userOperation.callGasLimit + userOperation.callGasLimit / 2n, // +50%
|
|
24
|
-
verificationGasLimit: userOperation.verificationGasLimit * 4n, // +300%
|
|
25
|
-
preVerificationGas: userOperation.preVerificationGas + userOperation.preVerificationGas / 20n // +5%
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
async getPaymasterEstimation({ userOperation, paymasterUrl, entryPoint, sponsorshipPolicyId }) {
|
|
29
|
-
const paymasterClient = (0, utils_1.getEip4337BundlerProvider)(paymasterUrl);
|
|
30
|
-
const gasEstimate = await paymasterClient.request({
|
|
31
|
-
method: constants_1.RPC_4337_CALLS.SPONSOR_USER_OPERATION,
|
|
32
|
-
params: sponsorshipPolicyId
|
|
33
|
-
? [(0, utils_1.userOperationToHexValues)(userOperation), entryPoint, { sponsorshipPolicyId }]
|
|
34
|
-
: [(0, utils_1.userOperationToHexValues)(userOperation), entryPoint]
|
|
35
|
-
});
|
|
36
|
-
return gasEstimate;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.PimlicoFeeEstimator = PimlicoFeeEstimator;
|
|
40
|
-
_PimlicoFeeEstimator_instances = new WeakSet(), _PimlicoFeeEstimator_getFeeData = async function _PimlicoFeeEstimator_getFeeData(bundlerClient) {
|
|
41
|
-
const { fast: { maxFeePerGas, maxPriorityFeePerGas } } = await bundlerClient.request({
|
|
42
|
-
method: 'pimlico_getUserOperationGasPrice'
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
maxFeePerGas: BigInt(maxFeePerGas),
|
|
46
|
-
maxPriorityFeePerGas: BigInt(maxPriorityFeePerGas)
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=PimlicoFeeEstimator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PimlicoFeeEstimator.js","sourceRoot":"","sources":["../../../../../src/packs/safe-4337/estimators/PimlicoFeeEstimator.ts"],"names":[],"mappings":";;;;;;;;;AAQA,oCAA8E;AAC9E,4CAA6C;AAE7C,MAAa,mBAAmB;IAAhC;;IAiDA,CAAC;IAhDC,KAAK,CAAC,eAAe,CAAC,EAAE,UAAU,EAA4B;QAC5D,MAAM,aAAa,GAAG,IAAA,iCAAyB,EAAC,UAAU,CAAC,CAAA;QAE3D,MAAM,OAAO,GAAG,MAAM,uBAAA,IAAI,uEAAY,MAAhB,IAAI,EAAa,aAAa,CAAC,CAAA;QAErD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,EAAE,aAAa,EAA4B;QAChE,OAAO;YACL,YAAY,EAAE,aAAa,CAAC,YAAY,GAAG,aAAa,CAAC,YAAY,GAAG,EAAE,EAAE,OAAO;YACnF,oBAAoB,EAAE,aAAa,CAAC,oBAAoB,GAAG,EAAE,EAAE,QAAQ;YACvE,kBAAkB,EAAE,aAAa,CAAC,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,GAAG,GAAG,CAAC,MAAM;SACrG,CAAA;IACH,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,EAC3B,aAAa,EACb,YAAY,EACZ,UAAU,EACV,mBAAmB,EACe;QAClC,MAAM,eAAe,GAAG,IAAA,iCAAyB,EAAC,YAAY,CAAC,CAAA;QAE/D,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC;YAChD,MAAM,EAAE,0BAAc,CAAC,sBAAsB;YAC7C,MAAM,EAAE,mBAAmB;gBACzB,CAAC,CAAC,CAAC,IAAA,gCAAwB,EAAC,aAAa,CAAC,EAAE,UAAU,EAAE,EAAE,mBAAmB,EAAE,CAAC;gBAChF,CAAC,CAAC,CAAC,IAAA,gCAAwB,EAAC,aAAa,CAAC,EAAE,UAAU,CAAC;SAC1D,CAAC,CAAA;QAEF,OAAO,WAAW,CAAA;IACpB,CAAC;CAgBF;AAjDD,kDAiDC;kFAdC,KAAK,0CACH,aAA4B;IAE5B,MAAM,EACJ,IAAI,EAAE,EAAE,YAAY,EAAE,oBAAoB,EAAE,EAC7C,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC;QAC9B,MAAM,EAAE,kCAAkC;KAC3C,CAAC,CAAA;IAEF,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC;QAClC,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,CAAC;KACnD,CAAA;AACH,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PimlicoFeeEstimator = void 0;
|
|
4
|
-
const PimlicoFeeEstimator_1 = require("./PimlicoFeeEstimator");
|
|
5
|
-
Object.defineProperty(exports, "PimlicoFeeEstimator", { enumerable: true, get: function () { return PimlicoFeeEstimator_1.PimlicoFeeEstimator; } });
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/packs/safe-4337/estimators/index.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAElD,oGAFA,yCAAmB,OAEA"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.USER_OPERATION_GAS_PRICE = exports.SPONSORED_GAS_ESTIMATION = exports.SAFE_OPERATION_RESPONSE = exports.GAS_ESTIMATION = exports.USER_OPERATION_BY_HASH = exports.USER_OPERATION_HEX_VALUES = exports.USER_OPERATION = exports.USER_OPERATION_RECEIPT = exports.ENTRYPOINTS = exports.USER_OPERATION_HASH = exports.PAYMASTER_URL = exports.BUNDLER_URL = exports.RPC_URL = exports.MODULE_ADDRESS = exports.CHAIN_ID = exports.PAYMASTER_TOKEN_ADDRESS = exports.PAYMASTER_ADDRESS = exports.SAFE_MODULES_V0_3_0 = exports.SAFE_ADDRESS_4337_PASSKEY = exports.SAFE_ADDRESS_4337_FALLBACKHANDLER_NOT_ENABLED = exports.SAFE_ADDRESS_4337_MODULE_NOT_ENABLED = exports.SAFE_ADDRESS_v1_3_0 = exports.SAFE_ADDRESS_v1_4_1 = exports.PREDICTED_SAFE_ADDRESS = exports.OWNER_2 = exports.OWNER_1 = void 0;
|
|
4
|
-
const types_kit_1 = require("@safe-global/types-kit");
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
|
-
exports.OWNER_1 = '0xFfAC5578BE8AC1B2B9D13b34cAf4A074B96B8A1b';
|
|
7
|
-
exports.OWNER_2 = '0x3059EfD1BCe33be41eeEfd5fb6D520d7fEd54E43';
|
|
8
|
-
exports.PREDICTED_SAFE_ADDRESS = '0x65e0d294F2d17CB9fB0f65111E9Ac8a00C4049dA';
|
|
9
|
-
exports.SAFE_ADDRESS_v1_4_1 = '0x717f4BB83D8DF2e5a3Cc603Ee27263ac9EFB6c12';
|
|
10
|
-
exports.SAFE_ADDRESS_v1_3_0 = '0x8C35a08Af278518B59D04ddDe3F1b370aD766D22';
|
|
11
|
-
exports.SAFE_ADDRESS_4337_MODULE_NOT_ENABLED = '0xfC82a1e4A045a44527e8b45FC70332C8F66fc32B';
|
|
12
|
-
exports.SAFE_ADDRESS_4337_FALLBACKHANDLER_NOT_ENABLED = '0xA6FDc4e18404E1715D1bC51B07266c91393C6622';
|
|
13
|
-
exports.SAFE_ADDRESS_4337_PASSKEY = '0x02DCbFD25178b6b8eFb45603D30b5123179117DD'; // Safe owned by passkey signer + 4337 module + fallback handler enabled
|
|
14
|
-
exports.SAFE_MODULES_V0_3_0 = '0.3.0';
|
|
15
|
-
exports.PAYMASTER_ADDRESS = '0x0000000000325602a77416A16136FDafd04b299f';
|
|
16
|
-
exports.PAYMASTER_TOKEN_ADDRESS = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238';
|
|
17
|
-
exports.CHAIN_ID = '0xaa36a7';
|
|
18
|
-
exports.MODULE_ADDRESS = '0xa581c4A4DB7175302464fF3C06380BC3270b4037';
|
|
19
|
-
exports.RPC_URL = 'https://sepolia.gateway.tenderly.co';
|
|
20
|
-
exports.BUNDLER_URL = 'https://bundler.url';
|
|
21
|
-
exports.PAYMASTER_URL = 'https://paymaster.url';
|
|
22
|
-
exports.USER_OPERATION_HASH = '0x3cb881d1969036174f38d636d22108d1d032145518b53104fc0b1e1296d2cc9c';
|
|
23
|
-
exports.ENTRYPOINTS = [constants_1.ENTRYPOINT_ADDRESS_V06, constants_1.ENTRYPOINT_ADDRESS_V07];
|
|
24
|
-
exports.USER_OPERATION_RECEIPT = {
|
|
25
|
-
userOpHash: '0x3cb881d1969036174f38d636d22108d1d032145518b53104fc0b1e1296d2cc9c',
|
|
26
|
-
sender: '0x1405B3659a11a16459fc27Fa1925b60388C38Ce1',
|
|
27
|
-
nonce: '0x1',
|
|
28
|
-
actualGasUsed: '0x27067',
|
|
29
|
-
actualGasCost: '0x42f29418377167',
|
|
30
|
-
success: true,
|
|
31
|
-
logs: [],
|
|
32
|
-
receipt: {
|
|
33
|
-
transactionHash: '0xef262d20f68e4900aa6380b8ac0f66f9c00a7d988179fa177ad9c9758f0e380e',
|
|
34
|
-
transactionIndex: '0x63',
|
|
35
|
-
blockHash: '0x65f8249337ffede2067a006a96da47d3d3445ca72492a6a82afa02899f05d2e5',
|
|
36
|
-
blockNumber: '0x5378b9',
|
|
37
|
-
from: '0x4337001Fff419768e088Ce247456c1B892888084',
|
|
38
|
-
to: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
|
|
39
|
-
cumulativeGasUsed: '0xc1a846',
|
|
40
|
-
gasUsed: '0x25e6c',
|
|
41
|
-
contractAddress: null,
|
|
42
|
-
logs: [],
|
|
43
|
-
logsBloom: '0x000000000000900000000000000000000000000000000000080000000002000000080000000000000402000100000000001000000000000080000200000100000000000000000000000000080000000000000000000000000000002000002000000000000a0000000000000000000800000000000000000000000010000200000000000060100000000000000040000000800000000000000008800000000000000000000000000000400000000000000200000000000000000002000000008000000002000100000001000000000000000000000020000000000000000020010040000000000020000010000008000200000000000000000000000000000000',
|
|
44
|
-
status: '0x1',
|
|
45
|
-
effectiveGasPrice: '0x1b67f3c201'
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
exports.USER_OPERATION = {
|
|
49
|
-
sender: '0x1405B3659a11a16459fc27Fa1925b60388C38Ce1',
|
|
50
|
-
nonce: '0x1',
|
|
51
|
-
initCode: '0x',
|
|
52
|
-
callData: '0x7bb3742800000000000000000000000038869bf66a61cf6bdb996a6ae40d5853fd43b52600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001848d80ff0a00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000132001c7d4b196cb0c7b01d743fbc6116a902379c723800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000d725e11588f040d86c4c49d8236e32a5868549f000000000000000000000000000000000000000000000000000000000000186a0001c7d4b196cb0c7b01d743fbc6116a902379c723800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000d725e11588f040d86c4c49d8236e32a5868549f000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
53
|
-
callGasLimit: 120784n,
|
|
54
|
-
verificationGasLimit: 83056n,
|
|
55
|
-
preVerificationGas: 48568n,
|
|
56
|
-
maxFeePerGas: 193584757388n,
|
|
57
|
-
maxPriorityFeePerGas: 1380000000n,
|
|
58
|
-
paymasterAndData: '0x',
|
|
59
|
-
signature: '0x000000000000000000000000a397ca32ee7fb5282256ee3465da0843485930b803d747516aac76e152f834051ac18fd2b3c0565590f9d65085538993c85c9bb189c940d15c15402c7c2885821b'
|
|
60
|
-
};
|
|
61
|
-
exports.USER_OPERATION_HEX_VALUES = {
|
|
62
|
-
sender: '0x1405B3659a11a16459fc27Fa1925b60388C38Ce1',
|
|
63
|
-
nonce: '0x1',
|
|
64
|
-
initCode: '0x',
|
|
65
|
-
callData: '0x7bb3742800000000000000000000000038869bf66a61cf6bdb996a6ae40d5853fd43b52600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001848d80ff0a00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000132001c7d4b196cb0c7b01d743fbc6116a902379c723800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000d725e11588f040d86c4c49d8236e32a5868549f000000000000000000000000000000000000000000000000000000000000186a0001c7d4b196cb0c7b01d743fbc6116a902379c723800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000d725e11588f040d86c4c49d8236e32a5868549f000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
66
|
-
callGasLimit: '0x1d7d0',
|
|
67
|
-
verificationGasLimit: '0x14470',
|
|
68
|
-
preVerificationGas: '0xbdb8',
|
|
69
|
-
maxFeePerGas: '0x2d128cfa8c',
|
|
70
|
-
maxPriorityFeePerGas: '0x52412100',
|
|
71
|
-
paymasterAndData: '0x',
|
|
72
|
-
signature: '0x000000000000000000000000a397ca32ee7fb5282256ee3465da0843485930b803d747516aac76e152f834051ac18fd2b3c0565590f9d65085538993c85c9bb189c940d15c15402c7c2885821b'
|
|
73
|
-
};
|
|
74
|
-
exports.USER_OPERATION_BY_HASH = {
|
|
75
|
-
userOperation: exports.USER_OPERATION_HEX_VALUES,
|
|
76
|
-
entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
|
|
77
|
-
transactionHash: '0xef262d20f68e4900aa6380b8ac0f66f9c00a7d988179fa177ad9c9758f0e380e',
|
|
78
|
-
blockHash: '0x65f8249337ffede2067a006a96da47d3d3445ca72492a6a82afa02899f05d2e5',
|
|
79
|
-
blockNumber: '0x5378b9'
|
|
80
|
-
};
|
|
81
|
-
exports.GAS_ESTIMATION = {
|
|
82
|
-
verificationGasLimit: '0x186A0',
|
|
83
|
-
preVerificationGas: '0x186A0',
|
|
84
|
-
callGasLimit: '0x186A0'
|
|
85
|
-
};
|
|
86
|
-
exports.SAFE_OPERATION_RESPONSE = {
|
|
87
|
-
created: '2024-05-31T10:12:21.169031Z',
|
|
88
|
-
modified: '2024-05-31T10:12:21.169031Z',
|
|
89
|
-
safeOperationHash: '0x5a62b1d61f8fca5f766e9456523bb42765d318058b5f235f967ffe3c2af8b1d7',
|
|
90
|
-
validAfter: null,
|
|
91
|
-
validUntil: null,
|
|
92
|
-
moduleAddress: '0xa581c4A4DB7175302464fF3C06380BC3270b4037',
|
|
93
|
-
confirmations: [
|
|
94
|
-
{
|
|
95
|
-
created: '2024-05-31T10:12:21.184585Z',
|
|
96
|
-
modified: '2024-05-31T10:12:21.184585Z',
|
|
97
|
-
owner: '0x3059EfD1BCe33be41eeEfd5fb6D520d7fEd54E43',
|
|
98
|
-
signature: '0xcb28e74375889e400a4d8aca46b8c59e1cf8825e373c26fa99c2fd7c078080e64fe30eaf1125257bdfe0b358b5caef68aa0420478145f52decc8e74c979d43ab1d',
|
|
99
|
-
signatureType: types_kit_1.SignatureTypes.EOA
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
|
-
preparedSignature: '0xcb28e74375889e400a4d8aca46b8c59e1cf8825e373c26fa99c2fd7c078080e64fe30eaf1125257bdfe0b358b5caef68aa0420478145f52decc8e74c979d43ab1c',
|
|
103
|
-
userOperation: {
|
|
104
|
-
ethereumTxHash: null,
|
|
105
|
-
sender: '0xE322e721bCe76cE7FCf3A475f139A9314571ad3D',
|
|
106
|
-
userOperationHash: '0x5d23b7d96a718582601183b1849a4c76b2a13d3787f15074d62a0b6e4a3f76a1',
|
|
107
|
-
nonce: 3,
|
|
108
|
-
initCode: '0x',
|
|
109
|
-
callData: '0x7bb37428000000000000000000000000e322e721bce76ce7fcf3a475f139a9314571ad3d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
110
|
-
callGasLimit: 122497,
|
|
111
|
-
verificationGasLimit: 123498,
|
|
112
|
-
preVerificationGas: 50705,
|
|
113
|
-
maxFeePerGas: 105183831060,
|
|
114
|
-
maxPriorityFeePerGas: 1380000000,
|
|
115
|
-
paymaster: null,
|
|
116
|
-
paymasterData: null,
|
|
117
|
-
signature: '0x54158da2d357241ee1c5c8fca9c4e1bfa6b92a60bd0ed1bea56f4092b008435153d6264a8a8c00925383ecaeaf9d839a2dc1ff006703c65b7f05d0ce8cdd57ab1b',
|
|
118
|
-
entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789'
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
exports.SPONSORED_GAS_ESTIMATION = {
|
|
122
|
-
paymasterAndData: '0x1405B3659a11a16459fc27Fa1925b60388C38Ce1',
|
|
123
|
-
...exports.GAS_ESTIMATION
|
|
124
|
-
};
|
|
125
|
-
exports.USER_OPERATION_GAS_PRICE = {
|
|
126
|
-
fast: { maxFeePerGas: '0x186A0', maxPriorityFeePerGas: '0x30D40' }
|
|
127
|
-
};
|
|
128
|
-
//# sourceMappingURL=fixtures.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.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AAiB,EAAE,oEAAoE;IACvF,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,4CAA4C;IAC3D,aAAa,EAAE;QACb;YACE,OAAO,EAAE,6BAA6B;YACtC,QAAQ,EAAE,6BAA6B;YACvC,KAAK,EAAE,4CAA4C;YACnD,SAAS,EACP,sIAAsI;YACxI,aAAa,EAAE,0BAAc,CAAC,GAAG;SAClC;KACF;IACD,iBAAiB,EACf,sIAAsI;IACxI,aAAa,EAAE;QACb,cAAc,EAAE,IAAI;QACpB,MAAM,EAAE,4CAA4C;QACpD,iBAAiB,EAAE,oEAAoE;QACvF,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,IAAI;QACd,QAAQ,EACN,4UAA4U;QAC9U,YAAY,EAAE,MAAM;QACpB,oBAAoB,EAAE,MAAM;QAC5B,kBAAkB,EAAE,KAAK;QACzB,YAAY,EAAE,YAAY;QAC1B,oBAAoB,EAAE,UAAU;QAChC,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,IAAI;QACnB,SAAS,EACP,sIAAsI;QACxI,UAAU,EAAE,4CAA4C;KACzD;CACF,CAAA;AAEY,QAAA,wBAAwB,GAAG;IACtC,gBAAgB,EAAE,4CAA4C;IAC9D,GAAG,sBAAc;CAClB,CAAA;AAEY,QAAA,wBAAwB,GAAG;IACtC,IAAI,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,oBAAoB,EAAE,SAAS,EAAE;CACnE,CAAA"}
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createSafe4337Pack = exports.generateTransferCallData = void 0;
|
|
27
|
-
const viem_1 = require("viem");
|
|
28
|
-
const Safe4337Pack_1 = require("../Safe4337Pack");
|
|
29
|
-
const fixtures = __importStar(require("./fixtures"));
|
|
30
|
-
const generateTransferCallData = (to, value) => {
|
|
31
|
-
const functionAbi = (0, viem_1.parseAbi)(['function transfer(address _to, uint256 _value) returns (bool)']);
|
|
32
|
-
return (0, viem_1.encodeFunctionData)({
|
|
33
|
-
abi: functionAbi,
|
|
34
|
-
functionName: 'transfer',
|
|
35
|
-
args: [to, value]
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
exports.generateTransferCallData = generateTransferCallData;
|
|
39
|
-
const safe4337PackCache = new Map();
|
|
40
|
-
const createSafe4337Pack = async (initOptions) => {
|
|
41
|
-
const key = JSON.stringify(initOptions);
|
|
42
|
-
if (safe4337PackCache.has(key)) {
|
|
43
|
-
return safe4337PackCache.get(key);
|
|
44
|
-
}
|
|
45
|
-
const safe4337Pack = await Safe4337Pack_1.Safe4337Pack.init({
|
|
46
|
-
provider: fixtures.RPC_URL,
|
|
47
|
-
signer: process.env.PRIVATE_KEY,
|
|
48
|
-
options: {
|
|
49
|
-
safeAddress: ''
|
|
50
|
-
},
|
|
51
|
-
...initOptions,
|
|
52
|
-
bundlerUrl: fixtures.BUNDLER_URL
|
|
53
|
-
});
|
|
54
|
-
safe4337PackCache.set(key, safe4337Pack);
|
|
55
|
-
return safe4337Pack;
|
|
56
|
-
};
|
|
57
|
-
exports.createSafe4337Pack = createSafe4337Pack;
|
|
58
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../src/packs/safe-4337/testing-utils/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAmD;AAEnD,kDAA8C;AAC9C,qDAAsC;AAE/B,MAAM,wBAAwB,GAAG,CAAC,EAAU,EAAE,KAAa,EAAE,EAAE;IACpE,MAAM,WAAW,GAAG,IAAA,eAAQ,EAAC,CAAC,+DAA+D,CAAC,CAAC,CAAA;IAE/F,OAAO,IAAA,yBAAkB,EAAC;QACxB,GAAG,EAAE,WAAW;QAChB,YAAY,EAAE,UAAU;QACxB,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC;KAClB,CAAC,CAAA;AACJ,CAAC,CAAA;AARY,QAAA,wBAAwB,4BAQpC;AAED,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAA;AAE5B,MAAM,kBAAkB,GAAG,KAAK,EACrC,WAAyC,EAClB,EAAE;IACzB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IAEvC,IAAI,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACnC,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,2BAAY,CAAC,IAAI,CAAC;QAC3C,QAAQ,EAAE,QAAQ,CAAC,OAAO;QAC1B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;QAC/B,OAAO,EAAE;YACP,WAAW,EAAE,EAAE;SAChB;QACD,GAAG,WAAW;QACd,UAAU,EAAE,QAAQ,CAAC,WAAW;KACjC,CAAC,CAAA;IAEF,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;IAExC,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AAtBY,QAAA,kBAAkB,sBAsB9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/packs/safe-4337/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isEntryPointV6 = exports.entryPointToSafeModules = exports.sameString = exports.EQ_OR_GT_0_3_0 = void 0;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
const EQ_0_2_0 = '0.2.0';
|
|
6
|
-
exports.EQ_OR_GT_0_3_0 = '>=0.3.0';
|
|
7
|
-
function sameString(str1, str2) {
|
|
8
|
-
return str1.toLowerCase() === str2.toLowerCase();
|
|
9
|
-
}
|
|
10
|
-
exports.sameString = sameString;
|
|
11
|
-
function entryPointToSafeModules(entryPoint) {
|
|
12
|
-
const moduleVersionToEntryPoint = {
|
|
13
|
-
[constants_1.ENTRYPOINT_ADDRESS_V06]: EQ_0_2_0,
|
|
14
|
-
[constants_1.ENTRYPOINT_ADDRESS_V07]: exports.EQ_OR_GT_0_3_0
|
|
15
|
-
};
|
|
16
|
-
return moduleVersionToEntryPoint[entryPoint];
|
|
17
|
-
}
|
|
18
|
-
exports.entryPointToSafeModules = entryPointToSafeModules;
|
|
19
|
-
function isEntryPointV6(address) {
|
|
20
|
-
return sameString(address, constants_1.ENTRYPOINT_ADDRESS_V06);
|
|
21
|
-
}
|
|
22
|
-
exports.isEntryPointV6 = isEntryPointV6;
|
|
23
|
-
//# sourceMappingURL=entrypoint.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoint.js","sourceRoot":"","sources":["../../../../../src/packs/safe-4337/utils/entrypoint.ts"],"names":[],"mappings":";;;AAAA,4CAA6E;AAE7E,MAAM,QAAQ,GAAG,OAAO,CAAA;AAEX,QAAA,cAAc,GAAG,SAAS,CAAA;AAEvC,SAAgB,UAAU,CAAC,IAAY,EAAE,IAAY;IACnD,OAAO,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAA;AAClD,CAAC;AAFD,gCAEC;AAED,SAAgB,uBAAuB,CAAC,UAAkB;IACxD,MAAM,yBAAyB,GAA4D;QACzF,CAAC,kCAAsB,CAAC,EAAE,QAAQ;QAClC,CAAC,kCAAsB,CAAC,EAAE,sBAAc;KACzC,CAAA;IAED,OAAO,yBAAyB,CAAC,UAAU,CAAC,CAAA;AAC9C,CAAC;AAPD,0DAOC;AAED,SAAgB,cAAc,CAAC,OAAe;IAC5C,OAAO,UAAU,CAAC,OAAO,EAAE,kCAAsB,CAAC,CAAA;AACpD,CAAC;AAFD,wCAEC"}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSignatureBytes = exports.addDummySignature = exports.DUMMY_AUTHENTICATOR_DATA = exports.DUMMY_CLIENT_DATA_FIELDS = exports.userOperationToHexValues = exports.calculateSafeUserOperationHash = exports.encodeMultiSendCallData = exports.signSafeOp = exports.getEip4337BundlerProvider = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
const types_kit_1 = require("@safe-global/types-kit");
|
|
6
|
-
const protocol_kit_1 = require("@safe-global/protocol-kit");
|
|
7
|
-
const constants_1 = require("./constants");
|
|
8
|
-
/**
|
|
9
|
-
* Gets the EIP-4337 bundler provider.
|
|
10
|
-
*
|
|
11
|
-
* @param {string} bundlerUrl The EIP-4337 bundler URL.
|
|
12
|
-
* @return {BundlerClient} The EIP-4337 bundler provider.
|
|
13
|
-
*/
|
|
14
|
-
function getEip4337BundlerProvider(bundlerUrl) {
|
|
15
|
-
const provider = (0, viem_1.createPublicClient)({
|
|
16
|
-
transport: (0, viem_1.http)(bundlerUrl),
|
|
17
|
-
rpcSchema: (0, viem_1.rpcSchema)()
|
|
18
|
-
});
|
|
19
|
-
return provider;
|
|
20
|
-
}
|
|
21
|
-
exports.getEip4337BundlerProvider = getEip4337BundlerProvider;
|
|
22
|
-
/**
|
|
23
|
-
* Signs typed data.
|
|
24
|
-
*
|
|
25
|
-
* @param {SafeUserOperation} safeUserOperation - Safe user operation to sign.
|
|
26
|
-
* @param {SafeProvider} safeProvider - Safe provider.
|
|
27
|
-
* @param {string} safe4337ModuleAddress - Safe 4337 module address.
|
|
28
|
-
* @return {Promise<SafeSignature>} The SafeSignature object containing the data and the signatures.
|
|
29
|
-
*/
|
|
30
|
-
async function signSafeOp(safeUserOperation, safeProvider, safe4337ModuleAddress) {
|
|
31
|
-
const signer = await safeProvider.getExternalSigner();
|
|
32
|
-
if (!signer) {
|
|
33
|
-
throw new Error('No signer found');
|
|
34
|
-
}
|
|
35
|
-
const chainId = await safeProvider.getChainId();
|
|
36
|
-
const signerAddress = signer.account.address;
|
|
37
|
-
const signature = await signer.signTypedData({
|
|
38
|
-
domain: {
|
|
39
|
-
chainId: Number(chainId),
|
|
40
|
-
verifyingContract: safe4337ModuleAddress
|
|
41
|
-
},
|
|
42
|
-
types: constants_1.EIP712_SAFE_OPERATION_TYPE,
|
|
43
|
-
message: {
|
|
44
|
-
...safeUserOperation,
|
|
45
|
-
nonce: (0, viem_1.toHex)(safeUserOperation.nonce),
|
|
46
|
-
validAfter: (0, viem_1.toHex)(safeUserOperation.validAfter),
|
|
47
|
-
validUntil: (0, viem_1.toHex)(safeUserOperation.validUntil),
|
|
48
|
-
maxFeePerGas: (0, viem_1.toHex)(safeUserOperation.maxFeePerGas),
|
|
49
|
-
maxPriorityFeePerGas: (0, viem_1.toHex)(safeUserOperation.maxPriorityFeePerGas)
|
|
50
|
-
},
|
|
51
|
-
primaryType: 'SafeOp'
|
|
52
|
-
});
|
|
53
|
-
return new protocol_kit_1.EthSafeSignature(signerAddress, signature);
|
|
54
|
-
}
|
|
55
|
-
exports.signSafeOp = signSafeOp;
|
|
56
|
-
/**
|
|
57
|
-
* Encodes multi-send data from transactions batch.
|
|
58
|
-
*
|
|
59
|
-
* @param {MetaTransactionData[]} transactions - an array of transaction to to be encoded.
|
|
60
|
-
* @return {string} The encoded data string.
|
|
61
|
-
*/
|
|
62
|
-
function encodeMultiSendCallData(transactions) {
|
|
63
|
-
return (0, viem_1.encodeFunctionData)({
|
|
64
|
-
abi: constants_1.ABI,
|
|
65
|
-
functionName: 'multiSend',
|
|
66
|
-
args: [
|
|
67
|
-
(0, protocol_kit_1.encodeMultiSendData)(transactions.map((tx) => ({ ...tx, operation: tx.operation ?? types_kit_1.OperationType.Call })))
|
|
68
|
-
]
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
exports.encodeMultiSendCallData = encodeMultiSendCallData;
|
|
72
|
-
/**
|
|
73
|
-
* Gets the safe user operation hash.
|
|
74
|
-
*
|
|
75
|
-
* @param {SafeUserOperation} safeUserOperation - The SafeUserOperation.
|
|
76
|
-
* @param {bigint} chainId - The chain id.
|
|
77
|
-
* @param {string} safe4337ModuleAddress - The Safe 4337 module address.
|
|
78
|
-
* @return {string} The hash of the safe operation.
|
|
79
|
-
*/
|
|
80
|
-
function calculateSafeUserOperationHash(safeUserOperation, chainId, safe4337ModuleAddress) {
|
|
81
|
-
return (0, viem_1.hashTypedData)({
|
|
82
|
-
domain: {
|
|
83
|
-
chainId: Number(chainId),
|
|
84
|
-
verifyingContract: safe4337ModuleAddress
|
|
85
|
-
},
|
|
86
|
-
types: constants_1.EIP712_SAFE_OPERATION_TYPE,
|
|
87
|
-
primaryType: 'SafeOp',
|
|
88
|
-
message: safeUserOperation
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
exports.calculateSafeUserOperationHash = calculateSafeUserOperationHash;
|
|
92
|
-
/**
|
|
93
|
-
* Converts various bigint values from a UserOperation to their hexadecimal representation.
|
|
94
|
-
*
|
|
95
|
-
* @param {UserOperation} userOperation - The UserOperation object whose values are to be converted.
|
|
96
|
-
* @returns {UserOperation} A new UserOperation object with the values converted to hexadecimal.
|
|
97
|
-
*/
|
|
98
|
-
function userOperationToHexValues(userOperation) {
|
|
99
|
-
const userOperationWithHexValues = {
|
|
100
|
-
...userOperation,
|
|
101
|
-
nonce: (0, viem_1.toHex)(BigInt(userOperation.nonce)),
|
|
102
|
-
callGasLimit: (0, viem_1.toHex)(userOperation.callGasLimit),
|
|
103
|
-
verificationGasLimit: (0, viem_1.toHex)(userOperation.verificationGasLimit),
|
|
104
|
-
preVerificationGas: (0, viem_1.toHex)(userOperation.preVerificationGas),
|
|
105
|
-
maxFeePerGas: (0, viem_1.toHex)(userOperation.maxFeePerGas),
|
|
106
|
-
maxPriorityFeePerGas: (0, viem_1.toHex)(userOperation.maxPriorityFeePerGas)
|
|
107
|
-
};
|
|
108
|
-
return userOperationWithHexValues;
|
|
109
|
-
}
|
|
110
|
-
exports.userOperationToHexValues = userOperationToHexValues;
|
|
111
|
-
/**
|
|
112
|
-
* Passkey Dummy client data JSON fields. This can be used for gas estimations, as it pads the fields enough
|
|
113
|
-
* to account for variations in WebAuthn implementations.
|
|
114
|
-
*/
|
|
115
|
-
exports.DUMMY_CLIENT_DATA_FIELDS = [
|
|
116
|
-
`"origin":"https://safe.global"`,
|
|
117
|
-
`"padding":"This pads the clientDataJSON so that we can leave room for additional implementation specific fields for a more accurate 'preVerificationGas' estimate."`
|
|
118
|
-
].join(',');
|
|
119
|
-
/**
|
|
120
|
-
* Dummy authenticator data. This can be used for gas estimations, as it ensures that the correct
|
|
121
|
-
* authenticator flags are set.
|
|
122
|
-
*/
|
|
123
|
-
exports.DUMMY_AUTHENTICATOR_DATA = new Uint8Array(37);
|
|
124
|
-
// Authenticator data is the concatenation of:
|
|
125
|
-
// - 32 byte SHA-256 hash of the relying party ID
|
|
126
|
-
// - 1 byte for the user verification flag
|
|
127
|
-
// - 4 bytes for the signature count
|
|
128
|
-
// We fill it all with `0xfe` and set the appropriate user verification flag.
|
|
129
|
-
exports.DUMMY_AUTHENTICATOR_DATA.fill(0xfe);
|
|
130
|
-
exports.DUMMY_AUTHENTICATOR_DATA[32] = 0x04;
|
|
131
|
-
/**
|
|
132
|
-
* This method creates a dummy signature for the SafeOperation based on the Safe threshold. We assume that all owners are passkeys
|
|
133
|
-
* This is useful for gas estimations
|
|
134
|
-
* @param userOperation - The user operation
|
|
135
|
-
* @param signer - The signer
|
|
136
|
-
* @param threshold - The Safe threshold
|
|
137
|
-
* @returns The user operation with the dummy passkey signature
|
|
138
|
-
*/
|
|
139
|
-
function addDummySignature(userOperation, signer, threshold) {
|
|
140
|
-
const signatures = [];
|
|
141
|
-
for (let i = 0; i < threshold; i++) {
|
|
142
|
-
const isContractSignature = true;
|
|
143
|
-
const passkeySignature = getSignatureBytes({
|
|
144
|
-
authenticatorData: exports.DUMMY_AUTHENTICATOR_DATA,
|
|
145
|
-
clientDataFields: exports.DUMMY_CLIENT_DATA_FIELDS,
|
|
146
|
-
r: BigInt(`0x${'ec'.repeat(32)}`),
|
|
147
|
-
s: BigInt(`0x${'d5a'.repeat(21)}f`)
|
|
148
|
-
});
|
|
149
|
-
signatures.push(new protocol_kit_1.EthSafeSignature(signer, passkeySignature, isContractSignature));
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
...userOperation,
|
|
153
|
-
signature: (0, viem_1.encodePacked)(['uint48', 'uint48', 'bytes'], [0, 0, (0, protocol_kit_1.buildSignatureBytes)(signatures)])
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
exports.addDummySignature = addDummySignature;
|
|
157
|
-
/**
|
|
158
|
-
* Encodes the given WebAuthn signature into a string. This computes the ABI-encoded signature parameters:
|
|
159
|
-
* ```solidity
|
|
160
|
-
* abi.encode(authenticatorData, clientDataFields, r, s);
|
|
161
|
-
* ```
|
|
162
|
-
*
|
|
163
|
-
* @param authenticatorData - The authenticator data as a Uint8Array.
|
|
164
|
-
* @param clientDataFields - The client data fields as a string.
|
|
165
|
-
* @param r - The value of r as a bigint.
|
|
166
|
-
* @param s - The value of s as a bigint.
|
|
167
|
-
* @returns The encoded string.
|
|
168
|
-
*/
|
|
169
|
-
function getSignatureBytes({ authenticatorData, clientDataFields, r, s }) {
|
|
170
|
-
// Helper functions
|
|
171
|
-
// Convert a number to a 64-byte hex string with padded upto Hex string with 32 bytes
|
|
172
|
-
const encodeUint256 = (x) => x.toString(16).padStart(64, '0');
|
|
173
|
-
// Calculate the byte size of the dynamic data along with the length parameter alligned to 32 bytes
|
|
174
|
-
const byteSize = (data) => 32 * (Math.ceil(data.length / 32) + 1); // +1 is for the length parameter
|
|
175
|
-
// Encode dynamic data padded with zeros if necessary in 32 bytes chunks
|
|
176
|
-
const encodeBytes = (data) => `${encodeUint256(data.length)}${(0, viem_1.toHex)(data).slice(2)}`.padEnd(byteSize(data) * 2, '0');
|
|
177
|
-
// authenticatorData starts after the first four words.
|
|
178
|
-
const authenticatorDataOffset = 32 * 4;
|
|
179
|
-
// clientDataFields starts immediately after the authenticator data.
|
|
180
|
-
const clientDataFieldsOffset = authenticatorDataOffset + byteSize(authenticatorData);
|
|
181
|
-
return ('0x' +
|
|
182
|
-
encodeUint256(authenticatorDataOffset) +
|
|
183
|
-
encodeUint256(clientDataFieldsOffset) +
|
|
184
|
-
encodeUint256(r) +
|
|
185
|
-
encodeUint256(s) +
|
|
186
|
-
encodeBytes(authenticatorData) +
|
|
187
|
-
encodeBytes(new TextEncoder().encode(clientDataFields)));
|
|
188
|
-
}
|
|
189
|
-
exports.getSignatureBytes = getSignatureBytes;
|
|
190
|
-
//# sourceMappingURL=utils.js.map
|