@rhinestone/sdk 1.5.0 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/accounts/error.d.ts +1 -1
- package/dist/src/accounts/error.js +1 -19
- package/dist/src/accounts/index.d.ts +5 -5
- package/dist/src/accounts/index.js +121 -157
- package/dist/src/accounts/json-rpc/index.d.ts +1 -1
- package/dist/src/accounts/json-rpc/index.js +8 -10
- package/dist/src/accounts/json-rpc/providers.d.ts +1 -1
- package/dist/src/accounts/json-rpc/providers.js +4 -7
- package/dist/src/accounts/kernel.d.ts +3 -3
- package/dist/src/accounts/kernel.js +66 -75
- package/dist/src/accounts/nexus.d.ts +3 -3
- package/dist/src/accounts/nexus.js +62 -73
- package/dist/src/accounts/passport.d.ts +3 -3
- package/dist/src/accounts/passport.js +9 -13
- package/dist/src/accounts/safe.d.ts +3 -3
- package/dist/src/accounts/safe.js +54 -63
- package/dist/src/accounts/signing/common.d.ts +2 -2
- package/dist/src/accounts/signing/common.js +30 -36
- package/dist/src/accounts/signing/message.d.ts +2 -2
- package/dist/src/accounts/signing/message.js +10 -12
- package/dist/src/accounts/signing/passkeys.js +11 -17
- package/dist/src/accounts/signing/typedData.d.ts +1 -1
- package/dist/src/accounts/signing/typedData.js +6 -8
- package/dist/src/accounts/startale.d.ts +3 -3
- package/dist/src/accounts/startale.js +37 -47
- package/dist/src/accounts/utils.d.ts +2 -2
- package/dist/src/accounts/utils.js +22 -28
- package/dist/src/accounts/walletClient.js +4 -8
- package/dist/src/actions/compact.d.ts +1 -1
- package/dist/src/actions/compact.js +22 -35
- package/dist/src/actions/deployment.d.ts +1 -1
- package/dist/src/actions/deployment.js +11 -13
- package/dist/src/actions/ecdsa.d.ts +1 -1
- package/dist/src/actions/ecdsa.js +14 -20
- package/dist/src/actions/index.d.ts +2 -2
- package/dist/src/actions/index.js +6 -10
- package/dist/src/actions/mfa.d.ts +1 -1
- package/dist/src/actions/mfa.js +18 -24
- package/dist/src/actions/passkeys.d.ts +2 -2
- package/dist/src/actions/passkeys.js +14 -20
- package/dist/src/actions/recovery.d.ts +1 -1
- package/dist/src/actions/recovery.js +25 -29
- package/dist/src/actions/smart-sessions.d.ts +1 -1
- package/dist/src/actions/smart-sessions.js +8 -12
- package/dist/src/auth/provider.d.ts +1 -1
- package/dist/src/auth/provider.js +1 -4
- package/dist/src/errors/index.d.ts +3 -3
- package/dist/src/errors/index.js +10 -54
- package/dist/src/execution/compact.d.ts +3 -3
- package/dist/src/execution/compact.js +10 -18
- package/dist/src/execution/error.js +1 -11
- package/dist/src/execution/index.d.ts +8 -8
- package/dist/src/execution/index.js +50 -65
- package/dist/src/execution/permit2.d.ts +5 -5
- package/dist/src/execution/permit2.js +8 -13
- package/dist/src/execution/singleChainOps.d.ts +2 -2
- package/dist/src/execution/singleChainOps.js +1 -3
- package/dist/src/execution/types.d.ts +1 -1
- package/dist/src/execution/types.js +1 -2
- package/dist/src/execution/utils.d.ts +4 -4
- package/dist/src/execution/utils.js +133 -156
- package/dist/src/index.d.ts +9 -9
- package/dist/src/index.js +55 -66
- package/dist/src/jwt-server/digest.js +3 -6
- package/dist/src/jwt-server/express.d.ts +1 -1
- package/dist/src/jwt-server/express.d.ts.map +1 -1
- package/dist/src/jwt-server/express.js +6 -7
- package/dist/src/jwt-server/handlers.d.ts +1 -1
- package/dist/src/jwt-server/handlers.js +7 -11
- package/dist/src/jwt-server/index.d.ts +7 -7
- package/dist/src/jwt-server/index.js +6 -17
- package/dist/src/jwt-server/jcs.js +1 -4
- package/dist/src/jwt-server/signer.d.ts +1 -1
- package/dist/src/jwt-server/signer.js +10 -13
- package/dist/src/jwt-server/sponsorship.js +2 -7
- package/dist/src/jwt-server/web.d.ts +1 -1
- package/dist/src/jwt-server/web.js +5 -9
- package/dist/src/modules/abi/smart-session-emissary.js +1 -3
- package/dist/src/modules/abi/smart-sessions.js +1 -4
- package/dist/src/modules/chain-abstraction.js +1 -5
- package/dist/src/modules/common.d.ts +1 -1
- package/dist/src/modules/common.js +1 -13
- package/dist/src/modules/index.d.ts +5 -5
- package/dist/src/modules/index.js +35 -50
- package/dist/src/modules/legacy.d.ts +2 -2
- package/dist/src/modules/legacy.js +11 -14
- package/dist/src/modules/read.d.ts +1 -1
- package/dist/src/modules/read.js +11 -15
- package/dist/src/modules/validators/core.d.ts +2 -2
- package/dist/src/modules/validators/core.js +26 -44
- package/dist/src/modules/validators/index.d.ts +2 -2
- package/dist/src/modules/validators/index.js +3 -19
- package/dist/src/modules/validators/policies/claim/permit2.d.ts +1 -1
- package/dist/src/modules/validators/policies/claim/permit2.js +39 -44
- package/dist/src/modules/validators/policies/claim/types.js +11 -14
- package/dist/src/modules/validators/smart-sessions.d.ts +3 -3
- package/dist/src/modules/validators/smart-sessions.js +65 -94
- package/dist/src/orchestrator/client.d.ts +2 -2
- package/dist/src/orchestrator/client.js +46 -50
- package/dist/src/orchestrator/consts.d.ts +1 -1
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +2 -8
- package/dist/src/orchestrator/error.js +1 -33
- package/dist/src/orchestrator/index.d.ts +7 -7
- package/dist/src/orchestrator/index.js +7 -56
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.js +19 -33
- package/dist/src/orchestrator/types.js +1 -17
- package/dist/src/orchestrator/utils.js +1 -3
- package/dist/src/types.d.ts +3 -3
- package/dist/src/types.js +1 -2
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.js +9 -15
- package/package.json +15 -98
|
@@ -1,79 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.deploy = deploy;
|
|
17
|
-
exports.setup = setup;
|
|
18
|
-
exports.toErc6492Signature = toErc6492Signature;
|
|
19
|
-
exports.getSmartAccount = getSmartAccount;
|
|
20
|
-
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
21
|
-
exports.getEip1271Signature = getEip1271Signature;
|
|
22
|
-
exports.getEmissarySignature = getEmissarySignature;
|
|
23
|
-
exports.getTypedDataPackedSignature = getTypedDataPackedSignature;
|
|
24
|
-
const viem_1 = require("viem");
|
|
25
|
-
const execution_1 = require("../execution");
|
|
26
|
-
const modules_1 = require("../modules");
|
|
27
|
-
const validators_1 = require("../modules/validators");
|
|
28
|
-
const core_1 = require("../modules/validators/core");
|
|
29
|
-
const error_1 = require("./error");
|
|
30
|
-
Object.defineProperty(exports, "AccountConfigurationNotSupportedError", { enumerable: true, get: function () { return error_1.AccountConfigurationNotSupportedError; } });
|
|
31
|
-
Object.defineProperty(exports, "AccountError", { enumerable: true, get: function () { return error_1.AccountError; } });
|
|
32
|
-
Object.defineProperty(exports, "Eip712DomainNotAvailableError", { enumerable: true, get: function () { return error_1.Eip712DomainNotAvailableError; } });
|
|
33
|
-
Object.defineProperty(exports, "Eip7702AccountMustHaveEoaError", { enumerable: true, get: function () { return error_1.Eip7702AccountMustHaveEoaError; } });
|
|
34
|
-
Object.defineProperty(exports, "Eip7702NotSupportedForAccountError", { enumerable: true, get: function () { return error_1.Eip7702NotSupportedForAccountError; } });
|
|
35
|
-
Object.defineProperty(exports, "EoaAccountMustHaveAccountError", { enumerable: true, get: function () { return error_1.EoaAccountMustHaveAccountError; } });
|
|
36
|
-
Object.defineProperty(exports, "EoaSigningMethodNotConfiguredError", { enumerable: true, get: function () { return error_1.EoaSigningMethodNotConfiguredError; } });
|
|
37
|
-
Object.defineProperty(exports, "EoaSigningNotSupportedError", { enumerable: true, get: function () { return error_1.EoaSigningNotSupportedError; } });
|
|
38
|
-
Object.defineProperty(exports, "ExistingEip7702AccountsNotSupportedError", { enumerable: true, get: function () { return error_1.ExistingEip7702AccountsNotSupportedError; } });
|
|
39
|
-
Object.defineProperty(exports, "FactoryArgsNotAvailableError", { enumerable: true, get: function () { return error_1.FactoryArgsNotAvailableError; } });
|
|
40
|
-
Object.defineProperty(exports, "isAccountError", { enumerable: true, get: function () { return error_1.isAccountError; } });
|
|
41
|
-
Object.defineProperty(exports, "ModuleInstallationNotSupportedError", { enumerable: true, get: function () { return error_1.ModuleInstallationNotSupportedError; } });
|
|
42
|
-
Object.defineProperty(exports, "OwnersFieldRequiredError", { enumerable: true, get: function () { return error_1.OwnersFieldRequiredError; } });
|
|
43
|
-
Object.defineProperty(exports, "SigningNotSupportedForAccountError", { enumerable: true, get: function () { return error_1.SigningNotSupportedForAccountError; } });
|
|
44
|
-
Object.defineProperty(exports, "SmartSessionsNotEnabledError", { enumerable: true, get: function () { return error_1.SmartSessionsNotEnabledError; } });
|
|
45
|
-
Object.defineProperty(exports, "WalletClientNoConnectedAccountError", { enumerable: true, get: function () { return error_1.WalletClientNoConnectedAccountError; } });
|
|
46
|
-
const kernel_1 = require("./kernel");
|
|
47
|
-
const nexus_1 = require("./nexus");
|
|
48
|
-
const passport_1 = require("./passport");
|
|
49
|
-
const safe_1 = require("./safe");
|
|
50
|
-
const common_1 = require("./signing/common");
|
|
51
|
-
const message_1 = require("./signing/message");
|
|
52
|
-
const typedData_1 = require("./signing/typedData");
|
|
53
|
-
const startale_1 = require("./startale");
|
|
54
|
-
const utils_1 = require("./utils");
|
|
1
|
+
import { concat, createPublicClient, encodeAbiParameters, encodeFunctionData, hashTypedData, size, zeroAddress, zeroHash, } from 'viem';
|
|
2
|
+
import { sendTransaction, sendTransactionInternal, sendUserOperationInternal, waitForExecution, } from '../execution/index.js';
|
|
3
|
+
import { getIntentExecutor, getSetup } from '../modules/index.js';
|
|
4
|
+
import { getOwnerValidator } from '../modules/validators/index.js';
|
|
5
|
+
import { getSocialRecoveryValidator } from '../modules/validators/core.js';
|
|
6
|
+
import { AccountConfigurationNotSupportedError, AccountError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, EoaSigningMethodNotConfiguredError, EoaSigningNotSupportedError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, ModuleInstallationNotSupportedError, OwnersFieldRequiredError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError, } from './error.js';
|
|
7
|
+
import { getAddress as getKernelAddress, getDeployArgs as getKernelDeployArgs, getEip712Domain as getKernelEip712Domain, getGuardianSmartAccount as getKernelGuardianSmartAccount, getInstallData as getKernelInstallData, getSmartAccount as getKernelSmartAccount, packSignature as packKernelSignature, wrapMessageHash as wrapKernelMessageHash, } from './kernel.js';
|
|
8
|
+
import { getAddress as getNexusAddress, getDefaultValidatorAddress as getNexusDefaultValidatorAddress, getDeployArgs as getNexusDeployArgs, getEip712Domain as getNexusEip712Domain, getEip7702InitCall as getNexusEip7702InitCall, getGuardianSmartAccount as getNexusGuardianSmartAccount, getInstallData as getNexusInstallData, getSmartAccount as getNexusSmartAccount, packSignature as packNexusSignature, signEip7702InitData as signNexusEip7702InitData, } from './nexus.js';
|
|
9
|
+
import { getAddress as getPassportAddress, getInstallData as getPassportInstallData, packSignature as packPassportSignature, } from './passport.js';
|
|
10
|
+
import { getAddress as getSafeAddress, getDeployArgs as getSafeDeployArgs, getEip712Domain as getSafeEip712Domain, getGuardianSmartAccount as getSafeGuardianSmartAccount, getInstallData as getSafeInstallData, getSmartAccount as getSafeSmartAccount, getV0DeployArgs as getSafeV0DeployArgs, packSignature as packSafeSignature, } from './safe.js';
|
|
11
|
+
import { convertOwnerSetToSignerSet } from './signing/common.js';
|
|
12
|
+
import { sign as signMessage } from './signing/message.js';
|
|
13
|
+
import { sign as signTypedData } from './signing/typedData.js';
|
|
14
|
+
import { getAddress as getStartaleAddress, getDeployArgs as getStartaleDeployArgs, getEip712Domain as getStartaleEip712Domain, getGuardianSmartAccount as getStartaleGuardianSmartAccount, getInstallData as getStartaleInstallData, getSmartAccount as getStartaleSmartAccount, packSignature as packStartaleSignature, } from './startale.js';
|
|
15
|
+
import { createTransport, getBundlerClient, } from './utils.js';
|
|
55
16
|
function getDeployArgs(config) {
|
|
56
17
|
const account = getAccountProvider(config);
|
|
57
18
|
switch (account.type) {
|
|
58
19
|
case 'safe': {
|
|
59
|
-
return (
|
|
20
|
+
return getSafeDeployArgs(config);
|
|
60
21
|
}
|
|
61
22
|
case 'nexus': {
|
|
62
|
-
return (
|
|
23
|
+
return getNexusDeployArgs(config);
|
|
63
24
|
}
|
|
64
25
|
case 'kernel': {
|
|
65
|
-
return (
|
|
26
|
+
return getKernelDeployArgs(config);
|
|
66
27
|
}
|
|
67
28
|
case 'startale': {
|
|
68
|
-
return (
|
|
29
|
+
return getStartaleDeployArgs(config);
|
|
69
30
|
}
|
|
70
31
|
case 'passport': {
|
|
71
32
|
// Mocked data; will be overridden by the actual deploy args
|
|
72
33
|
return {
|
|
73
|
-
factory:
|
|
74
|
-
factoryData:
|
|
75
|
-
salt:
|
|
76
|
-
implementation:
|
|
34
|
+
factory: zeroAddress,
|
|
35
|
+
factoryData: zeroHash,
|
|
36
|
+
salt: zeroHash,
|
|
37
|
+
implementation: zeroAddress,
|
|
77
38
|
initializationCallData: '0x',
|
|
78
39
|
initData: '0x',
|
|
79
40
|
};
|
|
@@ -87,7 +48,7 @@ function getV0DeployArgs(config) {
|
|
|
87
48
|
const account = getAccountProvider(config);
|
|
88
49
|
switch (account.type) {
|
|
89
50
|
case 'safe': {
|
|
90
|
-
return (
|
|
51
|
+
return getSafeV0DeployArgs(config);
|
|
91
52
|
}
|
|
92
53
|
default: {
|
|
93
54
|
throw new Error(`Unsupported account type: ${account.type}`);
|
|
@@ -107,7 +68,7 @@ function getInitCode(config) {
|
|
|
107
68
|
else {
|
|
108
69
|
const deployArgs = getDeployArgs(config);
|
|
109
70
|
if (!deployArgs) {
|
|
110
|
-
throw new
|
|
71
|
+
throw new FactoryArgsNotAvailableError();
|
|
111
72
|
}
|
|
112
73
|
const { factory, factoryData } = deployArgs;
|
|
113
74
|
return {
|
|
@@ -129,7 +90,7 @@ function getV0InitCode(config) {
|
|
|
129
90
|
else {
|
|
130
91
|
const deployArgs = getV0DeployArgs(config);
|
|
131
92
|
if (!deployArgs) {
|
|
132
|
-
throw new
|
|
93
|
+
throw new FactoryArgsNotAvailableError();
|
|
133
94
|
}
|
|
134
95
|
const { factory, factoryData } = deployArgs;
|
|
135
96
|
return {
|
|
@@ -141,23 +102,23 @@ function getV0InitCode(config) {
|
|
|
141
102
|
async function signEip7702InitData(config) {
|
|
142
103
|
const eoa = config.eoa;
|
|
143
104
|
if (!eoa) {
|
|
144
|
-
throw new
|
|
105
|
+
throw new Eip7702AccountMustHaveEoaError();
|
|
145
106
|
}
|
|
146
107
|
const account = getAccountProvider(config);
|
|
147
108
|
switch (account.type) {
|
|
148
109
|
case 'nexus': {
|
|
149
|
-
return await (
|
|
110
|
+
return await signNexusEip7702InitData(config, eoa);
|
|
150
111
|
}
|
|
151
112
|
case 'eoa': {
|
|
152
|
-
throw new
|
|
113
|
+
throw new Eip7702NotSupportedForAccountError(account.type);
|
|
153
114
|
}
|
|
154
115
|
case 'safe':
|
|
155
116
|
case 'kernel':
|
|
156
117
|
case 'startale': {
|
|
157
|
-
throw new
|
|
118
|
+
throw new Eip7702NotSupportedForAccountError(account.type);
|
|
158
119
|
}
|
|
159
120
|
default: {
|
|
160
|
-
throw new
|
|
121
|
+
throw new Eip7702NotSupportedForAccountError(account.type);
|
|
161
122
|
}
|
|
162
123
|
}
|
|
163
124
|
}
|
|
@@ -165,15 +126,15 @@ function getEip7702InitCall(config, signature) {
|
|
|
165
126
|
const account = getAccountProvider(config);
|
|
166
127
|
switch (account.type) {
|
|
167
128
|
case 'nexus': {
|
|
168
|
-
return (
|
|
129
|
+
return getNexusEip7702InitCall(config, signature);
|
|
169
130
|
}
|
|
170
131
|
case 'safe':
|
|
171
132
|
case 'kernel':
|
|
172
133
|
case 'startale': {
|
|
173
|
-
throw new
|
|
134
|
+
throw new Eip7702NotSupportedForAccountError(account.type);
|
|
174
135
|
}
|
|
175
136
|
default: {
|
|
176
|
-
throw new
|
|
137
|
+
throw new Eip7702NotSupportedForAccountError(account.type);
|
|
177
138
|
}
|
|
178
139
|
}
|
|
179
140
|
}
|
|
@@ -181,22 +142,22 @@ function getEip712Domain(config, chain) {
|
|
|
181
142
|
const account = getAccountProvider(config);
|
|
182
143
|
switch (account.type) {
|
|
183
144
|
case 'nexus': {
|
|
184
|
-
return (
|
|
145
|
+
return getNexusEip712Domain(config, chain);
|
|
185
146
|
}
|
|
186
147
|
case 'safe': {
|
|
187
|
-
return (
|
|
148
|
+
return getSafeEip712Domain(config, chain);
|
|
188
149
|
}
|
|
189
150
|
case 'kernel': {
|
|
190
|
-
return (
|
|
151
|
+
return getKernelEip712Domain(config, chain);
|
|
191
152
|
}
|
|
192
153
|
case 'startale': {
|
|
193
|
-
return (
|
|
154
|
+
return getStartaleEip712Domain(config, chain);
|
|
194
155
|
}
|
|
195
156
|
case 'eoa': {
|
|
196
|
-
throw new
|
|
157
|
+
throw new Eip712DomainNotAvailableError('EOA accounts do not have an EIP-712 domain');
|
|
197
158
|
}
|
|
198
159
|
default: {
|
|
199
|
-
throw new
|
|
160
|
+
throw new Eip712DomainNotAvailableError(`Account type ${account.type} not yet supported`);
|
|
200
161
|
}
|
|
201
162
|
}
|
|
202
163
|
}
|
|
@@ -206,22 +167,22 @@ function getModuleInstallationCalls(config, module) {
|
|
|
206
167
|
const account = getAccountProvider(config);
|
|
207
168
|
switch (account.type) {
|
|
208
169
|
case 'safe': {
|
|
209
|
-
return [(
|
|
170
|
+
return [getSafeInstallData(module)];
|
|
210
171
|
}
|
|
211
172
|
case 'nexus': {
|
|
212
|
-
return [(
|
|
173
|
+
return [getNexusInstallData(module)];
|
|
213
174
|
}
|
|
214
175
|
case 'kernel': {
|
|
215
|
-
return (
|
|
176
|
+
return getKernelInstallData(module);
|
|
216
177
|
}
|
|
217
178
|
case 'startale': {
|
|
218
|
-
return [(
|
|
179
|
+
return [getStartaleInstallData(module)];
|
|
219
180
|
}
|
|
220
181
|
case 'passport': {
|
|
221
|
-
return [(
|
|
182
|
+
return [getPassportInstallData(module)];
|
|
222
183
|
}
|
|
223
184
|
case 'eoa': {
|
|
224
|
-
throw new
|
|
185
|
+
throw new ModuleInstallationNotSupportedError(account.type);
|
|
225
186
|
}
|
|
226
187
|
}
|
|
227
188
|
}
|
|
@@ -234,7 +195,7 @@ function getModuleInstallationCalls(config, module) {
|
|
|
234
195
|
}
|
|
235
196
|
function getModuleUninstallationCalls(config, module) {
|
|
236
197
|
const address = getAddress(config);
|
|
237
|
-
const data =
|
|
198
|
+
const data = encodeFunctionData({
|
|
238
199
|
abi: [
|
|
239
200
|
{
|
|
240
201
|
type: 'function',
|
|
@@ -265,30 +226,30 @@ function getModuleUninstallationCalls(config, module) {
|
|
|
265
226
|
function getAddress(config) {
|
|
266
227
|
if (is7702(config)) {
|
|
267
228
|
if (!config.eoa) {
|
|
268
|
-
throw new
|
|
229
|
+
throw new Eip7702AccountMustHaveEoaError();
|
|
269
230
|
}
|
|
270
231
|
return config.eoa.address;
|
|
271
232
|
}
|
|
272
233
|
const account = getAccountProvider(config);
|
|
273
234
|
switch (account.type) {
|
|
274
235
|
case 'safe': {
|
|
275
|
-
return (
|
|
236
|
+
return getSafeAddress(config);
|
|
276
237
|
}
|
|
277
238
|
case 'nexus': {
|
|
278
|
-
return (
|
|
239
|
+
return getNexusAddress(config);
|
|
279
240
|
}
|
|
280
241
|
case 'kernel': {
|
|
281
|
-
return (
|
|
242
|
+
return getKernelAddress(config);
|
|
282
243
|
}
|
|
283
244
|
case 'startale': {
|
|
284
|
-
return (
|
|
245
|
+
return getStartaleAddress(config);
|
|
285
246
|
}
|
|
286
247
|
case 'passport': {
|
|
287
|
-
return (
|
|
248
|
+
return getPassportAddress(config);
|
|
288
249
|
}
|
|
289
250
|
case 'eoa': {
|
|
290
251
|
if (!config.eoa) {
|
|
291
|
-
throw new
|
|
252
|
+
throw new AccountError({
|
|
292
253
|
message: 'EOA account must have an EOA configured',
|
|
293
254
|
});
|
|
294
255
|
}
|
|
@@ -309,33 +270,33 @@ function checkAddress(config) {
|
|
|
309
270
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
310
271
|
async function getEip1271Signature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
311
272
|
if (config.account?.type === 'eoa') {
|
|
312
|
-
throw new
|
|
273
|
+
throw new EoaSigningNotSupportedError('packed signatures');
|
|
313
274
|
}
|
|
314
|
-
signers = signers ??
|
|
315
|
-
const signFn = (hash) => (
|
|
275
|
+
signers = signers ?? convertOwnerSetToSignerSet(config.owners);
|
|
276
|
+
const signFn = (hash) => signMessage(signers, chain, address, hash, false);
|
|
316
277
|
const account = getAccountProvider(config);
|
|
317
278
|
const address = getAddress(config);
|
|
318
279
|
switch (account.type) {
|
|
319
280
|
case 'safe': {
|
|
320
281
|
const signature = await signFn(hash);
|
|
321
|
-
return (
|
|
282
|
+
return packSafeSignature(signature, validator, transformSignature);
|
|
322
283
|
}
|
|
323
284
|
case 'nexus': {
|
|
324
285
|
const signature = await signFn(hash);
|
|
325
|
-
const defaultValidatorAddress = (
|
|
326
|
-
return (
|
|
286
|
+
const defaultValidatorAddress = getNexusDefaultValidatorAddress(account.version);
|
|
287
|
+
return packNexusSignature(signature, validator, transformSignature, defaultValidatorAddress);
|
|
327
288
|
}
|
|
328
289
|
case 'passport': {
|
|
329
290
|
const signature = await signFn(hash);
|
|
330
|
-
return (
|
|
291
|
+
return packPassportSignature(signature, validator, transformSignature);
|
|
331
292
|
}
|
|
332
293
|
case 'kernel': {
|
|
333
|
-
const signature = await signFn((
|
|
334
|
-
return (
|
|
294
|
+
const signature = await signFn(wrapKernelMessageHash(hash, address));
|
|
295
|
+
return packKernelSignature(signature, validator, transformSignature);
|
|
335
296
|
}
|
|
336
297
|
case 'startale': {
|
|
337
298
|
const signature = await signFn(hash);
|
|
338
|
-
return (
|
|
299
|
+
return packStartaleSignature(signature, validator, transformSignature);
|
|
339
300
|
}
|
|
340
301
|
default: {
|
|
341
302
|
throw new Error(`Unsupported account type: ${account.type}`);
|
|
@@ -345,46 +306,46 @@ async function getEip1271Signature(config, signers, chain, validator, hash, tran
|
|
|
345
306
|
// Signs and packs a signature to be used by the emissary validator
|
|
346
307
|
async function getEmissarySignature(config, signers, chain, hash, transformSignature = (signature) => signature) {
|
|
347
308
|
if (config.account?.type === 'eoa') {
|
|
348
|
-
throw new
|
|
309
|
+
throw new EoaSigningNotSupportedError('packed signatures');
|
|
349
310
|
}
|
|
350
|
-
signers = signers ??
|
|
311
|
+
signers = signers ?? convertOwnerSetToSignerSet(config.owners);
|
|
351
312
|
const address = getAddress(config);
|
|
352
|
-
const signFn = (hash) => (
|
|
313
|
+
const signFn = (hash) => signMessage(signers, chain, address, hash, false);
|
|
353
314
|
const signature = await signFn(hash);
|
|
354
315
|
return transformSignature(signature);
|
|
355
316
|
}
|
|
356
317
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
357
318
|
async function getTypedDataPackedSignature(config, signers, chain, validator, parameters, transformSignature = (signature) => signature) {
|
|
358
319
|
if (config.account?.type === 'eoa') {
|
|
359
|
-
throw new
|
|
320
|
+
throw new EoaSigningNotSupportedError('packed signatures');
|
|
360
321
|
}
|
|
361
322
|
const address = getAddress(config);
|
|
362
|
-
signers = signers ??
|
|
363
|
-
const signFn = (parameters) => (
|
|
323
|
+
signers = signers ?? convertOwnerSetToSignerSet(config.owners);
|
|
324
|
+
const signFn = (parameters) => signTypedData(signers, chain, address, parameters);
|
|
364
325
|
const account = getAccountProvider(config);
|
|
365
326
|
switch (account.type) {
|
|
366
327
|
case 'safe': {
|
|
367
328
|
const signature = await signFn(parameters);
|
|
368
|
-
return (
|
|
329
|
+
return packSafeSignature(signature, validator, transformSignature);
|
|
369
330
|
}
|
|
370
331
|
case 'nexus': {
|
|
371
332
|
const signature = await signFn(parameters);
|
|
372
|
-
const defaultValidatorAddress = (
|
|
373
|
-
return (
|
|
333
|
+
const defaultValidatorAddress = getNexusDefaultValidatorAddress(account.version);
|
|
334
|
+
return packNexusSignature(signature, validator, transformSignature, defaultValidatorAddress);
|
|
374
335
|
}
|
|
375
336
|
case 'passport': {
|
|
376
337
|
const signature = await signFn(parameters);
|
|
377
|
-
return (
|
|
338
|
+
return packPassportSignature(signature, validator, transformSignature);
|
|
378
339
|
}
|
|
379
340
|
case 'kernel': {
|
|
380
341
|
const address = getAddress(config);
|
|
381
|
-
const signMessageFn = (hash) => (
|
|
382
|
-
const signature = await signMessageFn((
|
|
383
|
-
return (
|
|
342
|
+
const signMessageFn = (hash) => signMessage(signers, chain, address, hash, false);
|
|
343
|
+
const signature = await signMessageFn(wrapKernelMessageHash(hashTypedData(parameters), address));
|
|
344
|
+
return packKernelSignature(signature, validator, transformSignature);
|
|
384
345
|
}
|
|
385
346
|
case 'startale': {
|
|
386
347
|
const signature = await signFn(parameters);
|
|
387
|
-
return (
|
|
348
|
+
return packStartaleSignature(signature, validator, transformSignature);
|
|
388
349
|
}
|
|
389
350
|
default: {
|
|
390
351
|
throw new Error(`Unsupported account type: ${account.type}`);
|
|
@@ -396,9 +357,9 @@ async function isDeployed(config, chain) {
|
|
|
396
357
|
if (account.type === 'eoa') {
|
|
397
358
|
return true;
|
|
398
359
|
}
|
|
399
|
-
const publicClient =
|
|
360
|
+
const publicClient = createPublicClient({
|
|
400
361
|
chain: chain,
|
|
401
|
-
transport:
|
|
362
|
+
transport: createTransport(chain, config.provider),
|
|
402
363
|
});
|
|
403
364
|
const address = getAddress(config);
|
|
404
365
|
const code = await publicClient.getCode({
|
|
@@ -407,7 +368,7 @@ async function isDeployed(config, chain) {
|
|
|
407
368
|
if (!code) {
|
|
408
369
|
return false;
|
|
409
370
|
}
|
|
410
|
-
return
|
|
371
|
+
return size(code) > 0;
|
|
411
372
|
}
|
|
412
373
|
async function deploy(config, chain, params) {
|
|
413
374
|
const deployed = await isDeployed(config, chain);
|
|
@@ -420,7 +381,7 @@ async function deploy(config, chain, params) {
|
|
|
420
381
|
}
|
|
421
382
|
const deployArgs = getDeployArgs(config);
|
|
422
383
|
if (!deployArgs) {
|
|
423
|
-
throw new
|
|
384
|
+
throw new FactoryArgsNotAvailableError();
|
|
424
385
|
}
|
|
425
386
|
const intentExecutorInstalled = 'intentExecutorInstalled' in deployArgs
|
|
426
387
|
? deployArgs.intentExecutorInstalled
|
|
@@ -445,10 +406,10 @@ async function setup(config, chain) {
|
|
|
445
406
|
if (account.type === 'eoa') {
|
|
446
407
|
return false;
|
|
447
408
|
}
|
|
448
|
-
const modules =
|
|
449
|
-
const publicClient =
|
|
409
|
+
const modules = getSetup(config);
|
|
410
|
+
const publicClient = createPublicClient({
|
|
450
411
|
chain,
|
|
451
|
-
transport:
|
|
412
|
+
transport: createTransport(chain, config.provider),
|
|
452
413
|
});
|
|
453
414
|
const address = getAddress(config);
|
|
454
415
|
const allModules = [
|
|
@@ -489,24 +450,24 @@ async function setup(config, chain) {
|
|
|
489
450
|
calls.push(...getModuleInstallationCalls(config, module));
|
|
490
451
|
}
|
|
491
452
|
// Select the transaction infra layer based on the intent executor status
|
|
492
|
-
const intentExecutor =
|
|
453
|
+
const intentExecutor = getIntentExecutor(config);
|
|
493
454
|
const hasIntentExecutor = modulesToInstall.every((module) => module.address !== intentExecutor.address);
|
|
494
455
|
let result;
|
|
495
456
|
if (hasIntentExecutor) {
|
|
496
|
-
result = await
|
|
457
|
+
result = await sendTransactionInternal(config, [chain], chain, {
|
|
497
458
|
callInputs: calls,
|
|
498
459
|
});
|
|
499
460
|
}
|
|
500
461
|
else {
|
|
501
|
-
result = await
|
|
462
|
+
result = await sendUserOperationInternal(config, chain, calls);
|
|
502
463
|
}
|
|
503
|
-
await
|
|
464
|
+
await waitForExecution(config, result, true);
|
|
504
465
|
return true;
|
|
505
466
|
}
|
|
506
467
|
async function deployWithIntent(chain, config, sponsored, eip7702InitSignature) {
|
|
507
|
-
const publicClient =
|
|
468
|
+
const publicClient = createPublicClient({
|
|
508
469
|
chain,
|
|
509
|
-
transport:
|
|
470
|
+
transport: createTransport(chain, config.provider),
|
|
510
471
|
});
|
|
511
472
|
const address = getAddress(config);
|
|
512
473
|
const code = await publicClient.getCode({ address });
|
|
@@ -519,25 +480,25 @@ async function deployWithIntent(chain, config, sponsored, eip7702InitSignature)
|
|
|
519
480
|
if (!initSignature && is7702(config)) {
|
|
520
481
|
initSignature = await signEip7702InitData(config);
|
|
521
482
|
}
|
|
522
|
-
const result = await
|
|
483
|
+
const result = await sendTransaction(config, {
|
|
523
484
|
sourceChains: [chain],
|
|
524
485
|
targetChain: chain,
|
|
525
486
|
calls: [],
|
|
526
487
|
sponsored,
|
|
527
488
|
eip7702InitSignature: initSignature,
|
|
528
489
|
});
|
|
529
|
-
await
|
|
490
|
+
await waitForExecution(config, result, true);
|
|
530
491
|
}
|
|
531
492
|
async function deployWithBundler(chain, config) {
|
|
532
|
-
const publicClient =
|
|
493
|
+
const publicClient = createPublicClient({
|
|
533
494
|
chain,
|
|
534
|
-
transport:
|
|
495
|
+
transport: createTransport(chain, config.provider),
|
|
535
496
|
});
|
|
536
|
-
const bundlerClient =
|
|
497
|
+
const bundlerClient = getBundlerClient(config, publicClient);
|
|
537
498
|
const smartAccount = await getSmartAccount(config, publicClient, chain);
|
|
538
499
|
const deployArgs = getDeployArgs(config);
|
|
539
500
|
if (!deployArgs) {
|
|
540
|
-
throw new
|
|
501
|
+
throw new FactoryArgsNotAvailableError();
|
|
541
502
|
}
|
|
542
503
|
const { factory, factoryData } = deployArgs;
|
|
543
504
|
const opHash = await bundlerClient.sendUserOperation({
|
|
@@ -546,7 +507,7 @@ async function deployWithBundler(chain, config) {
|
|
|
546
507
|
factoryData,
|
|
547
508
|
calls: [
|
|
548
509
|
{
|
|
549
|
-
to:
|
|
510
|
+
to: zeroAddress,
|
|
550
511
|
value: 0n,
|
|
551
512
|
data: '0x',
|
|
552
513
|
},
|
|
@@ -564,16 +525,16 @@ async function toErc6492Signature(config, signature, chain) {
|
|
|
564
525
|
// Account is not deployed, use ERC-6492
|
|
565
526
|
const initCode = getInitCode(config);
|
|
566
527
|
if (!initCode) {
|
|
567
|
-
throw new
|
|
528
|
+
throw new FactoryArgsNotAvailableError();
|
|
568
529
|
}
|
|
569
530
|
const deployArgs = getDeployArgs(config);
|
|
570
531
|
if (!deployArgs) {
|
|
571
|
-
throw new
|
|
532
|
+
throw new FactoryArgsNotAvailableError();
|
|
572
533
|
}
|
|
573
534
|
const { factory, factoryData } = deployArgs;
|
|
574
535
|
const magicBytes = '0x6492649264926492649264926492649264926492649264926492649264926492';
|
|
575
|
-
return
|
|
576
|
-
|
|
536
|
+
return concat([
|
|
537
|
+
encodeAbiParameters([
|
|
577
538
|
{ name: 'create2Factory', type: 'address' },
|
|
578
539
|
{ name: 'factoryCalldata', type: 'bytes' },
|
|
579
540
|
{ name: 'originalERC1271Signature', type: 'bytes' },
|
|
@@ -587,33 +548,33 @@ async function getSmartAccount(config, client, chain) {
|
|
|
587
548
|
throw new Error('getSmartAccount is not supported for EOA accounts');
|
|
588
549
|
}
|
|
589
550
|
if (!config.owners) {
|
|
590
|
-
throw new
|
|
551
|
+
throw new OwnersFieldRequiredError();
|
|
591
552
|
}
|
|
592
553
|
const account = getAccountProvider(config);
|
|
593
554
|
const address = getAddress(config);
|
|
594
|
-
const ownerValidator =
|
|
595
|
-
const signers =
|
|
596
|
-
const signFn = (hash) => (
|
|
555
|
+
const ownerValidator = getOwnerValidator(config);
|
|
556
|
+
const signers = convertOwnerSetToSignerSet(config.owners);
|
|
557
|
+
const signFn = (hash) => signMessage(signers, chain, address, hash, true);
|
|
597
558
|
switch (account.type) {
|
|
598
559
|
case 'safe': {
|
|
599
|
-
return (
|
|
560
|
+
return getSafeSmartAccount(client, address, config.owners, ownerValidator.address, signFn);
|
|
600
561
|
}
|
|
601
562
|
case 'nexus': {
|
|
602
|
-
const defaultValidatorAddress = (
|
|
603
|
-
return (
|
|
563
|
+
const defaultValidatorAddress = getNexusDefaultValidatorAddress(account.version);
|
|
564
|
+
return getNexusSmartAccount(client, address, config.owners, ownerValidator.address, signFn, defaultValidatorAddress);
|
|
604
565
|
}
|
|
605
566
|
case 'kernel': {
|
|
606
|
-
return (
|
|
567
|
+
return getKernelSmartAccount(client, address, config.owners, ownerValidator.address, signFn);
|
|
607
568
|
}
|
|
608
569
|
case 'startale': {
|
|
609
|
-
return (
|
|
570
|
+
return getStartaleSmartAccount(client, address, config.owners, ownerValidator.address, signFn);
|
|
610
571
|
}
|
|
611
572
|
}
|
|
612
573
|
}
|
|
613
574
|
async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
614
575
|
const address = getAddress(config);
|
|
615
576
|
const accounts = guardians.type === 'ecdsa' ? guardians.accounts : [];
|
|
616
|
-
const socialRecoveryValidator =
|
|
577
|
+
const socialRecoveryValidator = getSocialRecoveryValidator(accounts);
|
|
617
578
|
if (!socialRecoveryValidator) {
|
|
618
579
|
throw new Error('Social recovery is not available');
|
|
619
580
|
}
|
|
@@ -621,21 +582,21 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
621
582
|
type: 'guardians',
|
|
622
583
|
guardians: accounts,
|
|
623
584
|
};
|
|
624
|
-
const signFn = (hash) => (
|
|
585
|
+
const signFn = (hash) => signMessage(signers, chain, address, hash, true);
|
|
625
586
|
const account = getAccountProvider(config);
|
|
626
587
|
switch (account.type) {
|
|
627
588
|
case 'safe': {
|
|
628
|
-
return (
|
|
589
|
+
return getSafeGuardianSmartAccount(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
629
590
|
}
|
|
630
591
|
case 'nexus': {
|
|
631
|
-
const defaultValidatorAddress = (
|
|
632
|
-
return (
|
|
592
|
+
const defaultValidatorAddress = getNexusDefaultValidatorAddress(account.version);
|
|
593
|
+
return getNexusGuardianSmartAccount(client, address, guardians, socialRecoveryValidator.address, signFn, defaultValidatorAddress);
|
|
633
594
|
}
|
|
634
595
|
case 'kernel': {
|
|
635
|
-
return (
|
|
596
|
+
return getKernelGuardianSmartAccount(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
636
597
|
}
|
|
637
598
|
case 'startale': {
|
|
638
|
-
return (
|
|
599
|
+
return getStartaleGuardianSmartAccount(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
639
600
|
}
|
|
640
601
|
}
|
|
641
602
|
}
|
|
@@ -651,3 +612,6 @@ function getAccountProvider(config) {
|
|
|
651
612
|
type: 'nexus',
|
|
652
613
|
};
|
|
653
614
|
}
|
|
615
|
+
export { getEip712Domain, getModuleInstallationCalls, getModuleUninstallationCalls, getAddress, checkAddress, getAccountProvider, getInitCode, getV0InitCode, signEip7702InitData, getEip7702InitCall, is7702, isDeployed, deploy, setup, toErc6492Signature, getSmartAccount, getGuardianSmartAccount, getEip1271Signature, getEmissarySignature, getTypedDataPackedSignature,
|
|
616
|
+
// Errors
|
|
617
|
+
isAccountError, AccountError, AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, EoaSigningMethodNotConfiguredError, EoaSigningNotSupportedError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, ModuleInstallationNotSupportedError, OwnersFieldRequiredError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Chain, type Transport } from 'viem';
|
|
2
|
-
import type { ProviderConfig } from '../../types';
|
|
2
|
+
import type { ProviderConfig } from '../../types.js';
|
|
3
3
|
declare function createTransport(chain: Chain, provider?: ProviderConfig): Transport;
|
|
4
4
|
export { createTransport };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createTransport = createTransport;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
const providers_1 = require("./providers");
|
|
1
|
+
import { http } from 'viem';
|
|
2
|
+
import { getAlchemyUrl, getCustomUrl } from './providers.js';
|
|
6
3
|
function createTransport(chain, provider) {
|
|
7
4
|
if (!provider) {
|
|
8
|
-
return
|
|
5
|
+
return http();
|
|
9
6
|
}
|
|
10
7
|
switch (provider.type) {
|
|
11
8
|
case 'alchemy': {
|
|
12
|
-
const alchemyUrl =
|
|
13
|
-
return
|
|
9
|
+
const alchemyUrl = getAlchemyUrl(chain.id, provider.apiKey);
|
|
10
|
+
return http(alchemyUrl);
|
|
14
11
|
}
|
|
15
12
|
case 'custom': {
|
|
16
|
-
const customUrl =
|
|
13
|
+
const customUrl = getCustomUrl(chain.id, provider.urls);
|
|
17
14
|
// Fall back to default provider if no custom URL configured for this chain
|
|
18
|
-
return
|
|
15
|
+
return http(customUrl);
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
18
|
}
|
|
19
|
+
export { createTransport };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SupportedChain } from '../../orchestrator';
|
|
1
|
+
import type { SupportedChain } from '../../orchestrator/index.js';
|
|
2
2
|
declare function getAlchemyUrl(chainId: SupportedChain, apiKey: string): string;
|
|
3
3
|
declare function getCustomUrl(chainId: number, urls: Record<number, string>): string | undefined;
|
|
4
4
|
export { getAlchemyUrl, getCustomUrl };
|