@0xsequence/account 1.4.7 → 1.4.8

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.
@@ -837,8 +837,47 @@ class Account {
837
837
  });
838
838
  return this.signDigest(digest, chainId, true, cantValidateBehavior);
839
839
  }
840
- async getAllSigners() {
840
+ async getSigners() {
841
841
  var _this4 = this;
842
+ const last = ts => ts.length ? ts[ts.length - 1] : undefined;
843
+ return (await Promise.all(this.networks.map(async function (network) {
844
+ var _last;
845
+ const {
846
+ chainId
847
+ } = network;
848
+ const status = await _this4.status(chainId);
849
+ let latestImageHash = (_last = last(status.presignedConfigurations)) == null ? void 0 : _last.nextImageHash;
850
+ if (!latestImageHash) {
851
+ if (status.onChain.version !== status.version) {
852
+ const migration = last(status.signedMigrations);
853
+ if (migration) {
854
+ const {
855
+ toVersion,
856
+ toConfig
857
+ } = migration;
858
+ const _coder = core.universal.genericCoderFor(toVersion);
859
+ latestImageHash = _coder.config.imageHashOf(toConfig);
860
+ }
861
+ }
862
+ }
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
+ }))).flat();
878
+ }
879
+ async getAllSigners() {
880
+ var _this5 = this;
842
881
  const allSigners = [];
843
882
 
844
883
  // We need to get the signers for each status
@@ -847,11 +886,11 @@ class Account {
847
886
 
848
887
  // Getting the status with `longestPath` set to true will give us all the possible configurations
849
888
  // between the current onChain config and the latest config, including the ones "flagged for removal"
850
- const status = await _this4.status(chainId, true);
889
+ const status = await _this5.status(chainId, true);
851
890
  const fullChain = [status.onChain.imageHash, ...(status.onChain.version !== status.version ? status.signedMigrations.map(m => core.universal.coderFor(m.toVersion).config.imageHashOf(m.toConfig)) : []), ...status.presignedConfigurations.map(update => update.nextImageHash)];
852
891
  return Promise.all(fullChain.map(async function (nextImageHash, iconf) {
853
892
  const isLast = iconf === fullChain.length - 1;
854
- const config = await _this4.tracker.configOfImageHash({
893
+ const config = await _this5.tracker.configOfImageHash({
855
894
  imageHash: nextImageHash
856
895
  });
857
896
  if (!config) {
@@ -837,8 +837,47 @@ class Account {
837
837
  });
838
838
  return this.signDigest(digest, chainId, true, cantValidateBehavior);
839
839
  }
840
- async getAllSigners() {
840
+ async getSigners() {
841
841
  var _this4 = this;
842
+ const last = ts => ts.length ? ts[ts.length - 1] : undefined;
843
+ return (await Promise.all(this.networks.map(async function (network) {
844
+ var _last;
845
+ const {
846
+ chainId
847
+ } = network;
848
+ const status = await _this4.status(chainId);
849
+ let latestImageHash = (_last = last(status.presignedConfigurations)) == null ? void 0 : _last.nextImageHash;
850
+ if (!latestImageHash) {
851
+ if (status.onChain.version !== status.version) {
852
+ const migration = last(status.signedMigrations);
853
+ if (migration) {
854
+ const {
855
+ toVersion,
856
+ toConfig
857
+ } = migration;
858
+ const _coder = core.universal.genericCoderFor(toVersion);
859
+ latestImageHash = _coder.config.imageHashOf(toConfig);
860
+ }
861
+ }
862
+ }
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
+ }))).flat();
878
+ }
879
+ async getAllSigners() {
880
+ var _this5 = this;
842
881
  const allSigners = [];
843
882
 
844
883
  // We need to get the signers for each status
@@ -847,11 +886,11 @@ class Account {
847
886
 
848
887
  // Getting the status with `longestPath` set to true will give us all the possible configurations
849
888
  // between the current onChain config and the latest config, including the ones "flagged for removal"
850
- const status = await _this4.status(chainId, true);
889
+ const status = await _this5.status(chainId, true);
851
890
  const fullChain = [status.onChain.imageHash, ...(status.onChain.version !== status.version ? status.signedMigrations.map(m => core.universal.coderFor(m.toVersion).config.imageHashOf(m.toConfig)) : []), ...status.presignedConfigurations.map(update => update.nextImageHash)];
852
891
  return Promise.all(fullChain.map(async function (nextImageHash, iconf) {
853
892
  const isLast = iconf === fullChain.length - 1;
854
- const config = await _this4.tracker.configOfImageHash({
893
+ const config = await _this5.tracker.configOfImageHash({
855
894
  imageHash: nextImageHash
856
895
  });
857
896
  if (!config) {
@@ -833,8 +833,47 @@ class Account {
833
833
  });
834
834
  return this.signDigest(digest, chainId, true, cantValidateBehavior);
835
835
  }
836
- async getAllSigners() {
836
+ async getSigners() {
837
837
  var _this4 = this;
838
+ const last = ts => ts.length ? ts[ts.length - 1] : undefined;
839
+ return (await Promise.all(this.networks.map(async function (network) {
840
+ var _last;
841
+ const {
842
+ chainId
843
+ } = network;
844
+ const status = await _this4.status(chainId);
845
+ let latestImageHash = (_last = last(status.presignedConfigurations)) == null ? void 0 : _last.nextImageHash;
846
+ if (!latestImageHash) {
847
+ if (status.onChain.version !== status.version) {
848
+ const migration = last(status.signedMigrations);
849
+ if (migration) {
850
+ const {
851
+ toVersion,
852
+ toConfig
853
+ } = migration;
854
+ const _coder = universal.genericCoderFor(toVersion);
855
+ latestImageHash = _coder.config.imageHashOf(toConfig);
856
+ }
857
+ }
858
+ }
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
+ }))).flat();
874
+ }
875
+ async getAllSigners() {
876
+ var _this5 = this;
838
877
  const allSigners = [];
839
878
 
840
879
  // We need to get the signers for each status
@@ -843,11 +882,11 @@ class Account {
843
882
 
844
883
  // Getting the status with `longestPath` set to true will give us all the possible configurations
845
884
  // between the current onChain config and the latest config, including the ones "flagged for removal"
846
- const status = await _this4.status(chainId, true);
885
+ const status = await _this5.status(chainId, true);
847
886
  const fullChain = [status.onChain.imageHash, ...(status.onChain.version !== status.version ? status.signedMigrations.map(m => universal.coderFor(m.toVersion).config.imageHashOf(m.toConfig)) : []), ...status.presignedConfigurations.map(update => update.nextImageHash)];
848
887
  return Promise.all(fullChain.map(async function (nextImageHash, iconf) {
849
888
  const isLast = iconf === fullChain.length - 1;
850
- const config = await _this4.tracker.configOfImageHash({
889
+ const config = await _this5.tracker.configOfImageHash({
851
890
  imageHash: nextImageHash
852
891
  });
853
892
  if (!config) {
@@ -138,6 +138,11 @@ export declare class Account {
138
138
  nonceSpace?: ethers.BigNumberish;
139
139
  }): Promise<ethers.providers.TransactionResponse | undefined>;
140
140
  signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, message: Record<string, any>, chainId: ethers.BigNumberish, cantValidateBehavior?: 'ignore' | 'eip6492' | 'throw'): Promise<string>;
141
+ getSigners(): Promise<Array<{
142
+ address: string;
143
+ network: ChainId;
144
+ weight: number;
145
+ }>>;
141
146
  getAllSigners(): Promise<{
142
147
  address: string;
143
148
  weight: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/account",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
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.7",
14
- "@0xsequence/migration": "1.4.7",
15
- "@0xsequence/network": "1.4.7",
16
- "@0xsequence/relayer": "1.4.7",
17
- "@0xsequence/sessions": "1.4.7",
18
- "@0xsequence/utils": "1.4.7",
19
- "@0xsequence/wallet": "1.4.7"
13
+ "@0xsequence/core": "1.4.8",
14
+ "@0xsequence/migration": "1.4.8",
15
+ "@0xsequence/network": "1.4.8",
16
+ "@0xsequence/relayer": "1.4.8",
17
+ "@0xsequence/sessions": "1.4.8",
18
+ "@0xsequence/utils": "1.4.8",
19
+ "@0xsequence/wallet": "1.4.8"
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.7",
25
- "@0xsequence/tests": "1.4.7"
24
+ "@0xsequence/signhub": "1.4.8",
25
+ "@0xsequence/tests": "1.4.8"
26
26
  },
27
27
  "files": [
28
28
  "src",
package/src/account.ts CHANGED
@@ -900,6 +900,44 @@ export class Account {
900
900
  return this.signDigest(digest, chainId, true, cantValidateBehavior)
901
901
  }
902
902
 
903
+ async getSigners(): Promise<Array<{ address: string; network: ChainId; weight: number }>> {
904
+ const last = <T>(ts: T[]): T | undefined => (ts.length ? ts[ts.length - 1] : undefined)
905
+
906
+ return (
907
+ await Promise.all(
908
+ this.networks.map(async network => {
909
+ const { chainId } = network
910
+ const status = await this.status(chainId)
911
+
912
+ let latestImageHash = last(status.presignedConfigurations)?.nextImageHash
913
+ if (!latestImageHash) {
914
+ if (status.onChain.version !== status.version) {
915
+ const migration = last(status.signedMigrations)
916
+ if (migration) {
917
+ const { toVersion, toConfig } = migration
918
+ const coder = universal.genericCoderFor(toVersion)
919
+ latestImageHash = coder.config.imageHashOf(toConfig)
920
+ }
921
+ }
922
+ }
923
+ if (!latestImageHash) {
924
+ latestImageHash = status.onChain.imageHash
925
+ }
926
+
927
+ const latestConfig = await this.tracker.configOfImageHash({ imageHash: latestImageHash })
928
+ if (!latestConfig) {
929
+ throw new Error(`unable to find config for image hash ${latestImageHash}`)
930
+ }
931
+
932
+ const coder = universal.genericCoderFor(latestConfig.version)
933
+ const signers = coder.config.signersOf(latestConfig)
934
+
935
+ return signers.map(signer => ({ ...signer, network: chainId }))
936
+ })
937
+ )
938
+ ).flat()
939
+ }
940
+
903
941
  async getAllSigners(): Promise<
904
942
  {
905
943
  address: string