@subwallet/extension-base 1.1.62-0 → 1.1.63-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.
@@ -3052,7 +3052,10 @@ class KoniExtension {
3052
3052
  let registry = new _types4.TypeRegistry();
3053
3053
  let isEvm = false;
3054
3054
  if ((0, _Extension.isJsonPayload)(payload)) {
3055
- // Get the metadata for the genesisHash
3055
+ /**
3056
+ * Get the metadata for the genesisHash
3057
+ * @todo: need to handle case metadata store in db
3058
+ */
3056
3059
  const currentMetadata = this.#koniState.knownMetadata.find(meta => meta.genesisHash === payload.genesisHash);
3057
3060
 
3058
3061
  // set the registry before calling the sign function
@@ -3061,12 +3064,23 @@ class KoniExtension {
3061
3064
  registry.register(currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.types);
3062
3065
  }
3063
3066
  const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
3064
- if (chainInfo && (_constants2._API_OPTIONS_CHAIN_GROUP.avail.includes(chainInfo.slug) || _constants2._API_OPTIONS_CHAIN_GROUP.goldberg.includes(chainInfo.slug))) {
3065
- const isChainActive = this.#koniState.getChainStateByKey(chainInfo.slug).active;
3066
- if (!isChainActive) {
3067
- reject(new Error('Please activate {{chain}} network before signing'.replaceAll('{{chain}}', chainInfo.name)));
3068
- return false;
3069
- } else {
3067
+ if (!currentMetadata) {
3068
+ /*
3069
+ * Some networks must have metadata to signing,
3070
+ * so if the chain not active (cannot use metadata from api), it must be rejected
3071
+ * */
3072
+ if (chainInfo && (_constants2._API_OPTIONS_CHAIN_GROUP.avail.includes(chainInfo.slug) || _constants2._API_OPTIONS_CHAIN_GROUP.goldberg.includes(chainInfo.slug)) // The special case for chains that need metadata to signing
3073
+ ) {
3074
+ // For case the chain does not have any provider
3075
+ if (!Object.keys(chainInfo.providers).length) {
3076
+ reject(new Error('{{chain}} network does not have any provider to connect, please update metadata from dApp'.replaceAll('{{chain}}', chainInfo.name)));
3077
+ return false;
3078
+ }
3079
+ const isChainActive = this.#koniState.getChainStateByKey(chainInfo.slug).active;
3080
+ if (!isChainActive) {
3081
+ reject(new Error('Please activate {{chain}} network before signing'.replaceAll('{{chain}}', chainInfo.name)));
3082
+ return false;
3083
+ }
3070
3084
  registry = this.#koniState.getSubstrateApi(chainInfo.slug).api.registry;
3071
3085
  }
3072
3086
  }
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.1.62-0'
16
+ version: '1.1.63-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -617,7 +617,9 @@ function updateLatestChainInfo(currentDataMap, latestChainInfoList) {
617
617
  providerKey
618
618
  } = randomizeProvider(currentChainInfo.providers);
619
619
  currentChainState.currentProvider = providerKey;
620
- needUpdateChainApiList.push(currentChainInfo);
620
+ if (currentChainState.active) {
621
+ needUpdateChainApiList.push(currentChainInfo);
622
+ }
621
623
  }
622
624
  needUpdate = true;
623
625
  }
@@ -2969,7 +2969,10 @@ export default class KoniExtension {
2969
2969
  let registry = new TypeRegistry();
2970
2970
  let isEvm = false;
2971
2971
  if (isJsonPayload(payload)) {
2972
- // Get the metadata for the genesisHash
2972
+ /**
2973
+ * Get the metadata for the genesisHash
2974
+ * @todo: need to handle case metadata store in db
2975
+ */
2973
2976
  const currentMetadata = this.#koniState.knownMetadata.find(meta => meta.genesisHash === payload.genesisHash);
2974
2977
 
2975
2978
  // set the registry before calling the sign function
@@ -2978,12 +2981,23 @@ export default class KoniExtension {
2978
2981
  registry.register(currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.types);
2979
2982
  }
2980
2983
  const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
2981
- if (chainInfo && (_API_OPTIONS_CHAIN_GROUP.avail.includes(chainInfo.slug) || _API_OPTIONS_CHAIN_GROUP.goldberg.includes(chainInfo.slug))) {
2982
- const isChainActive = this.#koniState.getChainStateByKey(chainInfo.slug).active;
2983
- if (!isChainActive) {
2984
- reject(new Error('Please activate {{chain}} network before signing'.replaceAll('{{chain}}', chainInfo.name)));
2985
- return false;
2986
- } else {
2984
+ if (!currentMetadata) {
2985
+ /*
2986
+ * Some networks must have metadata to signing,
2987
+ * so if the chain not active (cannot use metadata from api), it must be rejected
2988
+ * */
2989
+ if (chainInfo && (_API_OPTIONS_CHAIN_GROUP.avail.includes(chainInfo.slug) || _API_OPTIONS_CHAIN_GROUP.goldberg.includes(chainInfo.slug)) // The special case for chains that need metadata to signing
2990
+ ) {
2991
+ // For case the chain does not have any provider
2992
+ if (!Object.keys(chainInfo.providers).length) {
2993
+ reject(new Error('{{chain}} network does not have any provider to connect, please update metadata from dApp'.replaceAll('{{chain}}', chainInfo.name)));
2994
+ return false;
2995
+ }
2996
+ const isChainActive = this.#koniState.getChainStateByKey(chainInfo.slug).active;
2997
+ if (!isChainActive) {
2998
+ reject(new Error('Please activate {{chain}} network before signing'.replaceAll('{{chain}}', chainInfo.name)));
2999
+ return false;
3000
+ }
2987
3001
  registry = this.#koniState.getSubstrateApi(chainInfo.slug).api.registry;
2988
3002
  }
2989
3003
  }
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.62-0",
20
+ "version": "1.1.63-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1870,10 +1870,10 @@
1870
1870
  "@sora-substrate/type-definitions": "^1.17.7",
1871
1871
  "@substrate/connect": "^0.8.9",
1872
1872
  "@subwallet/chain-list": "0.2.59",
1873
- "@subwallet/extension-base": "^1.1.62-0",
1874
- "@subwallet/extension-chains": "^1.1.62-0",
1875
- "@subwallet/extension-dapp": "^1.1.62-0",
1876
- "@subwallet/extension-inject": "^1.1.62-0",
1873
+ "@subwallet/extension-base": "^1.1.63-0",
1874
+ "@subwallet/extension-chains": "^1.1.63-0",
1875
+ "@subwallet/extension-dapp": "^1.1.63-0",
1876
+ "@subwallet/extension-inject": "^1.1.63-0",
1877
1877
  "@subwallet/keyring": "^0.1.5",
1878
1878
  "@subwallet/ui-keyring": "^0.1.5",
1879
1879
  "@walletconnect/sign-client": "^2.8.4",
package/packageInfo.js CHANGED
@@ -7,5 +7,5 @@ export const packageInfo = {
7
7
  name: '@subwallet/extension-base',
8
8
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
9
9
  type: 'esm',
10
- version: '1.1.62-0'
10
+ version: '1.1.63-0'
11
11
  };
@@ -448,7 +448,9 @@ export function updateLatestChainInfo(currentDataMap, latestChainInfoList) {
448
448
  providerKey
449
449
  } = randomizeProvider(currentChainInfo.providers);
450
450
  currentChainState.currentProvider = providerKey;
451
- needUpdateChainApiList.push(currentChainInfo);
451
+ if (currentChainState.active) {
452
+ needUpdateChainApiList.push(currentChainInfo);
453
+ }
452
454
  }
453
455
  needUpdate = true;
454
456
  }