@rhinestone/sdk 1.0.0-alpha.9 → 1.0.0-beta.38
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 +38 -3
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +55 -7
- package/dist/src/accounts/index.d.ts +30 -15
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +284 -140
- package/dist/src/accounts/index.test.js +3 -5
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +14 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +15 -0
- package/dist/src/accounts/kernel.d.ts +4 -3
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +32 -6
- package/dist/src/accounts/kernel.test.js +41 -19
- package/dist/src/accounts/nexus.d.ts +11 -4
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +182 -25
- package/dist/src/accounts/nexus.test.js +44 -18
- package/dist/src/accounts/safe.d.ts +2 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +88 -58
- package/dist/src/accounts/safe.test.js +40 -14
- package/dist/src/accounts/signing/common.d.ts +27 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +145 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +47 -0
- package/dist/src/accounts/signing/passkeys.d.ts +36 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +125 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.test.js +88 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +35 -0
- package/dist/src/accounts/startale.d.ts +2 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +3 -3
- package/dist/src/accounts/startale.test.js +9 -14
- package/dist/src/accounts/utils.d.ts +4 -4
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +3 -40
- package/dist/src/accounts/walletClient.d.ts +7 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +38 -0
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +23 -38
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +29 -294
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/actions/smart-session.d.ts +6 -0
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +35 -0
- package/dist/src/execution/compact.d.ts +150 -7
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +112 -95
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +34 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +62 -42
- package/dist/src/execution/permit2.d.ts +148 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +282 -0
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/types.d.ts +35 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +36 -27
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +357 -103
- package/dist/src/index.d.ts +41 -22
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +199 -65
- 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 +4 -18
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +15 -63
- package/dist/src/modules/index.test.js +9 -26
- package/dist/src/modules/omni-account.d.ts +2 -1
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +3 -1
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +4 -0
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +64 -41
- package/dist/src/modules/validators/core.test.js +7 -7
- package/dist/src/modules/validators/smart-sessions.js +3 -3
- package/dist/src/modules/validators/smart-sessions.test.js +4 -7
- package/dist/src/orchestrator/client.d.ts +4 -4
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +30 -15
- package/dist/src/orchestrator/index.d.ts +2 -3
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -3
- package/dist/src/orchestrator/registry.d.ts +1 -23
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +37 -33
- package/dist/src/orchestrator/registry.test.js +7 -7
- package/dist/src/orchestrator/types.d.ts +97 -29
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +74 -10
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +72 -1
- package/dist/src/actions/index.test.d.ts.map +0 -1
- package/dist/src/actions/index.test.js +0 -302
- package/dist/src/orchestrator/registry.json +0 -365
- /package/dist/src/{actions → accounts/json-rpc}/index.test.d.ts +0 -0
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WalletClientNoConnectedAccountError = exports.SmartSessionsNotEnabledError = exports.SigningNotSupportedForAccountError = exports.OwnersFieldRequiredError = exports.ModuleInstallationNotSupportedError = exports.FactoryArgsNotAvailableError = exports.ExistingEip7702AccountsNotSupportedError = exports.EoaSigningNotSupportedError = exports.EoaSigningMethodNotConfiguredError = exports.Eip7702NotSupportedForAccountError = exports.Eip7702AccountMustHaveEoaError = exports.AccountConfigurationNotSupportedError = exports.AccountError = exports.isAccountError = void 0;
|
|
4
4
|
exports.getModuleInstallationCalls = getModuleInstallationCalls;
|
|
5
5
|
exports.getModuleUninstallationCalls = getModuleUninstallationCalls;
|
|
6
6
|
exports.getAddress = getAddress;
|
|
7
|
+
exports.checkAddress = checkAddress;
|
|
7
8
|
exports.getAccountProvider = getAccountProvider;
|
|
8
9
|
exports.getInitCode = getInitCode;
|
|
10
|
+
exports.signEip7702InitData = signEip7702InitData;
|
|
11
|
+
exports.getEip7702InitCall = getEip7702InitCall;
|
|
12
|
+
exports.is7702 = is7702;
|
|
9
13
|
exports.isDeployed = isDeployed;
|
|
10
14
|
exports.deploy = deploy;
|
|
15
|
+
exports.setup = setup;
|
|
16
|
+
exports.toErc6492Signature = toErc6492Signature;
|
|
11
17
|
exports.getSmartAccount = getSmartAccount;
|
|
12
18
|
exports.getSmartSessionSmartAccount = getSmartSessionSmartAccount;
|
|
13
19
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
14
20
|
exports.getPackedSignature = getPackedSignature;
|
|
21
|
+
exports.getTypedDataPackedSignature = getTypedDataPackedSignature;
|
|
15
22
|
const viem_1 = require("viem");
|
|
16
23
|
const execution_1 = require("../execution");
|
|
17
24
|
const smart_session_1 = require("../execution/smart-session");
|
|
@@ -19,18 +26,26 @@ const modules_1 = require("../modules");
|
|
|
19
26
|
const validators_1 = require("../modules/validators");
|
|
20
27
|
const core_1 = require("../modules/validators/core");
|
|
21
28
|
const error_1 = require("./error");
|
|
29
|
+
Object.defineProperty(exports, "AccountConfigurationNotSupportedError", { enumerable: true, get: function () { return error_1.AccountConfigurationNotSupportedError; } });
|
|
22
30
|
Object.defineProperty(exports, "AccountError", { enumerable: true, get: function () { return error_1.AccountError; } });
|
|
23
31
|
Object.defineProperty(exports, "Eip7702AccountMustHaveEoaError", { enumerable: true, get: function () { return error_1.Eip7702AccountMustHaveEoaError; } });
|
|
24
32
|
Object.defineProperty(exports, "Eip7702NotSupportedForAccountError", { enumerable: true, get: function () { return error_1.Eip7702NotSupportedForAccountError; } });
|
|
33
|
+
Object.defineProperty(exports, "EoaSigningMethodNotConfiguredError", { enumerable: true, get: function () { return error_1.EoaSigningMethodNotConfiguredError; } });
|
|
34
|
+
Object.defineProperty(exports, "EoaSigningNotSupportedError", { enumerable: true, get: function () { return error_1.EoaSigningNotSupportedError; } });
|
|
25
35
|
Object.defineProperty(exports, "ExistingEip7702AccountsNotSupportedError", { enumerable: true, get: function () { return error_1.ExistingEip7702AccountsNotSupportedError; } });
|
|
26
36
|
Object.defineProperty(exports, "FactoryArgsNotAvailableError", { enumerable: true, get: function () { return error_1.FactoryArgsNotAvailableError; } });
|
|
27
37
|
Object.defineProperty(exports, "isAccountError", { enumerable: true, get: function () { return error_1.isAccountError; } });
|
|
38
|
+
Object.defineProperty(exports, "ModuleInstallationNotSupportedError", { enumerable: true, get: function () { return error_1.ModuleInstallationNotSupportedError; } });
|
|
39
|
+
Object.defineProperty(exports, "OwnersFieldRequiredError", { enumerable: true, get: function () { return error_1.OwnersFieldRequiredError; } });
|
|
28
40
|
Object.defineProperty(exports, "SigningNotSupportedForAccountError", { enumerable: true, get: function () { return error_1.SigningNotSupportedForAccountError; } });
|
|
29
|
-
Object.defineProperty(exports, "SignMessageNotSupportedByAccountError", { enumerable: true, get: function () { return error_1.SignMessageNotSupportedByAccountError; } });
|
|
30
41
|
Object.defineProperty(exports, "SmartSessionsNotEnabledError", { enumerable: true, get: function () { return error_1.SmartSessionsNotEnabledError; } });
|
|
42
|
+
Object.defineProperty(exports, "WalletClientNoConnectedAccountError", { enumerable: true, get: function () { return error_1.WalletClientNoConnectedAccountError; } });
|
|
31
43
|
const kernel_1 = require("./kernel");
|
|
32
44
|
const nexus_1 = require("./nexus");
|
|
33
45
|
const safe_1 = require("./safe");
|
|
46
|
+
const common_1 = require("./signing/common");
|
|
47
|
+
const message_1 = require("./signing/message");
|
|
48
|
+
const typedData_1 = require("./signing/typedData");
|
|
34
49
|
const startale_1 = require("./startale");
|
|
35
50
|
const utils_1 = require("./utils");
|
|
36
51
|
function getDeployArgs(config) {
|
|
@@ -48,12 +63,21 @@ function getDeployArgs(config) {
|
|
|
48
63
|
case 'startale': {
|
|
49
64
|
return (0, startale_1.getDeployArgs)(config);
|
|
50
65
|
}
|
|
66
|
+
case 'eoa': {
|
|
67
|
+
throw new Error('EOA accounts do not have deploy args');
|
|
68
|
+
}
|
|
51
69
|
}
|
|
52
70
|
}
|
|
53
71
|
function getInitCode(config) {
|
|
54
72
|
if (is7702(config)) {
|
|
55
73
|
return undefined;
|
|
56
74
|
}
|
|
75
|
+
else if (config.account?.type === 'eoa') {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
else if (config.initData) {
|
|
79
|
+
return config.initData;
|
|
80
|
+
}
|
|
57
81
|
else {
|
|
58
82
|
const { factory, factoryData } = getDeployArgs(config);
|
|
59
83
|
if (!factory || !factoryData) {
|
|
@@ -65,6 +89,45 @@ function getInitCode(config) {
|
|
|
65
89
|
};
|
|
66
90
|
}
|
|
67
91
|
}
|
|
92
|
+
async function signEip7702InitData(config) {
|
|
93
|
+
const eoa = config.eoa;
|
|
94
|
+
if (!eoa) {
|
|
95
|
+
throw new error_1.Eip7702AccountMustHaveEoaError();
|
|
96
|
+
}
|
|
97
|
+
const account = getAccountProvider(config);
|
|
98
|
+
switch (account.type) {
|
|
99
|
+
case 'nexus': {
|
|
100
|
+
return await (0, nexus_1.signEip7702InitData)(config, eoa);
|
|
101
|
+
}
|
|
102
|
+
case 'eoa': {
|
|
103
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
104
|
+
}
|
|
105
|
+
case 'safe':
|
|
106
|
+
case 'kernel':
|
|
107
|
+
case 'startale': {
|
|
108
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
109
|
+
}
|
|
110
|
+
default: {
|
|
111
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function getEip7702InitCall(config, signature) {
|
|
116
|
+
const account = getAccountProvider(config);
|
|
117
|
+
switch (account.type) {
|
|
118
|
+
case 'nexus': {
|
|
119
|
+
return await (0, nexus_1.getEip7702InitCall)(config, signature);
|
|
120
|
+
}
|
|
121
|
+
case 'safe':
|
|
122
|
+
case 'kernel':
|
|
123
|
+
case 'startale': {
|
|
124
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
125
|
+
}
|
|
126
|
+
default: {
|
|
127
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
68
131
|
function getModuleInstallationCalls(config, module) {
|
|
69
132
|
const address = getAddress(config);
|
|
70
133
|
function getInstallData() {
|
|
@@ -82,6 +145,9 @@ function getModuleInstallationCalls(config, module) {
|
|
|
82
145
|
case 'startale': {
|
|
83
146
|
return [(0, startale_1.getInstallData)(module)];
|
|
84
147
|
}
|
|
148
|
+
case 'eoa': {
|
|
149
|
+
throw new error_1.ModuleInstallationNotSupportedError(account.type);
|
|
150
|
+
}
|
|
85
151
|
}
|
|
86
152
|
}
|
|
87
153
|
const installData = getInstallData();
|
|
@@ -142,30 +208,93 @@ function getAddress(config) {
|
|
|
142
208
|
case 'startale': {
|
|
143
209
|
return (0, startale_1.getAddress)(config);
|
|
144
210
|
}
|
|
211
|
+
case 'eoa': {
|
|
212
|
+
if (!config.eoa) {
|
|
213
|
+
throw new error_1.AccountError({
|
|
214
|
+
message: 'EOA account must have an EOA configured',
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return config.eoa.address;
|
|
218
|
+
}
|
|
145
219
|
}
|
|
146
220
|
}
|
|
221
|
+
function checkAddress(config) {
|
|
222
|
+
if (!config.initData) {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
return (config.initData.address.toLowerCase() === getAddress(config).toLowerCase());
|
|
226
|
+
}
|
|
147
227
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
148
228
|
async function getPackedSignature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
149
|
-
|
|
150
|
-
|
|
229
|
+
if (config.account?.type === 'eoa') {
|
|
230
|
+
throw new error_1.EoaSigningNotSupportedError('packed signatures');
|
|
231
|
+
}
|
|
232
|
+
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
233
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, false);
|
|
151
234
|
const account = getAccountProvider(config);
|
|
152
235
|
const address = getAddress(config);
|
|
153
236
|
switch (account.type) {
|
|
154
237
|
case 'safe': {
|
|
155
|
-
|
|
238
|
+
const signature = await signFn(hash);
|
|
239
|
+
return (0, safe_1.packSignature)(signature, validator, transformSignature);
|
|
240
|
+
}
|
|
241
|
+
case 'nexus': {
|
|
242
|
+
const signature = await signFn(hash);
|
|
243
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
244
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, defaultValidatorAddress);
|
|
245
|
+
}
|
|
246
|
+
case 'kernel': {
|
|
247
|
+
const signature = await signFn((0, kernel_1.wrapMessageHash)(hash, address));
|
|
248
|
+
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
249
|
+
}
|
|
250
|
+
case 'startale': {
|
|
251
|
+
const signature = await signFn(hash);
|
|
252
|
+
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
253
|
+
}
|
|
254
|
+
default: {
|
|
255
|
+
throw new Error(`Unsupported account type: ${account.type}`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Signs and packs a signature to be EIP-1271 compatible
|
|
260
|
+
async function getTypedDataPackedSignature(config, signers, chain, validator, parameters, transformSignature = (signature) => signature) {
|
|
261
|
+
if (config.account?.type === 'eoa') {
|
|
262
|
+
throw new error_1.EoaSigningNotSupportedError('packed signatures');
|
|
263
|
+
}
|
|
264
|
+
const address = getAddress(config);
|
|
265
|
+
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
266
|
+
const signFn = (parameters) => (0, typedData_1.sign)(signers, chain, address, parameters);
|
|
267
|
+
const account = getAccountProvider(config);
|
|
268
|
+
switch (account.type) {
|
|
269
|
+
case 'safe': {
|
|
270
|
+
const signature = await signFn(parameters);
|
|
271
|
+
return (0, safe_1.packSignature)(signature, validator, transformSignature);
|
|
156
272
|
}
|
|
157
273
|
case 'nexus': {
|
|
158
|
-
|
|
274
|
+
const signature = await signFn(parameters);
|
|
275
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
276
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, defaultValidatorAddress);
|
|
159
277
|
}
|
|
160
278
|
case 'kernel': {
|
|
161
|
-
|
|
279
|
+
const address = getAddress(config);
|
|
280
|
+
const signMessageFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, false);
|
|
281
|
+
const signature = await signMessageFn((0, kernel_1.wrapMessageHash)((0, viem_1.hashTypedData)(parameters), address));
|
|
282
|
+
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
162
283
|
}
|
|
163
284
|
case 'startale': {
|
|
164
|
-
|
|
285
|
+
const signature = await signFn(parameters);
|
|
286
|
+
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
287
|
+
}
|
|
288
|
+
default: {
|
|
289
|
+
throw new Error(`Unsupported account type: ${account.type}`);
|
|
165
290
|
}
|
|
166
291
|
}
|
|
167
292
|
}
|
|
168
|
-
async function isDeployed(
|
|
293
|
+
async function isDeployed(config, chain) {
|
|
294
|
+
const account = getAccountProvider(config);
|
|
295
|
+
if (account.type === 'eoa') {
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
169
298
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
170
299
|
chain: chain,
|
|
171
300
|
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
@@ -184,10 +313,89 @@ async function isDeployed(chain, config) {
|
|
|
184
313
|
return (0, viem_1.size)(code) > 0;
|
|
185
314
|
}
|
|
186
315
|
async function deploy(config, chain, session) {
|
|
187
|
-
|
|
316
|
+
const account = getAccountProvider(config);
|
|
317
|
+
if (account.type === 'eoa') {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
const deployed = await isDeployed(config, chain);
|
|
321
|
+
if (deployed) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
const asUserOp = config.initData && !config.initData.intentExecutorInstalled;
|
|
325
|
+
if (asUserOp) {
|
|
326
|
+
await deployWithBundler(chain, config);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
await deployWithIntent(chain, config);
|
|
330
|
+
}
|
|
188
331
|
if (session) {
|
|
189
332
|
await (0, smart_session_1.enableSmartSession)(chain, config, session);
|
|
190
333
|
}
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
// Installs the missing modules
|
|
337
|
+
// Checks if the provided modules are already installed
|
|
338
|
+
// Useful for existing (already deployed) accounts
|
|
339
|
+
async function setup(config, chain) {
|
|
340
|
+
const account = getAccountProvider(config);
|
|
341
|
+
if (account.type === 'eoa') {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
const modules = (0, modules_1.getSetup)(config);
|
|
345
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
346
|
+
chain,
|
|
347
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
348
|
+
});
|
|
349
|
+
const address = getAddress(config);
|
|
350
|
+
const allModules = [
|
|
351
|
+
...modules.validators,
|
|
352
|
+
...modules.executors,
|
|
353
|
+
...modules.fallbacks,
|
|
354
|
+
...modules.hooks,
|
|
355
|
+
];
|
|
356
|
+
// Check if the modules are already installed
|
|
357
|
+
const installedResults = await publicClient.multicall({
|
|
358
|
+
contracts: allModules.map((module) => ({
|
|
359
|
+
address: address,
|
|
360
|
+
abi: [
|
|
361
|
+
{
|
|
362
|
+
type: 'function',
|
|
363
|
+
name: 'isModuleInstalled',
|
|
364
|
+
inputs: [
|
|
365
|
+
{ type: 'uint256', name: 'moduleTypeId' },
|
|
366
|
+
{ type: 'address', name: 'module' },
|
|
367
|
+
{ type: 'bytes', name: 'additionalContext' },
|
|
368
|
+
],
|
|
369
|
+
outputs: [{ type: 'bool', name: 'isInstalled' }],
|
|
370
|
+
stateMutability: 'view',
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
functionName: 'isModuleInstalled',
|
|
374
|
+
args: [module.type, module.address, module.additionalContext],
|
|
375
|
+
})),
|
|
376
|
+
});
|
|
377
|
+
const isInstalled = installedResults.map((result) => result.result);
|
|
378
|
+
const modulesToInstall = allModules.filter((_, index) => !isInstalled[index]);
|
|
379
|
+
if (modulesToInstall.length === 0) {
|
|
380
|
+
// Nothing to install
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
const calls = [];
|
|
384
|
+
for (const module of modulesToInstall) {
|
|
385
|
+
calls.push(...getModuleInstallationCalls(config, module));
|
|
386
|
+
}
|
|
387
|
+
// Select the transaction infra layer based on the intent executor status
|
|
388
|
+
const intentExecutor = (0, modules_1.getIntentExecutor)(config);
|
|
389
|
+
const hasIntentExecutor = modulesToInstall.every((module) => module.address !== intentExecutor.address);
|
|
390
|
+
let result;
|
|
391
|
+
if (hasIntentExecutor) {
|
|
392
|
+
result = await (0, execution_1.sendTransactionInternal)(config, [chain], chain, calls, {});
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
result = await (0, execution_1.sendUserOperationInternal)(config, chain, calls);
|
|
396
|
+
}
|
|
397
|
+
await (0, execution_1.waitForExecution)(config, result, true);
|
|
398
|
+
return true;
|
|
191
399
|
}
|
|
192
400
|
async function deployWithIntent(chain, config) {
|
|
193
401
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
@@ -200,7 +408,7 @@ async function deployWithIntent(chain, config) {
|
|
|
200
408
|
// Already deployed
|
|
201
409
|
return;
|
|
202
410
|
}
|
|
203
|
-
await (0, execution_1.sendTransaction)(config, {
|
|
411
|
+
const result = await (0, execution_1.sendTransaction)(config, {
|
|
204
412
|
targetChain: chain,
|
|
205
413
|
calls: [
|
|
206
414
|
{
|
|
@@ -209,19 +417,73 @@ async function deployWithIntent(chain, config) {
|
|
|
209
417
|
},
|
|
210
418
|
],
|
|
211
419
|
});
|
|
420
|
+
await (0, execution_1.waitForExecution)(config, result, true);
|
|
421
|
+
}
|
|
422
|
+
async function deployWithBundler(chain, config) {
|
|
423
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
424
|
+
chain,
|
|
425
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
426
|
+
});
|
|
427
|
+
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
428
|
+
const smartAccount = await getSmartAccount(config, publicClient, chain);
|
|
429
|
+
const { factory, factoryData } = getDeployArgs(config);
|
|
430
|
+
const opHash = await bundlerClient.sendUserOperation({
|
|
431
|
+
account: smartAccount,
|
|
432
|
+
factory,
|
|
433
|
+
factoryData,
|
|
434
|
+
calls: [
|
|
435
|
+
{
|
|
436
|
+
to: viem_1.zeroAddress,
|
|
437
|
+
value: 0n,
|
|
438
|
+
data: '0x',
|
|
439
|
+
},
|
|
440
|
+
],
|
|
441
|
+
});
|
|
442
|
+
await bundlerClient.waitForUserOperationReceipt({
|
|
443
|
+
hash: opHash,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
async function toErc6492Signature(config, signature, chain) {
|
|
447
|
+
const deployed = await isDeployed(config, chain);
|
|
448
|
+
if (deployed) {
|
|
449
|
+
return signature;
|
|
450
|
+
}
|
|
451
|
+
// Account is not deployed, use ERC-6492
|
|
452
|
+
const initCode = getInitCode(config);
|
|
453
|
+
if (!initCode) {
|
|
454
|
+
throw new error_1.FactoryArgsNotAvailableError();
|
|
455
|
+
}
|
|
456
|
+
const { factory, factoryData } = initCode;
|
|
457
|
+
const magicBytes = '0x6492649264926492649264926492649264926492649264926492649264926492';
|
|
458
|
+
return (0, viem_1.concat)([
|
|
459
|
+
(0, viem_1.encodeAbiParameters)([
|
|
460
|
+
{ name: 'create2Factory', type: 'address' },
|
|
461
|
+
{ name: 'factoryCalldata', type: 'bytes' },
|
|
462
|
+
{ name: 'originalERC1271Signature', type: 'bytes' },
|
|
463
|
+
], [factory, factoryData, signature]),
|
|
464
|
+
magicBytes,
|
|
465
|
+
]);
|
|
212
466
|
}
|
|
213
467
|
async function getSmartAccount(config, client, chain) {
|
|
468
|
+
// EOA accounts don't need smart account functionality
|
|
469
|
+
if (config.account?.type === 'eoa') {
|
|
470
|
+
throw new Error('getSmartAccount is not supported for EOA accounts');
|
|
471
|
+
}
|
|
472
|
+
if (!config.owners) {
|
|
473
|
+
throw new error_1.OwnersFieldRequiredError();
|
|
474
|
+
}
|
|
214
475
|
const account = getAccountProvider(config);
|
|
215
476
|
const address = getAddress(config);
|
|
216
477
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
217
|
-
const signers = convertOwnerSetToSignerSet(config.owners);
|
|
218
|
-
const signFn = (hash) => sign(signers, chain, hash);
|
|
478
|
+
const signers = (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
479
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
219
480
|
switch (account.type) {
|
|
220
481
|
case 'safe': {
|
|
221
482
|
return (0, safe_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
222
483
|
}
|
|
223
484
|
case 'nexus': {
|
|
224
|
-
|
|
485
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
486
|
+
return (0, nexus_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn, defaultValidatorAddress);
|
|
225
487
|
}
|
|
226
488
|
case 'kernel': {
|
|
227
489
|
return (0, kernel_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
@@ -242,14 +504,15 @@ async function getSmartSessionSmartAccount(config, client, chain, session, enabl
|
|
|
242
504
|
session,
|
|
243
505
|
enableData: enableData || undefined,
|
|
244
506
|
};
|
|
245
|
-
const signFn = (hash) => sign(signers, chain, hash);
|
|
507
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
246
508
|
const account = getAccountProvider(config);
|
|
247
509
|
switch (account.type) {
|
|
248
510
|
case 'safe': {
|
|
249
511
|
return (0, safe_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
250
512
|
}
|
|
251
513
|
case 'nexus': {
|
|
252
|
-
|
|
514
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
515
|
+
return (0, nexus_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn, defaultValidatorAddress);
|
|
253
516
|
}
|
|
254
517
|
case 'kernel': {
|
|
255
518
|
return (0, kernel_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
@@ -270,14 +533,15 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
270
533
|
type: 'guardians',
|
|
271
534
|
guardians: accounts,
|
|
272
535
|
};
|
|
273
|
-
const signFn = (hash) => sign(signers, chain, hash);
|
|
536
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
274
537
|
const account = getAccountProvider(config);
|
|
275
538
|
switch (account.type) {
|
|
276
539
|
case 'safe': {
|
|
277
540
|
return (0, safe_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
278
541
|
}
|
|
279
542
|
case 'nexus': {
|
|
280
|
-
|
|
543
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
544
|
+
return (0, nexus_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn, defaultValidatorAddress);
|
|
281
545
|
}
|
|
282
546
|
case 'kernel': {
|
|
283
547
|
return (0, kernel_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
@@ -287,87 +551,9 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
287
551
|
}
|
|
288
552
|
}
|
|
289
553
|
}
|
|
290
|
-
async function sign(signers, chain, hash) {
|
|
291
|
-
switch (signers.type) {
|
|
292
|
-
case 'owner': {
|
|
293
|
-
switch (signers.kind) {
|
|
294
|
-
case 'ecdsa': {
|
|
295
|
-
const signatures = await Promise.all(signers.accounts.map((account) => signEcdsa(account, hash)));
|
|
296
|
-
return (0, viem_1.concat)(signatures);
|
|
297
|
-
}
|
|
298
|
-
case 'passkey': {
|
|
299
|
-
return await signPasskey(signers.account, chain, hash);
|
|
300
|
-
}
|
|
301
|
-
case 'multi-factor': {
|
|
302
|
-
const signatures = await Promise.all(signers.validators.map(async (validator) => {
|
|
303
|
-
if (validator === null) {
|
|
304
|
-
return '0x';
|
|
305
|
-
}
|
|
306
|
-
const validatorSigners = convertOwnerSetToSignerSet(validator);
|
|
307
|
-
return sign(validatorSigners, chain, hash);
|
|
308
|
-
}));
|
|
309
|
-
const data = (0, viem_1.encodeAbiParameters)([
|
|
310
|
-
{
|
|
311
|
-
components: [
|
|
312
|
-
{
|
|
313
|
-
internalType: 'bytes32',
|
|
314
|
-
name: 'packedValidatorAndId',
|
|
315
|
-
type: 'bytes32',
|
|
316
|
-
},
|
|
317
|
-
{ internalType: 'bytes', name: 'data', type: 'bytes' },
|
|
318
|
-
],
|
|
319
|
-
name: 'validators',
|
|
320
|
-
type: 'tuple[]',
|
|
321
|
-
},
|
|
322
|
-
], [
|
|
323
|
-
signers.validators.map((validator, index) => {
|
|
324
|
-
const validatorModule = (0, core_1.getValidator)(validator);
|
|
325
|
-
return {
|
|
326
|
-
packedValidatorAndId: (0, viem_1.concat)([
|
|
327
|
-
(0, viem_1.pad)((0, viem_1.toHex)(validator.id), {
|
|
328
|
-
size: 12,
|
|
329
|
-
}),
|
|
330
|
-
validatorModule.address,
|
|
331
|
-
]),
|
|
332
|
-
data: signatures[index],
|
|
333
|
-
};
|
|
334
|
-
}),
|
|
335
|
-
]);
|
|
336
|
-
return data;
|
|
337
|
-
}
|
|
338
|
-
default: {
|
|
339
|
-
throw new Error('Unsupported owner kind');
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
case 'session': {
|
|
344
|
-
const sessionSigners = convertOwnerSetToSignerSet(signers.session.owners);
|
|
345
|
-
return sign(sessionSigners, chain, hash);
|
|
346
|
-
}
|
|
347
|
-
case 'guardians': {
|
|
348
|
-
const signatures = await Promise.all(signers.guardians.map((account) => signEcdsa(account, hash)));
|
|
349
|
-
return (0, viem_1.concat)(signatures);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
async function signEcdsa(account, hash) {
|
|
354
|
-
if (!account.signMessage) {
|
|
355
|
-
throw new error_1.SigningNotSupportedForAccountError();
|
|
356
|
-
}
|
|
357
|
-
return await account.signMessage({ message: { raw: hash } });
|
|
358
|
-
}
|
|
359
|
-
async function signPasskey(account, chain, hash) {
|
|
360
|
-
const { webauthn, signature } = await account.sign({ hash });
|
|
361
|
-
const usePrecompiled = (0, modules_1.isRip7212SupportedNetwork)(chain);
|
|
362
|
-
const encodedSignature = (0, modules_1.getWebauthnValidatorSignature)({
|
|
363
|
-
webauthn,
|
|
364
|
-
signature,
|
|
365
|
-
usePrecompiled,
|
|
366
|
-
});
|
|
367
|
-
return encodedSignature;
|
|
368
|
-
}
|
|
369
554
|
function is7702(config) {
|
|
370
|
-
|
|
555
|
+
const account = getAccountProvider(config);
|
|
556
|
+
return account.type !== 'eoa' && config.eoa !== undefined;
|
|
371
557
|
}
|
|
372
558
|
function getAccountProvider(config) {
|
|
373
559
|
if (config.account) {
|
|
@@ -377,45 +563,3 @@ function getAccountProvider(config) {
|
|
|
377
563
|
type: 'nexus',
|
|
378
564
|
};
|
|
379
565
|
}
|
|
380
|
-
function convertOwnerSetToSignerSet(owners) {
|
|
381
|
-
switch (owners.type) {
|
|
382
|
-
case 'ecdsa': {
|
|
383
|
-
return {
|
|
384
|
-
type: 'owner',
|
|
385
|
-
kind: 'ecdsa',
|
|
386
|
-
accounts: owners.accounts,
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
case 'passkey': {
|
|
390
|
-
return {
|
|
391
|
-
type: 'owner',
|
|
392
|
-
kind: 'passkey',
|
|
393
|
-
account: owners.account,
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
case 'multi-factor': {
|
|
397
|
-
return {
|
|
398
|
-
type: 'owner',
|
|
399
|
-
kind: 'multi-factor',
|
|
400
|
-
validators: owners.validators.map((validator, index) => {
|
|
401
|
-
switch (validator.type) {
|
|
402
|
-
case 'ecdsa': {
|
|
403
|
-
return {
|
|
404
|
-
type: 'ecdsa',
|
|
405
|
-
id: index,
|
|
406
|
-
accounts: validator.accounts,
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
case 'passkey': {
|
|
410
|
-
return {
|
|
411
|
-
type: 'passkey',
|
|
412
|
-
id: index,
|
|
413
|
-
account: validator.account,
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}),
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
@@ -12,19 +12,17 @@ const _1 = require(".");
|
|
|
12
12
|
accounts: [consts_1.accountA, consts_1.accountB],
|
|
13
13
|
threshold: 1,
|
|
14
14
|
},
|
|
15
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
16
15
|
});
|
|
17
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
16
|
+
(0, vitest_1.expect)(address).toEqual('0x0681de31e060b384F0b08A3bAC99E9bDFf302474');
|
|
18
17
|
});
|
|
19
18
|
(0, vitest_1.test)('Safe, passkey owner with a session', () => {
|
|
20
19
|
const address = (0, _1.getAddress)({
|
|
21
20
|
owners: {
|
|
22
21
|
type: 'passkey',
|
|
23
|
-
|
|
22
|
+
accounts: [consts_1.passkeyAccount],
|
|
24
23
|
},
|
|
25
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
26
24
|
});
|
|
27
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
25
|
+
(0, vitest_1.expect)(address).toEqual('0x894b88C04B4DE6AbDdcE81E8bdc91927E37d6ceD');
|
|
28
26
|
});
|
|
29
27
|
});
|
|
30
28
|
(0, vitest_1.describe)('Sign', () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAQ,KAAK,SAAS,EAAE,MAAM,MAAM,CAAA;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,iBAAS,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAc3E;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTransport = createTransport;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const providers_1 = require("./providers");
|
|
6
|
+
function createTransport(chain, provider) {
|
|
7
|
+
if (!provider) {
|
|
8
|
+
return (0, viem_1.http)();
|
|
9
|
+
}
|
|
10
|
+
switch (provider.type) {
|
|
11
|
+
case 'alchemy': {
|
|
12
|
+
const alchemyUrl = (0, providers_1.getAlchemyUrl)(chain.id, provider.apiKey);
|
|
13
|
+
return (0, viem_1.http)(alchemyUrl);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chains_1 = require("viem/chains");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
(0, vitest_1.describe)('JSON-RPC', () => {
|
|
7
|
+
(0, vitest_1.describe)('createTransport', () => {
|
|
8
|
+
(0, vitest_1.test)('Alchemy', () => {
|
|
9
|
+
const transport = (0, index_1.createTransport)(chains_1.base, {
|
|
10
|
+
type: 'alchemy',
|
|
11
|
+
apiKey: '123',
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.expect)(transport).toBeDefined();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/providers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,iBAAS,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAStE;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAlchemyUrl = getAlchemyUrl;
|
|
4
|
+
const shared_configs_1 = require("@rhinestone/shared-configs");
|
|
5
|
+
function getAlchemyUrl(chainId, apiKey) {
|
|
6
|
+
const urlTemplate = shared_configs_1.providerRegistry.Alchemy.url_template;
|
|
7
|
+
const chainParam = shared_configs_1.providerRegistry.Alchemy.chain_mapping[chainId];
|
|
8
|
+
if (!chainParam) {
|
|
9
|
+
throw new Error(`Unsupported chain: ${chainId}`);
|
|
10
|
+
}
|
|
11
|
+
return urlTemplate
|
|
12
|
+
.replace('{{chain_param}}', chainParam)
|
|
13
|
+
.replace('\$\{ALCHEMY_API_KEY\}', apiKey);
|
|
14
|
+
}
|