@subwallet/extension-base 1.1.20-1 → 1.1.20-3

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.
@@ -39,7 +39,7 @@ function subscribeAstarStakingMetadata(chain, substrateApi, callback) {
39
39
  // temporary fix for Astar, there's no limit for now
40
40
  maxWithdrawalRequestPerValidator: 1,
41
41
  // by default
42
- allowCancelUnstaking: true,
42
+ allowCancelUnstaking: false,
43
43
  unstakingPeriod
44
44
  });
45
45
  });
@@ -75,7 +75,7 @@ async function getAstarStakingMetadata(chain, substrateApi) {
75
75
  // temporary fix for Astar, there's no limit for now
76
76
  maxWithdrawalRequestPerValidator: 1,
77
77
  // by default
78
- allowCancelUnstaking: true,
78
+ allowCancelUnstaking: false,
79
79
  unstakingPeriod
80
80
  };
81
81
  }
@@ -114,7 +114,7 @@ async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi,
114
114
  nominationList.push({
115
115
  status: dappStakingStatus,
116
116
  chain: chainInfo.slug,
117
- validatorAddress: dappAddress.toLowerCase(),
117
+ validatorAddress: (0, _utilCrypto.isEthereumAddress)(dappAddress) ? dappAddress.toLowerCase() : dappAddress,
118
118
  activeStake: currentStake,
119
119
  validatorMinStake: '0',
120
120
  validatorIdentity: dappInfo === null || dappInfo === void 0 ? void 0 : dappInfo.name,
@@ -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.20-1'
16
+ version: '1.1.20-3'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -645,9 +645,11 @@ class ChainService {
645
645
  } else {
646
646
  const mergedChainInfoMap = latestChainInfoMap;
647
647
  for (const [storedSlug, storedChainInfo] of Object.entries(storedChainSettingMap)) {
648
- if (storedSlug in latestChainInfoMap) {
649
- // check predefined chains first, keep setting for providers and currentProvider
650
- // TODO: review merging providers
648
+ const chainInfo = latestChainInfoMap[storedSlug];
649
+
650
+ // Network is existed on change list
651
+ // check predefined chains first, keep setting for providers and currentProvider
652
+ if (chainInfo) {
651
653
  // Keep customer provider only
652
654
  const providers = {
653
655
  ...mergedChainInfoMap[storedSlug].providers
@@ -673,18 +675,20 @@ class ChainService {
673
675
  }
674
676
  }
675
677
  }
678
+ const hasProvider = Object.values(providers).length > 0;
679
+ const canActive = hasProvider && chainInfo.chainStatus === _types._ChainStatus.ACTIVE;
676
680
  this.dataMap.chainStateMap[storedSlug] = {
677
681
  currentProvider: currentProvider,
678
682
  slug: storedSlug,
679
683
  connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
680
- active: storedChainInfo.active
684
+ active: canActive && storedChainInfo.active
681
685
  };
682
686
  newStorageData.push({
683
687
  ...mergedChainInfoMap[storedSlug],
684
- active: storedChainInfo.active,
688
+ active: canActive && storedChainInfo.active,
685
689
  currentProvider: currentProvider
686
690
  });
687
- } else {
691
+ } else if ((0, _utils._isCustomChain)(storedSlug)) {
688
692
  var _storedChainInfo$subs, _storedChainInfo$evmI;
689
693
  // only custom chains are left
690
694
  // check custom chain duplicated with predefined chain => merge into predefined chain
@@ -731,6 +735,8 @@ class ChainService {
731
735
  currentProvider: storedChainInfo.currentProvider
732
736
  });
733
737
  }
738
+ } else {
739
+ // Todo: Remove chain from storage
734
740
  }
735
741
  }
736
742
 
@@ -760,6 +766,7 @@ class ChainService {
760
766
  async initAssetRegistry(deprecatedCustomChainMap) {
761
767
  const storedAssetRegistry = await this.dbService.getAllAssetStore();
762
768
  const latestAssetRegistry = await this.fetchLatestData(_constants._CHAIN_ASSET_SRC, _chainList.ChainAssetMap);
769
+ const availableChains = Object.values(this.dataMap.chainInfoMap).filter(info => info.chainStatus === _types._ChainStatus.ACTIVE).map(chainInfo => chainInfo.slug);
763
770
 
764
771
  // Fill out zk assets from latestAssetRegistry if not supported
765
772
  if (!_utils2.MODULE_SUPPORT.MANTA_ZK) {
@@ -794,14 +801,19 @@ class ChainService {
794
801
  });
795
802
  for (const storedAssetInfo of Object.values(parsedStoredAssetRegistry)) {
796
803
  let duplicated = false;
804
+ let deprecated = false;
797
805
  for (const defaultChainAsset of Object.values(latestAssetRegistry)) {
798
806
  // case merge custom asset with default asset
799
807
  if ((0, _utils._isEqualSmartContractAsset)(storedAssetInfo, defaultChainAsset)) {
800
808
  duplicated = true;
801
809
  break;
802
810
  }
811
+ if (availableChains.indexOf(storedAssetInfo.originChain) === -1) {
812
+ deprecated = true;
813
+ break;
814
+ }
803
815
  }
804
- if (!duplicated) {
816
+ if (!duplicated && !deprecated) {
805
817
  mergedAssetRegistry[storedAssetInfo.slug] = storedAssetInfo;
806
818
  } else {
807
819
  deprecatedAssets.push(storedAssetInfo.slug);
@@ -11,7 +11,6 @@ var _recoverHistoryStatus = require("@subwallet/extension-base/services/history-
11
11
  var _promise = require("@subwallet/extension-base/utils/promise");
12
12
  var _uiKeyring = require("@subwallet/ui-keyring");
13
13
  var _rxjs = require("rxjs");
14
- var _subsquidMultiChainHistory = require("./subsquid-multi-chain-history");
15
14
  // Copyright 2019-2022 @subwallet/extension-base
16
15
  // SPDX-License-Identifier: Apache-2.0
17
16
 
@@ -32,10 +31,12 @@ class HistoryService {
32
31
  if (!addresses || addresses.length === 0) {
33
32
  return [];
34
33
  }
35
- const chainMap = this.chainService.getChainInfoMap();
36
34
 
37
35
  // Query data from subscan or any indexer
38
- const historyRecords = await (0, _subsquidMultiChainHistory.fetchMultiChainHistories)(addresses, chainMap);
36
+ // const chainMap = this.chainService.getChainInfoMap();
37
+ // const historyRecords = await fetchMultiChainHistories(addresses, chainMap);
38
+ // Pause deprecated until have new update
39
+ const historyRecords = [];
39
40
 
40
41
  // Fill additional info
41
42
  const accountMap = Object.entries(this.keyringService.accounts).reduce((map, _ref) => {
@@ -23,7 +23,7 @@ export function subscribeAstarStakingMetadata(chain, substrateApi, callback) {
23
23
  // temporary fix for Astar, there's no limit for now
24
24
  maxWithdrawalRequestPerValidator: 1,
25
25
  // by default
26
- allowCancelUnstaking: true,
26
+ allowCancelUnstaking: false,
27
27
  unstakingPeriod
28
28
  });
29
29
  });
@@ -59,7 +59,7 @@ export async function getAstarStakingMetadata(chain, substrateApi) {
59
59
  // temporary fix for Astar, there's no limit for now
60
60
  maxWithdrawalRequestPerValidator: 1,
61
61
  // by default
62
- allowCancelUnstaking: true,
62
+ allowCancelUnstaking: false,
63
63
  unstakingPeriod
64
64
  };
65
65
  }
@@ -98,7 +98,7 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
98
98
  nominationList.push({
99
99
  status: dappStakingStatus,
100
100
  chain: chainInfo.slug,
101
- validatorAddress: dappAddress.toLowerCase(),
101
+ validatorAddress: isEthereumAddress(dappAddress) ? dappAddress.toLowerCase() : dappAddress,
102
102
  activeStake: currentStake,
103
103
  validatorMinStake: '0',
104
104
  validatorIdentity: dappInfo === null || dappInfo === void 0 ? void 0 : dappInfo.name,
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.20-1",
20
+ "version": "1.1.20-3",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1307,11 +1307,11 @@
1307
1307
  "@reduxjs/toolkit": "^1.9.1",
1308
1308
  "@sora-substrate/type-definitions": "^1.17.7",
1309
1309
  "@substrate/connect": "^0.7.26",
1310
- "@subwallet/chain-list": "0.2.20-beta.5",
1311
- "@subwallet/extension-base": "^1.1.20-1",
1312
- "@subwallet/extension-chains": "^1.1.20-1",
1313
- "@subwallet/extension-dapp": "^1.1.20-1",
1314
- "@subwallet/extension-inject": "^1.1.20-1",
1310
+ "@subwallet/chain-list": "0.2.20",
1311
+ "@subwallet/extension-base": "^1.1.20-3",
1312
+ "@subwallet/extension-chains": "^1.1.20-3",
1313
+ "@subwallet/extension-dapp": "^1.1.20-3",
1314
+ "@subwallet/extension-inject": "^1.1.20-3",
1315
1315
  "@subwallet/keyring": "^0.1.1",
1316
1316
  "@subwallet/ui-keyring": "^0.1.1",
1317
1317
  "@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.20-1'
10
+ version: '1.1.20-3'
11
11
  };
@@ -629,9 +629,11 @@ export class ChainService {
629
629
  } else {
630
630
  const mergedChainInfoMap = latestChainInfoMap;
631
631
  for (const [storedSlug, storedChainInfo] of Object.entries(storedChainSettingMap)) {
632
- if (storedSlug in latestChainInfoMap) {
633
- // check predefined chains first, keep setting for providers and currentProvider
634
- // TODO: review merging providers
632
+ const chainInfo = latestChainInfoMap[storedSlug];
633
+
634
+ // Network is existed on change list
635
+ // check predefined chains first, keep setting for providers and currentProvider
636
+ if (chainInfo) {
635
637
  // Keep customer provider only
636
638
  const providers = {
637
639
  ...mergedChainInfoMap[storedSlug].providers
@@ -657,18 +659,20 @@ export class ChainService {
657
659
  }
658
660
  }
659
661
  }
662
+ const hasProvider = Object.values(providers).length > 0;
663
+ const canActive = hasProvider && chainInfo.chainStatus === _ChainStatus.ACTIVE;
660
664
  this.dataMap.chainStateMap[storedSlug] = {
661
665
  currentProvider: currentProvider,
662
666
  slug: storedSlug,
663
667
  connectionStatus: _ChainConnectionStatus.DISCONNECTED,
664
- active: storedChainInfo.active
668
+ active: canActive && storedChainInfo.active
665
669
  };
666
670
  newStorageData.push({
667
671
  ...mergedChainInfoMap[storedSlug],
668
- active: storedChainInfo.active,
672
+ active: canActive && storedChainInfo.active,
669
673
  currentProvider: currentProvider
670
674
  });
671
- } else {
675
+ } else if (_isCustomChain(storedSlug)) {
672
676
  var _storedChainInfo$subs, _storedChainInfo$evmI;
673
677
  // only custom chains are left
674
678
  // check custom chain duplicated with predefined chain => merge into predefined chain
@@ -715,6 +719,8 @@ export class ChainService {
715
719
  currentProvider: storedChainInfo.currentProvider
716
720
  });
717
721
  }
722
+ } else {
723
+ // Todo: Remove chain from storage
718
724
  }
719
725
  }
720
726
 
@@ -743,6 +749,7 @@ export class ChainService {
743
749
  async initAssetRegistry(deprecatedCustomChainMap) {
744
750
  const storedAssetRegistry = await this.dbService.getAllAssetStore();
745
751
  const latestAssetRegistry = await this.fetchLatestData(_CHAIN_ASSET_SRC, ChainAssetMap);
752
+ const availableChains = Object.values(this.dataMap.chainInfoMap).filter(info => info.chainStatus === _ChainStatus.ACTIVE).map(chainInfo => chainInfo.slug);
746
753
 
747
754
  // Fill out zk assets from latestAssetRegistry if not supported
748
755
  if (!MODULE_SUPPORT.MANTA_ZK) {
@@ -777,14 +784,19 @@ export class ChainService {
777
784
  });
778
785
  for (const storedAssetInfo of Object.values(parsedStoredAssetRegistry)) {
779
786
  let duplicated = false;
787
+ let deprecated = false;
780
788
  for (const defaultChainAsset of Object.values(latestAssetRegistry)) {
781
789
  // case merge custom asset with default asset
782
790
  if (_isEqualSmartContractAsset(storedAssetInfo, defaultChainAsset)) {
783
791
  duplicated = true;
784
792
  break;
785
793
  }
794
+ if (availableChains.indexOf(storedAssetInfo.originChain) === -1) {
795
+ deprecated = true;
796
+ break;
797
+ }
786
798
  }
787
- if (!duplicated) {
799
+ if (!duplicated && !deprecated) {
788
800
  mergedAssetRegistry[storedAssetInfo.slug] = storedAssetInfo;
789
801
  } else {
790
802
  deprecatedAssets.push(storedAssetInfo.slug);
@@ -8,7 +8,6 @@ import { historyRecover, HistoryRecoverStatus } from '@subwallet/extension-base/
8
8
  import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
9
9
  import { keyring } from '@subwallet/ui-keyring';
10
10
  import { BehaviorSubject } from 'rxjs';
11
- import { fetchMultiChainHistories } from "./subsquid-multi-chain-history.js";
12
11
  export class HistoryService {
13
12
  historySubject = new BehaviorSubject([]);
14
13
  #needRecoveryHistories = {};
@@ -26,10 +25,12 @@ export class HistoryService {
26
25
  if (!addresses || addresses.length === 0) {
27
26
  return [];
28
27
  }
29
- const chainMap = this.chainService.getChainInfoMap();
30
28
 
31
29
  // Query data from subscan or any indexer
32
- const historyRecords = await fetchMultiChainHistories(addresses, chainMap);
30
+ // const chainMap = this.chainService.getChainInfoMap();
31
+ // const historyRecords = await fetchMultiChainHistories(addresses, chainMap);
32
+ // Pause deprecated until have new update
33
+ const historyRecords = [];
33
34
 
34
35
  // Fill additional info
35
36
  const accountMap = Object.entries(this.keyringService.accounts).reduce((map, [address, account]) => {