@0xsequence/account 1.4.9 → 1.6.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/0xsequence-account.cjs.dev.js +28 -16
- package/dist/0xsequence-account.cjs.prod.js +28 -16
- package/dist/0xsequence-account.esm.js +28 -16
- package/dist/declarations/src/account.d.ts +2 -0
- package/package.json +10 -10
- package/src/account.ts +14 -10
- package/src/orchestrator/wrapper.ts +2 -18
|
@@ -76,10 +76,10 @@ function encodeGasRefundTransaction(option) {
|
|
|
76
76
|
}
|
|
77
77
|
class AccountSigner {
|
|
78
78
|
constructor(account, chainId, options) {
|
|
79
|
-
this._isSigner = true;
|
|
80
79
|
this.account = account;
|
|
81
80
|
this.chainId = chainId;
|
|
82
81
|
this.options = options;
|
|
82
|
+
this._isSigner = true;
|
|
83
83
|
}
|
|
84
84
|
get provider() {
|
|
85
85
|
return this.account.providerFor(this.chainId);
|
|
@@ -142,7 +142,6 @@ class AccountSigner {
|
|
|
142
142
|
nonceSpace: this.options.nonceSpace
|
|
143
143
|
} : undefined); // Will always have a transaction response
|
|
144
144
|
}
|
|
145
|
-
|
|
146
145
|
getBalance(blockTag) {
|
|
147
146
|
return this.provider.getBalance(this.account.address, blockTag);
|
|
148
147
|
}
|
|
@@ -205,6 +204,14 @@ class Chain0Reader {
|
|
|
205
204
|
}
|
|
206
205
|
class Account {
|
|
207
206
|
constructor(options) {
|
|
207
|
+
this.address = void 0;
|
|
208
|
+
this.networks = void 0;
|
|
209
|
+
this.tracker = void 0;
|
|
210
|
+
this.contexts = void 0;
|
|
211
|
+
this.migrator = void 0;
|
|
212
|
+
this.migrations = void 0;
|
|
213
|
+
this.orchestrator = void 0;
|
|
214
|
+
this.jwt = void 0;
|
|
208
215
|
this.address = ethers.ethers.utils.getAddress(options.address);
|
|
209
216
|
this.contexts = options.contexts;
|
|
210
217
|
this.tracker = options.tracker;
|
|
@@ -442,7 +449,7 @@ class Account {
|
|
|
442
449
|
return txs;
|
|
443
450
|
}
|
|
444
451
|
async decorateTransactions(bundles, status, chainId) {
|
|
445
|
-
var _chainId
|
|
452
|
+
var _chainId, _bundles$;
|
|
446
453
|
if (!Array.isArray(bundles)) {
|
|
447
454
|
// Recurse with array
|
|
448
455
|
return this.decorateTransactions([bundles], status, chainId);
|
|
@@ -464,7 +471,7 @@ class Account {
|
|
|
464
471
|
entrypoint,
|
|
465
472
|
chainId,
|
|
466
473
|
// Intent of the first bundle is used
|
|
467
|
-
intent: bundles[0]
|
|
474
|
+
intent: (_bundles$ = bundles[0]) == null ? void 0 : _bundles$.intent,
|
|
468
475
|
transactions: [...bootstrapBundle.transactions, ...bundles.map(bundle => ({
|
|
469
476
|
to: bundle.entrypoint,
|
|
470
477
|
data: core.commons.transaction.encodeBundleExecData(bundle),
|
|
@@ -477,7 +484,15 @@ class Account {
|
|
|
477
484
|
|
|
478
485
|
// Re-compute the meta-transaction id to use the guest module subdigest
|
|
479
486
|
if (!status.onChain.deployed) {
|
|
480
|
-
|
|
487
|
+
const id = core.commons.transaction.subdigestOfGuestModuleTransactions(this.contexts[this.version].guestModule, chainId, decoratedBundle.transactions);
|
|
488
|
+
if (decoratedBundle.intent === undefined) {
|
|
489
|
+
decoratedBundle.intent = {
|
|
490
|
+
id,
|
|
491
|
+
wallet: this.address
|
|
492
|
+
};
|
|
493
|
+
} else {
|
|
494
|
+
decoratedBundle.intent.id = id;
|
|
495
|
+
}
|
|
481
496
|
}
|
|
482
497
|
return decoratedBundle;
|
|
483
498
|
}
|
|
@@ -670,9 +685,11 @@ class Account {
|
|
|
670
685
|
decorate: true,
|
|
671
686
|
cantValidateBehavior: 'ignore'
|
|
672
687
|
};
|
|
673
|
-
const
|
|
674
|
-
space: options == null ? void 0 : options.nonceSpace
|
|
675
|
-
|
|
688
|
+
const nonceOptions = (options == null ? void 0 : options.nonceSpace) && {
|
|
689
|
+
space: options == null ? void 0 : options.nonceSpace,
|
|
690
|
+
serial: options == null ? void 0 : options.serial
|
|
691
|
+
};
|
|
692
|
+
const signed = await wallet.signTransactions(txs, nonceOptions, metadata);
|
|
676
693
|
return _extends({}, signed, {
|
|
677
694
|
signature: await this.decorateSignature(signed.signature, status)
|
|
678
695
|
});
|
|
@@ -754,10 +771,10 @@ class Account {
|
|
|
754
771
|
if (!Array.isArray(signedBundle)) {
|
|
755
772
|
return this.sendSignedTransactions([signedBundle], chainId, quote, pstatus, callback);
|
|
756
773
|
}
|
|
757
|
-
const status = pstatus || (await this.status(
|
|
774
|
+
const status = pstatus || (await this.status(chainId));
|
|
758
775
|
this.mustBeFullyMigrated(status);
|
|
759
|
-
const decoratedBundle = await this.decorateTransactions(signedBundle, status);
|
|
760
|
-
callback == null
|
|
776
|
+
const decoratedBundle = await this.decorateTransactions(signedBundle, status, chainId);
|
|
777
|
+
callback == null || callback(decoratedBundle);
|
|
761
778
|
return this.relayer(chainId).relay(decoratedBundle, quote);
|
|
762
779
|
}
|
|
763
780
|
async fillGasLimits(txs, chainId, status) {
|
|
@@ -788,7 +805,6 @@ class Account {
|
|
|
788
805
|
entrypoint: this.address,
|
|
789
806
|
nonce: 0 // The relayer also ignored the nonce
|
|
790
807
|
};
|
|
791
|
-
|
|
792
808
|
const decoratedBundle = await this.decorateTransactions(signedBundle, wstatus);
|
|
793
809
|
const data = core.commons.transaction.encodeBundleExecData(decoratedBundle);
|
|
794
810
|
const res = await this.relayer(chainId).getFeeOptionsRaw(decoratedBundle.entrypoint, data, options);
|
|
@@ -823,10 +839,6 @@ class Account {
|
|
|
823
839
|
bundles.push(signed);
|
|
824
840
|
}
|
|
825
841
|
bundles.push(...childBundles.filter(b => b.transactions.length > 0));
|
|
826
|
-
if (bundles.length === 0) {
|
|
827
|
-
// Nothing to send?
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
842
|
return this.sendSignedTransactions(bundles, chainId, quote, undefined, callback);
|
|
831
843
|
}
|
|
832
844
|
async signTypedData(domain, types, message, chainId, cantValidateBehavior = 'ignore') {
|
|
@@ -76,10 +76,10 @@ function encodeGasRefundTransaction(option) {
|
|
|
76
76
|
}
|
|
77
77
|
class AccountSigner {
|
|
78
78
|
constructor(account, chainId, options) {
|
|
79
|
-
this._isSigner = true;
|
|
80
79
|
this.account = account;
|
|
81
80
|
this.chainId = chainId;
|
|
82
81
|
this.options = options;
|
|
82
|
+
this._isSigner = true;
|
|
83
83
|
}
|
|
84
84
|
get provider() {
|
|
85
85
|
return this.account.providerFor(this.chainId);
|
|
@@ -142,7 +142,6 @@ class AccountSigner {
|
|
|
142
142
|
nonceSpace: this.options.nonceSpace
|
|
143
143
|
} : undefined); // Will always have a transaction response
|
|
144
144
|
}
|
|
145
|
-
|
|
146
145
|
getBalance(blockTag) {
|
|
147
146
|
return this.provider.getBalance(this.account.address, blockTag);
|
|
148
147
|
}
|
|
@@ -205,6 +204,14 @@ class Chain0Reader {
|
|
|
205
204
|
}
|
|
206
205
|
class Account {
|
|
207
206
|
constructor(options) {
|
|
207
|
+
this.address = void 0;
|
|
208
|
+
this.networks = void 0;
|
|
209
|
+
this.tracker = void 0;
|
|
210
|
+
this.contexts = void 0;
|
|
211
|
+
this.migrator = void 0;
|
|
212
|
+
this.migrations = void 0;
|
|
213
|
+
this.orchestrator = void 0;
|
|
214
|
+
this.jwt = void 0;
|
|
208
215
|
this.address = ethers.ethers.utils.getAddress(options.address);
|
|
209
216
|
this.contexts = options.contexts;
|
|
210
217
|
this.tracker = options.tracker;
|
|
@@ -442,7 +449,7 @@ class Account {
|
|
|
442
449
|
return txs;
|
|
443
450
|
}
|
|
444
451
|
async decorateTransactions(bundles, status, chainId) {
|
|
445
|
-
var _chainId
|
|
452
|
+
var _chainId, _bundles$;
|
|
446
453
|
if (!Array.isArray(bundles)) {
|
|
447
454
|
// Recurse with array
|
|
448
455
|
return this.decorateTransactions([bundles], status, chainId);
|
|
@@ -464,7 +471,7 @@ class Account {
|
|
|
464
471
|
entrypoint,
|
|
465
472
|
chainId,
|
|
466
473
|
// Intent of the first bundle is used
|
|
467
|
-
intent: bundles[0]
|
|
474
|
+
intent: (_bundles$ = bundles[0]) == null ? void 0 : _bundles$.intent,
|
|
468
475
|
transactions: [...bootstrapBundle.transactions, ...bundles.map(bundle => ({
|
|
469
476
|
to: bundle.entrypoint,
|
|
470
477
|
data: core.commons.transaction.encodeBundleExecData(bundle),
|
|
@@ -477,7 +484,15 @@ class Account {
|
|
|
477
484
|
|
|
478
485
|
// Re-compute the meta-transaction id to use the guest module subdigest
|
|
479
486
|
if (!status.onChain.deployed) {
|
|
480
|
-
|
|
487
|
+
const id = core.commons.transaction.subdigestOfGuestModuleTransactions(this.contexts[this.version].guestModule, chainId, decoratedBundle.transactions);
|
|
488
|
+
if (decoratedBundle.intent === undefined) {
|
|
489
|
+
decoratedBundle.intent = {
|
|
490
|
+
id,
|
|
491
|
+
wallet: this.address
|
|
492
|
+
};
|
|
493
|
+
} else {
|
|
494
|
+
decoratedBundle.intent.id = id;
|
|
495
|
+
}
|
|
481
496
|
}
|
|
482
497
|
return decoratedBundle;
|
|
483
498
|
}
|
|
@@ -670,9 +685,11 @@ class Account {
|
|
|
670
685
|
decorate: true,
|
|
671
686
|
cantValidateBehavior: 'ignore'
|
|
672
687
|
};
|
|
673
|
-
const
|
|
674
|
-
space: options == null ? void 0 : options.nonceSpace
|
|
675
|
-
|
|
688
|
+
const nonceOptions = (options == null ? void 0 : options.nonceSpace) && {
|
|
689
|
+
space: options == null ? void 0 : options.nonceSpace,
|
|
690
|
+
serial: options == null ? void 0 : options.serial
|
|
691
|
+
};
|
|
692
|
+
const signed = await wallet.signTransactions(txs, nonceOptions, metadata);
|
|
676
693
|
return _extends({}, signed, {
|
|
677
694
|
signature: await this.decorateSignature(signed.signature, status)
|
|
678
695
|
});
|
|
@@ -754,10 +771,10 @@ class Account {
|
|
|
754
771
|
if (!Array.isArray(signedBundle)) {
|
|
755
772
|
return this.sendSignedTransactions([signedBundle], chainId, quote, pstatus, callback);
|
|
756
773
|
}
|
|
757
|
-
const status = pstatus || (await this.status(
|
|
774
|
+
const status = pstatus || (await this.status(chainId));
|
|
758
775
|
this.mustBeFullyMigrated(status);
|
|
759
|
-
const decoratedBundle = await this.decorateTransactions(signedBundle, status);
|
|
760
|
-
callback == null
|
|
776
|
+
const decoratedBundle = await this.decorateTransactions(signedBundle, status, chainId);
|
|
777
|
+
callback == null || callback(decoratedBundle);
|
|
761
778
|
return this.relayer(chainId).relay(decoratedBundle, quote);
|
|
762
779
|
}
|
|
763
780
|
async fillGasLimits(txs, chainId, status) {
|
|
@@ -788,7 +805,6 @@ class Account {
|
|
|
788
805
|
entrypoint: this.address,
|
|
789
806
|
nonce: 0 // The relayer also ignored the nonce
|
|
790
807
|
};
|
|
791
|
-
|
|
792
808
|
const decoratedBundle = await this.decorateTransactions(signedBundle, wstatus);
|
|
793
809
|
const data = core.commons.transaction.encodeBundleExecData(decoratedBundle);
|
|
794
810
|
const res = await this.relayer(chainId).getFeeOptionsRaw(decoratedBundle.entrypoint, data, options);
|
|
@@ -823,10 +839,6 @@ class Account {
|
|
|
823
839
|
bundles.push(signed);
|
|
824
840
|
}
|
|
825
841
|
bundles.push(...childBundles.filter(b => b.transactions.length > 0));
|
|
826
|
-
if (bundles.length === 0) {
|
|
827
|
-
// Nothing to send?
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
842
|
return this.sendSignedTransactions(bundles, chainId, quote, undefined, callback);
|
|
831
843
|
}
|
|
832
844
|
async signTypedData(domain, types, message, chainId, cantValidateBehavior = 'ignore') {
|
|
@@ -72,10 +72,10 @@ function encodeGasRefundTransaction(option) {
|
|
|
72
72
|
}
|
|
73
73
|
class AccountSigner {
|
|
74
74
|
constructor(account, chainId, options) {
|
|
75
|
-
this._isSigner = true;
|
|
76
75
|
this.account = account;
|
|
77
76
|
this.chainId = chainId;
|
|
78
77
|
this.options = options;
|
|
78
|
+
this._isSigner = true;
|
|
79
79
|
}
|
|
80
80
|
get provider() {
|
|
81
81
|
return this.account.providerFor(this.chainId);
|
|
@@ -138,7 +138,6 @@ class AccountSigner {
|
|
|
138
138
|
nonceSpace: this.options.nonceSpace
|
|
139
139
|
} : undefined); // Will always have a transaction response
|
|
140
140
|
}
|
|
141
|
-
|
|
142
141
|
getBalance(blockTag) {
|
|
143
142
|
return this.provider.getBalance(this.account.address, blockTag);
|
|
144
143
|
}
|
|
@@ -201,6 +200,14 @@ class Chain0Reader {
|
|
|
201
200
|
}
|
|
202
201
|
class Account {
|
|
203
202
|
constructor(options) {
|
|
203
|
+
this.address = void 0;
|
|
204
|
+
this.networks = void 0;
|
|
205
|
+
this.tracker = void 0;
|
|
206
|
+
this.contexts = void 0;
|
|
207
|
+
this.migrator = void 0;
|
|
208
|
+
this.migrations = void 0;
|
|
209
|
+
this.orchestrator = void 0;
|
|
210
|
+
this.jwt = void 0;
|
|
204
211
|
this.address = ethers.utils.getAddress(options.address);
|
|
205
212
|
this.contexts = options.contexts;
|
|
206
213
|
this.tracker = options.tracker;
|
|
@@ -438,7 +445,7 @@ class Account {
|
|
|
438
445
|
return txs;
|
|
439
446
|
}
|
|
440
447
|
async decorateTransactions(bundles, status, chainId) {
|
|
441
|
-
var _chainId
|
|
448
|
+
var _chainId, _bundles$;
|
|
442
449
|
if (!Array.isArray(bundles)) {
|
|
443
450
|
// Recurse with array
|
|
444
451
|
return this.decorateTransactions([bundles], status, chainId);
|
|
@@ -460,7 +467,7 @@ class Account {
|
|
|
460
467
|
entrypoint,
|
|
461
468
|
chainId,
|
|
462
469
|
// Intent of the first bundle is used
|
|
463
|
-
intent: bundles[0]
|
|
470
|
+
intent: (_bundles$ = bundles[0]) == null ? void 0 : _bundles$.intent,
|
|
464
471
|
transactions: [...bootstrapBundle.transactions, ...bundles.map(bundle => ({
|
|
465
472
|
to: bundle.entrypoint,
|
|
466
473
|
data: commons.transaction.encodeBundleExecData(bundle),
|
|
@@ -473,7 +480,15 @@ class Account {
|
|
|
473
480
|
|
|
474
481
|
// Re-compute the meta-transaction id to use the guest module subdigest
|
|
475
482
|
if (!status.onChain.deployed) {
|
|
476
|
-
|
|
483
|
+
const id = commons.transaction.subdigestOfGuestModuleTransactions(this.contexts[this.version].guestModule, chainId, decoratedBundle.transactions);
|
|
484
|
+
if (decoratedBundle.intent === undefined) {
|
|
485
|
+
decoratedBundle.intent = {
|
|
486
|
+
id,
|
|
487
|
+
wallet: this.address
|
|
488
|
+
};
|
|
489
|
+
} else {
|
|
490
|
+
decoratedBundle.intent.id = id;
|
|
491
|
+
}
|
|
477
492
|
}
|
|
478
493
|
return decoratedBundle;
|
|
479
494
|
}
|
|
@@ -666,9 +681,11 @@ class Account {
|
|
|
666
681
|
decorate: true,
|
|
667
682
|
cantValidateBehavior: 'ignore'
|
|
668
683
|
};
|
|
669
|
-
const
|
|
670
|
-
space: options == null ? void 0 : options.nonceSpace
|
|
671
|
-
|
|
684
|
+
const nonceOptions = (options == null ? void 0 : options.nonceSpace) && {
|
|
685
|
+
space: options == null ? void 0 : options.nonceSpace,
|
|
686
|
+
serial: options == null ? void 0 : options.serial
|
|
687
|
+
};
|
|
688
|
+
const signed = await wallet.signTransactions(txs, nonceOptions, metadata);
|
|
672
689
|
return _extends({}, signed, {
|
|
673
690
|
signature: await this.decorateSignature(signed.signature, status)
|
|
674
691
|
});
|
|
@@ -750,10 +767,10 @@ class Account {
|
|
|
750
767
|
if (!Array.isArray(signedBundle)) {
|
|
751
768
|
return this.sendSignedTransactions([signedBundle], chainId, quote, pstatus, callback);
|
|
752
769
|
}
|
|
753
|
-
const status = pstatus || (await this.status(
|
|
770
|
+
const status = pstatus || (await this.status(chainId));
|
|
754
771
|
this.mustBeFullyMigrated(status);
|
|
755
|
-
const decoratedBundle = await this.decorateTransactions(signedBundle, status);
|
|
756
|
-
callback == null
|
|
772
|
+
const decoratedBundle = await this.decorateTransactions(signedBundle, status, chainId);
|
|
773
|
+
callback == null || callback(decoratedBundle);
|
|
757
774
|
return this.relayer(chainId).relay(decoratedBundle, quote);
|
|
758
775
|
}
|
|
759
776
|
async fillGasLimits(txs, chainId, status) {
|
|
@@ -784,7 +801,6 @@ class Account {
|
|
|
784
801
|
entrypoint: this.address,
|
|
785
802
|
nonce: 0 // The relayer also ignored the nonce
|
|
786
803
|
};
|
|
787
|
-
|
|
788
804
|
const decoratedBundle = await this.decorateTransactions(signedBundle, wstatus);
|
|
789
805
|
const data = commons.transaction.encodeBundleExecData(decoratedBundle);
|
|
790
806
|
const res = await this.relayer(chainId).getFeeOptionsRaw(decoratedBundle.entrypoint, data, options);
|
|
@@ -819,10 +835,6 @@ class Account {
|
|
|
819
835
|
bundles.push(signed);
|
|
820
836
|
}
|
|
821
837
|
bundles.push(...childBundles.filter(b => b.transactions.length > 0));
|
|
822
|
-
if (bundles.length === 0) {
|
|
823
|
-
// Nothing to send?
|
|
824
|
-
return;
|
|
825
|
-
}
|
|
826
838
|
return this.sendSignedTransactions(bundles, chainId, quote, undefined, callback);
|
|
827
839
|
}
|
|
828
840
|
async signTypedData(domain, types, message, chainId, cantValidateBehavior = 'ignore') {
|
|
@@ -109,6 +109,7 @@ export declare class Account {
|
|
|
109
109
|
signMessage(message: ethers.BytesLike, chainId: ethers.BigNumberish, cantValidateBehavior?: 'ignore' | 'eip6492' | 'throw'): Promise<string>;
|
|
110
110
|
signTransactions(txs: commons.transaction.Transactionish, chainId: ethers.BigNumberish, pstatus?: AccountStatus, options?: {
|
|
111
111
|
nonceSpace?: ethers.BigNumberish;
|
|
112
|
+
serial?: boolean;
|
|
112
113
|
}): Promise<commons.transaction.SignedTransactionBundle>;
|
|
113
114
|
signMigrations(chainId: ethers.BigNumberish, editConfig: (prevConfig: commons.config.Config) => commons.config.Config): Promise<boolean>;
|
|
114
115
|
signAllMigrations(editConfig: (prevConfig: commons.config.Config) => commons.config.Config): Promise<{
|
|
@@ -136,6 +137,7 @@ export declare class Account {
|
|
|
136
137
|
}): Promise<PreparedTransactions>;
|
|
137
138
|
sendTransaction(txs: commons.transaction.Transactionish, chainId: ethers.BigNumberish, quote?: FeeQuote, skipPreDecorate?: boolean, callback?: (bundle: commons.transaction.IntendedTransactionBundle) => void, options?: {
|
|
138
139
|
nonceSpace?: ethers.BigNumberish;
|
|
140
|
+
serial?: boolean;
|
|
139
141
|
}): Promise<ethers.providers.TransactionResponse | undefined>;
|
|
140
142
|
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, message: Record<string, any>, chainId: ethers.BigNumberish, cantValidateBehavior?: 'ignore' | 'eip6492' | 'throw'): Promise<string>;
|
|
141
143
|
getSigners(): Promise<Array<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/account",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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.
|
|
14
|
-
"@0xsequence/
|
|
15
|
-
"@0xsequence/
|
|
16
|
-
"@0xsequence/
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/
|
|
13
|
+
"@0xsequence/core": "1.6.0",
|
|
14
|
+
"@0xsequence/migration": "1.6.0",
|
|
15
|
+
"@0xsequence/network": "1.6.0",
|
|
16
|
+
"@0xsequence/relayer": "1.6.0",
|
|
17
|
+
"@0xsequence/sessions": "1.6.0",
|
|
18
|
+
"@0xsequence/utils": "1.6.0",
|
|
19
|
+
"@0xsequence/wallet": "1.6.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
23
23
|
"nyc": "^15.1.0",
|
|
24
|
-
"@0xsequence/
|
|
25
|
-
"@0xsequence/
|
|
24
|
+
"@0xsequence/tests": "1.6.0",
|
|
25
|
+
"@0xsequence/signhub": "1.6.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]
|
|
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
|
-
|
|
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
|
|
@@ -663,6 +669,7 @@ export class Account {
|
|
|
663
669
|
pstatus?: AccountStatus,
|
|
664
670
|
options?: {
|
|
665
671
|
nonceSpace?: ethers.BigNumberish
|
|
672
|
+
serial?: boolean
|
|
666
673
|
}
|
|
667
674
|
): Promise<commons.transaction.SignedTransactionBundle> {
|
|
668
675
|
const status = pstatus || (await this.status(chainId))
|
|
@@ -679,7 +686,8 @@ export class Account {
|
|
|
679
686
|
cantValidateBehavior: 'ignore'
|
|
680
687
|
}
|
|
681
688
|
|
|
682
|
-
const
|
|
689
|
+
const nonceOptions = options?.nonceSpace && { space: options?.nonceSpace, serial: options?.serial }
|
|
690
|
+
const signed = await wallet.signTransactions(txs, nonceOptions, metadata)
|
|
683
691
|
|
|
684
692
|
return {
|
|
685
693
|
...signed,
|
|
@@ -773,10 +781,10 @@ export class Account {
|
|
|
773
781
|
if (!Array.isArray(signedBundle)) {
|
|
774
782
|
return this.sendSignedTransactions([signedBundle], chainId, quote, pstatus, callback)
|
|
775
783
|
}
|
|
776
|
-
const status = pstatus || (await this.status(
|
|
784
|
+
const status = pstatus || (await this.status(chainId))
|
|
777
785
|
this.mustBeFullyMigrated(status)
|
|
778
786
|
|
|
779
|
-
const decoratedBundle = await this.decorateTransactions(signedBundle, status)
|
|
787
|
+
const decoratedBundle = await this.decorateTransactions(signedBundle, status, chainId)
|
|
780
788
|
callback?.(decoratedBundle)
|
|
781
789
|
|
|
782
790
|
return this.relayer(chainId).relay(decoratedBundle, quote)
|
|
@@ -865,6 +873,7 @@ export class Account {
|
|
|
865
873
|
callback?: (bundle: commons.transaction.IntendedTransactionBundle) => void,
|
|
866
874
|
options?: {
|
|
867
875
|
nonceSpace?: ethers.BigNumberish
|
|
876
|
+
serial?: boolean
|
|
868
877
|
}
|
|
869
878
|
): Promise<ethers.providers.TransactionResponse | undefined> {
|
|
870
879
|
const status = await this.status(chainId)
|
|
@@ -881,11 +890,6 @@ export class Account {
|
|
|
881
890
|
}
|
|
882
891
|
bundles.push(...childBundles.filter(b => b.transactions.length > 0))
|
|
883
892
|
|
|
884
|
-
if (bundles.length === 0) {
|
|
885
|
-
// Nothing to send?
|
|
886
|
-
return
|
|
887
|
-
}
|
|
888
|
-
|
|
889
893
|
return this.sendSignedTransactions(bundles, chainId, quote, undefined, callback)
|
|
890
894
|
}
|
|
891
895
|
|
|
@@ -46,16 +46,7 @@ export class AccountOrchestratorWrapper implements signers.SapientSigner {
|
|
|
46
46
|
return this.account.decorateTransactions(bundle, status)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
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
|
-
|
|
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 {}
|