@rhinestone/sdk 1.0.0-alpha.25 → 1.0.0-alpha.27
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/accounts/error.d.ts +12 -5
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +19 -10
- package/dist/src/accounts/index.d.ts +11 -4
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +119 -40
- package/dist/src/accounts/index.test.js +2 -2
- package/dist/src/accounts/kernel.d.ts +1 -1
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +29 -1
- package/dist/src/accounts/kernel.test.js +37 -4
- package/dist/src/accounts/nexus.d.ts +4 -3
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +82 -14
- package/dist/src/accounts/nexus.test.js +35 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +79 -55
- package/dist/src/accounts/safe.test.js +35 -2
- package/dist/src/accounts/signing/common.d.ts +1 -1
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +14 -13
- package/dist/src/accounts/signing/message.js +3 -3
- package/dist/src/accounts/signing/passkeys.d.ts +8 -1
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -1
- package/dist/src/accounts/signing/passkeys.js +35 -0
- package/dist/src/accounts/signing/passkeys.test.js +15 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -1
- package/dist/src/accounts/walletClient.js +2 -1
- package/dist/src/actions/index.d.ts +30 -2
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +37 -6
- package/dist/src/actions/index.test.js +11 -11
- package/dist/src/execution/error.d.ts +8 -1
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +10 -1
- package/dist/src/execution/index.d.ts +12 -3
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +25 -17
- package/dist/src/execution/utils.d.ts +1 -1
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +24 -6
- package/dist/src/index.d.ts +6 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +19 -3
- package/dist/src/modules/common.d.ts +10 -4
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +22 -1
- package/dist/src/modules/index.d.ts +2 -1
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +16 -13
- package/dist/src/modules/index.test.js +8 -7
- package/dist/src/modules/validators/core.d.ts +4 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +24 -14
- package/dist/src/modules/validators/core.test.js +4 -4
- package/dist/src/orchestrator/client.js +6 -6
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +11 -10
- package/dist/src/orchestrator/registry.test.js +4 -4
- package/dist/src/types.d.ts +30 -20
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src/accounts/custom.d.ts +0 -18
- package/dist/src/accounts/custom.d.ts.map +0 -1
- package/dist/src/accounts/custom.js +0 -121
- package/dist/src/accounts/custom.test.d.ts +0 -2
- package/dist/src/accounts/custom.test.d.ts.map +0 -1
- package/dist/src/accounts/custom.test.js +0 -64
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WEBAUTHN_V0_VALIDATOR_ADDRESS = exports.MULTI_FACTOR_VALIDATOR_ADDRESS = exports.WEBAUTHN_VALIDATOR_ADDRESS = exports.OWNABLE_VALIDATOR_ADDRESS = void 0;
|
|
4
4
|
exports.getOwnerValidator = getOwnerValidator;
|
|
5
5
|
exports.getOwnableValidator = getOwnableValidator;
|
|
6
6
|
exports.getWebAuthnValidator = getWebAuthnValidator;
|
|
@@ -8,17 +8,21 @@ exports.getMultiFactorValidator = getMultiFactorValidator;
|
|
|
8
8
|
exports.getSocialRecoveryValidator = getSocialRecoveryValidator;
|
|
9
9
|
exports.getValidator = getValidator;
|
|
10
10
|
exports.getMockSignature = getMockSignature;
|
|
11
|
+
exports.supportsEip712 = supportsEip712;
|
|
11
12
|
const viem_1 = require("viem");
|
|
12
13
|
const common_1 = require("../common");
|
|
13
|
-
const OWNABLE_VALIDATOR_ADDRESS = '
|
|
14
|
+
const OWNABLE_VALIDATOR_ADDRESS = '0x000000000013fdb5234e4e3162a810f54d9f7e98';
|
|
14
15
|
exports.OWNABLE_VALIDATOR_ADDRESS = OWNABLE_VALIDATOR_ADDRESS;
|
|
15
|
-
const WEBAUTHN_VALIDATOR_ADDRESS = '
|
|
16
|
+
const WEBAUTHN_VALIDATOR_ADDRESS = '0x0000000000578c4cb0e472a5462da43c495c3f33';
|
|
16
17
|
exports.WEBAUTHN_VALIDATOR_ADDRESS = WEBAUTHN_VALIDATOR_ADDRESS;
|
|
17
|
-
const SOCIAL_RECOVERY_VALIDATOR_ADDRESS = '
|
|
18
|
-
const MULTI_FACTOR_VALIDATOR_ADDRESS = '
|
|
18
|
+
const SOCIAL_RECOVERY_VALIDATOR_ADDRESS = '0xa04d053b3c8021e8d5bf641816c42daa75d8b597';
|
|
19
|
+
const MULTI_FACTOR_VALIDATOR_ADDRESS = '0xf6bdf42c9be18ceca5c06c42a43daf7fbbe7896b';
|
|
19
20
|
exports.MULTI_FACTOR_VALIDATOR_ADDRESS = MULTI_FACTOR_VALIDATOR_ADDRESS;
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
// Legacy
|
|
22
|
+
const OWNABLE_V0_VALIDATOR_ADDRESS = '0x2483da3a338895199e5e538530213157e931bf06';
|
|
23
|
+
const OWNABLE_BETA_VALIDATOR_ADDRESS = '0x0000000000e9e6e96bcaa3c113187cdb7e38aed9';
|
|
24
|
+
const WEBAUTHN_V0_VALIDATOR_ADDRESS = '0x0000000000578c4cb0e472a5462da43c495c3f33';
|
|
25
|
+
exports.WEBAUTHN_V0_VALIDATOR_ADDRESS = WEBAUTHN_V0_VALIDATOR_ADDRESS;
|
|
22
26
|
const ECDSA_MOCK_SIGNATURE = '0x81d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b';
|
|
23
27
|
const WEBAUTHN_MOCK_SIGNATURE = '0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001b9b86eb98fda3ed4d797d9e690588dfadf17b329a76a47cec935bebf92d7ddc80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000019b2e9410bb6850f9f660a03d609d5a844fb96bcdc87a15139b03ee22c70f469100d2b865a215c3bf786387064effa8fcedcb1d625b5148f8a1236d5e3ff11acf000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763050000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22396a4546696a75684557724d34534f572d7443684a625545484550343456636a634a2d42716f3166544d38222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a38303830222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000';
|
|
24
28
|
function getOwnerValidator(config) {
|
|
@@ -26,8 +30,7 @@ function getOwnerValidator(config) {
|
|
|
26
30
|
}
|
|
27
31
|
function getMockSignature(ownerSet) {
|
|
28
32
|
switch (ownerSet.type) {
|
|
29
|
-
case 'ecdsa':
|
|
30
|
-
case 'ecdsa-v0': {
|
|
33
|
+
case 'ecdsa': {
|
|
31
34
|
const owners = ownerSet.accounts.map((account) => account.address);
|
|
32
35
|
const signatures = owners.map(() => ECDSA_MOCK_SIGNATURE);
|
|
33
36
|
return (0, viem_1.concat)(signatures);
|
|
@@ -68,9 +71,7 @@ function getMockSignature(ownerSet) {
|
|
|
68
71
|
function getValidator(owners) {
|
|
69
72
|
switch (owners.type) {
|
|
70
73
|
case 'ecdsa':
|
|
71
|
-
return getOwnableValidator(owners.threshold ?? 1, owners.accounts.map((account) => account.address));
|
|
72
|
-
case 'ecdsa-v0':
|
|
73
|
-
return getOwnableValidator(owners.threshold ?? 1, owners.accounts.map((account) => account.address), OWNABLE_V0_VALIDATOR_ADDRESS);
|
|
74
|
+
return getOwnableValidator(owners.threshold ?? 1, owners.accounts.map((account) => account.address), owners.module);
|
|
74
75
|
case 'passkey':
|
|
75
76
|
return getWebAuthnValidator(owners.threshold ?? 1, owners.accounts.map((account) => ({
|
|
76
77
|
pubKey: account.publicKey,
|
|
@@ -96,7 +97,7 @@ function getOwnableValidator(threshold, owners, address) {
|
|
|
96
97
|
type: common_1.MODULE_TYPE_ID_VALIDATOR,
|
|
97
98
|
};
|
|
98
99
|
}
|
|
99
|
-
function getWebAuthnValidator(threshold, webAuthnCredentials) {
|
|
100
|
+
function getWebAuthnValidator(threshold, webAuthnCredentials, address) {
|
|
100
101
|
function getPublicKey(webAuthnCredential) {
|
|
101
102
|
if (typeof webAuthnCredential.pubKey === 'string' ||
|
|
102
103
|
webAuthnCredential.pubKey instanceof Uint8Array) {
|
|
@@ -117,7 +118,7 @@ function getWebAuthnValidator(threshold, webAuthnCredentials) {
|
|
|
117
118
|
}
|
|
118
119
|
const publicKeys = webAuthnCredentials.map(getPublicKey);
|
|
119
120
|
return {
|
|
120
|
-
address: WEBAUTHN_VALIDATOR_ADDRESS,
|
|
121
|
+
address: address ?? WEBAUTHN_VALIDATOR_ADDRESS,
|
|
121
122
|
initData: (0, viem_1.encodeAbiParameters)([
|
|
122
123
|
{ name: 'threshold', type: 'uint256' },
|
|
123
124
|
{
|
|
@@ -225,3 +226,12 @@ function parsePublicKey(publicKey) {
|
|
|
225
226
|
y: BigInt((0, viem_1.bytesToHex)(y)),
|
|
226
227
|
};
|
|
227
228
|
}
|
|
229
|
+
function supportsEip712(validator) {
|
|
230
|
+
switch (validator.address.toLowerCase()) {
|
|
231
|
+
case OWNABLE_BETA_VALIDATOR_ADDRESS: // Ownable Validator V1-beta
|
|
232
|
+
case OWNABLE_V0_VALIDATOR_ADDRESS: // Ownable Validator V0
|
|
233
|
+
return false;
|
|
234
|
+
default:
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
@@ -14,7 +14,7 @@ const core_1 = require("./core");
|
|
|
14
14
|
});
|
|
15
15
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
16
16
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
17
|
-
(0, vitest_1.expect)(validator.address).toEqual('
|
|
17
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x000000000013fdb5234e4e3162a810f54d9f7e98');
|
|
18
18
|
(0, vitest_1.expect)(validator.initData).toEqual('0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
19
19
|
});
|
|
20
20
|
(0, vitest_1.test)('ECDSA: two addresses', () => {
|
|
@@ -24,7 +24,7 @@ const core_1 = require("./core");
|
|
|
24
24
|
});
|
|
25
25
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
26
26
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
27
|
-
(0, vitest_1.expect)(validator.address).toEqual('
|
|
27
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x000000000013fdb5234e4e3162a810f54d9f7e98');
|
|
28
28
|
(0, vitest_1.expect)(validator.initData).toEqual('0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
29
29
|
});
|
|
30
30
|
(0, vitest_1.test)('ECDSA: three addresses, custom threshold', () => {
|
|
@@ -35,7 +35,7 @@ const core_1 = require("./core");
|
|
|
35
35
|
});
|
|
36
36
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
37
37
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
38
|
-
(0, vitest_1.expect)(validator.address).toEqual('
|
|
38
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x000000000013fdb5234e4e3162a810f54d9f7e98');
|
|
39
39
|
(0, vitest_1.expect)(validator.initData).toEqual('0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
40
40
|
});
|
|
41
41
|
(0, vitest_1.test)('Passkey', () => {
|
|
@@ -45,7 +45,7 @@ const core_1 = require("./core");
|
|
|
45
45
|
});
|
|
46
46
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
47
47
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
48
|
-
(0, vitest_1.expect)(validator.address).toEqual('
|
|
48
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x0000000000578c4cb0e472a5462da43c495c3f33');
|
|
49
49
|
(0, vitest_1.expect)(validator.initData).toEqual('0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d10000000000000000000000000000000000000000000000000000000000000000');
|
|
50
50
|
});
|
|
51
51
|
});
|
|
@@ -49,7 +49,7 @@ class Orchestrator {
|
|
|
49
49
|
}
|
|
50
50
|
catch (error) {
|
|
51
51
|
this.parseError(error);
|
|
52
|
-
throw new
|
|
52
|
+
throw new error_1.OrchestratorError({ message: 'Failed to get portfolio' });
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async getMaxTokenAmount(userAddress, destinationChainId, destinationTokenAddress, destinationGasUnits, sponsored) {
|
|
@@ -112,7 +112,7 @@ class Orchestrator {
|
|
|
112
112
|
}
|
|
113
113
|
catch (error) {
|
|
114
114
|
this.parseError(error);
|
|
115
|
-
throw new
|
|
115
|
+
throw new error_1.OrchestratorError({ message: 'Failed to get intent cost' });
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
async getIntentRoute(input) {
|
|
@@ -128,7 +128,7 @@ class Orchestrator {
|
|
|
128
128
|
}
|
|
129
129
|
catch (error) {
|
|
130
130
|
this.parseError(error);
|
|
131
|
-
throw new
|
|
131
|
+
throw new error_1.OrchestratorError({ message: 'Failed to get intent route' });
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
async submitIntent(signedIntentOp) {
|
|
@@ -144,7 +144,7 @@ class Orchestrator {
|
|
|
144
144
|
}
|
|
145
145
|
catch (error) {
|
|
146
146
|
this.parseError(error);
|
|
147
|
-
throw new
|
|
147
|
+
throw new error_1.OrchestratorError({ message: 'Failed to submit intent' });
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
async simulateIntent(signedIntentOp) {
|
|
@@ -160,7 +160,7 @@ class Orchestrator {
|
|
|
160
160
|
}
|
|
161
161
|
catch (error) {
|
|
162
162
|
this.parseError(error);
|
|
163
|
-
throw new
|
|
163
|
+
throw new error_1.OrchestratorError({ message: 'Failed to simulate intent' });
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
async getIntentOpStatus(intentId) {
|
|
@@ -174,7 +174,7 @@ class Orchestrator {
|
|
|
174
174
|
}
|
|
175
175
|
catch (error) {
|
|
176
176
|
this.parseError(error);
|
|
177
|
-
throw new
|
|
177
|
+
throw new error_1.OrchestratorError({ message: 'Failed to get intent op status' });
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
parseError(error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAA0B,MAAM,MAAM,CAAA;AAcvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAA0B,MAAM,MAAM,CAAA;AAcvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1D,iBAAS,oBAAoB,IAAI,MAAM,EAAE,CAExC;AAMD,iBAAS,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAY7C;AAED,iBAAS,cAAc,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAetE;AAED,iBAAS,eAAe,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAsB3E;AAOD,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAmB5C;AAED,iBAAS,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAG3C;AAED,iBAAS,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAS3E;AAED,iBAAS,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAO1D;AAED,iBAAS,2BAA2B,CAAC,UAAU,CAAC,EAAE,OAAO;;EAaxD;AAED,iBAAS,mBAAmB,CAC1B,KAAK,EAAE,WAAW,GAAG,OAAO,EAC5B,OAAO,EAAE,MAAM,GACd,OAAO,CAKT;AAED,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,uBAAuB,EACvB,2BAA2B,EAC3B,mBAAmB,GACpB,CAAA"}
|
|
@@ -13,6 +13,7 @@ exports.resolveTokenAddress = resolveTokenAddress;
|
|
|
13
13
|
const shared_configs_1 = require("@rhinestone/shared-configs");
|
|
14
14
|
const viem_1 = require("viem");
|
|
15
15
|
const chains_1 = require("viem/chains");
|
|
16
|
+
const error_1 = require("./error");
|
|
16
17
|
function getSupportedChainIds() {
|
|
17
18
|
return shared_configs_1.chains.map((chain) => chain.id);
|
|
18
19
|
}
|
|
@@ -22,42 +23,42 @@ function getChainEntry(chainId) {
|
|
|
22
23
|
function getWethAddress(chain) {
|
|
23
24
|
const chainEntry = getChainEntry(chain.id);
|
|
24
25
|
if (!chainEntry) {
|
|
25
|
-
throw new
|
|
26
|
+
throw new error_1.UnsupportedChainError(chain.id);
|
|
26
27
|
}
|
|
27
28
|
const wethToken = chainEntry.tokens.find((token) => token.symbol === 'WETH');
|
|
28
29
|
if (!wethToken) {
|
|
29
|
-
throw new
|
|
30
|
+
throw new error_1.UnsupportedTokenError('WETH', chain.id);
|
|
30
31
|
}
|
|
31
32
|
return wethToken.address;
|
|
32
33
|
}
|
|
33
34
|
function getTokenSymbol(tokenAddress, chainId) {
|
|
34
35
|
const chainEntry = getChainEntry(chainId);
|
|
35
36
|
if (!chainEntry) {
|
|
36
|
-
throw new
|
|
37
|
+
throw new error_1.UnsupportedChainError(chainId);
|
|
37
38
|
}
|
|
38
39
|
const token = chainEntry.tokens.find((t) => t.address.toLowerCase() === tokenAddress.toLowerCase());
|
|
39
40
|
if (!token) {
|
|
40
|
-
throw new
|
|
41
|
+
throw new error_1.UnsupportedTokenError(tokenAddress, chainId);
|
|
41
42
|
}
|
|
42
43
|
return token.symbol;
|
|
43
44
|
}
|
|
44
45
|
function getTokenAddress(tokenSymbol, chainId) {
|
|
45
46
|
if (chainId === chains_1.polygon.id && tokenSymbol === 'ETH') {
|
|
46
|
-
throw new
|
|
47
|
+
throw new error_1.UnsupportedTokenError(tokenSymbol, chainId);
|
|
47
48
|
}
|
|
48
49
|
if (chainId === chains_1.sonic.id && tokenSymbol !== 'USDC') {
|
|
49
|
-
throw new
|
|
50
|
+
throw new error_1.UnsupportedTokenError(tokenSymbol, chainId);
|
|
50
51
|
}
|
|
51
52
|
if (tokenSymbol === 'ETH') {
|
|
52
53
|
return viem_1.zeroAddress;
|
|
53
54
|
}
|
|
54
55
|
const chainEntry = getChainEntry(chainId);
|
|
55
56
|
if (!chainEntry) {
|
|
56
|
-
throw new
|
|
57
|
+
throw new error_1.UnsupportedChainError(chainId);
|
|
57
58
|
}
|
|
58
59
|
const token = chainEntry.tokens.find((t) => t.symbol === tokenSymbol);
|
|
59
60
|
if (!token) {
|
|
60
|
-
throw new
|
|
61
|
+
throw new error_1.UnsupportedTokenError(tokenSymbol, chainId);
|
|
61
62
|
}
|
|
62
63
|
return token.address;
|
|
63
64
|
}
|
|
@@ -80,7 +81,7 @@ function getChainById(chainId) {
|
|
|
80
81
|
[chains_1.sonic.id]: chains_1.sonic,
|
|
81
82
|
};
|
|
82
83
|
if (!isChainIdSupported(chainId)) {
|
|
83
|
-
throw new
|
|
84
|
+
throw new error_1.UnsupportedChainError(chainId);
|
|
84
85
|
}
|
|
85
86
|
return chains[chainId];
|
|
86
87
|
}
|
|
@@ -98,7 +99,7 @@ function isTokenAddressSupported(address, chainId) {
|
|
|
98
99
|
function getSupportedTokens(chainId) {
|
|
99
100
|
const chainEntry = getChainEntry(chainId);
|
|
100
101
|
if (!chainEntry) {
|
|
101
|
-
throw new
|
|
102
|
+
throw new error_1.UnsupportedChainError(chainId);
|
|
102
103
|
}
|
|
103
104
|
return chainEntry.tokens;
|
|
104
105
|
}
|
|
@@ -73,7 +73,7 @@ const UNSUPPORTED_TOKEN_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
|
73
73
|
(0, vitest_1.expect)(chain.name).toBe(chains_1.mainnet.name);
|
|
74
74
|
});
|
|
75
75
|
(0, vitest_1.test)('throws error for unsupported chain', () => {
|
|
76
|
-
(0, vitest_1.expect)(() => (0, registry_1.getChainById)(UNSUPPORTED_CHAIN_ID)).toThrow(`
|
|
76
|
+
(0, vitest_1.expect)(() => (0, registry_1.getChainById)(UNSUPPORTED_CHAIN_ID)).toThrow(`Unsupported chain ${UNSUPPORTED_CHAIN_ID}`);
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
79
|
(0, vitest_1.describe)('isTestnet', () => {
|
|
@@ -84,7 +84,7 @@ const UNSUPPORTED_TOKEN_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
|
84
84
|
(0, vitest_1.expect)((0, registry_1.isTestnet)(chains_1.sepolia.id)).toBe(true);
|
|
85
85
|
});
|
|
86
86
|
(0, vitest_1.test)('throws error for unsupported chain', () => {
|
|
87
|
-
(0, vitest_1.expect)(() => (0, registry_1.isTestnet)(UNSUPPORTED_CHAIN_ID)).toThrow(`
|
|
87
|
+
(0, vitest_1.expect)(() => (0, registry_1.isTestnet)(UNSUPPORTED_CHAIN_ID)).toThrow(`Unsupported chain ${UNSUPPORTED_CHAIN_ID}`);
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
90
|
(0, vitest_1.describe)('isTokenAddressSupported', () => {
|
|
@@ -104,7 +104,7 @@ const UNSUPPORTED_TOKEN_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
|
104
104
|
(0, vitest_1.expect)(tokens.find((t) => t.symbol === TOKEN_SYMBOLS.USDC)).toBeDefined();
|
|
105
105
|
});
|
|
106
106
|
(0, vitest_1.test)('throws error for unsupported chain', () => {
|
|
107
|
-
(0, vitest_1.expect)(() => (0, registry_1.getSupportedTokens)(UNSUPPORTED_CHAIN_ID)).toThrow(`
|
|
107
|
+
(0, vitest_1.expect)(() => (0, registry_1.getSupportedTokens)(UNSUPPORTED_CHAIN_ID)).toThrow(`Unsupported chain ${UNSUPPORTED_CHAIN_ID}`);
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
(0, vitest_1.describe)('getDefaultAccountAccessList', () => {
|
|
@@ -128,7 +128,7 @@ const UNSUPPORTED_TOKEN_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
|
128
128
|
(0, vitest_1.expect)(result).toBe(TOKEN_ADDRESSES.ETHEREUM_USDC);
|
|
129
129
|
});
|
|
130
130
|
(0, vitest_1.test)('throw error for unsupported token', () => {
|
|
131
|
-
(0, vitest_1.expect)(() => (0, registry_1.resolveTokenAddress)(TOKEN_SYMBOLS.USDT, chains_1.baseSepolia.id)).toThrow(`Unsupported token
|
|
131
|
+
(0, vitest_1.expect)(() => (0, registry_1.resolveTokenAddress)(TOKEN_SYMBOLS.USDT, chains_1.baseSepolia.id)).toThrow(`Unsupported token ${TOKEN_SYMBOLS.USDT} for chain ${chains_1.baseSepolia.id}`);
|
|
132
132
|
});
|
|
133
133
|
(0, vitest_1.test)('throws error for unsupported chain', () => {
|
|
134
134
|
(0, vitest_1.expect)(() => (0, registry_1.resolveTokenAddress)(TOKEN_SYMBOLS.USDC, UNSUPPORTED_CHAIN_ID)).toThrow(`Unsupported chain ${UNSUPPORTED_CHAIN_ID}`);
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
import type { Account, Address, Chain, Hex } from 'viem';
|
|
2
2
|
import type { WebAuthnAccount } from 'viem/account-abstraction';
|
|
3
|
-
import type { ValidatorConfig } from './accounts/utils';
|
|
4
|
-
import type { Module } from './modules/common';
|
|
5
3
|
import type { EnableSessionData } from './modules/validators/smart-sessions';
|
|
6
4
|
import type { SettlementLayer } from './orchestrator/types';
|
|
7
5
|
type AccountType = 'safe' | 'nexus' | 'kernel' | 'startale' | 'custom';
|
|
8
|
-
interface
|
|
9
|
-
type:
|
|
10
|
-
|
|
6
|
+
interface SafeAccount {
|
|
7
|
+
type: 'safe';
|
|
8
|
+
version?: '1.4.1';
|
|
9
|
+
adapter?: '1.0.0' | '2.0.0';
|
|
11
10
|
}
|
|
12
|
-
interface
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
getPackedSignature: (signature: Hex, validator: ValidatorConfig, transformSignature: (signature: Hex) => Hex) => Promise<Hex>;
|
|
20
|
-
getSessionStubSignature: (session: Session, enableData: EnableSessionData | null) => Promise<Hex>;
|
|
21
|
-
signSessionUserOperation: (session: Session, enableData: EnableSessionData | null, hash: Hex) => Promise<Hex>;
|
|
22
|
-
getStubSignature: () => Promise<Hex>;
|
|
23
|
-
sign: (hash: Hex) => Promise<Hex>;
|
|
11
|
+
interface NexusAccount {
|
|
12
|
+
type: 'nexus';
|
|
13
|
+
version?: '1.0.2' | '1.2.0' | 'rhinestone-1.0.0-beta' | 'rhinestone-1.0.0';
|
|
14
|
+
}
|
|
15
|
+
interface KernelAccount {
|
|
16
|
+
type: 'kernel';
|
|
17
|
+
version?: '3.1' | '3.2' | '3.3';
|
|
24
18
|
}
|
|
19
|
+
interface StartaleAccount {
|
|
20
|
+
type: 'startale';
|
|
21
|
+
}
|
|
22
|
+
type AccountProviderConfig = SafeAccount | NexusAccount | KernelAccount | StartaleAccount;
|
|
25
23
|
interface OwnableValidatorConfig {
|
|
26
|
-
type: 'ecdsa'
|
|
24
|
+
type: 'ecdsa';
|
|
27
25
|
accounts: Account[];
|
|
28
26
|
threshold?: number;
|
|
27
|
+
module?: Address;
|
|
29
28
|
}
|
|
30
29
|
interface WebauthnValidatorConfig {
|
|
31
30
|
type: 'passkey';
|
|
32
31
|
accounts: WebAuthnAccount[];
|
|
33
32
|
threshold?: number;
|
|
33
|
+
module?: Address;
|
|
34
34
|
}
|
|
35
35
|
interface MultiFactorValidatorConfig {
|
|
36
36
|
type: 'multi-factor';
|
|
37
37
|
validators: (OwnableValidatorConfig | WebauthnValidatorConfig)[];
|
|
38
38
|
threshold?: number;
|
|
39
|
+
module?: Address;
|
|
39
40
|
}
|
|
40
41
|
interface ProviderConfig {
|
|
41
42
|
type: 'alchemy';
|
|
@@ -109,6 +110,12 @@ interface RhinestoneAccountConfig {
|
|
|
109
110
|
sessions?: Session[];
|
|
110
111
|
recovery?: Recovery;
|
|
111
112
|
eoa?: Account;
|
|
113
|
+
initData?: {
|
|
114
|
+
address: Address;
|
|
115
|
+
factory: Address;
|
|
116
|
+
factoryData: Hex;
|
|
117
|
+
intentExecutorInstalled: boolean;
|
|
118
|
+
};
|
|
112
119
|
provider?: ProviderConfig;
|
|
113
120
|
bundler?: BundlerConfig;
|
|
114
121
|
paymaster?: PaymasterConfig;
|
|
@@ -135,17 +142,19 @@ interface TokenRequest {
|
|
|
135
142
|
}
|
|
136
143
|
type OwnerSignerSet = {
|
|
137
144
|
type: 'owner';
|
|
138
|
-
kind: 'ecdsa'
|
|
145
|
+
kind: 'ecdsa';
|
|
139
146
|
accounts: Account[];
|
|
147
|
+
module?: Address;
|
|
140
148
|
} | {
|
|
141
149
|
type: 'owner';
|
|
142
150
|
kind: 'passkey';
|
|
143
151
|
accounts: WebAuthnAccount[];
|
|
152
|
+
module?: Address;
|
|
144
153
|
} | {
|
|
145
154
|
type: 'owner';
|
|
146
155
|
kind: 'multi-factor';
|
|
147
156
|
validators: ({
|
|
148
|
-
type: 'ecdsa'
|
|
157
|
+
type: 'ecdsa';
|
|
149
158
|
id: number | Hex;
|
|
150
159
|
accounts: Account[];
|
|
151
160
|
} | {
|
|
@@ -153,6 +162,7 @@ type OwnerSignerSet = {
|
|
|
153
162
|
id: number | Hex;
|
|
154
163
|
accounts: WebAuthnAccount[];
|
|
155
164
|
})[];
|
|
165
|
+
module?: Address;
|
|
156
166
|
};
|
|
157
167
|
interface SessionSignerSet {
|
|
158
168
|
type: 'session';
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,KAAK,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEtE,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CAC5B;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,uBAAuB,GAAG,kBAAkB,CAAA;CAC3E;AAED,UAAU,aAAa;IACrB,IAAI,EAAE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AAA;CACb;AAED,UAAU,qBAAsB,SAAQ,eAAe;IACrD,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;IACtB,WAAW,EAAE,KAAK,CAAA;CACnB;AAED,KAAK,WAAW,GAAG,oBAAoB,GAAG,qBAAqB,CAAA;AAE/D,YAAY,EACV,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,EACX,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,SAAS,EACT,OAAO,EACP,QAAQ,EACR,MAAM,EACN,mCAAmC,GACpC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type Abi, type Address, type Hex, type PublicClient } from 'viem';
|
|
2
|
-
import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
-
import type { Module } from '../modules/common';
|
|
4
|
-
import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
5
|
-
import type { RhinestoneAccountConfig, Session } from '../types';
|
|
6
|
-
import { type ValidatorConfig } from './utils';
|
|
7
|
-
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
8
|
-
factory: Address;
|
|
9
|
-
factoryData: Hex;
|
|
10
|
-
};
|
|
11
|
-
declare function getInstallData(config: RhinestoneAccountConfig, module: Module): Hex[];
|
|
12
|
-
declare function getAddress(config: RhinestoneAccountConfig): Address;
|
|
13
|
-
declare function getPackedSignature(config: RhinestoneAccountConfig, signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
14
|
-
declare function getSessionSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
15
|
-
declare function getBaseSmartAccount(address: Address, client: PublicClient, validatorAddress: Address, getStubSignature: () => Promise<Hex>, signUserOperation: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, '0.7'>>>;
|
|
16
|
-
declare function getSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, address: Address, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
17
|
-
export { getDeployArgs, getInstallData, getAddress, getPackedSignature, getSessionSmartAccount, getBaseSmartAccount, getSmartAccount, };
|
|
18
|
-
//# sourceMappingURL=custom.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../accounts/custom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EAEZ,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAEhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;EAMrD;AAED,iBAAS,cAAc,CACrB,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,MAAM,GACb,GAAG,EAAE,CAMP;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAM5D;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,uBAAuB,EAC/B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAWvE;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,iEAyBrC;AAED,iBAAe,mBAAmB,CAChC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,YAAY,EACpB,gBAAgB,EAAE,OAAO,EACzB,gBAAgB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EACpC,iBAAiB,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAC7C,OAAO,CAAC,YAAY,CAAC,0BAA0B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAgE/D;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAelC;AAED,OAAO,EACL,aAAa,EACb,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,GAChB,CAAA"}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDeployArgs = getDeployArgs;
|
|
4
|
-
exports.getInstallData = getInstallData;
|
|
5
|
-
exports.getAddress = getAddress;
|
|
6
|
-
exports.getPackedSignature = getPackedSignature;
|
|
7
|
-
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
8
|
-
exports.getBaseSmartAccount = getBaseSmartAccount;
|
|
9
|
-
exports.getSmartAccount = getSmartAccount;
|
|
10
|
-
const viem_1 = require("viem");
|
|
11
|
-
const account_abstraction_1 = require("viem/account-abstraction");
|
|
12
|
-
const utils_1 = require("./utils");
|
|
13
|
-
function getDeployArgs(config) {
|
|
14
|
-
if (!config.account || !config.account.custom) {
|
|
15
|
-
throw new Error('Account provider not found');
|
|
16
|
-
}
|
|
17
|
-
return config.account.custom.getDeployArgs();
|
|
18
|
-
}
|
|
19
|
-
function getInstallData(config, module) {
|
|
20
|
-
if (!config.account || !config.account.custom) {
|
|
21
|
-
throw new Error('Account provider not found');
|
|
22
|
-
}
|
|
23
|
-
return config.account.custom.getInstallData(module);
|
|
24
|
-
}
|
|
25
|
-
function getAddress(config) {
|
|
26
|
-
if (!config.account || !config.account.custom) {
|
|
27
|
-
throw new Error('Account provider not found');
|
|
28
|
-
}
|
|
29
|
-
return config.account.custom.getAddress();
|
|
30
|
-
}
|
|
31
|
-
async function getPackedSignature(config, signature, validator, transformSignature = (signature) => signature) {
|
|
32
|
-
if (!config.account || !config.account.custom) {
|
|
33
|
-
throw new Error('Account provider not found');
|
|
34
|
-
}
|
|
35
|
-
return config.account.custom.getPackedSignature(signature, validator, transformSignature);
|
|
36
|
-
}
|
|
37
|
-
async function getSessionSmartAccount(config, client, address, session, validatorAddress, enableData) {
|
|
38
|
-
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
39
|
-
if (!config.account || !config.account.custom) {
|
|
40
|
-
throw new Error('Account provider not found');
|
|
41
|
-
}
|
|
42
|
-
return config.account.custom.getSessionStubSignature(session, enableData);
|
|
43
|
-
}, async (hash) => {
|
|
44
|
-
if (!config.account || !config.account.custom) {
|
|
45
|
-
throw new Error('Account provider not found');
|
|
46
|
-
}
|
|
47
|
-
return config.account.custom.signSessionUserOperation(session, enableData, hash);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
async function getBaseSmartAccount(address, client, validatorAddress, getStubSignature, signUserOperation) {
|
|
51
|
-
return await (0, account_abstraction_1.toSmartAccount)({
|
|
52
|
-
client,
|
|
53
|
-
entryPoint: {
|
|
54
|
-
abi: account_abstraction_1.entryPoint07Abi,
|
|
55
|
-
address: account_abstraction_1.entryPoint07Address,
|
|
56
|
-
version: '0.7',
|
|
57
|
-
},
|
|
58
|
-
async decodeCalls() {
|
|
59
|
-
throw new Error('Not implemented');
|
|
60
|
-
},
|
|
61
|
-
async encodeCalls(calls) {
|
|
62
|
-
return (0, utils_1.encode7579Calls)({
|
|
63
|
-
mode: {
|
|
64
|
-
type: calls.length > 1 ? 'batchcall' : 'call',
|
|
65
|
-
revertOnError: false,
|
|
66
|
-
selector: '0x',
|
|
67
|
-
context: '0x',
|
|
68
|
-
},
|
|
69
|
-
callData: calls,
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
async getAddress() {
|
|
73
|
-
return address;
|
|
74
|
-
},
|
|
75
|
-
async getFactoryArgs() {
|
|
76
|
-
return {};
|
|
77
|
-
},
|
|
78
|
-
async getNonce() {
|
|
79
|
-
const key = (0, viem_1.concat)([validatorAddress, '0x00000000']);
|
|
80
|
-
const nonce = await (0, utils_1.getAccountNonce)(client, {
|
|
81
|
-
address,
|
|
82
|
-
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
83
|
-
key: BigInt(key),
|
|
84
|
-
});
|
|
85
|
-
return nonce;
|
|
86
|
-
},
|
|
87
|
-
async getStubSignature() {
|
|
88
|
-
return getStubSignature();
|
|
89
|
-
},
|
|
90
|
-
async signMessage() {
|
|
91
|
-
throw new Error('Not implemented');
|
|
92
|
-
},
|
|
93
|
-
async signTypedData() {
|
|
94
|
-
throw new Error('Not implemented');
|
|
95
|
-
},
|
|
96
|
-
async signUserOperation(parameters) {
|
|
97
|
-
const { chainId = client.chain?.id, ...userOperation } = parameters;
|
|
98
|
-
if (!chainId)
|
|
99
|
-
throw new Error('Chain id not found');
|
|
100
|
-
const hash = (0, account_abstraction_1.getUserOperationHash)({
|
|
101
|
-
userOperation: {
|
|
102
|
-
...userOperation,
|
|
103
|
-
sender: userOperation.sender ?? (await this.getAddress()),
|
|
104
|
-
signature: '0x',
|
|
105
|
-
},
|
|
106
|
-
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
107
|
-
entryPointVersion: '0.7',
|
|
108
|
-
chainId: chainId,
|
|
109
|
-
});
|
|
110
|
-
return await signUserOperation(hash);
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
async function getSmartAccount(config, client, address, validatorAddress, sign) {
|
|
115
|
-
return getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
116
|
-
if (!config.account || !config.account.custom) {
|
|
117
|
-
throw new Error('Account provider not found');
|
|
118
|
-
}
|
|
119
|
-
return config.account.custom.getStubSignature();
|
|
120
|
-
}, sign);
|
|
121
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom.test.d.ts","sourceRoot":"","sources":["../../../accounts/custom.test.ts"],"names":[],"mappings":""}
|