@0xsequence/account 0.0.0-20230217200148

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.
@@ -0,0 +1,479 @@
1
+ import { defaults, migrator, version } from '@0xsequence/migration';
2
+ import { ethers } from 'ethers';
3
+ import { commons, universal } from '@0xsequence/core';
4
+ import { Wallet } from '@0xsequence/wallet';
5
+ import { isRelayer, RpcRelayer } from '@0xsequence/relayer';
6
+ import { encodeTypedDataDigest } from '@0xsequence/utils';
7
+
8
+ function _extends() {
9
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
10
+ for (var i = 1; i < arguments.length; i++) {
11
+ var source = arguments[i];
12
+ for (var key in source) {
13
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
14
+ target[key] = source[key];
15
+ }
16
+ }
17
+ }
18
+ return target;
19
+ };
20
+ return _extends.apply(this, arguments);
21
+ }
22
+
23
+ class Chain0Reader {
24
+ async isDeployed(_wallet) {
25
+ return false;
26
+ }
27
+ async implementation(_wallet) {
28
+ return undefined;
29
+ }
30
+ async imageHash(_wallet) {
31
+ return undefined;
32
+ }
33
+ async nonce(_wallet, _space) {
34
+ return ethers.constants.Zero;
35
+ }
36
+ async isValidSignature(_wallet, _digest, _signature) {
37
+ throw new Error('Method not supported.');
38
+ }
39
+ }
40
+ class Account {
41
+ constructor(options) {
42
+ this.address = void 0;
43
+ this.networks = void 0;
44
+ this.tracker = void 0;
45
+ this.contexts = void 0;
46
+ this.migrator = void 0;
47
+ this.migrations = void 0;
48
+ this.orchestrator = void 0;
49
+ this.address = ethers.utils.getAddress(options.address);
50
+ this.contexts = options.contexts;
51
+ this.tracker = options.tracker;
52
+ this.networks = options.networks;
53
+ this.orchestrator = options.orchestrator;
54
+ this.migrations = options.migrations || defaults.DefaultMigrations;
55
+ this.migrator = new migrator.Migrator(options.tracker, this.migrations, this.contexts);
56
+ }
57
+ static async new(options) {
58
+ var _options$migrations;
59
+ const mig = new migrator.Migrator(options.tracker, (_options$migrations = options.migrations) != null ? _options$migrations : defaults.DefaultMigrations, options.contexts);
60
+ const lastMigration = mig.lastMigration();
61
+ const lastCoder = lastMigration.configCoder;
62
+ const config = lastCoder.fromSimple(options.config);
63
+ const imageHash = lastCoder.imageHashOf(config);
64
+ const context = options.contexts[lastMigration.version];
65
+ const address = commons.context.addressOf(context, imageHash);
66
+ await options.tracker.saveCounterfactualWallet({
67
+ config,
68
+ context: Object.values(options.contexts)
69
+ });
70
+ return new Account({
71
+ address,
72
+ tracker: options.tracker,
73
+ contexts: options.contexts,
74
+ networks: options.networks,
75
+ orchestrator: options.orchestrator,
76
+ migrations: options.migrations
77
+ });
78
+ }
79
+ get version() {
80
+ return this.migrator.lastMigration().version;
81
+ }
82
+ get coders() {
83
+ const lastMigration = this.migrator.lastMigration();
84
+ return {
85
+ signature: lastMigration.signatureCoder,
86
+ config: lastMigration.configCoder
87
+ };
88
+ }
89
+ network(chainId) {
90
+ const tcid = ethers.BigNumber.from(chainId);
91
+ const found = this.networks.find(n => tcid.eq(n.chainId));
92
+ if (!found) throw new Error(`Network not found for chainId ${chainId}`);
93
+ return found;
94
+ }
95
+ provider(chainId) {
96
+ const found = this.network(chainId);
97
+ if (!found.provider && !found.rpcUrl) throw new Error(`Provider not found for chainId ${chainId}`);
98
+ return found.provider || new ethers.providers.JsonRpcProvider(found.rpcUrl);
99
+ }
100
+ reader(chainId) {
101
+ if (ethers.constants.Zero.eq(chainId)) return new Chain0Reader();
102
+
103
+ // TODO: Networks should be able to provide a reader directly
104
+ // and we should default to the on-chain reader
105
+ return new commons.reader.OnChainReader(this.provider(chainId));
106
+ }
107
+ relayer(chainId) {
108
+ const found = this.network(chainId);
109
+ if (!found.relayer) throw new Error(`Relayer not found for chainId ${chainId}`);
110
+ if (isRelayer(found.relayer)) return found.relayer;
111
+ return new RpcRelayer(found.relayer);
112
+ }
113
+ setOrchestrator(orchestrator) {
114
+ this.orchestrator = orchestrator;
115
+ }
116
+ contextFor(version) {
117
+ const ctx = this.contexts[version];
118
+ if (!ctx) throw new Error(`Context not found for version ${version}`);
119
+ return ctx;
120
+ }
121
+ walletForStatus(chainId, status) {
122
+ const coder = universal.coderFor(status.version);
123
+ return this.walletFor(chainId, this.contextFor(status.version), status.config, coder);
124
+ }
125
+ walletFor(chainId, context, config, coders) {
126
+ return new Wallet({
127
+ config,
128
+ context,
129
+ chainId,
130
+ coders,
131
+ address: this.address,
132
+ orchestrator: this.orchestrator,
133
+ reader: this.reader(chainId)
134
+ });
135
+ }
136
+
137
+ // Gets the current on-chain version of the wallet
138
+ // on a given network
139
+ async onchainVersionInfo(chainId) {
140
+ // First we need to use the tracker to get the counterfactual imageHash
141
+ const firstImageHash = await this.tracker.imageHashOfCounterfactualWallet({
142
+ wallet: this.address
143
+ });
144
+ if (!firstImageHash) {
145
+ throw new Error(`Counterfactual imageHash not found for wallet ${this.address}`);
146
+ }
147
+ const current = await version.versionOf(this.address, firstImageHash.imageHash, this.contexts, this.reader(chainId));
148
+
149
+ // To find the first version, we need to try the firstImageHash
150
+ // with every context, and find the first one that matches
151
+ const first = version.counterfactualVersion(this.address, firstImageHash.imageHash, Object.values(this.contexts));
152
+ return {
153
+ first: _extends({}, firstImageHash, {
154
+ version: first
155
+ }),
156
+ current
157
+ };
158
+ }
159
+
160
+ // Get the status of the account on a given network
161
+ // this does the following process:
162
+ // 1. Get the current on-chain status of the wallet (version + imageHash)
163
+ // 2. Get any pending migrations that have been signed by the wallet
164
+ // 3. Get any pending configuration updates that have been signed by the wallet
165
+ // 4. Fetch reverse lookups for both on-chain and pending configurations
166
+ async status(chainId, longestPath = false) {
167
+ const isDeployedPromise = this.reader(chainId).isDeployed(this.address);
168
+ const onChainVersionInfoPromise = this.onchainVersionInfo(chainId);
169
+ let onChainImageHash = await this.reader(chainId).imageHash(this.address);
170
+ if (!onChainImageHash) {
171
+ const counterfactualImageHash = await this.tracker.imageHashOfCounterfactualWallet({
172
+ wallet: this.address
173
+ });
174
+ onChainImageHash = counterfactualImageHash == null ? void 0 : counterfactualImageHash.imageHash;
175
+ }
176
+ if (!onChainImageHash) {
177
+ throw new Error(`On-chain imageHash not found for wallet ${this.address}`);
178
+ }
179
+ const onChainConfig = await this.tracker.configOfImageHash({
180
+ imageHash: onChainImageHash
181
+ });
182
+ if (!onChainConfig) {
183
+ throw new Error(`On-chain config not found for imageHash ${onChainImageHash}`);
184
+ }
185
+ const {
186
+ current: onChainVersion,
187
+ first: onChainFirstInfo
188
+ } = await onChainVersionInfoPromise;
189
+ let fromImageHash = onChainImageHash;
190
+ let version = onChainVersion;
191
+ let signedMigrations = [];
192
+ if (onChainVersion !== this.version) {
193
+ // We either need to use the presigned configuration updates, or we haven't performed
194
+ // any updates yet, so we can only use the on-chain imageHash as-is
195
+ const presignedMigrate = await this.migrator.getAllMigratePresignedTransaction({
196
+ address: this.address,
197
+ fromImageHash: onChainImageHash,
198
+ fromVersion: onChainVersion,
199
+ chainId
200
+ });
201
+
202
+ // The migrator returns the original version and imageHash
203
+ // if no presigned migration is found, so no need to check here
204
+ fromImageHash = presignedMigrate.lastImageHash;
205
+ version = presignedMigrate.lastVersion;
206
+ signedMigrations = presignedMigrate.signedMigrations;
207
+ }
208
+ const presigned = await this.tracker.loadPresignedConfiguration({
209
+ wallet: this.address,
210
+ fromImageHash: fromImageHash,
211
+ longestPath
212
+ });
213
+ const imageHash = presigned && presigned.length > 0 ? presigned[presigned.length - 1].nextImageHash : fromImageHash;
214
+ const config = await this.tracker.configOfImageHash({
215
+ imageHash
216
+ });
217
+ if (!config) {
218
+ throw new Error(`Config not found for imageHash ${imageHash}`);
219
+ }
220
+ const isDeployed = await isDeployedPromise;
221
+ const checkpoint = universal.coderFor(version).config.checkpointOf(config);
222
+ return {
223
+ original: onChainFirstInfo,
224
+ onChain: {
225
+ imageHash: onChainImageHash,
226
+ config: onChainConfig,
227
+ version: onChainVersion,
228
+ deployed: isDeployed
229
+ },
230
+ fullyMigrated: version === this.version,
231
+ signedMigrations,
232
+ version,
233
+ presignedConfigurations: presigned,
234
+ imageHash,
235
+ config,
236
+ checkpoint,
237
+ canOnchainValidate: version === this.version && isDeployed
238
+ };
239
+ }
240
+ mustBeFullyMigrated(status) {
241
+ if (!status.fullyMigrated) {
242
+ throw new Error(`Wallet ${this.address} is not fully migrated`);
243
+ }
244
+ }
245
+ decorateTransactions(bundle, status) {
246
+ const bootstrapBundle = this.buildBootstrapTransactions(status);
247
+ if (bootstrapBundle.transactions.length === 0) {
248
+ return bundle;
249
+ }
250
+ return {
251
+ entrypoint: bootstrapBundle.entrypoint,
252
+ chainId: bundle.chainId,
253
+ intent: bundle.intent,
254
+ transactions: [...bootstrapBundle.transactions, {
255
+ to: bundle.entrypoint,
256
+ data: commons.transaction.encodeBundleExecData(bundle),
257
+ gasLimit: 0,
258
+ delegateCall: false,
259
+ revertOnError: true,
260
+ value: 0
261
+ }]
262
+ };
263
+ }
264
+ decorateSignature(signature, status) {
265
+ if (status.presignedConfigurations.length === 0) {
266
+ return signature;
267
+ }
268
+ const coder = this.coders.signature;
269
+ const chain = status.presignedConfigurations.map(c => c.signature);
270
+ const chainedSignature = coder.chainSignatures(signature, chain);
271
+ return coder.encode(chainedSignature);
272
+ }
273
+ async publishWitness() {
274
+ const digest = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(`This is a Sequence account woo! ${Date.now()}`));
275
+ const signature = await this.signDigest(digest, 0, false);
276
+ const decoded = this.coders.signature.decode(signature);
277
+ const signatures = this.coders.signature.signaturesOfDecoded(decoded);
278
+ return this.tracker.saveWitnesses({
279
+ wallet: this.address,
280
+ digest,
281
+ chainId: 0,
282
+ signatures
283
+ });
284
+ }
285
+ async signDigest(digest, chainId, decorate = true) {
286
+ // If we are signing a digest for chainId zero then we can never be fully migrated
287
+ // because Sequence v1 doesn't allow for signing a message on "all chains"
288
+
289
+ // So we ignore the state on "chain zero" and instead use one of the states of the networks
290
+ // wallet-webapp should ensure the wallet is as migrated as possible, trying to mimic
291
+ // the behaviour of being migrated on all chains
292
+
293
+ const chainRef = ethers.constants.Zero.eq(chainId) ? this.networks[0].chainId : chainId;
294
+ const status = await this.status(chainRef);
295
+ this.mustBeFullyMigrated(status);
296
+ const wallet = this.walletForStatus(chainId, status);
297
+ const signature = await wallet.signDigest(digest);
298
+ return decorate ? this.decorateSignature(signature, status) : signature;
299
+ }
300
+ async editConfig(changes) {
301
+ const currentConfig = await this.status(0).then(s => s.config);
302
+ const newConfig = this.coders.config.editConfig(currentConfig, _extends({}, changes, {
303
+ checkpoint: this.coders.config.checkpointOf(currentConfig).add(1)
304
+ }));
305
+ return this.updateConfig(newConfig);
306
+ }
307
+ async updateConfig(config) {
308
+ // config should be for the current version of the wallet
309
+ if (!this.coders.config.isWalletConfig(config)) {
310
+ throw new Error(`Invalid config for wallet ${this.address}`);
311
+ }
312
+ const nextImageHash = this.coders.config.imageHashOf(config);
313
+
314
+ // sign an update config struct
315
+ const updateStruct = this.coders.signature.hashSetImageHash(nextImageHash);
316
+
317
+ // sign the update struct, using chain id 0
318
+ const signature = await this.signDigest(updateStruct, 0, false);
319
+
320
+ // save the presigned transaction to the sessions tracker
321
+ return this.tracker.savePresignedConfiguration({
322
+ wallet: this.address,
323
+ nextConfig: config,
324
+ signature
325
+ });
326
+ }
327
+
328
+ /**
329
+ * This method is used to bootstrap the wallet on a given chain.
330
+ * this deploys the wallets and executes all the necessary transactions
331
+ * for that wallet to start working with the given version.
332
+ *
333
+ * This usually involves: (a) deploying the wallet, (b) executing migrations
334
+ *
335
+ * Notice: It should NOT explicitly include chained signatures. Unless internally used
336
+ * by any of the migrations.
337
+ *
338
+ */
339
+ buildBootstrapTransactions(status) {
340
+ const transactions = [];
341
+
342
+ // Add wallet deployment if needed
343
+ if (!status.onChain.deployed) {
344
+ // Wallet deployment will vary depending on the version
345
+ // so we need to use the context to get the correct deployment
346
+ const deployTransaction = Wallet.buildDeployTransaction(status.original.context, status.original.imageHash);
347
+ transactions.push(...deployTransaction.transactions);
348
+ }
349
+
350
+ // Get pending migrations
351
+ transactions.push(...status.signedMigrations.map(m => ({
352
+ to: m.tx.entrypoint,
353
+ data: commons.transaction.encodeBundleExecData(m.tx),
354
+ value: 0,
355
+ gasLimit: 0,
356
+ revertOnError: true,
357
+ delegateCall: false
358
+ })));
359
+
360
+ // Everything is encoded as a bundle
361
+ // using the GuestModule of the account version
362
+ const {
363
+ guestModule
364
+ } = this.contextFor(status.version);
365
+ return {
366
+ entrypoint: guestModule,
367
+ transactions
368
+ };
369
+ }
370
+ async bootstrapTransactions(chainId) {
371
+ const status = await this.status(chainId);
372
+ return this.buildBootstrapTransactions(status);
373
+ }
374
+ async doBootstrap(chainId, feeQuote) {
375
+ const bootstrapTxs = await this.bootstrapTransactions(chainId);
376
+ const intended = commons.transaction.intendTransactionBundle(bootstrapTxs, this.address, chainId, ethers.utils.hexlify(ethers.utils.randomBytes(32)));
377
+ return this.relayer(chainId).relay(intended, feeQuote);
378
+ }
379
+ signMessage(message, chainId) {
380
+ return this.signDigest(ethers.utils.keccak256(message), chainId);
381
+ }
382
+ async signTransactions(txs, chainId) {
383
+ const status = await this.status(chainId);
384
+ this.mustBeFullyMigrated(status);
385
+ const wallet = this.walletForStatus(chainId, status);
386
+ const signed = await wallet.signTransactions(txs);
387
+ return _extends({}, signed, {
388
+ signature: this.decorateSignature(signed.signature, status)
389
+ });
390
+ }
391
+ async signMigrations(chainId, editConfig) {
392
+ const status = await this.status(chainId);
393
+ if (status.fullyMigrated) return false;
394
+ const wallet = this.walletForStatus(chainId, status);
395
+ const signed = await this.migrator.signNextMigration(this.address, status.version, wallet, editConfig(wallet.config));
396
+ if (!signed) return false;
397
+ await this.tracker.saveMigration(this.address, signed, this.contexts);
398
+ return true;
399
+ }
400
+ async signAllMigrations(editConfig) {
401
+ return Promise.all(this.networks.map(n => this.signMigrations(n.chainId, editConfig)));
402
+ }
403
+ async isMigratedAllChains() {
404
+ const statuses = await Promise.all(this.networks.map(n => this.status(n.chainId)));
405
+ return statuses.every(s => s.fullyMigrated);
406
+ }
407
+ async sendSignedTransactions(signedBundle, chainId, quote) {
408
+ const status = await this.status(signedBundle.chainId);
409
+ this.mustBeFullyMigrated(status);
410
+ const decoratedBundle = this.decorateTransactions(signedBundle, status);
411
+ return this.relayer(chainId).relay(decoratedBundle, quote);
412
+ }
413
+ async sendTransaction(txs, chainId, quote, skipLazyUpdate = false) {
414
+ if (!skipLazyUpdate) {
415
+ // if onchain wallet config is not up to date
416
+ // then we should append an extra transaction that updates it
417
+ // to the latest "lazy" state
418
+ const status = await this.status(chainId);
419
+ if (status.onChain.imageHash !== status.imageHash) {
420
+ const wallet = this.walletForStatus(chainId, status);
421
+ const updateConfig = await wallet.buildUpdateConfigurationTransaction(status.config);
422
+ txs = [Array.isArray(txs) ? txs : [txs], updateConfig.transactions].flat();
423
+ }
424
+ }
425
+ const signed = await this.signTransactions(txs, chainId);
426
+ return this.sendSignedTransactions(signed, chainId, quote);
427
+ }
428
+ async signTypedData(domain, types, message, chainId) {
429
+ const digest = encodeTypedDataDigest({
430
+ domain,
431
+ types,
432
+ message
433
+ });
434
+ return this.signDigest(digest, chainId);
435
+ }
436
+ async getAllSigners() {
437
+ var _this = this;
438
+ const networks = this.networks;
439
+
440
+ // Getting all status with `longestPath` set to true will give us all the possible configurations
441
+ // between the current onChain config and the latest config, including the ones "flagged for removal"
442
+ const statuses = await Promise.all(networks.map(n => this.status(n.chainId, true)));
443
+ const allSigners = [];
444
+
445
+ // We need to get the signers for each status
446
+ await Promise.all(statuses.map(async function (status, inet) {
447
+ const chainId = networks[inet].chainId;
448
+ return Promise.all(status.presignedConfigurations.map(async function (update, iconf) {
449
+ const isLast = iconf === status.presignedConfigurations.length - 1;
450
+ const config = await _this.tracker.configOfImageHash({
451
+ imageHash: update.nextImageHash
452
+ });
453
+ if (!config) {
454
+ console.warn(`AllSigners may be incomplete, config not found for imageHash ${update.nextImageHash}`);
455
+ return;
456
+ }
457
+ const coder = universal.genericCoderFor(config.version);
458
+ const signers = coder.config.signersOf(config);
459
+ signers.forEach(signer => {
460
+ const exists = allSigners.find(s => s.address === signer.address && s.network === chainId);
461
+ if (exists && isLast && exists.flaggedForRemoval) {
462
+ exists.flaggedForRemoval = false;
463
+ return;
464
+ }
465
+ if (exists) return;
466
+ allSigners.push({
467
+ address: signer.address,
468
+ weight: signer.weight,
469
+ network: chainId,
470
+ flaggedForRemoval: !isLast
471
+ });
472
+ });
473
+ }));
474
+ }));
475
+ return allSigners;
476
+ }
477
+ }
478
+
479
+ export { Account };
@@ -0,0 +1,117 @@
1
+ import { tracker } from '@0xsequence/sessions';
2
+ import { migrator } from '@0xsequence/migration';
3
+ import { Orchestrator } from '@0xsequence/signhub';
4
+ import { NetworkConfig } from '@0xsequence/network';
5
+ import { ethers, TypedDataDomain, TypedDataField } from 'ethers';
6
+ import { commons } from '@0xsequence/core';
7
+ import { PresignedConfigLink } from '@0xsequence/sessions/src/tracker';
8
+ import { Wallet } from '@0xsequence/wallet';
9
+ import { FeeQuote, Relayer } from '@0xsequence/relayer';
10
+ export type AccountStatus = {
11
+ original: {
12
+ version: number;
13
+ imageHash: string;
14
+ context: commons.context.WalletContext;
15
+ };
16
+ onChain: {
17
+ imageHash: string;
18
+ config: commons.config.Config;
19
+ version: number;
20
+ deployed: boolean;
21
+ };
22
+ fullyMigrated: boolean;
23
+ signedMigrations: migrator.SignedMigration[];
24
+ version: number;
25
+ presignedConfigurations: PresignedConfigLink[];
26
+ imageHash: string;
27
+ config: commons.config.Config;
28
+ checkpoint: ethers.BigNumberish;
29
+ canOnchainValidate: boolean;
30
+ };
31
+ export type AccountOptions = {
32
+ address: string;
33
+ tracker: tracker.ConfigTracker & migrator.PresignedMigrationTracker;
34
+ contexts: commons.context.VersionedContext;
35
+ migrations?: migrator.Migrations;
36
+ orchestrator: Orchestrator;
37
+ networks: NetworkConfig[];
38
+ };
39
+ export declare class Account {
40
+ readonly address: string;
41
+ readonly networks: NetworkConfig[];
42
+ readonly tracker: tracker.ConfigTracker & migrator.PresignedMigrationTracker;
43
+ readonly contexts: commons.context.VersionedContext;
44
+ readonly migrator: migrator.Migrator;
45
+ readonly migrations: migrator.Migrations;
46
+ private orchestrator;
47
+ constructor(options: AccountOptions);
48
+ static new(options: {
49
+ config: commons.config.SimpleConfig;
50
+ tracker: tracker.ConfigTracker & migrator.PresignedMigrationTracker;
51
+ contexts: commons.context.VersionedContext;
52
+ orchestrator: Orchestrator;
53
+ networks: NetworkConfig[];
54
+ migrations?: migrator.Migrations;
55
+ }): Promise<Account>;
56
+ get version(): number;
57
+ get coders(): {
58
+ signature: commons.signature.SignatureCoder;
59
+ config: commons.config.ConfigCoder;
60
+ };
61
+ network(chainId: ethers.BigNumberish): NetworkConfig;
62
+ provider(chainId: ethers.BigNumberish): ethers.providers.Provider;
63
+ reader(chainId: ethers.BigNumberish): commons.reader.Reader;
64
+ relayer(chainId: ethers.BigNumberish): Relayer;
65
+ setOrchestrator(orchestrator: Orchestrator): void;
66
+ contextFor(version: number): commons.context.WalletContext;
67
+ walletForStatus(chainId: ethers.BigNumberish, status: AccountStatus): Wallet;
68
+ walletFor(chainId: ethers.BigNumberish, context: commons.context.WalletContext, config: commons.config.Config, coders: typeof this.coders): Wallet;
69
+ onchainVersionInfo(chainId: ethers.BigNumberish): Promise<{
70
+ first: {
71
+ imageHash: string;
72
+ context: commons.context.WalletContext;
73
+ version: number;
74
+ };
75
+ current: number;
76
+ }>;
77
+ status(chainId: ethers.BigNumberish, longestPath?: boolean): Promise<AccountStatus>;
78
+ private mustBeFullyMigrated;
79
+ decorateTransactions(bundle: commons.transaction.IntendedTransactionBundle, status: AccountStatus): commons.transaction.IntendedTransactionBundle;
80
+ decorateSignature<T extends ethers.BytesLike>(signature: T, status: AccountStatus): T | string;
81
+ publishWitness(): Promise<void>;
82
+ signDigest(digest: ethers.BytesLike, chainId: ethers.BigNumberish, decorate?: boolean): Promise<string>;
83
+ editConfig(changes: {
84
+ add?: commons.config.SimpleSigner[];
85
+ remove?: string[];
86
+ threshold?: ethers.BigNumberish;
87
+ }): Promise<void>;
88
+ updateConfig(config: commons.config.Config): Promise<void>;
89
+ /**
90
+ * This method is used to bootstrap the wallet on a given chain.
91
+ * this deploys the wallets and executes all the necessary transactions
92
+ * for that wallet to start working with the given version.
93
+ *
94
+ * This usually involves: (a) deploying the wallet, (b) executing migrations
95
+ *
96
+ * Notice: It should NOT explicitly include chained signatures. Unless internally used
97
+ * by any of the migrations.
98
+ *
99
+ */
100
+ buildBootstrapTransactions(status: AccountStatus): commons.transaction.TransactionBundle;
101
+ bootstrapTransactions(chainId: ethers.BigNumberish): Promise<commons.transaction.TransactionBundle>;
102
+ doBootstrap(chainId: ethers.BigNumberish, feeQuote?: FeeQuote): Promise<commons.transaction.TransactionResponse<any>>;
103
+ signMessage(message: ethers.BytesLike, chainId: ethers.BigNumberish): Promise<string>;
104
+ signTransactions(txs: commons.transaction.Transactionish, chainId: ethers.BigNumberish): Promise<commons.transaction.SignedTransactionBundle>;
105
+ signMigrations(chainId: ethers.BigNumberish, editConfig: (prevConfig: commons.config.Config) => commons.config.Config): Promise<boolean>;
106
+ signAllMigrations(editConfig: (prevConfig: commons.config.Config) => commons.config.Config): Promise<boolean[]>;
107
+ isMigratedAllChains(): Promise<boolean>;
108
+ sendSignedTransactions(signedBundle: commons.transaction.IntendedTransactionBundle, chainId: ethers.BigNumberish, quote?: FeeQuote): Promise<ethers.providers.TransactionResponse>;
109
+ sendTransaction(txs: commons.transaction.Transactionish, chainId: ethers.BigNumberish, quote?: FeeQuote, skipLazyUpdate?: boolean): Promise<ethers.providers.TransactionResponse>;
110
+ signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, message: Record<string, any>, chainId: ethers.BigNumberish): Promise<string>;
111
+ getAllSigners(): Promise<{
112
+ address: string;
113
+ weight: number;
114
+ network: number;
115
+ flaggedForRemoval: boolean;
116
+ }[]>;
117
+ }
@@ -0,0 +1 @@
1
+ export * from './account';
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@0xsequence/account",
3
+ "version": "0.0.0-20230217200148",
4
+ "description": "tools for migrating sequence wallets to new versions",
5
+ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/account",
6
+ "source": "src/index.ts",
7
+ "main": "dist/0xsequence-account.cjs.js",
8
+ "module": "dist/0xsequence-account.esm.js",
9
+ "author": "Horizon Blockchain Games",
10
+ "license": "Apache-2.0",
11
+ "dependencies": {
12
+ "@0xsequence/core": "0.0.0-20230217200148",
13
+ "@0xsequence/migration": "0.0.0-20230217200148",
14
+ "@0xsequence/network": "0.0.0-20230217200148",
15
+ "@0xsequence/relayer": "0.0.0-20230217200148",
16
+ "@0xsequence/sessions": "0.0.0-20230217200148",
17
+ "@0xsequence/utils": "0.0.0-20230217200148",
18
+ "@0xsequence/wallet": "0.0.0-20230217200148",
19
+ "ethers": "^5.5.2"
20
+ },
21
+ "devDependencies": {
22
+ "@0xsequence/signhub": "0.0.0-20230217200148",
23
+ "@0xsequence/tests": "0.0.0-20230217200148",
24
+ "@istanbuljs/nyc-config-typescript": "^1.0.2",
25
+ "nyc": "^15.1.0"
26
+ },
27
+ "files": [
28
+ "src",
29
+ "dist"
30
+ ],
31
+ "scripts": {
32
+ "test": "pnpm test:concurrently 'pnpm test:run'",
33
+ "test:run": "pnpm test:file tests/**/*.spec.ts",
34
+ "test:file": "TS_NODE_PROJECT=../../tsconfig.test.json mocha -r ts-node/register --timeout 120000",
35
+ "test:concurrently": "concurrently -k --success first 'pnpm start:hardhat2 > /dev/null'",
36
+ "start:hardhat2": "hardhat node --hostname 0.0.0.0 --port 7048 --config ./hardhat2.config.js",
37
+ "test:coverage": "nyc pnpm test"
38
+ }
39
+ }