@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,23 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.getSmartAccount = getSmartAccount;
|
|
10
|
-
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
11
|
-
exports.signEip7702InitData = signEip7702InitData;
|
|
12
|
-
exports.getEip7702InitCall = getEip7702InitCall;
|
|
13
|
-
const viem_1 = require("viem");
|
|
14
|
-
const account_abstraction_1 = require("viem/account-abstraction");
|
|
15
|
-
const modules_1 = require("../modules");
|
|
16
|
-
const validators_1 = require("../modules/validators");
|
|
17
|
-
const core_1 = require("../modules/validators/core");
|
|
18
|
-
const error_1 = require("./error");
|
|
19
|
-
const utils_1 = require("./utils");
|
|
20
|
-
const NEXUS_DEFAULT_VALIDATOR_ADDRESS = core_1.OWNABLE_VALIDATOR_ADDRESS;
|
|
1
|
+
import { concat, decodeFunctionData, encodeAbiParameters, encodeFunctionData, encodePacked, getContractAddress, keccak256, parseAbi, size, toHex, zeroAddress, zeroHash, } from 'viem';
|
|
2
|
+
import { entryPoint07Abi, entryPoint07Address, getUserOperationHash, toSmartAccount, } from 'viem/account-abstraction';
|
|
3
|
+
import { getSetup as getModuleSetup } from '../modules/index.js';
|
|
4
|
+
import { getMockSignature } from '../modules/validators/index.js';
|
|
5
|
+
import { OWNABLE_VALIDATOR_ADDRESS } from '../modules/validators/core.js';
|
|
6
|
+
import { AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, SigningNotSupportedForAccountError, } from './error.js';
|
|
7
|
+
import { encode7579Calls, getAccountNonce } from './utils.js';
|
|
8
|
+
const NEXUS_DEFAULT_VALIDATOR_ADDRESS = OWNABLE_VALIDATOR_ADDRESS;
|
|
21
9
|
const NEXUS_VERSION = '1.2.0';
|
|
22
10
|
const NEXUS_IMPLEMENTATION_ADDRESS = '0x000000000032ddc454c3bdcba80484ad5a798705';
|
|
23
11
|
const NEXUS_FACTORY_ADDRESS = '0x0000000000679a258c64d2f20f310e12b64b7375';
|
|
@@ -40,21 +28,21 @@ function getDeployArgs(config) {
|
|
|
40
28
|
if (v0Result) {
|
|
41
29
|
return v0Result;
|
|
42
30
|
}
|
|
43
|
-
throw new
|
|
31
|
+
throw new AccountConfigurationNotSupportedError('Invalid factory data: unrecognized schema', 'nexus');
|
|
44
32
|
}
|
|
45
33
|
const account = config.account;
|
|
46
|
-
const defaultSalt =
|
|
34
|
+
const defaultSalt = keccak256('0x');
|
|
47
35
|
const salt = account?.salt ?? defaultSalt;
|
|
48
|
-
const moduleSetup = (
|
|
36
|
+
const moduleSetup = getModuleSetup(config);
|
|
49
37
|
// Filter out the default validator
|
|
50
38
|
const defaultValidator = moduleSetup.validators.find((v) => v.address === NEXUS_DEFAULT_VALIDATOR_ADDRESS);
|
|
51
39
|
const defaultValidatorInitData = defaultValidator
|
|
52
40
|
? defaultValidator.initData
|
|
53
41
|
: '0x';
|
|
54
42
|
const validators = moduleSetup.validators.filter((v) => v.address !== NEXUS_DEFAULT_VALIDATOR_ADDRESS);
|
|
55
|
-
const bootstrapData =
|
|
56
|
-
?
|
|
57
|
-
abi:
|
|
43
|
+
const bootstrapData = size(defaultValidatorInitData)
|
|
44
|
+
? encodeFunctionData({
|
|
45
|
+
abi: parseAbi([
|
|
58
46
|
'struct BootstrapConfig {address module;bytes initData;}',
|
|
59
47
|
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
60
48
|
'function initNexusWithDefaultValidatorAndOtherModulesNoRegistry(bytes calldata defaultValidatorInitData,BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
|
|
@@ -71,7 +59,7 @@ function getDeployArgs(config) {
|
|
|
71
59
|
initData: e.initData,
|
|
72
60
|
})),
|
|
73
61
|
{
|
|
74
|
-
module:
|
|
62
|
+
module: zeroAddress,
|
|
75
63
|
initData: '0x',
|
|
76
64
|
},
|
|
77
65
|
moduleSetup.fallbacks.map((f) => ({
|
|
@@ -81,8 +69,8 @@ function getDeployArgs(config) {
|
|
|
81
69
|
[],
|
|
82
70
|
],
|
|
83
71
|
})
|
|
84
|
-
:
|
|
85
|
-
abi:
|
|
72
|
+
: encodeFunctionData({
|
|
73
|
+
abi: parseAbi([
|
|
86
74
|
'struct BootstrapConfig {address module;bytes initData;}',
|
|
87
75
|
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
88
76
|
'function initNexusNoRegistry(BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
|
|
@@ -98,7 +86,7 @@ function getDeployArgs(config) {
|
|
|
98
86
|
initData: e.initData,
|
|
99
87
|
})),
|
|
100
88
|
{
|
|
101
|
-
module:
|
|
89
|
+
module: zeroAddress,
|
|
102
90
|
initData: '0x',
|
|
103
91
|
},
|
|
104
92
|
moduleSetup.fallbacks.map((f) => ({
|
|
@@ -108,14 +96,14 @@ function getDeployArgs(config) {
|
|
|
108
96
|
[],
|
|
109
97
|
],
|
|
110
98
|
});
|
|
111
|
-
const initData =
|
|
112
|
-
const factoryData =
|
|
113
|
-
abi:
|
|
99
|
+
const initData = encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_ADDRESS, bootstrapData]);
|
|
100
|
+
const factoryData = encodeFunctionData({
|
|
101
|
+
abi: parseAbi(['function createAccount(bytes,bytes32)']),
|
|
114
102
|
functionName: 'createAccount',
|
|
115
103
|
args: [initData, salt],
|
|
116
104
|
});
|
|
117
|
-
const initializationCallData =
|
|
118
|
-
abi:
|
|
105
|
+
const initializationCallData = encodeFunctionData({
|
|
106
|
+
abi: parseAbi(['function initializeAccount(bytes)']),
|
|
119
107
|
functionName: 'initializeAccount',
|
|
120
108
|
args: [initData],
|
|
121
109
|
});
|
|
@@ -141,7 +129,7 @@ function getAddress(config) {
|
|
|
141
129
|
? NEXUS_CREATION_CODE
|
|
142
130
|
: '0x603d3d8160223d3973000000039dfcad030719b07296710f045f0558f760095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3';
|
|
143
131
|
const accountInitData = factory.toLowerCase() === NEXUS_FACTORY_ADDRESS
|
|
144
|
-
?
|
|
132
|
+
? encodeAbiParameters([
|
|
145
133
|
{
|
|
146
134
|
name: 'address',
|
|
147
135
|
type: 'address',
|
|
@@ -152,28 +140,28 @@ function getAddress(config) {
|
|
|
152
140
|
},
|
|
153
141
|
], [implementation, initializationCallData])
|
|
154
142
|
: '0x';
|
|
155
|
-
const address =
|
|
143
|
+
const address = getContractAddress({
|
|
156
144
|
opcode: 'CREATE2',
|
|
157
145
|
from: factory,
|
|
158
146
|
salt,
|
|
159
|
-
bytecode:
|
|
147
|
+
bytecode: concat([creationCode, accountInitData]),
|
|
160
148
|
});
|
|
161
149
|
return address;
|
|
162
150
|
}
|
|
163
151
|
function getEip712Domain(config, chain) {
|
|
164
152
|
if (config.initData) {
|
|
165
|
-
throw new
|
|
153
|
+
throw new Eip712DomainNotAvailableError('Existing Nexus accounts are not yet supported');
|
|
166
154
|
}
|
|
167
155
|
return {
|
|
168
156
|
name: 'Nexus',
|
|
169
157
|
version: NEXUS_VERSION,
|
|
170
158
|
chainId: chain.id,
|
|
171
159
|
verifyingContract: getAddress(config),
|
|
172
|
-
salt:
|
|
160
|
+
salt: zeroHash,
|
|
173
161
|
};
|
|
174
162
|
}
|
|
175
163
|
function getInstallData(module) {
|
|
176
|
-
return
|
|
164
|
+
return encodeFunctionData({
|
|
177
165
|
abi: [
|
|
178
166
|
{
|
|
179
167
|
type: 'function',
|
|
@@ -217,36 +205,36 @@ function getDefaultValidatorAddress(version) {
|
|
|
217
205
|
}
|
|
218
206
|
async function packSignature(signature, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
219
207
|
const validatorAddress = validator.address === defaultValidatorAddress
|
|
220
|
-
?
|
|
208
|
+
? zeroAddress
|
|
221
209
|
: validator.address;
|
|
222
|
-
const packedSig =
|
|
210
|
+
const packedSig = encodePacked(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
|
|
223
211
|
return packedSig;
|
|
224
212
|
}
|
|
225
213
|
async function getSmartAccount(client, address, owners, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
226
214
|
return getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
227
|
-
return
|
|
215
|
+
return getMockSignature(owners);
|
|
228
216
|
}, sign, defaultValidatorAddress);
|
|
229
217
|
}
|
|
230
218
|
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
231
219
|
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
232
|
-
return
|
|
220
|
+
return getMockSignature(guardians);
|
|
233
221
|
}, async (hash) => {
|
|
234
222
|
return await sign(hash);
|
|
235
223
|
}, defaultValidatorAddress);
|
|
236
224
|
}
|
|
237
225
|
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation, defaultValidatorAddress) {
|
|
238
|
-
return await
|
|
226
|
+
return await toSmartAccount({
|
|
239
227
|
client,
|
|
240
228
|
entryPoint: {
|
|
241
|
-
abi:
|
|
242
|
-
address:
|
|
229
|
+
abi: entryPoint07Abi,
|
|
230
|
+
address: entryPoint07Address,
|
|
243
231
|
version: '0.7',
|
|
244
232
|
},
|
|
245
233
|
async decodeCalls() {
|
|
246
234
|
throw new Error('Not implemented');
|
|
247
235
|
},
|
|
248
236
|
async encodeCalls(calls) {
|
|
249
|
-
return
|
|
237
|
+
return encode7579Calls({
|
|
250
238
|
mode: {
|
|
251
239
|
type: calls.length > 1 ? 'batchcall' : 'call',
|
|
252
240
|
revertOnError: false,
|
|
@@ -264,19 +252,19 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
|
|
|
264
252
|
},
|
|
265
253
|
async getNonce(args) {
|
|
266
254
|
const validatorAddress = nonceValidatorAddress === defaultValidatorAddress
|
|
267
|
-
?
|
|
255
|
+
? zeroAddress
|
|
268
256
|
: nonceValidatorAddress;
|
|
269
257
|
const TIMESTAMP_ADJUSTMENT = 16777215n; // max value for size 3
|
|
270
258
|
const defaultedKey = (args?.key ?? 0n) % TIMESTAMP_ADJUSTMENT;
|
|
271
259
|
const defaultedValidationMode = '0x00';
|
|
272
|
-
const key =
|
|
273
|
-
|
|
260
|
+
const key = concat([
|
|
261
|
+
toHex(defaultedKey, { size: 3 }),
|
|
274
262
|
defaultedValidationMode,
|
|
275
263
|
validatorAddress,
|
|
276
264
|
]);
|
|
277
|
-
return
|
|
265
|
+
return getAccountNonce(client, {
|
|
278
266
|
address,
|
|
279
|
-
entryPointAddress:
|
|
267
|
+
entryPointAddress: entryPoint07Address,
|
|
280
268
|
key: BigInt(key),
|
|
281
269
|
});
|
|
282
270
|
},
|
|
@@ -293,13 +281,13 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
|
|
|
293
281
|
const { chainId = client.chain?.id, ...userOperation } = parameters;
|
|
294
282
|
if (!chainId)
|
|
295
283
|
throw new Error('Chain id not found');
|
|
296
|
-
const hash =
|
|
284
|
+
const hash = getUserOperationHash({
|
|
297
285
|
userOperation: {
|
|
298
286
|
...userOperation,
|
|
299
287
|
sender: userOperation.sender ?? (await this.getAddress()),
|
|
300
288
|
signature: '0x',
|
|
301
289
|
},
|
|
302
|
-
entryPointAddress:
|
|
290
|
+
entryPointAddress: entryPoint07Address,
|
|
303
291
|
entryPointVersion: '0.7',
|
|
304
292
|
chainId: chainId,
|
|
305
293
|
});
|
|
@@ -314,7 +302,7 @@ async function signEip7702InitData(config, eoa) {
|
|
|
314
302
|
}
|
|
315
303
|
const { initData } = deployArgs;
|
|
316
304
|
if (!eoa.signTypedData) {
|
|
317
|
-
throw new
|
|
305
|
+
throw new SigningNotSupportedForAccountError();
|
|
318
306
|
}
|
|
319
307
|
const signature = await eoa.signTypedData({
|
|
320
308
|
domain: {
|
|
@@ -342,7 +330,7 @@ function getEip7702InitCall(config, signature) {
|
|
|
342
330
|
const chainIds = [0n];
|
|
343
331
|
const chainIdIndex = 0n;
|
|
344
332
|
const chainIdsLength = 1n;
|
|
345
|
-
const encodedData =
|
|
333
|
+
const encodedData = encodePacked(['uint256', 'uint256', 'uint256', 'bytes'], [chainIdIndex, chainIdsLength, chainIds[0], initData]);
|
|
346
334
|
return encodedData;
|
|
347
335
|
}
|
|
348
336
|
const deployArgs = getDeployArgs(config);
|
|
@@ -351,8 +339,8 @@ function getEip7702InitCall(config, signature) {
|
|
|
351
339
|
}
|
|
352
340
|
const { initData } = deployArgs;
|
|
353
341
|
const encodedData = getEncodedData(initData);
|
|
354
|
-
const accountFullData =
|
|
355
|
-
const accountInitCallData =
|
|
342
|
+
const accountFullData = concat([signature, encodedData]);
|
|
343
|
+
const accountInitCallData = encodeFunctionData({
|
|
356
344
|
abi: [
|
|
357
345
|
{
|
|
358
346
|
type: 'function',
|
|
@@ -377,14 +365,14 @@ function getEip7702InitCall(config, signature) {
|
|
|
377
365
|
}
|
|
378
366
|
function tryDecodeV1FactoryData(factory, factoryData) {
|
|
379
367
|
try {
|
|
380
|
-
const decoded =
|
|
381
|
-
abi:
|
|
368
|
+
const decoded = decodeFunctionData({
|
|
369
|
+
abi: parseAbi(['function createAccount(bytes,bytes32)']),
|
|
382
370
|
data: factoryData,
|
|
383
371
|
});
|
|
384
372
|
const initData = decoded.args[0];
|
|
385
373
|
const salt = decoded.args[1];
|
|
386
|
-
const initializationCallData =
|
|
387
|
-
abi:
|
|
374
|
+
const initializationCallData = encodeFunctionData({
|
|
375
|
+
abi: parseAbi(['function initializeAccount(bytes)']),
|
|
388
376
|
functionName: 'initializeAccount',
|
|
389
377
|
args: [initData],
|
|
390
378
|
});
|
|
@@ -406,8 +394,8 @@ function tryDecodeV1FactoryData(factory, factoryData) {
|
|
|
406
394
|
}
|
|
407
395
|
function tryDecodeV0FactoryData(factory, factoryData) {
|
|
408
396
|
try {
|
|
409
|
-
const decoded =
|
|
410
|
-
abi:
|
|
397
|
+
const decoded = decodeFunctionData({
|
|
398
|
+
abi: parseAbi([
|
|
411
399
|
'function createAccount(address eoaOwner,uint256 index,address[] attesters,uint8 threshold)',
|
|
412
400
|
]),
|
|
413
401
|
data: factoryData,
|
|
@@ -416,21 +404,21 @@ function tryDecodeV0FactoryData(factory, factoryData) {
|
|
|
416
404
|
const index = decoded.args[1];
|
|
417
405
|
const attesters = decoded.args[2];
|
|
418
406
|
const threshold = decoded.args[3];
|
|
419
|
-
const salt =
|
|
407
|
+
const salt = keccak256(encodePacked(['address', 'uint256', 'address[]', 'uint8'], [owner, index, attesters, threshold]));
|
|
420
408
|
const implementation = factory.toLowerCase() === NEXUS_FACTORY_ADDRESS
|
|
421
409
|
? NEXUS_IMPLEMENTATION_ADDRESS
|
|
422
410
|
: NEXUS_IMPLEMENTATION_1_0_0;
|
|
423
|
-
const registry =
|
|
424
|
-
const bootstrapData =
|
|
425
|
-
abi:
|
|
411
|
+
const registry = zeroAddress;
|
|
412
|
+
const bootstrapData = encodeFunctionData({
|
|
413
|
+
abi: parseAbi([
|
|
426
414
|
'function initNexusWithSingleValidator(address validator,bytes data,address registry,address[] attesters,uint8 threshold)',
|
|
427
415
|
]),
|
|
428
416
|
functionName: 'initNexusWithSingleValidator',
|
|
429
417
|
args: [NEXUS_K1_VALIDATOR, owner, registry, attesters, threshold],
|
|
430
418
|
});
|
|
431
|
-
const initData =
|
|
432
|
-
const initializationCallData =
|
|
433
|
-
abi:
|
|
419
|
+
const initData = encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_1_0_0, bootstrapData]);
|
|
420
|
+
const initializationCallData = encodeFunctionData({
|
|
421
|
+
abi: parseAbi(['function initializeAccount(bytes)']),
|
|
434
422
|
functionName: 'initializeAccount',
|
|
435
423
|
args: [initData],
|
|
436
424
|
});
|
|
@@ -453,3 +441,4 @@ function tryDecodeV0FactoryData(factory, factoryData) {
|
|
|
453
441
|
function isAbiDecodingError(error) {
|
|
454
442
|
return (error instanceof Error && error.name === 'AbiFunctionSignatureNotFoundError');
|
|
455
443
|
}
|
|
444
|
+
export { getEip712Domain, getInstallData, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Hex } from 'viem';
|
|
2
|
-
import type { Module } from '../modules/common';
|
|
3
|
-
import type { RhinestoneAccountConfig } from '../types';
|
|
4
|
-
import type { ValidatorConfig } from './utils';
|
|
2
|
+
import type { Module } from '../modules/common.js';
|
|
3
|
+
import type { RhinestoneAccountConfig } from '../types.js';
|
|
4
|
+
import type { ValidatorConfig } from './utils.js';
|
|
5
5
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
6
6
|
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
7
7
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAddress = getAddress;
|
|
4
|
-
exports.packSignature = packSignature;
|
|
5
|
-
exports.getInstallData = getInstallData;
|
|
6
|
-
const viem_1 = require("viem");
|
|
1
|
+
import { concat, encodeAbiParameters, encodeFunctionData, encodePacked, getContractAddress, keccak256, padHex, } from 'viem';
|
|
7
2
|
const CREATION_CODE = '0x6054600f3d396034805130553df3fe63906111273d3560e01c14602b57363d3d373d3d3d3d369030545af43d82803e156027573d90f35b3d90fd5b30543d5260203df3';
|
|
8
3
|
const PASSPORT_FACTORY_ADDRESS = '0xd70c6386ca012cdeb249b4e46c53d3507d9cbb87';
|
|
9
4
|
const PASSPORT_MAIN_MODULE = '0x0d1bf2f4ab334324665aeb8d481ff92cde289439';
|
|
@@ -20,25 +15,25 @@ function getAddress(config) {
|
|
|
20
15
|
account: owner,
|
|
21
16
|
}));
|
|
22
17
|
const salt = encodeImageHash(owners.threshold ?? 1, ownerAccounts);
|
|
23
|
-
const accountInitData =
|
|
24
|
-
const address =
|
|
18
|
+
const accountInitData = padHex(PASSPORT_MAIN_MODULE, { size: 32 });
|
|
19
|
+
const address = getContractAddress({
|
|
25
20
|
opcode: 'CREATE2',
|
|
26
21
|
from: PASSPORT_FACTORY_ADDRESS,
|
|
27
22
|
salt,
|
|
28
|
-
bytecode:
|
|
23
|
+
bytecode: concat([CREATION_CODE, accountInitData]),
|
|
29
24
|
});
|
|
30
25
|
return address;
|
|
31
26
|
}
|
|
32
27
|
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
33
28
|
const validatorAddress = validator.address;
|
|
34
|
-
const packedSig =
|
|
29
|
+
const packedSig = encodePacked(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
|
|
35
30
|
return packedSig;
|
|
36
31
|
}
|
|
37
32
|
function encodeImageHash(threshold, accounts) {
|
|
38
33
|
const sorted = accounts.sort((a, b) => a.account.address.toLowerCase() < b.account.address.toLowerCase() ? -1 : 1);
|
|
39
|
-
let imageHash =
|
|
34
|
+
let imageHash = encodePacked(['uint256'], [BigInt(threshold)]);
|
|
40
35
|
for (const account of sorted) {
|
|
41
|
-
imageHash =
|
|
36
|
+
imageHash = keccak256(encodeAbiParameters([
|
|
42
37
|
{
|
|
43
38
|
type: 'bytes32',
|
|
44
39
|
},
|
|
@@ -53,7 +48,7 @@ function encodeImageHash(threshold, accounts) {
|
|
|
53
48
|
return imageHash;
|
|
54
49
|
}
|
|
55
50
|
function getInstallData(module) {
|
|
56
|
-
return
|
|
51
|
+
return encodeFunctionData({
|
|
57
52
|
abi: [
|
|
58
53
|
{
|
|
59
54
|
type: 'function',
|
|
@@ -80,3 +75,4 @@ function getInstallData(module) {
|
|
|
80
75
|
args: [module.type, module.address, module.initData],
|
|
81
76
|
});
|
|
82
77
|
}
|
|
78
|
+
export { getAddress, packSignature, getInstallData };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Abi, type Address, type Chain, type Hex, type PublicClient } from 'viem';
|
|
2
2
|
import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
-
import type { Module } from '../modules/common';
|
|
4
|
-
import type { OwnerSet, RhinestoneAccountConfig } from '../types';
|
|
5
|
-
import { type ValidatorConfig } from './utils';
|
|
3
|
+
import type { Module } from '../modules/common.js';
|
|
4
|
+
import type { OwnerSet, RhinestoneAccountConfig } from '../types.js';
|
|
5
|
+
import { type ValidatorConfig } from './utils.js';
|
|
6
6
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
7
7
|
factory: `0x${string}`;
|
|
8
8
|
factoryData: `0x${string}`;
|