@0xsequence/account 0.0.0-20230309215219 → 0.0.0-20230320165616

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.
@@ -80,6 +80,9 @@ class Account {
80
80
  migrations: options.migrations
81
81
  });
82
82
  }
83
+ getAddress() {
84
+ return Promise.resolve(this.address);
85
+ }
83
86
  get version() {
84
87
  return this.migrator.lastMigration().version;
85
88
  }
@@ -279,7 +282,7 @@ class Account {
279
282
  };
280
283
  }
281
284
  decorateSignature(signature, status) {
282
- if (status.presignedConfigurations.length === 0) {
285
+ if (!status.presignedConfigurations || status.presignedConfigurations.length === 0) {
283
286
  return signature;
284
287
  }
285
288
  const coder = this.coders.signature;
@@ -299,7 +302,7 @@ class Account {
299
302
  signatures
300
303
  });
301
304
  }
302
- async signDigest(digest, chainId, decorate = true) {
305
+ async signDigest(digest, chainId, decorate = true, useOnchain = false) {
303
306
  // If we are signing a digest for chainId zero then we can never be fully migrated
304
307
  // because Sequence v1 doesn't allow for signing a message on "all chains"
305
308
 
@@ -310,9 +313,10 @@ class Account {
310
313
  const chainRef = ethers.ethers.constants.Zero.eq(chainId) ? this.networks[0].chainId : chainId;
311
314
  const status = await this.status(chainRef);
312
315
  this.mustBeFullyMigrated(status);
313
- const wallet = this.walletForStatus(chainId, status);
316
+ const useStatus = useOnchain ? status.onChain : status;
317
+ const wallet = this.walletForStatus(chainId, useStatus);
314
318
  const signature = await wallet.signDigest(digest);
315
- return decorate ? this.decorateSignature(signature, status) : signature;
319
+ return decorate ? this.decorateSignature(signature, useStatus) : signature;
316
320
  }
317
321
  async editConfig(changes) {
318
322
  const currentConfig = await this.status(0).then(s => s.config);
@@ -80,6 +80,9 @@ class Account {
80
80
  migrations: options.migrations
81
81
  });
82
82
  }
83
+ getAddress() {
84
+ return Promise.resolve(this.address);
85
+ }
83
86
  get version() {
84
87
  return this.migrator.lastMigration().version;
85
88
  }
@@ -279,7 +282,7 @@ class Account {
279
282
  };
280
283
  }
281
284
  decorateSignature(signature, status) {
282
- if (status.presignedConfigurations.length === 0) {
285
+ if (!status.presignedConfigurations || status.presignedConfigurations.length === 0) {
283
286
  return signature;
284
287
  }
285
288
  const coder = this.coders.signature;
@@ -299,7 +302,7 @@ class Account {
299
302
  signatures
300
303
  });
301
304
  }
302
- async signDigest(digest, chainId, decorate = true) {
305
+ async signDigest(digest, chainId, decorate = true, useOnchain = false) {
303
306
  // If we are signing a digest for chainId zero then we can never be fully migrated
304
307
  // because Sequence v1 doesn't allow for signing a message on "all chains"
305
308
 
@@ -310,9 +313,10 @@ class Account {
310
313
  const chainRef = ethers.ethers.constants.Zero.eq(chainId) ? this.networks[0].chainId : chainId;
311
314
  const status = await this.status(chainRef);
312
315
  this.mustBeFullyMigrated(status);
313
- const wallet = this.walletForStatus(chainId, status);
316
+ const useStatus = useOnchain ? status.onChain : status;
317
+ const wallet = this.walletForStatus(chainId, useStatus);
314
318
  const signature = await wallet.signDigest(digest);
315
- return decorate ? this.decorateSignature(signature, status) : signature;
319
+ return decorate ? this.decorateSignature(signature, useStatus) : signature;
316
320
  }
317
321
  async editConfig(changes) {
318
322
  const currentConfig = await this.status(0).then(s => s.config);
@@ -76,6 +76,9 @@ class Account {
76
76
  migrations: options.migrations
77
77
  });
78
78
  }
79
+ getAddress() {
80
+ return Promise.resolve(this.address);
81
+ }
79
82
  get version() {
80
83
  return this.migrator.lastMigration().version;
81
84
  }
@@ -275,7 +278,7 @@ class Account {
275
278
  };
276
279
  }
277
280
  decorateSignature(signature, status) {
278
- if (status.presignedConfigurations.length === 0) {
281
+ if (!status.presignedConfigurations || status.presignedConfigurations.length === 0) {
279
282
  return signature;
280
283
  }
281
284
  const coder = this.coders.signature;
@@ -295,7 +298,7 @@ class Account {
295
298
  signatures
296
299
  });
297
300
  }
298
- async signDigest(digest, chainId, decorate = true) {
301
+ async signDigest(digest, chainId, decorate = true, useOnchain = false) {
299
302
  // If we are signing a digest for chainId zero then we can never be fully migrated
300
303
  // because Sequence v1 doesn't allow for signing a message on "all chains"
301
304
 
@@ -306,9 +309,10 @@ class Account {
306
309
  const chainRef = ethers.constants.Zero.eq(chainId) ? this.networks[0].chainId : chainId;
307
310
  const status = await this.status(chainRef);
308
311
  this.mustBeFullyMigrated(status);
309
- const wallet = this.walletForStatus(chainId, status);
312
+ const useStatus = useOnchain ? status.onChain : status;
313
+ const wallet = this.walletForStatus(chainId, useStatus);
310
314
  const signature = await wallet.signDigest(digest);
311
- return decorate ? this.decorateSignature(signature, status) : signature;
315
+ return decorate ? this.decorateSignature(signature, useStatus) : signature;
312
316
  }
313
317
  async editConfig(changes) {
314
318
  const currentConfig = await this.status(0).then(s => s.config);
@@ -53,6 +53,7 @@ export declare class Account {
53
53
  networks: NetworkConfig[];
54
54
  migrations?: migrator.Migrations;
55
55
  }): Promise<Account>;
56
+ getAddress(): Promise<string>;
56
57
  get version(): number;
57
58
  get coders(): {
58
59
  signature: commons.signature.SignatureCoder;
@@ -64,7 +65,7 @@ export declare class Account {
64
65
  relayer(chainId: ethers.BigNumberish): Relayer;
65
66
  setOrchestrator(orchestrator: Orchestrator): void;
66
67
  contextFor(version: number): commons.context.WalletContext;
67
- walletForStatus(chainId: ethers.BigNumberish, status: AccountStatus): Wallet;
68
+ walletForStatus(chainId: ethers.BigNumberish, status: Pick<AccountStatus, 'version'> & Pick<AccountStatus, 'config'>): Wallet;
68
69
  walletFor(chainId: ethers.BigNumberish, context: commons.context.WalletContext, config: commons.config.Config, coders: typeof this.coders): Wallet;
69
70
  onchainVersionInfo(chainId: ethers.BigNumberish): Promise<{
70
71
  first: {
@@ -78,9 +79,9 @@ export declare class Account {
78
79
  private mustBeFullyMigrated;
79
80
  predecorateTransactions(txs: commons.transaction.Transactionish, status: AccountStatus, chainId: ethers.BigNumberish): Promise<commons.transaction.Transactionish>;
80
81
  decorateTransactions(bundle: commons.transaction.IntendedTransactionBundle, status: AccountStatus): commons.transaction.IntendedTransactionBundle;
81
- decorateSignature<T extends ethers.BytesLike>(signature: T, status: AccountStatus): T | string;
82
+ decorateSignature<T extends ethers.BytesLike>(signature: T, status: Partial<Pick<AccountStatus, 'presignedConfigurations'>>): T | string;
82
83
  publishWitness(): Promise<void>;
83
- signDigest(digest: ethers.BytesLike, chainId: ethers.BigNumberish, decorate?: boolean): Promise<string>;
84
+ signDigest(digest: ethers.BytesLike, chainId: ethers.BigNumberish, decorate?: boolean, useOnchain?: boolean): Promise<string>;
84
85
  editConfig(changes: {
85
86
  add?: commons.config.SimpleSigner[];
86
87
  remove?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/account",
3
- "version": "0.0.0-20230309215219",
3
+ "version": "0.0.0-20230320165616",
4
4
  "description": "tools for migrating sequence wallets to new versions",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/account",
6
6
  "source": "src/index.ts",
@@ -9,18 +9,18 @@
9
9
  "author": "Horizon Blockchain Games",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
- "@0xsequence/core": "0.0.0-20230309215219",
13
- "@0xsequence/migration": "0.0.0-20230309215219",
14
- "@0xsequence/network": "0.0.0-20230309215219",
15
- "@0xsequence/relayer": "0.0.0-20230309215219",
16
- "@0xsequence/sessions": "0.0.0-20230309215219",
17
- "@0xsequence/utils": "0.0.0-20230309215219",
18
- "@0xsequence/wallet": "0.0.0-20230309215219",
12
+ "@0xsequence/core": "0.0.0-20230320165616",
13
+ "@0xsequence/migration": "0.0.0-20230320165616",
14
+ "@0xsequence/network": "0.0.0-20230320165616",
15
+ "@0xsequence/relayer": "0.0.0-20230320165616",
16
+ "@0xsequence/sessions": "0.0.0-20230320165616",
17
+ "@0xsequence/utils": "0.0.0-20230320165616",
18
+ "@0xsequence/wallet": "0.0.0-20230320165616",
19
19
  "ethers": "^5.5.2"
20
20
  },
21
21
  "devDependencies": {
22
- "@0xsequence/signhub": "0.0.0-20230309215219",
23
- "@0xsequence/tests": "0.0.0-20230309215219",
22
+ "@0xsequence/signhub": "0.0.0-20230320165616",
23
+ "@0xsequence/tests": "0.0.0-20230320165616",
24
24
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
25
25
  "nyc": "^15.1.0"
26
26
  },
package/src/account.ts CHANGED
@@ -135,6 +135,10 @@ export class Account {
135
135
  })
136
136
  }
137
137
 
138
+ getAddress(): Promise<string> {
139
+ return Promise.resolve(this.address)
140
+ }
141
+
138
142
  get version(): number {
139
143
  return this.migrator.lastMigration().version
140
144
  }
@@ -191,7 +195,7 @@ export class Account {
191
195
 
192
196
  walletForStatus(
193
197
  chainId: ethers.BigNumberish,
194
- status: AccountStatus
198
+ status: Pick<AccountStatus, 'version'> & Pick<AccountStatus, 'config'>
195
199
  ): Wallet {
196
200
  const coder = universal.coderFor(status.version)
197
201
  return this.walletFor(
@@ -399,9 +403,9 @@ export class Account {
399
403
 
400
404
  decorateSignature<T extends ethers.BytesLike>(
401
405
  signature: T,
402
- status: AccountStatus,
406
+ status: Partial<Pick<AccountStatus, 'presignedConfigurations'>>,
403
407
  ): T | string {
404
- if (status.presignedConfigurations.length === 0) {
408
+ if (!status.presignedConfigurations || status.presignedConfigurations.length === 0) {
405
409
  return signature
406
410
  }
407
411
 
@@ -423,7 +427,8 @@ export class Account {
423
427
  async signDigest(
424
428
  digest: ethers.BytesLike,
425
429
  chainId: ethers.BigNumberish,
426
- decorate: boolean = true
430
+ decorate: boolean = true,
431
+ useOnchain: boolean = false
427
432
  ): Promise<string> {
428
433
  // If we are signing a digest for chainId zero then we can never be fully migrated
429
434
  // because Sequence v1 doesn't allow for signing a message on "all chains"
@@ -437,10 +442,11 @@ export class Account {
437
442
 
438
443
  this.mustBeFullyMigrated(status)
439
444
 
440
- const wallet = this.walletForStatus(chainId, status)
445
+ const useStatus = useOnchain ? status.onChain : status
446
+ const wallet = this.walletForStatus(chainId, useStatus)
441
447
  const signature = await wallet.signDigest(digest)
442
448
 
443
- return decorate ? this.decorateSignature(signature, status) : signature
449
+ return decorate ? this.decorateSignature(signature, useStatus as any) : signature
444
450
  }
445
451
 
446
452
  async editConfig(