@safe-global/relay-kit 3.0.1 → 3.1.0-alpha.1
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/packs/safe-4337/Safe4337Pack.d.ts +11 -5
- package/dist/src/packs/safe-4337/Safe4337Pack.js +184 -108
- package/dist/src/packs/safe-4337/Safe4337Pack.js.map +1 -1
- package/dist/src/packs/safe-4337/Safe4337Pack.test.js +218 -29
- package/dist/src/packs/safe-4337/Safe4337Pack.test.js.map +1 -1
- package/dist/src/packs/safe-4337/SafeOperation.d.ts +3 -1
- package/dist/src/packs/safe-4337/SafeOperation.js +2 -1
- package/dist/src/packs/safe-4337/SafeOperation.js.map +1 -1
- package/dist/src/packs/safe-4337/SafeOperation.test.js +5 -0
- package/dist/src/packs/safe-4337/SafeOperation.test.js.map +1 -1
- package/dist/src/packs/safe-4337/constants.d.ts +2 -0
- package/dist/src/packs/safe-4337/constants.js +5 -2
- package/dist/src/packs/safe-4337/constants.js.map +1 -1
- package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.js +2 -2
- package/dist/src/packs/safe-4337/estimators/PimlicoFeeEstimator.js.map +1 -1
- package/dist/src/packs/safe-4337/testing-utils/fixtures.d.ts +36 -0
- package/dist/src/packs/safe-4337/testing-utils/fixtures.js +41 -5
- package/dist/src/packs/safe-4337/testing-utils/fixtures.js.map +1 -1
- package/dist/src/packs/safe-4337/testing-utils/helpers.js +0 -1
- package/dist/src/packs/safe-4337/testing-utils/helpers.js.map +1 -1
- package/dist/src/packs/safe-4337/types.d.ts +2 -4
- package/dist/src/packs/safe-4337/utils/entrypoint.d.ts +4 -0
- package/dist/src/packs/safe-4337/utils/entrypoint.js +23 -0
- package/dist/src/packs/safe-4337/utils/entrypoint.js.map +1 -0
- package/dist/src/packs/safe-4337/utils.d.ts +61 -5
- package/dist/src/packs/safe-4337/utils.js +131 -9
- package/dist/src/packs/safe-4337/utils.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RPC_4337_CALLS = exports.INTERFACES = exports.EIP712_SAFE_OPERATION_TYPE = exports.DEFAULT_SAFE_MODULES_VERSION = exports.DEFAULT_SAFE_VERSION = void 0;
|
|
3
|
+
exports.RPC_4337_CALLS = exports.ENTRYPOINT_ADDRESS_V07 = exports.ENTRYPOINT_ADDRESS_V06 = exports.INTERFACES = exports.EIP712_SAFE_OPERATION_TYPE = exports.DEFAULT_SAFE_MODULES_VERSION = exports.DEFAULT_SAFE_VERSION = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
5
|
exports.DEFAULT_SAFE_VERSION = '1.4.1';
|
|
6
6
|
exports.DEFAULT_SAFE_MODULES_VERSION = '0.2.0';
|
|
@@ -25,8 +25,11 @@ exports.INTERFACES = new ethers_1.ethers.Interface([
|
|
|
25
25
|
'function enableModules(address[])',
|
|
26
26
|
'function multiSend(bytes memory transactions) public payable',
|
|
27
27
|
'function executeUserOp(address to, uint256 value, bytes data, uint8 operation)',
|
|
28
|
-
'function approve(address _spender, uint256 _value)'
|
|
28
|
+
'function approve(address _spender, uint256 _value)',
|
|
29
|
+
'function configure((uint256 x, uint256 y, uint176 verifiers) signer)'
|
|
29
30
|
]);
|
|
31
|
+
exports.ENTRYPOINT_ADDRESS_V06 = '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789';
|
|
32
|
+
exports.ENTRYPOINT_ADDRESS_V07 = '0x0000000071727De22E5E9d8BAf0edAc6f37da032';
|
|
30
33
|
exports.RPC_4337_CALLS = {
|
|
31
34
|
ESTIMATE_USER_OPERATION_GAS: 'eth_estimateUserOperationGas',
|
|
32
35
|
SEND_USER_OPERATION: 'eth_sendUserOperation',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/packs/safe-4337/constants.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAElB,QAAA,oBAAoB,GAAG,OAAO,CAAA;AAC9B,QAAA,4BAA4B,GAAG,OAAO,CAAA;AAEtC,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;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/packs/safe-4337/constants.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAElB,QAAA,oBAAoB,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5C,0BAA0B,EAAE,4BAA4B;IACxD,0BAA0B,EAAE,6BAA6B;IACzD,sBAAsB,EAAE,0BAA0B;IAClD,QAAQ,EAAE,aAAa;IACvB,sBAAsB,EAAE,yBAAyB;CAClD,CAAA"}
|
|
@@ -20,8 +20,8 @@ class PimlicoFeeEstimator {
|
|
|
20
20
|
}
|
|
21
21
|
async adjustEstimation({ userOperation }) {
|
|
22
22
|
return {
|
|
23
|
-
callGasLimit: userOperation.callGasLimit + userOperation.callGasLimit / 2n,
|
|
24
|
-
verificationGasLimit: userOperation.verificationGasLimit
|
|
23
|
+
callGasLimit: userOperation.callGasLimit + userOperation.callGasLimit / 2n, // +50%
|
|
24
|
+
verificationGasLimit: userOperation.verificationGasLimit * 4n // +300%
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
async getPaymasterEstimation({ userOperation, paymasterUrl, entryPoint, sponsorshipPolicyId }) {
|
|
@@ -1 +1 @@
|
|
|
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;;
|
|
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;;IAwCA,CAAC;IAvCC,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,CAAC,QAAQ;SACvE,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,MAAM,GAAG,mBAAmB;YAChC,CAAC,CAAC,CAAC,IAAA,gCAAwB,EAAC,aAAa,CAAC,EAAE,UAAU,EAAE,EAAE,mBAAmB,EAAE,CAAC;YAChF,CAAC,CAAC,CAAC,IAAA,gCAAwB,EAAC,aAAa,CAAC,EAAE,UAAU,CAAC,CAAA;QAEzD,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,0BAAc,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAA;QAE7F,OAAO,WAAW,CAAA;IACpB,CAAC;CASF;AAxCD,kDAwCC;kFAPC,KAAK,0CACH,aAAqC;IAErC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAA;IAEjF,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -5,9 +5,12 @@ export declare const SAFE_ADDRESS_v1_4_1 = "0x717f4BB83D8DF2e5a3Cc603Ee27263ac9E
|
|
|
5
5
|
export declare const SAFE_ADDRESS_v1_3_0 = "0x8C35a08Af278518B59D04ddDe3F1b370aD766D22";
|
|
6
6
|
export declare const SAFE_ADDRESS_4337_MODULE_NOT_ENABLED = "0xfC82a1e4A045a44527e8b45FC70332C8F66fc32B";
|
|
7
7
|
export declare const SAFE_ADDRESS_4337_FALLBACKHANDLER_NOT_ENABLED = "0xA6FDc4e18404E1715D1bC51B07266c91393C6622";
|
|
8
|
+
export declare const SAFE_ADDRESS_4337_PASSKEY = "0x76ddC0104697B5c58D8C9a7fD5723A345d5aA906";
|
|
9
|
+
export declare const SAFE_MODULES_V0_3_0 = "0.3.0";
|
|
8
10
|
export declare const PAYMASTER_ADDRESS = "0x0000000000325602a77416A16136FDafd04b299f";
|
|
9
11
|
export declare const PAYMASTER_TOKEN_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
|
|
10
12
|
export declare const CHAIN_ID = "0xaa36a7";
|
|
13
|
+
export declare const MODULE_ADDRESS = "0xa581c4A4DB7175302464fF3C06380BC3270b4037";
|
|
11
14
|
export declare const RPC_URL = "https://sepolia.gateway.tenderly.co";
|
|
12
15
|
export declare const BUNDLER_URL = "https://bundler.url";
|
|
13
16
|
export declare const PAYMASTER_URL = "https://paymaster.url";
|
|
@@ -87,6 +90,39 @@ export declare const GAS_ESTIMATION: {
|
|
|
87
90
|
preVerificationGas: string;
|
|
88
91
|
callGasLimit: string;
|
|
89
92
|
};
|
|
93
|
+
export declare const SAFE_OPERATION_RESPONSE: {
|
|
94
|
+
created: string;
|
|
95
|
+
modified: string;
|
|
96
|
+
safeOperationHash: string;
|
|
97
|
+
validAfter: null;
|
|
98
|
+
validUntil: null;
|
|
99
|
+
moduleAddress: string;
|
|
100
|
+
confirmations: {
|
|
101
|
+
created: string;
|
|
102
|
+
modified: string;
|
|
103
|
+
owner: string;
|
|
104
|
+
signature: string;
|
|
105
|
+
signatureType: string;
|
|
106
|
+
}[];
|
|
107
|
+
preparedSignature: string;
|
|
108
|
+
userOperation: {
|
|
109
|
+
ethereumTxHash: null;
|
|
110
|
+
sender: string;
|
|
111
|
+
userOperationHash: string;
|
|
112
|
+
nonce: number;
|
|
113
|
+
initCode: string;
|
|
114
|
+
callData: string;
|
|
115
|
+
callGasLimit: number;
|
|
116
|
+
verificationGasLimit: number;
|
|
117
|
+
preVerificationGas: number;
|
|
118
|
+
maxFeePerGas: number;
|
|
119
|
+
maxPriorityFeePerGas: number;
|
|
120
|
+
paymaster: null;
|
|
121
|
+
paymasterData: null;
|
|
122
|
+
signature: string;
|
|
123
|
+
entryPoint: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
90
126
|
export declare const SPONSORED_GAS_ESTIMATION: {
|
|
91
127
|
verificationGasLimit: string;
|
|
92
128
|
preVerificationGas: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.USER_OPERATION_GAS_PRICE = exports.SPONSORED_GAS_ESTIMATION = 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.CHAIN_ID = exports.PAYMASTER_TOKEN_ADDRESS = exports.PAYMASTER_ADDRESS = 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;
|
|
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 constants_1 = require("../constants");
|
|
4
5
|
exports.OWNER_1 = '0xFfAC5578BE8AC1B2B9D13b34cAf4A074B96B8A1b';
|
|
5
6
|
exports.OWNER_2 = '0x3059EfD1BCe33be41eeEfd5fb6D520d7fEd54E43';
|
|
6
7
|
exports.PREDICTED_SAFE_ADDRESS = '0x65e0d294F2d17CB9fB0f65111E9Ac8a00C4049dA';
|
|
@@ -8,17 +9,17 @@ exports.SAFE_ADDRESS_v1_4_1 = '0x717f4BB83D8DF2e5a3Cc603Ee27263ac9EFB6c12';
|
|
|
8
9
|
exports.SAFE_ADDRESS_v1_3_0 = '0x8C35a08Af278518B59D04ddDe3F1b370aD766D22';
|
|
9
10
|
exports.SAFE_ADDRESS_4337_MODULE_NOT_ENABLED = '0xfC82a1e4A045a44527e8b45FC70332C8F66fc32B';
|
|
10
11
|
exports.SAFE_ADDRESS_4337_FALLBACKHANDLER_NOT_ENABLED = '0xA6FDc4e18404E1715D1bC51B07266c91393C6622';
|
|
12
|
+
exports.SAFE_ADDRESS_4337_PASSKEY = '0x76ddC0104697B5c58D8C9a7fD5723A345d5aA906'; // Safe owned by passkey signer + 4337 module + fallback handler enabled
|
|
13
|
+
exports.SAFE_MODULES_V0_3_0 = '0.3.0';
|
|
11
14
|
exports.PAYMASTER_ADDRESS = '0x0000000000325602a77416A16136FDafd04b299f';
|
|
12
15
|
exports.PAYMASTER_TOKEN_ADDRESS = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238';
|
|
13
16
|
exports.CHAIN_ID = '0xaa36a7';
|
|
17
|
+
exports.MODULE_ADDRESS = '0xa581c4A4DB7175302464fF3C06380BC3270b4037';
|
|
14
18
|
exports.RPC_URL = 'https://sepolia.gateway.tenderly.co';
|
|
15
19
|
exports.BUNDLER_URL = 'https://bundler.url';
|
|
16
20
|
exports.PAYMASTER_URL = 'https://paymaster.url';
|
|
17
21
|
exports.USER_OPERATION_HASH = '0x3cb881d1969036174f38d636d22108d1d032145518b53104fc0b1e1296d2cc9c';
|
|
18
|
-
exports.ENTRYPOINTS = [
|
|
19
|
-
'0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
|
|
20
|
-
'0x0000000071727De22E5E9d8BAf0edAc6f37da032'
|
|
21
|
-
];
|
|
22
|
+
exports.ENTRYPOINTS = [constants_1.ENTRYPOINT_ADDRESS_V06, constants_1.ENTRYPOINT_ADDRESS_V07];
|
|
22
23
|
exports.USER_OPERATION_RECEIPT = {
|
|
23
24
|
userOpHash: '0x3cb881d1969036174f38d636d22108d1d032145518b53104fc0b1e1296d2cc9c',
|
|
24
25
|
sender: '0x1405B3659a11a16459fc27Fa1925b60388C38Ce1',
|
|
@@ -81,6 +82,41 @@ exports.GAS_ESTIMATION = {
|
|
|
81
82
|
preVerificationGas: '0x186A0',
|
|
82
83
|
callGasLimit: '0x186A0'
|
|
83
84
|
};
|
|
85
|
+
exports.SAFE_OPERATION_RESPONSE = {
|
|
86
|
+
created: '2024-05-31T10:12:21.169031Z',
|
|
87
|
+
modified: '2024-05-31T10:12:21.169031Z',
|
|
88
|
+
safeOperationHash: '0x5a62b1d61f8fca5f766e9456523bb42765d318058b5f235f967ffe3c2af8b1d7',
|
|
89
|
+
validAfter: null,
|
|
90
|
+
validUntil: null,
|
|
91
|
+
moduleAddress: '0xa581c4A4DB7175302464fF3C06380BC3270b4037',
|
|
92
|
+
confirmations: [
|
|
93
|
+
{
|
|
94
|
+
created: '2024-05-31T10:12:21.184585Z',
|
|
95
|
+
modified: '2024-05-31T10:12:21.184585Z',
|
|
96
|
+
owner: '0x3059EfD1BCe33be41eeEfd5fb6D520d7fEd54E43',
|
|
97
|
+
signature: '0xcb28e74375889e400a4d8aca46b8c59e1cf8825e373c26fa99c2fd7c078080e64fe30eaf1125257bdfe0b358b5caef68aa0420478145f52decc8e74c979d43ab1d',
|
|
98
|
+
signatureType: 'EOA'
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
preparedSignature: '0xcb28e74375889e400a4d8aca46b8c59e1cf8825e373c26fa99c2fd7c078080e64fe30eaf1125257bdfe0b358b5caef68aa0420478145f52decc8e74c979d43ab1c',
|
|
102
|
+
userOperation: {
|
|
103
|
+
ethereumTxHash: null,
|
|
104
|
+
sender: '0xE322e721bCe76cE7FCf3A475f139A9314571ad3D',
|
|
105
|
+
userOperationHash: '0x5d23b7d96a718582601183b1849a4c76b2a13d3787f15074d62a0b6e4a3f76a1',
|
|
106
|
+
nonce: 3,
|
|
107
|
+
initCode: '0x',
|
|
108
|
+
callData: '0x7bb37428000000000000000000000000e322e721bce76ce7fcf3a475f139a9314571ad3d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
109
|
+
callGasLimit: 122497,
|
|
110
|
+
verificationGasLimit: 123498,
|
|
111
|
+
preVerificationGas: 50705,
|
|
112
|
+
maxFeePerGas: 105183831060,
|
|
113
|
+
maxPriorityFeePerGas: 1380000000,
|
|
114
|
+
paymaster: null,
|
|
115
|
+
paymasterData: null,
|
|
116
|
+
signature: '0x54158da2d357241ee1c5c8fca9c4e1bfa6b92a60bd0ed1bea56f4092b008435153d6264a8a8c00925383ecaeaf9d839a2dc1ff006703c65b7f05d0ce8cdd57ab1b',
|
|
117
|
+
entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789'
|
|
118
|
+
}
|
|
119
|
+
};
|
|
84
120
|
exports.SPONSORED_GAS_ESTIMATION = {
|
|
85
121
|
paymasterAndData: '0x1405B3659a11a16459fc27Fa1925b60388C38Ce1',
|
|
86
122
|
...exports.GAS_ESTIMATION
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../../../src/packs/safe-4337/testing-utils/fixtures.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../../../src/packs/safe-4337/testing-utils/fixtures.ts"],"names":[],"mappings":";;;AAAA,4CAA6E;AAEhE,QAAA,OAAO,GAAG,4CAA4C,CAAA;AACtD,QAAA,OAAO,GAAG,4CAA4C,CAAA;AACtD,QAAA,sBAAsB,GAAG,4CAA4C,CAAA;AACrE,QAAA,mBAAmB,GAAG,4CAA4C,CAAA;AAClE,QAAA,mBAAmB,GAAG,4CAA4C,CAAA;AAClE,QAAA,oCAAoC,GAAG,4CAA4C,CAAA;AACnF,QAAA,6CAA6C,GACxD,4CAA4C,CAAA;AACjC,QAAA,yBAAyB,GAAG,4CAA4C,CAAA,CAAC,wEAAwE;AACjJ,QAAA,mBAAmB,GAAG,OAAO,CAAA;AAC7B,QAAA,iBAAiB,GAAG,4CAA4C,CAAA;AAChE,QAAA,uBAAuB,GAAG,4CAA4C,CAAA;AACtE,QAAA,QAAQ,GAAG,UAAU,CAAA;AACrB,QAAA,cAAc,GAAG,4CAA4C,CAAA;AAC7D,QAAA,OAAO,GAAG,qCAAqC,CAAA;AAC/C,QAAA,WAAW,GAAG,qBAAqB,CAAA;AACnC,QAAA,aAAa,GAAG,uBAAuB,CAAA;AAEvC,QAAA,mBAAmB,GAC9B,oEAAoE,CAAA;AAEzD,QAAA,WAAW,GAAG,CAAC,kCAAsB,EAAE,kCAAsB,CAAC,CAAA;AAE9D,QAAA,sBAAsB,GAAG;IACpC,UAAU,EAAE,oEAAoE;IAChF,MAAM,EAAE,4CAA4C;IACpD,KAAK,EAAE,KAAK;IACZ,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,kBAAkB;IACjC,OAAO,EAAE,IAAI;IACb,IAAI,EAA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oBAAoB,EAAE,SAAS;IAC/B,kBAAkB,EAAE,SAAS;IAC7B,YAAY,EAAE,SAAS;CACxB,CAAA;AAEY,QAAA,uBAAuB,GAAG;IACrC,OAAO,EAAE,6BAA6B;IACtC,QAAQ,EAAE,6BAA6B;IACvC,iBAAiB,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,KAAK;SACrB;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../src/packs/safe-4337/testing-utils/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA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AAC,CAAC,CAAA;IAEjD,OAAO,KAAK,CAAC,kBAAkB,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAA;AAC1D,CAAC,CAAA;AALY,QAAA,wBAAwB,4BAKpC;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,5 +1,5 @@
|
|
|
1
1
|
import Safe, { SafeProviderConfig } from '@safe-global/protocol-kit';
|
|
2
|
-
import { EstimateGasData, MetaTransactionData, SafeVersion, UserOperation } from '@safe-global/safe-core-sdk-types';
|
|
2
|
+
import { EstimateGasData, MetaTransactionData, SafeOperationResponse, SafeVersion, UserOperation } from '@safe-global/safe-core-sdk-types';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
4
|
import EthSafeOperation from './SafeOperation';
|
|
5
5
|
type ExistingSafeOptions = {
|
|
@@ -23,7 +23,6 @@ export type Safe4337InitOptions = {
|
|
|
23
23
|
provider: SafeProviderConfig['provider'];
|
|
24
24
|
signer?: SafeProviderConfig['signer'];
|
|
25
25
|
bundlerUrl: string;
|
|
26
|
-
rpcUrl: string;
|
|
27
26
|
safeModulesVersion?: string;
|
|
28
27
|
customContracts?: {
|
|
29
28
|
entryPointAddress?: string;
|
|
@@ -38,7 +37,6 @@ export type Safe4337Options = {
|
|
|
38
37
|
bundlerUrl: string;
|
|
39
38
|
paymasterOptions?: PaymasterOptions;
|
|
40
39
|
bundlerClient: ethers.JsonRpcProvider;
|
|
41
|
-
publicClient: ethers.JsonRpcProvider;
|
|
42
40
|
entryPointAddress: string;
|
|
43
41
|
safe4337ModuleAddress: string;
|
|
44
42
|
};
|
|
@@ -52,7 +50,7 @@ export type Safe4337CreateTransactionProps = {
|
|
|
52
50
|
};
|
|
53
51
|
};
|
|
54
52
|
export type Safe4337ExecutableProps = {
|
|
55
|
-
executable: EthSafeOperation;
|
|
53
|
+
executable: EthSafeOperation | SafeOperationResponse;
|
|
56
54
|
};
|
|
57
55
|
export type EstimateSponsoredGasData = {
|
|
58
56
|
paymasterAndData: string;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,GAA2B;QACxD,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,5 +1,6 @@
|
|
|
1
|
+
import { SafeUserOperation, MetaTransactionData, SafeSignature, UserOperation } from '@safe-global/safe-core-sdk-types';
|
|
2
|
+
import { SafeProvider } from '@safe-global/protocol-kit';
|
|
1
3
|
import { ethers } from 'ethers';
|
|
2
|
-
import { UserOperation } from '@safe-global/safe-core-sdk-types';
|
|
3
4
|
/**
|
|
4
5
|
* Gets the EIP-4337 bundler provider.
|
|
5
6
|
*
|
|
@@ -8,12 +9,30 @@ import { UserOperation } from '@safe-global/safe-core-sdk-types';
|
|
|
8
9
|
*/
|
|
9
10
|
export declare function getEip4337BundlerProvider(bundlerUrl: string): ethers.JsonRpcProvider;
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* Signs typed data.
|
|
12
13
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* @
|
|
14
|
+
* @param {SafeUserOperation} safeUserOperation - Safe user operation to sign.
|
|
15
|
+
* @param {SafeProvider} safeProvider - Safe provider.
|
|
16
|
+
* @param {string} safe4337ModuleAddress - Safe 4337 module address.
|
|
17
|
+
* @return {Promise<SafeSignature>} The SafeSignature object containing the data and the signatures.
|
|
15
18
|
*/
|
|
16
|
-
export declare function
|
|
19
|
+
export declare function signSafeOp(safeUserOperation: SafeUserOperation, safeProvider: SafeProvider, safe4337ModuleAddress: string): Promise<SafeSignature>;
|
|
20
|
+
/**
|
|
21
|
+
* Encodes multi-send data from transactions batch.
|
|
22
|
+
*
|
|
23
|
+
* @param {MetaTransactionData[]} transactions - an array of transaction to to be encoded.
|
|
24
|
+
* @return {string} The encoded data string.
|
|
25
|
+
*/
|
|
26
|
+
export declare function encodeMultiSendCallData(transactions: MetaTransactionData[]): string;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the safe user operation hash.
|
|
29
|
+
*
|
|
30
|
+
* @param {SafeUserOperation} safeUserOperation - The SafeUserOperation.
|
|
31
|
+
* @param {bigint} chainId - The chain id.
|
|
32
|
+
* @param {string} safe4337ModuleAddress - The Safe 4337 module address.
|
|
33
|
+
* @return {string} The hash of the safe operation.
|
|
34
|
+
*/
|
|
35
|
+
export declare function calculateSafeUserOperationHash(safeUserOperation: SafeUserOperation, chainId: bigint, safe4337ModuleAddress: string): string;
|
|
17
36
|
/**
|
|
18
37
|
* Converts various bigint values from a UserOperation to their hexadecimal representation.
|
|
19
38
|
*
|
|
@@ -33,3 +52,40 @@ export declare function userOperationToHexValues(userOperation: UserOperation):
|
|
|
33
52
|
paymasterAndData: string;
|
|
34
53
|
signature: string;
|
|
35
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Passkey Dummy client data JSON fields. This can be used for gas estimations, as it pads the fields enough
|
|
57
|
+
* to account for variations in WebAuthn implementations.
|
|
58
|
+
*/
|
|
59
|
+
export declare const DUMMY_CLIENT_DATA_FIELDS: string;
|
|
60
|
+
/**
|
|
61
|
+
* Dummy authenticator data. This can be used for gas estimations, as it ensures that the correct
|
|
62
|
+
* authenticator flags are set.
|
|
63
|
+
*/
|
|
64
|
+
export declare const DUMMY_AUTHENTICATOR_DATA: Uint8Array;
|
|
65
|
+
/**
|
|
66
|
+
* This method creates a dummy signature for the SafeOperation based on the Safe threshold. We assume that all owners are passkeys
|
|
67
|
+
* This is useful for gas estimations
|
|
68
|
+
* @param userOperation - The user operation
|
|
69
|
+
* @param signer - The signer
|
|
70
|
+
* @param threshold - The Safe threshold
|
|
71
|
+
* @returns The user operation with the dummy passkey signature
|
|
72
|
+
*/
|
|
73
|
+
export declare function addDummySignature(userOperation: UserOperation, signer: string, threshold: number): UserOperation;
|
|
74
|
+
/**
|
|
75
|
+
* Encodes the given WebAuthn signature into a string. This computes the ABI-encoded signature parameters:
|
|
76
|
+
* ```solidity
|
|
77
|
+
* abi.encode(authenticatorData, clientDataFields, r, s);
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @param authenticatorData - The authenticator data as a Uint8Array.
|
|
81
|
+
* @param clientDataFields - The client data fields as a string.
|
|
82
|
+
* @param r - The value of r as a bigint.
|
|
83
|
+
* @param s - The value of s as a bigint.
|
|
84
|
+
* @returns The encoded string.
|
|
85
|
+
*/
|
|
86
|
+
export declare function getSignatureBytes({ authenticatorData, clientDataFields, r, s }: {
|
|
87
|
+
authenticatorData: Uint8Array;
|
|
88
|
+
clientDataFields: string;
|
|
89
|
+
r: bigint;
|
|
90
|
+
s: bigint;
|
|
91
|
+
}): string;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.userOperationToHexValues = exports.
|
|
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 safe_core_sdk_types_1 = require("@safe-global/safe-core-sdk-types");
|
|
5
|
+
const protocol_kit_1 = require("@safe-global/protocol-kit");
|
|
4
6
|
const ethers_1 = require("ethers");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
5
8
|
/**
|
|
6
9
|
* Gets the EIP-4337 bundler provider.
|
|
7
10
|
*
|
|
@@ -16,18 +19,58 @@ function getEip4337BundlerProvider(bundlerUrl) {
|
|
|
16
19
|
}
|
|
17
20
|
exports.getEip4337BundlerProvider = getEip4337BundlerProvider;
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
22
|
+
* Signs typed data.
|
|
20
23
|
*
|
|
21
|
-
* @param {
|
|
22
|
-
* @
|
|
24
|
+
* @param {SafeUserOperation} safeUserOperation - Safe user operation to sign.
|
|
25
|
+
* @param {SafeProvider} safeProvider - Safe provider.
|
|
26
|
+
* @param {string} safe4337ModuleAddress - Safe 4337 module address.
|
|
27
|
+
* @return {Promise<SafeSignature>} The SafeSignature object containing the data and the signatures.
|
|
23
28
|
*/
|
|
24
|
-
function
|
|
25
|
-
const
|
|
26
|
-
|
|
29
|
+
async function signSafeOp(safeUserOperation, safeProvider, safe4337ModuleAddress) {
|
|
30
|
+
const signer = (await safeProvider.getExternalSigner());
|
|
31
|
+
const chainId = await safeProvider.getChainId();
|
|
32
|
+
const signerAddress = await signer.getAddress();
|
|
33
|
+
const signature = await signer.signTypedData({
|
|
34
|
+
chainId,
|
|
35
|
+
verifyingContract: safe4337ModuleAddress
|
|
36
|
+
}, constants_1.EIP712_SAFE_OPERATION_TYPE, {
|
|
37
|
+
...safeUserOperation,
|
|
38
|
+
nonce: ethers_1.ethers.toBeHex(safeUserOperation.nonce),
|
|
39
|
+
validAfter: ethers_1.ethers.toBeHex(safeUserOperation.validAfter),
|
|
40
|
+
validUntil: ethers_1.ethers.toBeHex(safeUserOperation.validUntil),
|
|
41
|
+
maxFeePerGas: ethers_1.ethers.toBeHex(safeUserOperation.maxFeePerGas),
|
|
42
|
+
maxPriorityFeePerGas: ethers_1.ethers.toBeHex(safeUserOperation.maxPriorityFeePerGas)
|
|
27
43
|
});
|
|
28
|
-
return
|
|
44
|
+
return new protocol_kit_1.EthSafeSignature(signerAddress, signature);
|
|
45
|
+
}
|
|
46
|
+
exports.signSafeOp = signSafeOp;
|
|
47
|
+
/**
|
|
48
|
+
* Encodes multi-send data from transactions batch.
|
|
49
|
+
*
|
|
50
|
+
* @param {MetaTransactionData[]} transactions - an array of transaction to to be encoded.
|
|
51
|
+
* @return {string} The encoded data string.
|
|
52
|
+
*/
|
|
53
|
+
function encodeMultiSendCallData(transactions) {
|
|
54
|
+
return constants_1.INTERFACES.encodeFunctionData('multiSend', [
|
|
55
|
+
(0, protocol_kit_1.encodeMultiSendData)(transactions.map((tx) => ({ ...tx, operation: tx.operation ?? safe_core_sdk_types_1.OperationType.Call })))
|
|
56
|
+
]);
|
|
29
57
|
}
|
|
30
|
-
exports.
|
|
58
|
+
exports.encodeMultiSendCallData = encodeMultiSendCallData;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the safe user operation hash.
|
|
61
|
+
*
|
|
62
|
+
* @param {SafeUserOperation} safeUserOperation - The SafeUserOperation.
|
|
63
|
+
* @param {bigint} chainId - The chain id.
|
|
64
|
+
* @param {string} safe4337ModuleAddress - The Safe 4337 module address.
|
|
65
|
+
* @return {string} The hash of the safe operation.
|
|
66
|
+
*/
|
|
67
|
+
function calculateSafeUserOperationHash(safeUserOperation, chainId, safe4337ModuleAddress) {
|
|
68
|
+
return ethers_1.ethers.TypedDataEncoder.hash({
|
|
69
|
+
chainId,
|
|
70
|
+
verifyingContract: safe4337ModuleAddress
|
|
71
|
+
}, constants_1.EIP712_SAFE_OPERATION_TYPE, safeUserOperation);
|
|
72
|
+
}
|
|
73
|
+
exports.calculateSafeUserOperationHash = calculateSafeUserOperationHash;
|
|
31
74
|
/**
|
|
32
75
|
* Converts various bigint values from a UserOperation to their hexadecimal representation.
|
|
33
76
|
*
|
|
@@ -47,4 +90,83 @@ function userOperationToHexValues(userOperation) {
|
|
|
47
90
|
return userOperationWithHexValues;
|
|
48
91
|
}
|
|
49
92
|
exports.userOperationToHexValues = userOperationToHexValues;
|
|
93
|
+
/**
|
|
94
|
+
* Passkey Dummy client data JSON fields. This can be used for gas estimations, as it pads the fields enough
|
|
95
|
+
* to account for variations in WebAuthn implementations.
|
|
96
|
+
*/
|
|
97
|
+
exports.DUMMY_CLIENT_DATA_FIELDS = [
|
|
98
|
+
`"origin":"https://safe.global"`,
|
|
99
|
+
`"padding":"This pads the clientDataJSON so that we can leave room for additional implementation specific fields for a more accurate 'preVerificationGas' estimate."`
|
|
100
|
+
].join(',');
|
|
101
|
+
/**
|
|
102
|
+
* Dummy authenticator data. This can be used for gas estimations, as it ensures that the correct
|
|
103
|
+
* authenticator flags are set.
|
|
104
|
+
*/
|
|
105
|
+
exports.DUMMY_AUTHENTICATOR_DATA = new Uint8Array(37);
|
|
106
|
+
// Authenticator data is the concatenation of:
|
|
107
|
+
// - 32 byte SHA-256 hash of the relying party ID
|
|
108
|
+
// - 1 byte for the user verification flag
|
|
109
|
+
// - 4 bytes for the signature count
|
|
110
|
+
// We fill it all with `0xfe` and set the appropriate user verification flag.
|
|
111
|
+
exports.DUMMY_AUTHENTICATOR_DATA.fill(0xfe);
|
|
112
|
+
exports.DUMMY_AUTHENTICATOR_DATA[32] = 0x04;
|
|
113
|
+
/**
|
|
114
|
+
* This method creates a dummy signature for the SafeOperation based on the Safe threshold. We assume that all owners are passkeys
|
|
115
|
+
* This is useful for gas estimations
|
|
116
|
+
* @param userOperation - The user operation
|
|
117
|
+
* @param signer - The signer
|
|
118
|
+
* @param threshold - The Safe threshold
|
|
119
|
+
* @returns The user operation with the dummy passkey signature
|
|
120
|
+
*/
|
|
121
|
+
function addDummySignature(userOperation, signer, threshold) {
|
|
122
|
+
const signatures = [];
|
|
123
|
+
for (let i = 0; i < threshold; i++) {
|
|
124
|
+
const isContractSignature = true;
|
|
125
|
+
const passkeySignature = getSignatureBytes({
|
|
126
|
+
authenticatorData: exports.DUMMY_AUTHENTICATOR_DATA,
|
|
127
|
+
clientDataFields: exports.DUMMY_CLIENT_DATA_FIELDS,
|
|
128
|
+
r: BigInt(`0x${'ec'.repeat(32)}`),
|
|
129
|
+
s: BigInt(`0x${'d5a'.repeat(21)}f`)
|
|
130
|
+
});
|
|
131
|
+
signatures.push(new protocol_kit_1.EthSafeSignature(signer, passkeySignature, isContractSignature));
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
...userOperation,
|
|
135
|
+
signature: ethers_1.ethers.solidityPacked(['uint48', 'uint48', 'bytes'], [0, 0, (0, protocol_kit_1.buildSignatureBytes)(signatures)])
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
exports.addDummySignature = addDummySignature;
|
|
139
|
+
/**
|
|
140
|
+
* Encodes the given WebAuthn signature into a string. This computes the ABI-encoded signature parameters:
|
|
141
|
+
* ```solidity
|
|
142
|
+
* abi.encode(authenticatorData, clientDataFields, r, s);
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @param authenticatorData - The authenticator data as a Uint8Array.
|
|
146
|
+
* @param clientDataFields - The client data fields as a string.
|
|
147
|
+
* @param r - The value of r as a bigint.
|
|
148
|
+
* @param s - The value of s as a bigint.
|
|
149
|
+
* @returns The encoded string.
|
|
150
|
+
*/
|
|
151
|
+
function getSignatureBytes({ authenticatorData, clientDataFields, r, s }) {
|
|
152
|
+
// Helper functions
|
|
153
|
+
// Convert a number to a 64-byte hex string with padded upto Hex string with 32 bytes
|
|
154
|
+
const encodeUint256 = (x) => x.toString(16).padStart(64, '0');
|
|
155
|
+
// Calculate the byte size of the dynamic data along with the length parameter alligned to 32 bytes
|
|
156
|
+
const byteSize = (data) => 32 * (Math.ceil(data.length / 32) + 1); // +1 is for the length parameter
|
|
157
|
+
// Encode dynamic data padded with zeros if necessary in 32 bytes chunks
|
|
158
|
+
const encodeBytes = (data) => `${encodeUint256(data.length)}${ethers_1.ethers.hexlify(data).slice(2)}`.padEnd(byteSize(data) * 2, '0');
|
|
159
|
+
// authenticatorData starts after the first four words.
|
|
160
|
+
const authenticatorDataOffset = 32 * 4;
|
|
161
|
+
// clientDataFields starts immediately after the authenticator data.
|
|
162
|
+
const clientDataFieldsOffset = authenticatorDataOffset + byteSize(authenticatorData);
|
|
163
|
+
return ('0x' +
|
|
164
|
+
encodeUint256(authenticatorDataOffset) +
|
|
165
|
+
encodeUint256(clientDataFieldsOffset) +
|
|
166
|
+
encodeUint256(r) +
|
|
167
|
+
encodeUint256(s) +
|
|
168
|
+
encodeBytes(authenticatorData) +
|
|
169
|
+
encodeBytes(new TextEncoder().encode(clientDataFields)));
|
|
170
|
+
}
|
|
171
|
+
exports.getSignatureBytes = getSignatureBytes;
|
|
50
172
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/packs/safe-4337/utils.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/packs/safe-4337/utils.ts"],"names":[],"mappings":";;;AAAA,0EAMyC;AACzC,4DAKkC;AAClC,mCAA+B;AAC/B,2CAAoE;AAEpE;;;;;GAKG;AACH,SAAgB,yBAAyB,CAAC,UAAkB;IAC1D,MAAM,QAAQ,GAAG,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