@0xsequence/account 1.4.7 → 1.4.9

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,52 @@ 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 ({
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 = core.universal.genericCoderFor(toVersion);
860
+ latestImageHash = _coder.config.imageHashOf(toConfig);
861
+ }
862
+ }
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 = core.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 [];
881
+ }
882
+ }))).flat();
883
+ }
884
+ async getAllSigners() {
885
+ var _this5 = this;
842
886
  const allSigners = [];
843
887
 
844
888
  // We need to get the signers for each status
@@ -847,11 +891,11 @@ class Account {
847
891
 
848
892
  // Getting the status with `longestPath` set to true will give us all the possible configurations
849
893
  // between the current onChain config and the latest config, including the ones "flagged for removal"
850
- const status = await _this4.status(chainId, true);
894
+ const status = await _this5.status(chainId, true);
851
895
  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
896
  return Promise.all(fullChain.map(async function (nextImageHash, iconf) {
853
897
  const isLast = iconf === fullChain.length - 1;
854
- const config = await _this4.tracker.configOfImageHash({
898
+ const config = await _this5.tracker.configOfImageHash({
855
899
  imageHash: nextImageHash
856
900
  });
857
901
  if (!config) {
@@ -837,8 +837,52 @@ 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 ({
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 = core.universal.genericCoderFor(toVersion);
860
+ latestImageHash = _coder.config.imageHashOf(toConfig);
861
+ }
862
+ }
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 = core.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 [];
881
+ }
882
+ }))).flat();
883
+ }
884
+ async getAllSigners() {
885
+ var _this5 = this;
842
886
  const allSigners = [];
843
887
 
844
888
  // We need to get the signers for each status
@@ -847,11 +891,11 @@ class Account {
847
891
 
848
892
  // Getting the status with `longestPath` set to true will give us all the possible configurations
849
893
  // between the current onChain config and the latest config, including the ones "flagged for removal"
850
- const status = await _this4.status(chainId, true);
894
+ const status = await _this5.status(chainId, true);
851
895
  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
896
  return Promise.all(fullChain.map(async function (nextImageHash, iconf) {
853
897
  const isLast = iconf === fullChain.length - 1;
854
- const config = await _this4.tracker.configOfImageHash({
898
+ const config = await _this5.tracker.configOfImageHash({
855
899
  imageHash: nextImageHash
856
900
  });
857
901
  if (!config) {
@@ -833,8 +833,52 @@ 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 ({
840
+ chainId,
841
+ name
842
+ }) {
843
+ try {
844
+ var _last;
845
+ const status = await _this4.status(chainId);
846
+ let latestImageHash = (_last = last(status.presignedConfigurations)) == null ? void 0 : _last.nextImageHash;
847
+ if (!latestImageHash) {
848
+ if (status.onChain.version !== status.version) {
849
+ const migration = last(status.signedMigrations);
850
+ if (migration) {
851
+ const {
852
+ toVersion,
853
+ toConfig
854
+ } = migration;
855
+ const _coder = universal.genericCoderFor(toVersion);
856
+ latestImageHash = _coder.config.imageHashOf(toConfig);
857
+ }
858
+ }
859
+ }
860
+ if (!latestImageHash) {
861
+ latestImageHash = status.onChain.imageHash;
862
+ }
863
+ const latestConfig = await _this4.tracker.configOfImageHash({
864
+ imageHash: latestImageHash
865
+ });
866
+ if (!latestConfig) {
867
+ throw new Error(`unable to find config for image hash ${latestImageHash}`);
868
+ }
869
+ const coder = universal.genericCoderFor(latestConfig.version);
870
+ const signers = coder.config.signersOf(latestConfig);
871
+ return signers.map(signer => _extends({}, signer, {
872
+ network: chainId
873
+ }));
874
+ } catch (error) {
875
+ console.warn(`unable to get signers on network ${chainId} ${name}`, error);
876
+ return [];
877
+ }
878
+ }))).flat();
879
+ }
880
+ async getAllSigners() {
881
+ var _this5 = this;
838
882
  const allSigners = [];
839
883
 
840
884
  // We need to get the signers for each status
@@ -843,11 +887,11 @@ class Account {
843
887
 
844
888
  // Getting the status with `longestPath` set to true will give us all the possible configurations
845
889
  // between the current onChain config and the latest config, including the ones "flagged for removal"
846
- const status = await _this4.status(chainId, true);
890
+ const status = await _this5.status(chainId, true);
847
891
  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
892
  return Promise.all(fullChain.map(async function (nextImageHash, iconf) {
849
893
  const isLast = iconf === fullChain.length - 1;
850
- const config = await _this4.tracker.configOfImageHash({
894
+ const config = await _this5.tracker.configOfImageHash({
851
895
  imageHash: nextImageHash
852
896
  });
853
897
  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.9",
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.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"
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.9",
25
+ "@0xsequence/tests": "1.4.9"
26
26
  },
27
27
  "files": [
28
28
  "src",
package/src/account.ts CHANGED
@@ -900,6 +900,48 @@ 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 ({ chainId, name }) => {
909
+ try {
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
+ } catch (error) {
937
+ console.warn(`unable to get signers on network ${chainId} ${name}`, error)
938
+ return []
939
+ }
940
+ })
941
+ )
942
+ ).flat()
943
+ }
944
+
903
945
  async getAllSigners(): Promise<
904
946
  {
905
947
  address: string