@subwallet/extension-base 1.3.22-0 → 1.3.23-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/background/KoniTypes.d.ts +75 -2
- package/background/KoniTypes.js +2 -0
- package/cjs/background/KoniTypes.js +2 -0
- package/cjs/constants/environment.js +4 -2
- package/cjs/constants/signing.js +6 -2
- package/cjs/core/logic-validation/recipientAddress.js +9 -1
- package/cjs/core/logic-validation/transfer.js +35 -29
- package/cjs/core/types.js +1 -0
- package/cjs/core/utils.js +12 -1
- package/cjs/defaults.js +1 -1
- package/cjs/koni/api/dotsama/crowdloan.js +1 -1
- package/cjs/koni/api/nft/index.js +9 -16
- package/cjs/koni/api/staking/index.js +3 -4
- package/cjs/koni/background/handlers/Extension.js +234 -96
- package/cjs/koni/background/handlers/State.js +15 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/cardano/consts.js +11 -0
- package/cjs/services/balance-service/helpers/subscribe/cardano/index.js +63 -0
- package/cjs/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
- package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +74 -0
- package/cjs/services/balance-service/helpers/subscribe/index.js +21 -7
- package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +2 -2
- package/cjs/services/balance-service/index.js +4 -2
- package/cjs/services/balance-service/transfer/cardano-transfer.js +122 -0
- package/cjs/services/balance-service/transfer/token.js +4 -4
- package/cjs/services/chain-service/handler/CardanoApi.js +176 -0
- package/cjs/services/chain-service/handler/CardanoChainHandler.js +83 -0
- package/cjs/services/chain-service/handler/TonApi.js +2 -5
- package/cjs/services/chain-service/index.js +29 -7
- package/cjs/services/chain-service/utils/index.js +40 -11
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
- package/cjs/services/earning-service/service.js +6 -12
- package/cjs/services/fee-service/service.js +19 -8
- package/cjs/services/history-service/index.js +4 -6
- package/cjs/services/inapp-notification-service/index.js +12 -4
- package/cjs/services/keyring-service/context/account-context.js +17 -2
- package/cjs/services/keyring-service/context/handlers/Derive.js +10 -7
- package/cjs/services/keyring-service/context/handlers/Migration.js +268 -0
- package/cjs/services/keyring-service/context/handlers/Mnemonic.js +2 -2
- package/cjs/services/keyring-service/context/handlers/Secret.js +1 -1
- package/cjs/services/keyring-service/utils.js +18 -0
- package/cjs/services/request-service/handler/CardanoRequestHandler.js +172 -0
- package/cjs/services/request-service/handler/EvmRequestHandler.js +1 -1
- package/cjs/services/request-service/index.js +20 -2
- package/cjs/services/setting-service/constants.js +10 -1
- package/cjs/services/storage-service/DatabaseService.js +3 -0
- package/cjs/services/storage-service/db-stores/InappNotification.js +6 -0
- package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -59
- package/cjs/services/swap-service/handler/chainflip-handler.js +33 -281
- package/cjs/services/swap-service/handler/hydradx-handler.js +23 -190
- package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -222
- package/cjs/services/swap-service/handler/uniswap-handler.js +331 -0
- package/cjs/services/swap-service/index.js +31 -22
- package/cjs/services/swap-service/utils.js +21 -38
- package/cjs/services/transaction-service/helpers/index.js +6 -1
- package/cjs/services/transaction-service/index.js +278 -21
- package/cjs/services/transaction-service/utils.js +5 -1
- package/cjs/types/account/info/keyring.js +12 -1
- package/cjs/types/fee/cardano.js +1 -0
- package/cjs/types/swap/index.js +7 -2
- package/cjs/utils/account/analyze.js +2 -1
- package/cjs/utils/account/common.js +29 -20
- package/cjs/utils/account/derive/info/solo.js +9 -4
- package/cjs/utils/account/derive/validate.js +36 -2
- package/cjs/utils/account/transform.js +38 -13
- package/cjs/utils/fee/transfer.js +40 -7
- package/cjs/utils/index.js +2 -2
- package/cjs/utils/staticData/index.js +7 -2
- package/constants/environment.d.ts +1 -0
- package/constants/environment.js +2 -1
- package/constants/signing.js +6 -2
- package/core/logic-validation/recipientAddress.js +11 -3
- package/core/logic-validation/transfer.js +9 -3
- package/core/substrate/xcm-parser.d.ts +1 -1
- package/core/types.d.ts +1 -0
- package/core/types.js +1 -0
- package/core/utils.d.ts +1 -0
- package/core/utils.js +13 -3
- package/defaults.d.ts +1 -1
- package/defaults.js +1 -1
- package/koni/api/dotsama/crowdloan.js +3 -3
- package/koni/api/nft/index.js +10 -16
- package/koni/api/nft/story_odyssey_nft/index.d.ts +1 -1
- package/koni/api/staking/index.js +4 -5
- package/koni/background/handlers/Extension.d.ts +9 -0
- package/koni/background/handlers/Extension.js +144 -8
- package/koni/background/handlers/State.d.ts +5 -1
- package/koni/background/handlers/State.js +16 -1
- package/package.json +71 -9
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/cardano/consts.d.ts +1 -0
- package/services/balance-service/helpers/subscribe/cardano/consts.js +4 -0
- package/services/balance-service/helpers/subscribe/cardano/index.d.ts +2 -0
- package/services/balance-service/helpers/subscribe/cardano/index.js +57 -0
- package/services/balance-service/helpers/subscribe/cardano/types.d.ts +34 -0
- package/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
- package/services/balance-service/helpers/subscribe/cardano/utils.d.ts +15 -0
- package/services/balance-service/helpers/subscribe/cardano/utils.js +62 -0
- package/services/balance-service/helpers/subscribe/index.d.ts +2 -2
- package/services/balance-service/helpers/subscribe/index.js +23 -9
- package/services/balance-service/helpers/subscribe/ton/utils.d.ts +1 -1
- package/services/balance-service/helpers/subscribe/ton/utils.js +1 -1
- package/services/balance-service/index.js +4 -2
- package/services/balance-service/transfer/cardano-transfer.d.ts +24 -0
- package/services/balance-service/transfer/cardano-transfer.js +114 -0
- package/services/balance-service/transfer/token.d.ts +1 -1
- package/services/balance-service/transfer/token.js +2 -2
- package/services/chain-service/handler/CardanoApi.d.ts +38 -0
- package/services/chain-service/handler/CardanoApi.js +167 -0
- package/services/chain-service/handler/CardanoChainHandler.d.ts +17 -0
- package/services/chain-service/handler/CardanoChainHandler.js +75 -0
- package/services/chain-service/handler/TonApi.js +3 -6
- package/services/chain-service/handler/types.d.ts +1 -0
- package/services/chain-service/index.d.ts +3 -1
- package/services/chain-service/index.js +29 -7
- package/services/chain-service/types.d.ts +9 -1
- package/services/chain-service/utils/index.d.ts +4 -0
- package/services/chain-service/utils/index.js +32 -11
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
- package/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
- package/services/earning-service/service.js +8 -14
- package/services/fee-service/service.js +19 -8
- package/services/history-service/index.js +6 -8
- package/services/inapp-notification-service/index.d.ts +3 -4
- package/services/inapp-notification-service/index.js +14 -6
- package/services/keyring-service/context/account-context.d.ts +6 -2
- package/services/keyring-service/context/account-context.js +17 -2
- package/services/keyring-service/context/handlers/Derive.d.ts +1 -1
- package/services/keyring-service/context/handlers/Derive.js +10 -8
- package/services/keyring-service/context/handlers/Migration.d.ts +17 -0
- package/services/keyring-service/context/handlers/Migration.js +258 -0
- package/services/keyring-service/context/handlers/Mnemonic.js +2 -2
- package/services/keyring-service/context/handlers/Secret.js +2 -2
- package/services/keyring-service/utils.d.ts +2 -0
- package/services/keyring-service/utils.js +11 -0
- package/services/request-service/handler/CardanoRequestHandler.d.ts +16 -0
- package/services/request-service/handler/CardanoRequestHandler.js +163 -0
- package/services/request-service/handler/EvmRequestHandler.js +1 -1
- package/services/request-service/index.d.ts +6 -3
- package/services/request-service/index.js +19 -5
- package/services/setting-service/constants.d.ts +3 -0
- package/services/setting-service/constants.js +6 -0
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +3 -0
- package/services/storage-service/db-stores/InappNotification.d.ts +1 -0
- package/services/storage-service/db-stores/InappNotification.js +6 -0
- package/services/swap-service/handler/asset-hub/handler.d.ts +1 -4
- package/services/swap-service/handler/asset-hub/handler.js +2 -61
- package/services/swap-service/handler/base-handler.d.ts +1 -4
- package/services/swap-service/handler/chainflip-handler.d.ts +2 -9
- package/services/swap-service/handler/chainflip-handler.js +31 -280
- package/services/swap-service/handler/hydradx-handler.d.ts +1 -6
- package/services/swap-service/handler/hydradx-handler.js +13 -180
- package/services/swap-service/handler/simpleswap-handler.d.ts +1 -4
- package/services/swap-service/handler/simpleswap-handler.js +5 -226
- package/services/swap-service/handler/uniswap-handler.d.ts +41 -0
- package/services/swap-service/handler/uniswap-handler.js +323 -0
- package/services/swap-service/index.js +30 -22
- package/services/swap-service/utils.d.ts +1 -5
- package/services/swap-service/utils.js +7 -21
- package/services/transaction-service/helpers/index.d.ts +2 -0
- package/services/transaction-service/helpers/index.js +4 -0
- package/services/transaction-service/index.d.ts +8 -2
- package/services/transaction-service/index.js +263 -10
- package/services/transaction-service/types.d.ts +7 -0
- package/services/transaction-service/utils.js +7 -2
- package/types/account/info/keyring.d.ts +4 -1
- package/types/account/info/keyring.js +9 -0
- package/types/account/info/proxy.d.ts +2 -0
- package/types/balance/index.d.ts +4 -1
- package/types/fee/base.d.ts +1 -1
- package/types/fee/cardano.d.ts +18 -0
- package/types/fee/cardano.js +1 -0
- package/types/fee/subscription.d.ts +4 -3
- package/types/swap/index.d.ts +11 -3
- package/types/swap/index.js +7 -2
- package/utils/account/analyze.js +2 -1
- package/utils/account/common.d.ts +11 -6
- package/utils/account/common.js +28 -19
- package/utils/account/derive/info/solo.js +10 -5
- package/utils/account/derive/validate.d.ts +1 -0
- package/utils/account/derive/validate.js +34 -1
- package/utils/account/transform.d.ts +2 -1
- package/utils/account/transform.js +37 -13
- package/utils/fee/transfer.d.ts +2 -1
- package/utils/fee/transfer.js +44 -11
- package/utils/index.js +4 -4
- package/utils/staticData/index.d.ts +4 -1
- package/utils/staticData/index.js +5 -1
- package/utils/staticData/oldChainPrefix.json +1 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CardanoChainHandler = void 0;
|
|
7
|
+
var _AbstractChainHandler = require("@subwallet/extension-base/services/chain-service/handler/AbstractChainHandler");
|
|
8
|
+
var _CardanoApi = require("@subwallet/extension-base/services/chain-service/handler/CardanoApi");
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
class CardanoChainHandler extends _AbstractChainHandler.AbstractChainHandler {
|
|
13
|
+
cardanoApiMap = {};
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line no-useless-constructor
|
|
16
|
+
constructor(parent) {
|
|
17
|
+
super(parent);
|
|
18
|
+
}
|
|
19
|
+
getCardanoApiMap() {
|
|
20
|
+
return this.cardanoApiMap;
|
|
21
|
+
}
|
|
22
|
+
getCardanoApiByChain(chain) {
|
|
23
|
+
return this.cardanoApiMap[chain];
|
|
24
|
+
}
|
|
25
|
+
getApiByChain(chain) {
|
|
26
|
+
return this.getCardanoApiByChain(chain);
|
|
27
|
+
}
|
|
28
|
+
setCardanoApi(chain, cardanoApi) {
|
|
29
|
+
this.cardanoApiMap[chain] = cardanoApi;
|
|
30
|
+
}
|
|
31
|
+
async initApi(chainSlug, apiUrl) {
|
|
32
|
+
let {
|
|
33
|
+
isTestnet,
|
|
34
|
+
onUpdateStatus,
|
|
35
|
+
providerName
|
|
36
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
37
|
+
const existed = this.getCardanoApiByChain(chainSlug);
|
|
38
|
+
if (existed) {
|
|
39
|
+
existed.connect();
|
|
40
|
+
if (apiUrl !== existed.apiUrl) {
|
|
41
|
+
existed.updateApiUrl(apiUrl).catch(console.error);
|
|
42
|
+
}
|
|
43
|
+
return existed;
|
|
44
|
+
}
|
|
45
|
+
const apiObject = new _CardanoApi.CardanoApi(chainSlug, apiUrl, {
|
|
46
|
+
isTestnet,
|
|
47
|
+
providerName
|
|
48
|
+
});
|
|
49
|
+
apiObject.connectionStatusSubject.subscribe(this.handleConnection.bind(this, chainSlug));
|
|
50
|
+
apiObject.connectionStatusSubject.subscribe(onUpdateStatus);
|
|
51
|
+
return Promise.resolve(apiObject);
|
|
52
|
+
}
|
|
53
|
+
async recoverApi(chain) {
|
|
54
|
+
const existed = this.getCardanoApiByChain(chain);
|
|
55
|
+
if (existed && !existed.isApiReadyOnce) {
|
|
56
|
+
console.log(`Reconnect ${existed.providerName || existed.chainSlug} at ${existed.apiUrl}`);
|
|
57
|
+
return existed.recoverConnect();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
destroyCardanoApi(chain) {
|
|
61
|
+
const cardanoApi = this.getCardanoApiByChain(chain);
|
|
62
|
+
cardanoApi === null || cardanoApi === void 0 ? void 0 : cardanoApi.destroy().catch(console.error);
|
|
63
|
+
}
|
|
64
|
+
async sleep() {
|
|
65
|
+
this.isSleeping = true;
|
|
66
|
+
this.cancelAllRecover();
|
|
67
|
+
await Promise.all(Object.values(this.getCardanoApiMap()).map(cardanoApi => {
|
|
68
|
+
return cardanoApi.disconnect().catch(console.error);
|
|
69
|
+
}));
|
|
70
|
+
return Promise.resolve();
|
|
71
|
+
}
|
|
72
|
+
wakeUp() {
|
|
73
|
+
var _this$parent;
|
|
74
|
+
this.isSleeping = false;
|
|
75
|
+
const activeChains = ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.getActiveChains()) || [];
|
|
76
|
+
for (const chain of activeChains) {
|
|
77
|
+
const cardanoApi = this.getCardanoApiByChain(chain);
|
|
78
|
+
cardanoApi === null || cardanoApi === void 0 ? void 0 : cardanoApi.connect();
|
|
79
|
+
}
|
|
80
|
+
return Promise.resolve();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.CardanoChainHandler = CardanoChainHandler;
|
|
@@ -57,10 +57,7 @@ class TonApi {
|
|
|
57
57
|
|
|
58
58
|
// Create new provider and api
|
|
59
59
|
this.apiUrl = apiUrl;
|
|
60
|
-
this.api =
|
|
61
|
-
endpoint: this.getJsonRpc(this.apiUrl),
|
|
62
|
-
apiKey: _consts.TON_CENTER_API_KEY
|
|
63
|
-
});
|
|
60
|
+
this.api = this.createProvider(apiUrl);
|
|
64
61
|
}
|
|
65
62
|
async recoverConnect() {
|
|
66
63
|
await this.disconnect();
|
|
@@ -163,7 +160,7 @@ class TonApi {
|
|
|
163
160
|
return await resp.json();
|
|
164
161
|
}
|
|
165
162
|
async getStatusByExtMsgHash(extMsgHash, extrinsicType) {
|
|
166
|
-
return (0, _utils.
|
|
163
|
+
return (0, _utils.retryTonTxStatus)(async () => {
|
|
167
164
|
var _externalTxInfo$out_m, _externalTxInfo$out_m2;
|
|
168
165
|
// retry many times to get transaction status and transaction hex
|
|
169
166
|
const externalTxInfoRaw = await this.getTxByInMsg(extMsgHash);
|
|
@@ -8,6 +8,7 @@ exports.filterAssetInfoMap = exports.ChainService = void 0;
|
|
|
8
8
|
var _chainList = require("@subwallet/chain-list");
|
|
9
9
|
var _types = require("@subwallet/chain-list/types");
|
|
10
10
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
11
|
+
var _CardanoChainHandler = require("@subwallet/extension-base/services/chain-service/handler/CardanoChainHandler");
|
|
11
12
|
var _EvmChainHandler = require("@subwallet/extension-base/services/chain-service/handler/EvmChainHandler");
|
|
12
13
|
var _MantaPrivateHandler = require("@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler");
|
|
13
14
|
var _SubstrateChainHandler = require("@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler");
|
|
@@ -82,6 +83,7 @@ class ChainService {
|
|
|
82
83
|
this.substrateChainHandler = new _SubstrateChainHandler.SubstrateChainHandler(this);
|
|
83
84
|
this.evmChainHandler = new _EvmChainHandler.EvmChainHandler(this);
|
|
84
85
|
this.tonChainHandler = new _TonChainHandler.TonChainHandler(this);
|
|
86
|
+
this.cardanoChainHandler = new _CardanoChainHandler.CardanoChainHandler(this);
|
|
85
87
|
this.logger = (0, _logger.logger)('chain-service');
|
|
86
88
|
}
|
|
87
89
|
get value() {
|
|
@@ -157,6 +159,12 @@ class ChainService {
|
|
|
157
159
|
getTonApiMap() {
|
|
158
160
|
return this.tonChainHandler.getTonApiMap();
|
|
159
161
|
}
|
|
162
|
+
getCardanoApi(slug) {
|
|
163
|
+
return this.cardanoChainHandler.getCardanoApiByChain(slug);
|
|
164
|
+
}
|
|
165
|
+
getCardanoApiMap() {
|
|
166
|
+
return this.cardanoChainHandler.getCardanoApiMap();
|
|
167
|
+
}
|
|
160
168
|
getChainCurrentProviderByKey(slug) {
|
|
161
169
|
const providerName = this.getChainStateByKey(slug).currentProvider;
|
|
162
170
|
const providerMap = this.getChainInfoByKey(slug).providers;
|
|
@@ -745,6 +753,15 @@ class ChainService {
|
|
|
745
753
|
});
|
|
746
754
|
this.tonChainHandler.setTonApi(chainInfo.slug, chainApi);
|
|
747
755
|
}
|
|
756
|
+
if (chainInfo.cardanoInfo !== null && chainInfo.cardanoInfo !== undefined) {
|
|
757
|
+
const isTestnet = chainInfo.isTestnet;
|
|
758
|
+
const chainApi = await this.cardanoChainHandler.initApi(chainInfo.slug, endpoint, {
|
|
759
|
+
isTestnet,
|
|
760
|
+
providerName,
|
|
761
|
+
onUpdateStatus
|
|
762
|
+
});
|
|
763
|
+
this.cardanoChainHandler.setCardanoApi(chainInfo.slug, chainApi);
|
|
764
|
+
}
|
|
748
765
|
}
|
|
749
766
|
destroyApiForChain(chainInfo) {
|
|
750
767
|
if (chainInfo.substrateInfo !== null) {
|
|
@@ -756,6 +773,9 @@ class ChainService {
|
|
|
756
773
|
if (chainInfo.tonInfo !== null) {
|
|
757
774
|
this.tonChainHandler.destroyTonApi(chainInfo.slug);
|
|
758
775
|
}
|
|
776
|
+
if (chainInfo.cardanoInfo !== null) {
|
|
777
|
+
this.cardanoChainHandler.destroyCardanoApi(chainInfo.slug);
|
|
778
|
+
}
|
|
759
779
|
}
|
|
760
780
|
async enableChain(chainSlug) {
|
|
761
781
|
const chainInfo = this.getChainInfoByKey(chainSlug);
|
|
@@ -1027,7 +1047,7 @@ class ChainService {
|
|
|
1027
1047
|
deprecatedChainMap[storedSlug] = duplicatedDefaultSlug;
|
|
1028
1048
|
deprecatedChains.push(storedSlug);
|
|
1029
1049
|
} else {
|
|
1030
|
-
var _storedChainInfo$bitc;
|
|
1050
|
+
var _storedChainInfo$bitc, _storedChainInfo$card;
|
|
1031
1051
|
mergedChainInfoMap[storedSlug] = {
|
|
1032
1052
|
slug: storedSlug,
|
|
1033
1053
|
name: storedChainInfo.name,
|
|
@@ -1037,6 +1057,7 @@ class ChainService {
|
|
|
1037
1057
|
substrateInfo: storedChainInfo.substrateInfo,
|
|
1038
1058
|
bitcoinInfo: (_storedChainInfo$bitc = storedChainInfo.bitcoinInfo) !== null && _storedChainInfo$bitc !== void 0 ? _storedChainInfo$bitc : null,
|
|
1039
1059
|
tonInfo: storedChainInfo.tonInfo,
|
|
1060
|
+
cardanoInfo: (_storedChainInfo$card = storedChainInfo.cardanoInfo) !== null && _storedChainInfo$card !== void 0 ? _storedChainInfo$card : null,
|
|
1040
1061
|
isTestnet: storedChainInfo.isTestnet,
|
|
1041
1062
|
chainStatus: storedChainInfo.chainStatus,
|
|
1042
1063
|
icon: storedChainInfo.icon,
|
|
@@ -1055,7 +1076,7 @@ class ChainService {
|
|
|
1055
1076
|
this.updateChainConnectionStatus(storedSlug, _types3._ChainConnectionStatus.DISCONNECTED);
|
|
1056
1077
|
}
|
|
1057
1078
|
} else {
|
|
1058
|
-
var _storedChainInfo$bitc2;
|
|
1079
|
+
var _storedChainInfo$bitc2, _storedChainInfo$card2;
|
|
1059
1080
|
// added chain from patch
|
|
1060
1081
|
mergedChainInfoMap[storedSlug] = {
|
|
1061
1082
|
slug: storedSlug,
|
|
@@ -1065,6 +1086,7 @@ class ChainService {
|
|
|
1065
1086
|
substrateInfo: storedChainInfo.substrateInfo,
|
|
1066
1087
|
bitcoinInfo: (_storedChainInfo$bitc2 = storedChainInfo.bitcoinInfo) !== null && _storedChainInfo$bitc2 !== void 0 ? _storedChainInfo$bitc2 : null,
|
|
1067
1088
|
tonInfo: storedChainInfo.tonInfo,
|
|
1089
|
+
cardanoInfo: (_storedChainInfo$card2 = storedChainInfo.cardanoInfo) !== null && _storedChainInfo$card2 !== void 0 ? _storedChainInfo$card2 : null,
|
|
1068
1090
|
isTestnet: storedChainInfo.isTestnet,
|
|
1069
1091
|
chainStatus: storedChainInfo.chainStatus,
|
|
1070
1092
|
icon: storedChainInfo.icon,
|
|
@@ -1236,6 +1258,7 @@ class ChainService {
|
|
|
1236
1258
|
let substrateInfo = null;
|
|
1237
1259
|
let evmInfo = null;
|
|
1238
1260
|
const tonInfo = null;
|
|
1261
|
+
const cardanoInfo = null;
|
|
1239
1262
|
if (params.chainSpec.genesisHash !== '') {
|
|
1240
1263
|
substrateInfo = {
|
|
1241
1264
|
crowdloanFunds: params.chainSpec.crowdloanFunds || null,
|
|
@@ -1274,6 +1297,7 @@ class ChainService {
|
|
|
1274
1297
|
evmInfo,
|
|
1275
1298
|
bitcoinInfo: null,
|
|
1276
1299
|
tonInfo,
|
|
1300
|
+
cardanoInfo,
|
|
1277
1301
|
isTestnet: false,
|
|
1278
1302
|
chainStatus: _types._ChainStatus.ACTIVE,
|
|
1279
1303
|
icon: '',
|
|
@@ -1385,6 +1409,7 @@ class ChainService {
|
|
|
1385
1409
|
// TODO: EVM chain might have WS provider
|
|
1386
1410
|
if (provider.startsWith('http')) {
|
|
1387
1411
|
// todo: handle validate ton provider
|
|
1412
|
+
// todo: handle validate cardano provider
|
|
1388
1413
|
|
|
1389
1414
|
// HTTP provider is EVM by default
|
|
1390
1415
|
api = await this.evmChainHandler.initApi('custom', provider);
|
|
@@ -1601,15 +1626,12 @@ class ChainService {
|
|
|
1601
1626
|
refreshEvmApi(slug) {
|
|
1602
1627
|
this.evmChainHandler.recoverApi(slug).catch(console.error);
|
|
1603
1628
|
}
|
|
1604
|
-
refreshTonApi(slug) {
|
|
1605
|
-
this.tonChainHandler.recoverApi(slug).catch(console.error);
|
|
1606
|
-
}
|
|
1607
1629
|
async stopAllChainApis() {
|
|
1608
|
-
await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep(), this.tonChainHandler.sleep()]);
|
|
1630
|
+
await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep(), this.tonChainHandler.sleep(), this.cardanoChainHandler.sleep()]);
|
|
1609
1631
|
this.stopCheckLatestChainData();
|
|
1610
1632
|
}
|
|
1611
1633
|
async resumeAllChainApis() {
|
|
1612
|
-
await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp(), this.tonChainHandler.wakeUp()]);
|
|
1634
|
+
await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp(), this.tonChainHandler.wakeUp(), this.cardanoChainHandler.wakeUp()]);
|
|
1613
1635
|
this.checkLatestData();
|
|
1614
1636
|
}
|
|
1615
1637
|
async initAssetSettings() {
|
|
@@ -12,6 +12,7 @@ var _exportNames = {
|
|
|
12
12
|
_isPureEvmChain: true,
|
|
13
13
|
_isPureSubstrateChain: true,
|
|
14
14
|
_isPureTonChain: true,
|
|
15
|
+
_isPureCardanoChain: true,
|
|
15
16
|
_getOriginChainOfAsset: true,
|
|
16
17
|
_getContractAddressOfToken: true,
|
|
17
18
|
_isNativeTokenTransferredByEvm: true,
|
|
@@ -19,6 +20,7 @@ var _exportNames = {
|
|
|
19
20
|
_checkSmartContractSupportByChain: true,
|
|
20
21
|
_isJettonToken: true,
|
|
21
22
|
_isTokenTransferredByTon: true,
|
|
23
|
+
_isTokenTransferredByCardano: true,
|
|
22
24
|
_getTokenOnChainAssetId: true,
|
|
23
25
|
_getTokenOnChainInfo: true,
|
|
24
26
|
_isBridgedToken: true,
|
|
@@ -26,6 +28,7 @@ var _exportNames = {
|
|
|
26
28
|
_isChainEvmCompatible: true,
|
|
27
29
|
_isChainBitcoinCompatible: true,
|
|
28
30
|
_isChainTonCompatible: true,
|
|
31
|
+
_isChainCardanoCompatible: true,
|
|
29
32
|
_isNativeToken: true,
|
|
30
33
|
_isNativeTokenBySlug: true,
|
|
31
34
|
_isSmartContractToken: true,
|
|
@@ -54,6 +57,7 @@ var _exportNames = {
|
|
|
54
57
|
_isLocalToken: true,
|
|
55
58
|
_isTokenEvmSmartContract: true,
|
|
56
59
|
_isTokenTonSmartContract: true,
|
|
60
|
+
_isCIP26Token: true,
|
|
57
61
|
_isTokenWasmSmartContract: true,
|
|
58
62
|
_isAssetSmartContractNft: true,
|
|
59
63
|
_isTokenGearSmartContract: true,
|
|
@@ -140,7 +144,9 @@ exports._isAssetHubToken = _isAssetHubToken;
|
|
|
140
144
|
exports._isAssetSmartContractNft = _isAssetSmartContractNft;
|
|
141
145
|
exports._isAssetValuable = _isAssetValuable;
|
|
142
146
|
exports._isBridgedToken = _isBridgedToken;
|
|
147
|
+
exports._isCIP26Token = _isCIP26Token;
|
|
143
148
|
exports._isChainBitcoinCompatible = _isChainBitcoinCompatible;
|
|
149
|
+
exports._isChainCardanoCompatible = _isChainCardanoCompatible;
|
|
144
150
|
exports._isChainEnabled = _isChainEnabled;
|
|
145
151
|
exports._isChainEvmCompatible = _isChainEvmCompatible;
|
|
146
152
|
exports._isChainSubstrateCompatible = _isChainSubstrateCompatible;
|
|
@@ -165,6 +171,7 @@ exports._isMantaZkAsset = _isMantaZkAsset;
|
|
|
165
171
|
exports._isNativeToken = _isNativeToken;
|
|
166
172
|
exports._isNativeTokenBySlug = _isNativeTokenBySlug;
|
|
167
173
|
exports._isNativeTokenTransferredByEvm = _isNativeTokenTransferredByEvm;
|
|
174
|
+
exports._isPureCardanoChain = _isPureCardanoChain;
|
|
168
175
|
exports._isPureEvmChain = _isPureEvmChain;
|
|
169
176
|
exports._isPureSubstrateChain = _isPureSubstrateChain;
|
|
170
177
|
exports._isPureTonChain = _isPureTonChain;
|
|
@@ -176,6 +183,7 @@ exports._isSupportOrdinal = void 0;
|
|
|
176
183
|
exports._isTokenEvmSmartContract = _isTokenEvmSmartContract;
|
|
177
184
|
exports._isTokenGearSmartContract = _isTokenGearSmartContract;
|
|
178
185
|
exports._isTokenTonSmartContract = _isTokenTonSmartContract;
|
|
186
|
+
exports._isTokenTransferredByCardano = _isTokenTransferredByCardano;
|
|
179
187
|
exports._isTokenTransferredByEvm = _isTokenTransferredByEvm;
|
|
180
188
|
exports._isTokenTransferredByTon = _isTokenTransferredByTon;
|
|
181
189
|
exports._isTokenWasmSmartContract = _isTokenWasmSmartContract;
|
|
@@ -248,13 +256,16 @@ function _isEqualSmartContractAsset(asset1, asset2) {
|
|
|
248
256
|
return false;
|
|
249
257
|
}
|
|
250
258
|
function _isPureEvmChain(chainInfo) {
|
|
251
|
-
return !!chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo;
|
|
259
|
+
return !!chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo;
|
|
252
260
|
}
|
|
253
261
|
function _isPureSubstrateChain(chainInfo) {
|
|
254
|
-
return !chainInfo.evmInfo && !!chainInfo.substrateInfo && !chainInfo.tonInfo;
|
|
262
|
+
return !chainInfo.evmInfo && !!chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo;
|
|
255
263
|
}
|
|
256
264
|
function _isPureTonChain(chainInfo) {
|
|
257
|
-
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !!chainInfo.tonInfo;
|
|
265
|
+
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !!chainInfo.tonInfo && !chainInfo.cardanoInfo;
|
|
266
|
+
}
|
|
267
|
+
function _isPureCardanoChain(chainInfo) {
|
|
268
|
+
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !!chainInfo.cardanoInfo;
|
|
258
269
|
}
|
|
259
270
|
function _getOriginChainOfAsset(assetSlug) {
|
|
260
271
|
if (assetSlug.startsWith(_types2._CUSTOM_PREFIX)) {
|
|
@@ -307,6 +318,9 @@ function _isJettonToken(tokenInfo) {
|
|
|
307
318
|
function _isTokenTransferredByTon(tokenInfo) {
|
|
308
319
|
return _isJettonToken(tokenInfo) || _isNativeToken(tokenInfo);
|
|
309
320
|
}
|
|
321
|
+
function _isTokenTransferredByCardano(tokenInfo) {
|
|
322
|
+
return _isCIP26Token(tokenInfo) || _isNativeToken(tokenInfo);
|
|
323
|
+
}
|
|
310
324
|
|
|
311
325
|
// Utils for balance functions
|
|
312
326
|
function _getTokenOnChainAssetId(tokenInfo) {
|
|
@@ -333,6 +347,9 @@ function _isChainBitcoinCompatible(chainInfo) {
|
|
|
333
347
|
function _isChainTonCompatible(chainInfo) {
|
|
334
348
|
return !!chainInfo.tonInfo;
|
|
335
349
|
}
|
|
350
|
+
function _isChainCardanoCompatible(chainInfo) {
|
|
351
|
+
return !!chainInfo.cardanoInfo;
|
|
352
|
+
}
|
|
336
353
|
function _isNativeToken(tokenInfo) {
|
|
337
354
|
return tokenInfo.assetType === _types._AssetType.NATIVE;
|
|
338
355
|
}
|
|
@@ -453,11 +470,12 @@ function _getTokenTypesSupportedByChain(chainInfo) {
|
|
|
453
470
|
return result;
|
|
454
471
|
}
|
|
455
472
|
function _getChainNativeTokenBasicInfo(chainInfo) {
|
|
473
|
+
const defaultTokenInfo = {
|
|
474
|
+
symbol: '',
|
|
475
|
+
decimals: -1
|
|
476
|
+
};
|
|
456
477
|
if (!chainInfo) {
|
|
457
|
-
return
|
|
458
|
-
symbol: '',
|
|
459
|
-
decimals: -1
|
|
460
|
-
};
|
|
478
|
+
return defaultTokenInfo;
|
|
461
479
|
}
|
|
462
480
|
if (chainInfo.substrateInfo) {
|
|
463
481
|
// substrate by default
|
|
@@ -475,11 +493,13 @@ function _getChainNativeTokenBasicInfo(chainInfo) {
|
|
|
475
493
|
symbol: chainInfo.tonInfo.symbol,
|
|
476
494
|
decimals: chainInfo.tonInfo.decimals
|
|
477
495
|
};
|
|
496
|
+
} else if (chainInfo.cardanoInfo) {
|
|
497
|
+
return {
|
|
498
|
+
symbol: chainInfo.cardanoInfo.symbol,
|
|
499
|
+
decimals: chainInfo.cardanoInfo.decimals
|
|
500
|
+
};
|
|
478
501
|
}
|
|
479
|
-
return
|
|
480
|
-
symbol: '',
|
|
481
|
-
decimals: -1
|
|
482
|
-
};
|
|
502
|
+
return defaultTokenInfo;
|
|
483
503
|
}
|
|
484
504
|
function _getChainNativeTokenSlug(chainInfo) {
|
|
485
505
|
if (_isCustomChain(chainInfo.slug)) {
|
|
@@ -497,6 +517,9 @@ function _isTokenTonSmartContract(tokenInfo) {
|
|
|
497
517
|
return [_types._AssetType.TEP74].includes(tokenInfo.assetType); // add TEP-62 when supporting
|
|
498
518
|
}
|
|
499
519
|
|
|
520
|
+
function _isCIP26Token(tokenInfo) {
|
|
521
|
+
return [_types._AssetType.CIP26].includes(tokenInfo.assetType);
|
|
522
|
+
}
|
|
500
523
|
function _isTokenWasmSmartContract(tokenInfo) {
|
|
501
524
|
return [_types._AssetType.PSP22, _types._AssetType.PSP34].includes(tokenInfo.assetType);
|
|
502
525
|
}
|
|
@@ -585,6 +608,9 @@ function _getBlockExplorerFromChain(chainInfo) {
|
|
|
585
608
|
if (_isPureEvmChain(chainInfo)) {
|
|
586
609
|
var _chainInfo$evmInfo5;
|
|
587
610
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$evmInfo5 = chainInfo.evmInfo) === null || _chainInfo$evmInfo5 === void 0 ? void 0 : _chainInfo$evmInfo5.blockExplorer;
|
|
611
|
+
} else if (_isPureCardanoChain(chainInfo)) {
|
|
612
|
+
var _chainInfo$cardanoInf;
|
|
613
|
+
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$cardanoInf = chainInfo.cardanoInfo) === null || _chainInfo$cardanoInf === void 0 ? void 0 : _chainInfo$cardanoInf.blockExplorer;
|
|
588
614
|
} else {
|
|
589
615
|
var _chainInfo$substrateI18;
|
|
590
616
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.blockExplorer;
|
|
@@ -756,6 +782,9 @@ const _chainInfoToChainType = chainInfo => {
|
|
|
756
782
|
if (_isChainTonCompatible(chainInfo)) {
|
|
757
783
|
return _types3.AccountChainType.TON;
|
|
758
784
|
}
|
|
785
|
+
if (_isChainCardanoCompatible(chainInfo)) {
|
|
786
|
+
return _types3.AccountChainType.CARDANO;
|
|
787
|
+
}
|
|
759
788
|
if (_isChainBitcoinCompatible(chainInfo)) {
|
|
760
789
|
return _types3.AccountChainType.BITCOIN;
|
|
761
790
|
}
|
|
@@ -11,7 +11,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
|
11
11
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
12
12
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
13
13
|
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
14
|
-
const ChainListVersion = '0.2.
|
|
14
|
+
const ChainListVersion = '0.2.101'; // update this when build chainlist
|
|
15
15
|
|
|
16
16
|
// todo: move this interface to chainlist
|
|
17
17
|
|
|
@@ -131,7 +131,7 @@ class BifrostMantaLiquidStakingPoolHandler extends _bifrost.default {
|
|
|
131
131
|
const chainApi = await this.substrateApi.isReady;
|
|
132
132
|
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
133
133
|
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
134
|
-
const extrinsic = chainApi.api.tx.vtokenMinting.redeem((0, _utils._getTokenOnChainInfo)(derivativeTokenInfo), amount);
|
|
134
|
+
const extrinsic = chainApi.api.tx.vtokenMinting.redeem(null, (0, _utils._getTokenOnChainInfo)(derivativeTokenInfo), amount);
|
|
135
135
|
return [_KoniTypes.ExtrinsicType.UNSTAKE_VMANTA, extrinsic];
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -296,7 +296,7 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
|
296
296
|
const chainApi = await this.substrateApi.isReady;
|
|
297
297
|
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
298
298
|
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
299
|
-
const extrinsic = chainApi.api.tx.vtokenMinting.redeem((0, _utils._getTokenOnChainInfo)(derivativeTokenInfo), amount);
|
|
299
|
+
const extrinsic = chainApi.api.tx.vtokenMinting.redeem(null, (0, _utils._getTokenOnChainInfo)(derivativeTokenInfo), amount);
|
|
300
300
|
return [_KoniTypes.ExtrinsicType.UNSTAKE_VDOT, extrinsic];
|
|
301
301
|
}
|
|
302
302
|
|
|
@@ -387,10 +387,8 @@ class EarningService {
|
|
|
387
387
|
async subscribePoolPositions(addresses, callback) {
|
|
388
388
|
let cancel = false;
|
|
389
389
|
await this.eventService.waitChainReady;
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
substrate: substrateAddresses
|
|
393
|
-
} = (0, _utils2.categoryAddresses)(addresses);
|
|
390
|
+
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
391
|
+
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
394
392
|
const activeChains = this.state.activeChainSlugs;
|
|
395
393
|
const unsubList = [];
|
|
396
394
|
for (const handler of Object.values(this.handlers)) {
|
|
@@ -536,10 +534,8 @@ class EarningService {
|
|
|
536
534
|
async getPoolReward(addresses, callback) {
|
|
537
535
|
let cancel = false;
|
|
538
536
|
await this.eventService.waitChainReady;
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
substrate: substrateAddresses
|
|
542
|
-
} = (0, _utils2.categoryAddresses)(addresses);
|
|
537
|
+
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
538
|
+
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
543
539
|
const activeChains = this.state.activeChainSlugs;
|
|
544
540
|
const unsubList = [];
|
|
545
541
|
for (const handler of Object.values(this.handlers)) {
|
|
@@ -594,10 +590,8 @@ class EarningService {
|
|
|
594
590
|
async fetchPoolRewardHistory(addresses, callback) {
|
|
595
591
|
let cancel = false;
|
|
596
592
|
await this.eventService.waitChainReady;
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
substrate: substrateAddresses
|
|
600
|
-
} = (0, _utils2.categoryAddresses)(addresses);
|
|
593
|
+
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
594
|
+
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
601
595
|
const activeChains = this.state.activeChainSlugs;
|
|
602
596
|
const unsubList = [];
|
|
603
597
|
for (const handler of Object.values(this.handlers)) {
|
|
@@ -15,7 +15,8 @@ class FeeService {
|
|
|
15
15
|
chainFeeSubscriptionMap = {
|
|
16
16
|
evm: {},
|
|
17
17
|
substrate: {},
|
|
18
|
-
ton: {}
|
|
18
|
+
ton: {},
|
|
19
|
+
cardano: {}
|
|
19
20
|
};
|
|
20
21
|
constructor(state) {
|
|
21
22
|
this.state = state;
|
|
@@ -109,21 +110,31 @@ class FeeService {
|
|
|
109
110
|
const api = this.state.getEvmApi(chain);
|
|
110
111
|
|
|
111
112
|
// TODO: Handle case type === evm and not have api
|
|
112
|
-
if (type === 'evm'
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
if (type === 'evm') {
|
|
114
|
+
if (api) {
|
|
115
|
+
(0, _utils2.calculateGasFeeParams)(api, chain).then(info => {
|
|
116
|
+
observer.next(info);
|
|
117
|
+
}).catch(e => {
|
|
118
|
+
console.warn(`Cannot get fee param for ${chain}`, e);
|
|
119
|
+
observer.next({
|
|
120
|
+
type: 'evm',
|
|
121
|
+
gasPrice: '0',
|
|
122
|
+
baseGasFee: undefined,
|
|
123
|
+
options: undefined
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
console.warn(`Cannot get fee param for ${chain}`, 'Cannot get api');
|
|
117
128
|
observer.next({
|
|
118
129
|
type: 'evm',
|
|
119
130
|
gasPrice: '0',
|
|
120
131
|
baseGasFee: undefined,
|
|
121
132
|
options: undefined
|
|
122
133
|
});
|
|
123
|
-
}
|
|
134
|
+
}
|
|
124
135
|
} else {
|
|
125
136
|
observer.next({
|
|
126
|
-
type
|
|
137
|
+
type,
|
|
127
138
|
busyNetwork: false,
|
|
128
139
|
options: {
|
|
129
140
|
slow: {
|
|
@@ -151,19 +151,17 @@ class HistoryService {
|
|
|
151
151
|
}
|
|
152
152
|
subscribeHistories(chain, proxyId, cb) {
|
|
153
153
|
const addresses = this.keyringService.context.getDecodedAddresses(proxyId, false);
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
substrate
|
|
157
|
-
} = (0, _utils2.categoryAddresses)(addresses);
|
|
154
|
+
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
155
|
+
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
158
156
|
const subscription = this.historySubject.subscribe(items => {
|
|
159
157
|
cb(items.filter(filterHistoryItemByAddressAndChain(chain, addresses)));
|
|
160
158
|
});
|
|
161
159
|
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
162
160
|
if ((0, _utils._isChainSubstrateCompatible)(chainInfo)) {
|
|
163
161
|
if ((0, _utils._isChainEvmCompatible)(chainInfo)) {
|
|
164
|
-
this.fetchSubscanTransactionHistory(chain,
|
|
162
|
+
this.fetchSubscanTransactionHistory(chain, evmAddresses);
|
|
165
163
|
} else {
|
|
166
|
-
this.fetchSubscanTransactionHistory(chain,
|
|
164
|
+
this.fetchSubscanTransactionHistory(chain, substrateAddresses);
|
|
167
165
|
}
|
|
168
166
|
}
|
|
169
167
|
return {
|
|
@@ -177,12 +177,17 @@ class InappNotificationService {
|
|
|
177
177
|
}
|
|
178
178
|
getCategorizedAddresses() {
|
|
179
179
|
const addresses = this.keyringService.context.getAllAddresses();
|
|
180
|
-
|
|
180
|
+
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
181
|
+
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
182
|
+
return {
|
|
183
|
+
evmAddresses: evmAddresses,
|
|
184
|
+
substrateAddresses: substrateAddresses
|
|
185
|
+
};
|
|
181
186
|
}
|
|
182
187
|
createAvailBridgeClaimNotification() {
|
|
183
188
|
const {
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
evmAddresses,
|
|
190
|
+
substrateAddresses
|
|
186
191
|
} = this.getCategorizedAddresses();
|
|
187
192
|
const chainAssets = this.chainService.getAssetRegistry();
|
|
188
193
|
let ASSET_TYPE;
|
|
@@ -269,7 +274,7 @@ class InappNotificationService {
|
|
|
269
274
|
// Polygon Claimable Handle
|
|
270
275
|
async createPolygonClaimableTransactions() {
|
|
271
276
|
const {
|
|
272
|
-
|
|
277
|
+
evmAddresses
|
|
273
278
|
} = this.getCategorizedAddresses();
|
|
274
279
|
const etherChains = [_chainList.COMMON_ASSETS.ETH, _chainList.COMMON_ASSETS.ETH_SEPOLIA];
|
|
275
280
|
const polygonAssets = Object.values(this.chainService.getAssetRegistry()).filter(asset => etherChains.includes(asset.slug));
|
|
@@ -440,5 +445,8 @@ class InappNotificationService {
|
|
|
440
445
|
removeAccountNotifications(proxyId) {
|
|
441
446
|
this.dbService.removeAccountNotifications(proxyId).catch(console.error);
|
|
442
447
|
}
|
|
448
|
+
migrateNotificationProxyId(proxyIds, newProxyId, newName) {
|
|
449
|
+
this.dbService.updateNotificationProxyId(proxyIds, newProxyId, newName);
|
|
450
|
+
}
|
|
443
451
|
}
|
|
444
452
|
exports.InappNotificationService = InappNotificationService;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AccountContext = void 0;
|
|
7
|
+
var _Migration = require("@subwallet/extension-base/services/keyring-service/context/handlers/Migration");
|
|
7
8
|
var _handlers = require("./handlers");
|
|
8
9
|
var _state = require("./state");
|
|
9
10
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
@@ -21,6 +22,7 @@ class AccountContext {
|
|
|
21
22
|
this.ledgerHandler = new _handlers.AccountLedgerHandler(this.parentService, this.state);
|
|
22
23
|
this.modifyHandler = new _handlers.AccountModifyHandler(this.parentService, this.state);
|
|
23
24
|
this.secretHandler = new _handlers.AccountSecretHandler(this.parentService, this.state);
|
|
25
|
+
this.migrationHandler = new _Migration.AccountMigrationHandler(this.parentService, this.state);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
// TODO: Merge to value
|
|
@@ -230,8 +232,8 @@ class AccountContext {
|
|
|
230
232
|
}
|
|
231
233
|
|
|
232
234
|
/* Derive account proxy */
|
|
233
|
-
derivationAccountProxyCreate(request) {
|
|
234
|
-
return this.deriveHandler.derivationAccountProxyCreate(request);
|
|
235
|
+
derivationAccountProxyCreate(request, isMigration) {
|
|
236
|
+
return this.deriveHandler.derivationAccountProxyCreate(request, isMigration);
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
/* Derive */
|
|
@@ -247,6 +249,19 @@ class AccountContext {
|
|
|
247
249
|
|
|
248
250
|
/* Inject */
|
|
249
251
|
|
|
252
|
+
/* Migration */
|
|
253
|
+
async migrateUnifiedAndFetchEligibleSoloAccounts(request, setMigratingModeFn) {
|
|
254
|
+
return await this.migrationHandler.migrateUnifiedAndFetchEligibleSoloAccounts(request, setMigratingModeFn);
|
|
255
|
+
}
|
|
256
|
+
migrateSoloAccount(request) {
|
|
257
|
+
return this.migrationHandler.migrateSoloToUnifiedAccount(request);
|
|
258
|
+
}
|
|
259
|
+
pingSession(request) {
|
|
260
|
+
return this.migrationHandler.pingSession(request);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* Migration */
|
|
264
|
+
|
|
250
265
|
/* Others */
|
|
251
266
|
|
|
252
267
|
removeNoneHardwareGenesisHash() {
|
|
@@ -15,7 +15,7 @@ var _Base = require("./Base");
|
|
|
15
15
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
const validDeriveKeypairTypes = [..._types2.SubstrateKeypairTypes, ..._types2.EthereumKeypairTypes, 'ton'];
|
|
18
|
+
const validDeriveKeypairTypes = [..._types2.SubstrateKeypairTypes, ..._types2.EthereumKeypairTypes, 'ton', 'cardano'];
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @class AccountDeriveHandler
|
|
@@ -220,6 +220,7 @@ class AccountDeriveHandler extends _Base.AccountBaseHandler {
|
|
|
220
220
|
* Derive account proxy
|
|
221
221
|
* */
|
|
222
222
|
derivationAccountProxyCreate(request) {
|
|
223
|
+
let isMigration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
223
224
|
const {
|
|
224
225
|
name,
|
|
225
226
|
proxyId: deriveId,
|
|
@@ -230,7 +231,7 @@ class AccountDeriveHandler extends _Base.AccountBaseHandler {
|
|
|
230
231
|
const rootId = this.state.value.accounts[parentProxyId].parentId || parentProxyId;
|
|
231
232
|
const rootProxyId = this.state.belongUnifiedAccount(rootId) || rootId;
|
|
232
233
|
const nameExists = this.state.checkNameExists(name);
|
|
233
|
-
if (nameExists) {
|
|
234
|
+
if (nameExists && !isMigration) {
|
|
234
235
|
throw new _types.SWCommonAccountError(_types.CommonAccountErrorType.ACCOUNT_NAME_EXISTED);
|
|
235
236
|
}
|
|
236
237
|
const validateRs = this.validateDerivePath({
|
|
@@ -354,11 +355,13 @@ class AccountDeriveHandler extends _Base.AccountBaseHandler {
|
|
|
354
355
|
}
|
|
355
356
|
const addresses = pairs.map(pair => pair.address);
|
|
356
357
|
const exists = this.state.checkAddressExists(addresses);
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
358
|
+
if (!isMigration) {
|
|
359
|
+
(0, _util.assert)(!exists, (0, _i18next.t)('Account already exists under the name "{{name}}"', {
|
|
360
|
+
replace: {
|
|
361
|
+
name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || ''
|
|
362
|
+
}
|
|
363
|
+
}));
|
|
364
|
+
}
|
|
362
365
|
childAccountProxy && this.state.upsertAccountProxyByKey(childAccountProxy);
|
|
363
366
|
this.state.upsertModifyPairs(modifyPairs);
|
|
364
367
|
for (const childPair of pairs) {
|