@0xsequence/account 1.4.8 → 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.
- package/dist/0xsequence-account.cjs.dev.js +49 -40
- package/dist/0xsequence-account.cjs.prod.js +49 -40
- package/dist/0xsequence-account.esm.js +49 -40
- package/package.json +10 -10
- package/src/account.ts +37 -32
- package/src/orchestrator/wrapper.ts +2 -18
|
@@ -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]
|
|
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
|
-
|
|
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(
|
|
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') {
|
|
@@ -840,40 +844,45 @@ class Account {
|
|
|
840
844
|
async getSigners() {
|
|
841
845
|
var _this4 = this;
|
|
842
846
|
const last = ts => ts.length ? ts[ts.length - 1] : undefined;
|
|
843
|
-
return (await Promise.all(this.networks.map(async function (
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
if (
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
847
|
+
return (await Promise.all(this.networks.map(async function ({
|
|
848
|
+
chainId,
|
|
849
|
+
name
|
|
850
|
+
}) {
|
|
851
|
+
try {
|
|
852
|
+
var _last;
|
|
853
|
+
const status = await _this4.status(chainId);
|
|
854
|
+
let latestImageHash = (_last = last(status.presignedConfigurations)) == null ? void 0 : _last.nextImageHash;
|
|
855
|
+
if (!latestImageHash) {
|
|
856
|
+
if (status.onChain.version !== status.version) {
|
|
857
|
+
const migration = last(status.signedMigrations);
|
|
858
|
+
if (migration) {
|
|
859
|
+
const {
|
|
860
|
+
toVersion,
|
|
861
|
+
toConfig
|
|
862
|
+
} = migration;
|
|
863
|
+
const _coder = core.universal.genericCoderFor(toVersion);
|
|
864
|
+
latestImageHash = _coder.config.imageHashOf(toConfig);
|
|
865
|
+
}
|
|
860
866
|
}
|
|
861
867
|
}
|
|
868
|
+
if (!latestImageHash) {
|
|
869
|
+
latestImageHash = status.onChain.imageHash;
|
|
870
|
+
}
|
|
871
|
+
const latestConfig = await _this4.tracker.configOfImageHash({
|
|
872
|
+
imageHash: latestImageHash
|
|
873
|
+
});
|
|
874
|
+
if (!latestConfig) {
|
|
875
|
+
throw new Error(`unable to find config for image hash ${latestImageHash}`);
|
|
876
|
+
}
|
|
877
|
+
const coder = core.universal.genericCoderFor(latestConfig.version);
|
|
878
|
+
const signers = coder.config.signersOf(latestConfig);
|
|
879
|
+
return signers.map(signer => _extends({}, signer, {
|
|
880
|
+
network: chainId
|
|
881
|
+
}));
|
|
882
|
+
} catch (error) {
|
|
883
|
+
console.warn(`unable to get signers on network ${chainId} ${name}`, error);
|
|
884
|
+
return [];
|
|
862
885
|
}
|
|
863
|
-
if (!latestImageHash) {
|
|
864
|
-
latestImageHash = status.onChain.imageHash;
|
|
865
|
-
}
|
|
866
|
-
const latestConfig = await _this4.tracker.configOfImageHash({
|
|
867
|
-
imageHash: latestImageHash
|
|
868
|
-
});
|
|
869
|
-
if (!latestConfig) {
|
|
870
|
-
throw new Error(`unable to find config for image hash ${latestImageHash}`);
|
|
871
|
-
}
|
|
872
|
-
const coder = core.universal.genericCoderFor(latestConfig.version);
|
|
873
|
-
const signers = coder.config.signersOf(latestConfig);
|
|
874
|
-
return signers.map(signer => _extends({}, signer, {
|
|
875
|
-
network: chainId
|
|
876
|
-
}));
|
|
877
886
|
}))).flat();
|
|
878
887
|
}
|
|
879
888
|
async getAllSigners() {
|
|
@@ -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]
|
|
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
|
-
|
|
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(
|
|
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') {
|
|
@@ -840,40 +844,45 @@ class Account {
|
|
|
840
844
|
async getSigners() {
|
|
841
845
|
var _this4 = this;
|
|
842
846
|
const last = ts => ts.length ? ts[ts.length - 1] : undefined;
|
|
843
|
-
return (await Promise.all(this.networks.map(async function (
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
if (
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
847
|
+
return (await Promise.all(this.networks.map(async function ({
|
|
848
|
+
chainId,
|
|
849
|
+
name
|
|
850
|
+
}) {
|
|
851
|
+
try {
|
|
852
|
+
var _last;
|
|
853
|
+
const status = await _this4.status(chainId);
|
|
854
|
+
let latestImageHash = (_last = last(status.presignedConfigurations)) == null ? void 0 : _last.nextImageHash;
|
|
855
|
+
if (!latestImageHash) {
|
|
856
|
+
if (status.onChain.version !== status.version) {
|
|
857
|
+
const migration = last(status.signedMigrations);
|
|
858
|
+
if (migration) {
|
|
859
|
+
const {
|
|
860
|
+
toVersion,
|
|
861
|
+
toConfig
|
|
862
|
+
} = migration;
|
|
863
|
+
const _coder = core.universal.genericCoderFor(toVersion);
|
|
864
|
+
latestImageHash = _coder.config.imageHashOf(toConfig);
|
|
865
|
+
}
|
|
860
866
|
}
|
|
861
867
|
}
|
|
868
|
+
if (!latestImageHash) {
|
|
869
|
+
latestImageHash = status.onChain.imageHash;
|
|
870
|
+
}
|
|
871
|
+
const latestConfig = await _this4.tracker.configOfImageHash({
|
|
872
|
+
imageHash: latestImageHash
|
|
873
|
+
});
|
|
874
|
+
if (!latestConfig) {
|
|
875
|
+
throw new Error(`unable to find config for image hash ${latestImageHash}`);
|
|
876
|
+
}
|
|
877
|
+
const coder = core.universal.genericCoderFor(latestConfig.version);
|
|
878
|
+
const signers = coder.config.signersOf(latestConfig);
|
|
879
|
+
return signers.map(signer => _extends({}, signer, {
|
|
880
|
+
network: chainId
|
|
881
|
+
}));
|
|
882
|
+
} catch (error) {
|
|
883
|
+
console.warn(`unable to get signers on network ${chainId} ${name}`, error);
|
|
884
|
+
return [];
|
|
862
885
|
}
|
|
863
|
-
if (!latestImageHash) {
|
|
864
|
-
latestImageHash = status.onChain.imageHash;
|
|
865
|
-
}
|
|
866
|
-
const latestConfig = await _this4.tracker.configOfImageHash({
|
|
867
|
-
imageHash: latestImageHash
|
|
868
|
-
});
|
|
869
|
-
if (!latestConfig) {
|
|
870
|
-
throw new Error(`unable to find config for image hash ${latestImageHash}`);
|
|
871
|
-
}
|
|
872
|
-
const coder = core.universal.genericCoderFor(latestConfig.version);
|
|
873
|
-
const signers = coder.config.signersOf(latestConfig);
|
|
874
|
-
return signers.map(signer => _extends({}, signer, {
|
|
875
|
-
network: chainId
|
|
876
|
-
}));
|
|
877
886
|
}))).flat();
|
|
878
887
|
}
|
|
879
888
|
async getAllSigners() {
|
|
@@ -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]
|
|
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
|
-
|
|
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(
|
|
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') {
|
|
@@ -836,40 +840,45 @@ class Account {
|
|
|
836
840
|
async getSigners() {
|
|
837
841
|
var _this4 = this;
|
|
838
842
|
const last = ts => ts.length ? ts[ts.length - 1] : undefined;
|
|
839
|
-
return (await Promise.all(this.networks.map(async function (
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
if (
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
843
|
+
return (await Promise.all(this.networks.map(async function ({
|
|
844
|
+
chainId,
|
|
845
|
+
name
|
|
846
|
+
}) {
|
|
847
|
+
try {
|
|
848
|
+
var _last;
|
|
849
|
+
const status = await _this4.status(chainId);
|
|
850
|
+
let latestImageHash = (_last = last(status.presignedConfigurations)) == null ? void 0 : _last.nextImageHash;
|
|
851
|
+
if (!latestImageHash) {
|
|
852
|
+
if (status.onChain.version !== status.version) {
|
|
853
|
+
const migration = last(status.signedMigrations);
|
|
854
|
+
if (migration) {
|
|
855
|
+
const {
|
|
856
|
+
toVersion,
|
|
857
|
+
toConfig
|
|
858
|
+
} = migration;
|
|
859
|
+
const _coder = universal.genericCoderFor(toVersion);
|
|
860
|
+
latestImageHash = _coder.config.imageHashOf(toConfig);
|
|
861
|
+
}
|
|
856
862
|
}
|
|
857
863
|
}
|
|
864
|
+
if (!latestImageHash) {
|
|
865
|
+
latestImageHash = status.onChain.imageHash;
|
|
866
|
+
}
|
|
867
|
+
const latestConfig = await _this4.tracker.configOfImageHash({
|
|
868
|
+
imageHash: latestImageHash
|
|
869
|
+
});
|
|
870
|
+
if (!latestConfig) {
|
|
871
|
+
throw new Error(`unable to find config for image hash ${latestImageHash}`);
|
|
872
|
+
}
|
|
873
|
+
const coder = universal.genericCoderFor(latestConfig.version);
|
|
874
|
+
const signers = coder.config.signersOf(latestConfig);
|
|
875
|
+
return signers.map(signer => _extends({}, signer, {
|
|
876
|
+
network: chainId
|
|
877
|
+
}));
|
|
878
|
+
} catch (error) {
|
|
879
|
+
console.warn(`unable to get signers on network ${chainId} ${name}`, error);
|
|
880
|
+
return [];
|
|
858
881
|
}
|
|
859
|
-
if (!latestImageHash) {
|
|
860
|
-
latestImageHash = status.onChain.imageHash;
|
|
861
|
-
}
|
|
862
|
-
const latestConfig = await _this4.tracker.configOfImageHash({
|
|
863
|
-
imageHash: latestImageHash
|
|
864
|
-
});
|
|
865
|
-
if (!latestConfig) {
|
|
866
|
-
throw new Error(`unable to find config for image hash ${latestImageHash}`);
|
|
867
|
-
}
|
|
868
|
-
const coder = universal.genericCoderFor(latestConfig.version);
|
|
869
|
-
const signers = coder.config.signersOf(latestConfig);
|
|
870
|
-
return signers.map(signer => _extends({}, signer, {
|
|
871
|
-
network: chainId
|
|
872
|
-
}));
|
|
873
882
|
}))).flat();
|
|
874
883
|
}
|
|
875
884
|
async getAllSigners() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/account",
|
|
3
|
-
"version": "1.
|
|
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.
|
|
14
|
-
"@0xsequence/migration": "1.
|
|
15
|
-
"@0xsequence/network": "1.
|
|
16
|
-
"@0xsequence/relayer": "1.
|
|
17
|
-
"@0xsequence/sessions": "1.
|
|
18
|
-
"@0xsequence/utils": "1.
|
|
19
|
-
"@0xsequence/wallet": "1.
|
|
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.
|
|
25
|
-
"@0xsequence/tests": "1.
|
|
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]
|
|
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
|
|
@@ -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(
|
|
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
|
|
|
@@ -905,34 +906,38 @@ export class Account {
|
|
|
905
906
|
|
|
906
907
|
return (
|
|
907
908
|
await Promise.all(
|
|
908
|
-
this.networks.map(async
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
909
|
+
this.networks.map(async ({ chainId, name }) => {
|
|
910
|
+
try {
|
|
911
|
+
const status = await this.status(chainId)
|
|
912
|
+
|
|
913
|
+
let latestImageHash = last(status.presignedConfigurations)?.nextImageHash
|
|
914
|
+
if (!latestImageHash) {
|
|
915
|
+
if (status.onChain.version !== status.version) {
|
|
916
|
+
const migration = last(status.signedMigrations)
|
|
917
|
+
if (migration) {
|
|
918
|
+
const { toVersion, toConfig } = migration
|
|
919
|
+
const coder = universal.genericCoderFor(toVersion)
|
|
920
|
+
latestImageHash = coder.config.imageHashOf(toConfig)
|
|
921
|
+
}
|
|
920
922
|
}
|
|
921
923
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
}
|
|
924
|
+
if (!latestImageHash) {
|
|
925
|
+
latestImageHash = status.onChain.imageHash
|
|
926
|
+
}
|
|
926
927
|
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
928
|
+
const latestConfig = await this.tracker.configOfImageHash({ imageHash: latestImageHash })
|
|
929
|
+
if (!latestConfig) {
|
|
930
|
+
throw new Error(`unable to find config for image hash ${latestImageHash}`)
|
|
931
|
+
}
|
|
931
932
|
|
|
932
|
-
|
|
933
|
-
|
|
933
|
+
const coder = universal.genericCoderFor(latestConfig.version)
|
|
934
|
+
const signers = coder.config.signersOf(latestConfig)
|
|
934
935
|
|
|
935
|
-
|
|
936
|
+
return signers.map(signer => ({ ...signer, network: chainId }))
|
|
937
|
+
} catch (error) {
|
|
938
|
+
console.warn(`unable to get signers on network ${chainId} ${name}`, error)
|
|
939
|
+
return []
|
|
940
|
+
}
|
|
936
941
|
})
|
|
937
942
|
)
|
|
938
943
|
).flat()
|
|
@@ -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 {}
|