@0xsequence/account 1.4.9 → 1.5.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.
@@ -442,7 +442,7 @@ class Account {
442
442
  return txs;
443
443
  }
444
444
  async decorateTransactions(bundles, status, chainId) {
445
- var _chainId;
445
+ var _chainId, _bundles$;
446
446
  if (!Array.isArray(bundles)) {
447
447
  // Recurse with array
448
448
  return this.decorateTransactions([bundles], status, chainId);
@@ -464,7 +464,7 @@ class Account {
464
464
  entrypoint,
465
465
  chainId,
466
466
  // Intent of the first bundle is used
467
- intent: bundles[0].intent,
467
+ intent: (_bundles$ = bundles[0]) == null ? void 0 : _bundles$.intent,
468
468
  transactions: [...bootstrapBundle.transactions, ...bundles.map(bundle => ({
469
469
  to: bundle.entrypoint,
470
470
  data: core.commons.transaction.encodeBundleExecData(bundle),
@@ -477,7 +477,15 @@ class Account {
477
477
 
478
478
  // Re-compute the meta-transaction id to use the guest module subdigest
479
479
  if (!status.onChain.deployed) {
480
- decoratedBundle.intent.id = core.commons.transaction.subdigestOfGuestModuleTransactions(this.contexts[this.version].guestModule, chainId, decoratedBundle.transactions);
480
+ const id = core.commons.transaction.subdigestOfGuestModuleTransactions(this.contexts[this.version].guestModule, chainId, decoratedBundle.transactions);
481
+ if (decoratedBundle.intent === undefined) {
482
+ decoratedBundle.intent = {
483
+ id,
484
+ wallet: this.address
485
+ };
486
+ } else {
487
+ decoratedBundle.intent.id = id;
488
+ }
481
489
  }
482
490
  return decoratedBundle;
483
491
  }
@@ -754,9 +762,9 @@ class Account {
754
762
  if (!Array.isArray(signedBundle)) {
755
763
  return this.sendSignedTransactions([signedBundle], chainId, quote, pstatus, callback);
756
764
  }
757
- const status = pstatus || (await this.status(signedBundle[0].chainId));
765
+ const status = pstatus || (await this.status(chainId));
758
766
  this.mustBeFullyMigrated(status);
759
- const decoratedBundle = await this.decorateTransactions(signedBundle, status);
767
+ const decoratedBundle = await this.decorateTransactions(signedBundle, status, chainId);
760
768
  callback == null ? void 0 : callback(decoratedBundle);
761
769
  return this.relayer(chainId).relay(decoratedBundle, quote);
762
770
  }
@@ -823,10 +831,6 @@ class Account {
823
831
  bundles.push(signed);
824
832
  }
825
833
  bundles.push(...childBundles.filter(b => b.transactions.length > 0));
826
- if (bundles.length === 0) {
827
- // Nothing to send?
828
- return;
829
- }
830
834
  return this.sendSignedTransactions(bundles, chainId, quote, undefined, callback);
831
835
  }
832
836
  async signTypedData(domain, types, message, chainId, cantValidateBehavior = 'ignore') {
@@ -442,7 +442,7 @@ class Account {
442
442
  return txs;
443
443
  }
444
444
  async decorateTransactions(bundles, status, chainId) {
445
- var _chainId;
445
+ var _chainId, _bundles$;
446
446
  if (!Array.isArray(bundles)) {
447
447
  // Recurse with array
448
448
  return this.decorateTransactions([bundles], status, chainId);
@@ -464,7 +464,7 @@ class Account {
464
464
  entrypoint,
465
465
  chainId,
466
466
  // Intent of the first bundle is used
467
- intent: bundles[0].intent,
467
+ intent: (_bundles$ = bundles[0]) == null ? void 0 : _bundles$.intent,
468
468
  transactions: [...bootstrapBundle.transactions, ...bundles.map(bundle => ({
469
469
  to: bundle.entrypoint,
470
470
  data: core.commons.transaction.encodeBundleExecData(bundle),
@@ -477,7 +477,15 @@ class Account {
477
477
 
478
478
  // Re-compute the meta-transaction id to use the guest module subdigest
479
479
  if (!status.onChain.deployed) {
480
- decoratedBundle.intent.id = core.commons.transaction.subdigestOfGuestModuleTransactions(this.contexts[this.version].guestModule, chainId, decoratedBundle.transactions);
480
+ const id = core.commons.transaction.subdigestOfGuestModuleTransactions(this.contexts[this.version].guestModule, chainId, decoratedBundle.transactions);
481
+ if (decoratedBundle.intent === undefined) {
482
+ decoratedBundle.intent = {
483
+ id,
484
+ wallet: this.address
485
+ };
486
+ } else {
487
+ decoratedBundle.intent.id = id;
488
+ }
481
489
  }
482
490
  return decoratedBundle;
483
491
  }
@@ -754,9 +762,9 @@ class Account {
754
762
  if (!Array.isArray(signedBundle)) {
755
763
  return this.sendSignedTransactions([signedBundle], chainId, quote, pstatus, callback);
756
764
  }
757
- const status = pstatus || (await this.status(signedBundle[0].chainId));
765
+ const status = pstatus || (await this.status(chainId));
758
766
  this.mustBeFullyMigrated(status);
759
- const decoratedBundle = await this.decorateTransactions(signedBundle, status);
767
+ const decoratedBundle = await this.decorateTransactions(signedBundle, status, chainId);
760
768
  callback == null ? void 0 : callback(decoratedBundle);
761
769
  return this.relayer(chainId).relay(decoratedBundle, quote);
762
770
  }
@@ -823,10 +831,6 @@ class Account {
823
831
  bundles.push(signed);
824
832
  }
825
833
  bundles.push(...childBundles.filter(b => b.transactions.length > 0));
826
- if (bundles.length === 0) {
827
- // Nothing to send?
828
- return;
829
- }
830
834
  return this.sendSignedTransactions(bundles, chainId, quote, undefined, callback);
831
835
  }
832
836
  async signTypedData(domain, types, message, chainId, cantValidateBehavior = 'ignore') {
@@ -438,7 +438,7 @@ class Account {
438
438
  return txs;
439
439
  }
440
440
  async decorateTransactions(bundles, status, chainId) {
441
- var _chainId;
441
+ var _chainId, _bundles$;
442
442
  if (!Array.isArray(bundles)) {
443
443
  // Recurse with array
444
444
  return this.decorateTransactions([bundles], status, chainId);
@@ -460,7 +460,7 @@ class Account {
460
460
  entrypoint,
461
461
  chainId,
462
462
  // Intent of the first bundle is used
463
- intent: bundles[0].intent,
463
+ intent: (_bundles$ = bundles[0]) == null ? void 0 : _bundles$.intent,
464
464
  transactions: [...bootstrapBundle.transactions, ...bundles.map(bundle => ({
465
465
  to: bundle.entrypoint,
466
466
  data: commons.transaction.encodeBundleExecData(bundle),
@@ -473,7 +473,15 @@ class Account {
473
473
 
474
474
  // Re-compute the meta-transaction id to use the guest module subdigest
475
475
  if (!status.onChain.deployed) {
476
- decoratedBundle.intent.id = commons.transaction.subdigestOfGuestModuleTransactions(this.contexts[this.version].guestModule, chainId, decoratedBundle.transactions);
476
+ const id = commons.transaction.subdigestOfGuestModuleTransactions(this.contexts[this.version].guestModule, chainId, decoratedBundle.transactions);
477
+ if (decoratedBundle.intent === undefined) {
478
+ decoratedBundle.intent = {
479
+ id,
480
+ wallet: this.address
481
+ };
482
+ } else {
483
+ decoratedBundle.intent.id = id;
484
+ }
477
485
  }
478
486
  return decoratedBundle;
479
487
  }
@@ -750,9 +758,9 @@ class Account {
750
758
  if (!Array.isArray(signedBundle)) {
751
759
  return this.sendSignedTransactions([signedBundle], chainId, quote, pstatus, callback);
752
760
  }
753
- const status = pstatus || (await this.status(signedBundle[0].chainId));
761
+ const status = pstatus || (await this.status(chainId));
754
762
  this.mustBeFullyMigrated(status);
755
- const decoratedBundle = await this.decorateTransactions(signedBundle, status);
763
+ const decoratedBundle = await this.decorateTransactions(signedBundle, status, chainId);
756
764
  callback == null ? void 0 : callback(decoratedBundle);
757
765
  return this.relayer(chainId).relay(decoratedBundle, quote);
758
766
  }
@@ -819,10 +827,6 @@ class Account {
819
827
  bundles.push(signed);
820
828
  }
821
829
  bundles.push(...childBundles.filter(b => b.transactions.length > 0));
822
- if (bundles.length === 0) {
823
- // Nothing to send?
824
- return;
825
- }
826
830
  return this.sendSignedTransactions(bundles, chainId, quote, undefined, callback);
827
831
  }
828
832
  async signTypedData(domain, types, message, chainId, cantValidateBehavior = 'ignore') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/account",
3
- "version": "1.4.9",
3
+ "version": "1.5.0",
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",
@@ -10,19 +10,19 @@
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "ethers": "^5.5.2",
13
- "@0xsequence/core": "1.4.9",
14
- "@0xsequence/utils": "1.4.9",
15
- "@0xsequence/sessions": "1.4.9",
16
- "@0xsequence/migration": "1.4.9",
17
- "@0xsequence/relayer": "1.4.9",
18
- "@0xsequence/wallet": "1.4.9",
19
- "@0xsequence/network": "1.4.9"
13
+ "@0xsequence/core": "1.5.0",
14
+ "@0xsequence/migration": "1.5.0",
15
+ "@0xsequence/network": "1.5.0",
16
+ "@0xsequence/relayer": "1.5.0",
17
+ "@0xsequence/sessions": "1.5.0",
18
+ "@0xsequence/utils": "1.5.0",
19
+ "@0xsequence/wallet": "1.5.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
23
23
  "nyc": "^15.1.0",
24
- "@0xsequence/signhub": "1.4.9",
25
- "@0xsequence/tests": "1.4.9"
24
+ "@0xsequence/signhub": "1.5.0",
25
+ "@0xsequence/tests": "1.5.0"
26
26
  },
27
27
  "files": [
28
28
  "src",
package/src/account.ts CHANGED
@@ -422,7 +422,7 @@ export class Account {
422
422
  entrypoint,
423
423
  chainId,
424
424
  // Intent of the first bundle is used
425
- intent: bundles[0].intent,
425
+ intent: bundles[0]?.intent,
426
426
  transactions: [
427
427
  ...bootstrapBundle.transactions,
428
428
  ...bundles.map(
@@ -440,11 +440,17 @@ export class Account {
440
440
 
441
441
  // Re-compute the meta-transaction id to use the guest module subdigest
442
442
  if (!status.onChain.deployed) {
443
- decoratedBundle.intent.id = commons.transaction.subdigestOfGuestModuleTransactions(
443
+ const id = commons.transaction.subdigestOfGuestModuleTransactions(
444
444
  this.contexts[this.version].guestModule,
445
445
  chainId,
446
446
  decoratedBundle.transactions
447
447
  )
448
+
449
+ if (decoratedBundle.intent === undefined) {
450
+ decoratedBundle.intent = { id, wallet: this.address }
451
+ } else {
452
+ decoratedBundle.intent.id = id
453
+ }
448
454
  }
449
455
 
450
456
  return decoratedBundle
@@ -773,10 +779,10 @@ export class Account {
773
779
  if (!Array.isArray(signedBundle)) {
774
780
  return this.sendSignedTransactions([signedBundle], chainId, quote, pstatus, callback)
775
781
  }
776
- const status = pstatus || (await this.status(signedBundle[0].chainId))
782
+ const status = pstatus || (await this.status(chainId))
777
783
  this.mustBeFullyMigrated(status)
778
784
 
779
- const decoratedBundle = await this.decorateTransactions(signedBundle, status)
785
+ const decoratedBundle = await this.decorateTransactions(signedBundle, status, chainId)
780
786
  callback?.(decoratedBundle)
781
787
 
782
788
  return this.relayer(chainId).relay(decoratedBundle, quote)
@@ -881,11 +887,6 @@ export class Account {
881
887
  }
882
888
  bundles.push(...childBundles.filter(b => b.transactions.length > 0))
883
889
 
884
- if (bundles.length === 0) {
885
- // Nothing to send?
886
- return
887
- }
888
-
889
890
  return this.sendSignedTransactions(bundles, chainId, quote, undefined, callback)
890
891
  }
891
892
 
@@ -46,16 +46,7 @@ export class AccountOrchestratorWrapper implements signers.SapientSigner {
46
46
  return this.account.decorateTransactions(bundle, status)
47
47
  }
48
48
 
49
- async requestSignature(
50
- _id: string,
51
- message: ethers.utils.BytesLike,
52
- metadata: object,
53
- callbacks: {
54
- onSignature: (signature: ethers.utils.BytesLike) => void
55
- onRejection: (error: string) => void
56
- onStatus: (situation: string) => void
57
- }
58
- ): Promise<boolean> {
49
+ sign(message: ethers.utils.BytesLike, metadata: object): Promise<ethers.utils.BytesLike> {
59
50
  if (!commons.isWalletSignRequestMetadata(metadata)) {
60
51
  throw new Error('AccountOrchestratorWrapper only supports wallet metadata requests')
61
52
  }
@@ -67,14 +58,7 @@ export class AccountOrchestratorWrapper implements signers.SapientSigner {
67
58
 
68
59
  // For Sequence nested signatures we must use `signDigest` and not `signMessage`
69
60
  // otherwise the account will hash the digest and the signature will be invalid.
70
- try {
71
- callbacks.onSignature(await this.account.signDigest(message, chainId, decorate, cantValidateBehavior, metadata))
72
- } catch (err) {
73
- callbacks.onRejection('Unable to sign account')
74
- return false
75
- }
76
-
77
- return true
61
+ return this.account.signDigest(message, chainId, decorate, cantValidateBehavior, metadata)
78
62
  }
79
63
 
80
64
  notifyStatusChange(_i: string, _s: Status, _m: object): void {}