@subwallet/extension-base 1.3.21-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/constants.js +8 -3
- 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/SubstrateChainHandler.js +3 -2
- package/cjs/services/chain-service/handler/TonApi.js +2 -5
- package/cjs/services/chain-service/index.js +38 -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/constants/chains.js +2 -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/handlers/native-staking/mythos.js +337 -0
- package/cjs/services/earning-service/service.js +10 -12
- package/cjs/services/earning-service/utils/index.js +2 -0
- 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/migration-service/scripts/databases/ClearMetadataDatabase.js +3 -23
- package/cjs/services/migration-service/scripts/databases/ClearMetadataForChains.js +40 -0
- package/cjs/services/migration-service/scripts/databases/ClearMetadataForMythos.js +15 -0
- package/cjs/services/migration-service/scripts/index.js +6 -2
- 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 +6 -0
- package/cjs/services/storage-service/db-stores/InappNotification.js +6 -0
- package/cjs/services/storage-service/db-stores/Metadata.js +3 -0
- package/cjs/services/storage-service/db-stores/Migration.js +6 -1
- 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 +102 -25
- 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/constants.js +8 -3
- 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/SubstrateChainHandler.js +3 -2
- 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 +4 -1
- package/services/chain-service/index.js +38 -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/constants/chains.d.ts +1 -0
- package/services/earning-service/constants/chains.js +2 -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/handlers/native-staking/mythos.d.ts +35 -0
- package/services/earning-service/handlers/native-staking/mythos.js +329 -0
- package/services/earning-service/service.js +12 -14
- package/services/earning-service/utils/index.js +2 -0
- 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/migration-service/scripts/databases/ClearMetadataDatabase.d.ts +3 -3
- package/services/migration-service/scripts/databases/ClearMetadataDatabase.js +3 -23
- package/services/migration-service/scripts/databases/ClearMetadataForChains.d.ts +5 -0
- package/services/migration-service/scripts/databases/ClearMetadataForChains.js +32 -0
- package/services/migration-service/scripts/databases/ClearMetadataForMythos.d.ts +4 -0
- package/services/migration-service/scripts/databases/ClearMetadataForMythos.js +7 -0
- package/services/migration-service/scripts/index.d.ts +1 -0
- package/services/migration-service/scripts/index.js +4 -1
- 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 +2 -0
- package/services/storage-service/DatabaseService.js +6 -0
- package/services/storage-service/db-stores/InappNotification.d.ts +1 -0
- package/services/storage-service/db-stores/InappNotification.js +6 -0
- package/services/storage-service/db-stores/Metadata.d.ts +1 -0
- package/services/storage-service/db-stores/Metadata.js +3 -0
- package/services/storage-service/db-stores/Migration.d.ts +1 -0
- package/services/storage-service/db-stores/Migration.js +6 -1
- 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
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { AssetLogoMap, AssetRefMap, ChainAssetMap, ChainInfoMap, ChainLogoMap, MultiChainAssetMap } from '@subwallet/chain-list';
|
|
5
5
|
import { _AssetRefPath, _AssetType, _ChainStatus, _SubstrateChainType } from '@subwallet/chain-list/types';
|
|
6
6
|
import { _DEFAULT_ACTIVE_CHAINS, _ZK_ASSET_PREFIX, LATEST_CHAIN_DATA_FETCHING_INTERVAL } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
|
+
import { CardanoChainHandler } from '@subwallet/extension-base/services/chain-service/handler/CardanoChainHandler';
|
|
7
8
|
import { EvmChainHandler } from '@subwallet/extension-base/services/chain-service/handler/EvmChainHandler';
|
|
8
9
|
import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
|
|
9
10
|
import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
|
|
@@ -11,6 +12,7 @@ import { TonChainHandler } from '@subwallet/extension-base/services/chain-servic
|
|
|
11
12
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
12
13
|
import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
13
14
|
import { _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
15
|
+
import { MYTHOS_MIGRATION_KEY } from '@subwallet/extension-base/services/migration-service/scripts';
|
|
14
16
|
import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
|
|
15
17
|
import { addLazy, calculateMetadataHash, fetchStaticData, filterAssetsByChainAndType, getShortMetadata, MODULE_SUPPORT } from '@subwallet/extension-base/utils';
|
|
16
18
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
@@ -67,6 +69,7 @@ export class ChainService {
|
|
|
67
69
|
this.substrateChainHandler = new SubstrateChainHandler(this);
|
|
68
70
|
this.evmChainHandler = new EvmChainHandler(this);
|
|
69
71
|
this.tonChainHandler = new TonChainHandler(this);
|
|
72
|
+
this.cardanoChainHandler = new CardanoChainHandler(this);
|
|
70
73
|
this.logger = createLogger('chain-service');
|
|
71
74
|
}
|
|
72
75
|
get value() {
|
|
@@ -140,6 +143,12 @@ export class ChainService {
|
|
|
140
143
|
getTonApiMap() {
|
|
141
144
|
return this.tonChainHandler.getTonApiMap();
|
|
142
145
|
}
|
|
146
|
+
getCardanoApi(slug) {
|
|
147
|
+
return this.cardanoChainHandler.getCardanoApiByChain(slug);
|
|
148
|
+
}
|
|
149
|
+
getCardanoApiMap() {
|
|
150
|
+
return this.cardanoChainHandler.getCardanoApiMap();
|
|
151
|
+
}
|
|
143
152
|
getChainCurrentProviderByKey(slug) {
|
|
144
153
|
const providerName = this.getChainStateByKey(slug).currentProvider;
|
|
145
154
|
const providerMap = this.getChainInfoByKey(slug).providers;
|
|
@@ -718,6 +727,15 @@ export class ChainService {
|
|
|
718
727
|
});
|
|
719
728
|
this.tonChainHandler.setTonApi(chainInfo.slug, chainApi);
|
|
720
729
|
}
|
|
730
|
+
if (chainInfo.cardanoInfo !== null && chainInfo.cardanoInfo !== undefined) {
|
|
731
|
+
const isTestnet = chainInfo.isTestnet;
|
|
732
|
+
const chainApi = await this.cardanoChainHandler.initApi(chainInfo.slug, endpoint, {
|
|
733
|
+
isTestnet,
|
|
734
|
+
providerName,
|
|
735
|
+
onUpdateStatus
|
|
736
|
+
});
|
|
737
|
+
this.cardanoChainHandler.setCardanoApi(chainInfo.slug, chainApi);
|
|
738
|
+
}
|
|
721
739
|
}
|
|
722
740
|
destroyApiForChain(chainInfo) {
|
|
723
741
|
if (chainInfo.substrateInfo !== null) {
|
|
@@ -729,6 +747,9 @@ export class ChainService {
|
|
|
729
747
|
if (chainInfo.tonInfo !== null) {
|
|
730
748
|
this.tonChainHandler.destroyTonApi(chainInfo.slug);
|
|
731
749
|
}
|
|
750
|
+
if (chainInfo.cardanoInfo !== null) {
|
|
751
|
+
this.cardanoChainHandler.destroyCardanoApi(chainInfo.slug);
|
|
752
|
+
}
|
|
732
753
|
}
|
|
733
754
|
async enableChain(chainSlug) {
|
|
734
755
|
const chainInfo = this.getChainInfoByKey(chainSlug);
|
|
@@ -999,7 +1020,7 @@ export class ChainService {
|
|
|
999
1020
|
deprecatedChainMap[storedSlug] = duplicatedDefaultSlug;
|
|
1000
1021
|
deprecatedChains.push(storedSlug);
|
|
1001
1022
|
} else {
|
|
1002
|
-
var _storedChainInfo$bitc;
|
|
1023
|
+
var _storedChainInfo$bitc, _storedChainInfo$card;
|
|
1003
1024
|
mergedChainInfoMap[storedSlug] = {
|
|
1004
1025
|
slug: storedSlug,
|
|
1005
1026
|
name: storedChainInfo.name,
|
|
@@ -1009,6 +1030,7 @@ export class ChainService {
|
|
|
1009
1030
|
substrateInfo: storedChainInfo.substrateInfo,
|
|
1010
1031
|
bitcoinInfo: (_storedChainInfo$bitc = storedChainInfo.bitcoinInfo) !== null && _storedChainInfo$bitc !== void 0 ? _storedChainInfo$bitc : null,
|
|
1011
1032
|
tonInfo: storedChainInfo.tonInfo,
|
|
1033
|
+
cardanoInfo: (_storedChainInfo$card = storedChainInfo.cardanoInfo) !== null && _storedChainInfo$card !== void 0 ? _storedChainInfo$card : null,
|
|
1012
1034
|
isTestnet: storedChainInfo.isTestnet,
|
|
1013
1035
|
chainStatus: storedChainInfo.chainStatus,
|
|
1014
1036
|
icon: storedChainInfo.icon,
|
|
@@ -1027,7 +1049,7 @@ export class ChainService {
|
|
|
1027
1049
|
this.updateChainConnectionStatus(storedSlug, _ChainConnectionStatus.DISCONNECTED);
|
|
1028
1050
|
}
|
|
1029
1051
|
} else {
|
|
1030
|
-
var _storedChainInfo$bitc2;
|
|
1052
|
+
var _storedChainInfo$bitc2, _storedChainInfo$card2;
|
|
1031
1053
|
// added chain from patch
|
|
1032
1054
|
mergedChainInfoMap[storedSlug] = {
|
|
1033
1055
|
slug: storedSlug,
|
|
@@ -1037,6 +1059,7 @@ export class ChainService {
|
|
|
1037
1059
|
substrateInfo: storedChainInfo.substrateInfo,
|
|
1038
1060
|
bitcoinInfo: (_storedChainInfo$bitc2 = storedChainInfo.bitcoinInfo) !== null && _storedChainInfo$bitc2 !== void 0 ? _storedChainInfo$bitc2 : null,
|
|
1039
1061
|
tonInfo: storedChainInfo.tonInfo,
|
|
1062
|
+
cardanoInfo: (_storedChainInfo$card2 = storedChainInfo.cardanoInfo) !== null && _storedChainInfo$card2 !== void 0 ? _storedChainInfo$card2 : null,
|
|
1040
1063
|
isTestnet: storedChainInfo.isTestnet,
|
|
1041
1064
|
chainStatus: storedChainInfo.chainStatus,
|
|
1042
1065
|
icon: storedChainInfo.icon,
|
|
@@ -1206,6 +1229,7 @@ export class ChainService {
|
|
|
1206
1229
|
let substrateInfo = null;
|
|
1207
1230
|
let evmInfo = null;
|
|
1208
1231
|
const tonInfo = null;
|
|
1232
|
+
const cardanoInfo = null;
|
|
1209
1233
|
if (params.chainSpec.genesisHash !== '') {
|
|
1210
1234
|
substrateInfo = {
|
|
1211
1235
|
crowdloanFunds: params.chainSpec.crowdloanFunds || null,
|
|
@@ -1244,6 +1268,7 @@ export class ChainService {
|
|
|
1244
1268
|
evmInfo,
|
|
1245
1269
|
bitcoinInfo: null,
|
|
1246
1270
|
tonInfo,
|
|
1271
|
+
cardanoInfo,
|
|
1247
1272
|
isTestnet: false,
|
|
1248
1273
|
chainStatus: _ChainStatus.ACTIVE,
|
|
1249
1274
|
icon: '',
|
|
@@ -1355,6 +1380,7 @@ export class ChainService {
|
|
|
1355
1380
|
// TODO: EVM chain might have WS provider
|
|
1356
1381
|
if (provider.startsWith('http')) {
|
|
1357
1382
|
// todo: handle validate ton provider
|
|
1383
|
+
// todo: handle validate cardano provider
|
|
1358
1384
|
|
|
1359
1385
|
// HTTP provider is EVM by default
|
|
1360
1386
|
api = await this.evmChainHandler.initApi('custom', provider);
|
|
@@ -1571,15 +1597,12 @@ export class ChainService {
|
|
|
1571
1597
|
refreshEvmApi(slug) {
|
|
1572
1598
|
this.evmChainHandler.recoverApi(slug).catch(console.error);
|
|
1573
1599
|
}
|
|
1574
|
-
refreshTonApi(slug) {
|
|
1575
|
-
this.tonChainHandler.recoverApi(slug).catch(console.error);
|
|
1576
|
-
}
|
|
1577
1600
|
async stopAllChainApis() {
|
|
1578
|
-
await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep(), this.tonChainHandler.sleep()]);
|
|
1601
|
+
await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep(), this.tonChainHandler.sleep(), this.cardanoChainHandler.sleep()]);
|
|
1579
1602
|
this.stopCheckLatestChainData();
|
|
1580
1603
|
}
|
|
1581
1604
|
async resumeAllChainApis() {
|
|
1582
|
-
await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp(), this.tonChainHandler.wakeUp()]);
|
|
1605
|
+
await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp(), this.tonChainHandler.wakeUp(), this.cardanoChainHandler.wakeUp()]);
|
|
1583
1606
|
this.checkLatestData();
|
|
1584
1607
|
}
|
|
1585
1608
|
async initAssetSettings() {
|
|
@@ -1827,4 +1850,12 @@ export class ChainService {
|
|
|
1827
1850
|
return chainAsset.originChain === chainSlug && (chainAsset.assetType === _AssetType.NATIVE || _isAssetCanPayTxFee(chainAsset));
|
|
1828
1851
|
}).map(chainAsset => chainAsset.slug);
|
|
1829
1852
|
}
|
|
1853
|
+
async isUseMetadataToCreateApi(chain) {
|
|
1854
|
+
const isMythos = ['mythos', 'muse_testnet'].includes(chain);
|
|
1855
|
+
if (isMythos) {
|
|
1856
|
+
return this.dbService.hasRunScript(MYTHOS_MIGRATION_KEY);
|
|
1857
|
+
} else {
|
|
1858
|
+
return true;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1830
1861
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
|
2
2
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _CrowdloanFund } from '@subwallet/chain-list/types';
|
|
3
|
+
import { CardanoBalanceItem } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/types';
|
|
3
4
|
import { AccountState, TxByMsgResponse } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/types';
|
|
4
5
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
5
6
|
import { TonWalletContract } from '@subwallet/keyring/types';
|
|
@@ -107,7 +108,7 @@ export interface _EvmApi extends _ChainBaseApi {
|
|
|
107
108
|
export interface _TonApi extends _ChainBaseApi, _TonUtilsApi {
|
|
108
109
|
isReady: Promise<_TonApi>;
|
|
109
110
|
}
|
|
110
|
-
|
|
111
|
+
interface _TonUtilsApi {
|
|
111
112
|
getBalance(address: Address): Promise<bigint>;
|
|
112
113
|
open<T extends Contract>(src: T): OpenedContract<T>;
|
|
113
114
|
estimateExternalMessageFee(walletContract: TonWalletContract, body: Cell, isInit: boolean, ignoreSignature?: boolean): Promise<EstimateExternalMessageFee>;
|
|
@@ -116,6 +117,12 @@ export interface _TonUtilsApi {
|
|
|
116
117
|
getStatusByExtMsgHash(extMsgHash: string): Promise<[boolean, string]>;
|
|
117
118
|
getAccountState(address: string): Promise<AccountState>;
|
|
118
119
|
}
|
|
120
|
+
export interface _CardanoApi extends _ChainBaseApi, _CardanoUtilsApi {
|
|
121
|
+
isReady: Promise<_CardanoApi>;
|
|
122
|
+
}
|
|
123
|
+
interface _CardanoUtilsApi {
|
|
124
|
+
getBalanceMap(address: string): Promise<CardanoBalanceItem[]>;
|
|
125
|
+
}
|
|
119
126
|
export interface EstimateExternalMessageFee {
|
|
120
127
|
source_fees: {
|
|
121
128
|
in_fwd_fee: number;
|
|
@@ -179,3 +186,4 @@ export interface _ValidateCustomAssetResponse extends _SmartContractTokenInfo {
|
|
|
179
186
|
export declare const _FUNGIBLE_CONTRACT_STANDARDS: _AssetType[];
|
|
180
187
|
export declare const _NFT_CONTRACT_STANDARDS: _AssetType[];
|
|
181
188
|
export declare const _SMART_CONTRACT_STANDARDS: _AssetType[];
|
|
189
|
+
export {};
|
|
@@ -11,6 +11,7 @@ export declare function _isEqualSmartContractAsset(asset1: _ChainAsset, asset2:
|
|
|
11
11
|
export declare function _isPureEvmChain(chainInfo: _ChainInfo): boolean;
|
|
12
12
|
export declare function _isPureSubstrateChain(chainInfo: _ChainInfo): boolean;
|
|
13
13
|
export declare function _isPureTonChain(chainInfo: _ChainInfo): boolean;
|
|
14
|
+
export declare function _isPureCardanoChain(chainInfo: _ChainInfo): boolean;
|
|
14
15
|
export declare function _getOriginChainOfAsset(assetSlug: string): string;
|
|
15
16
|
export declare function _getContractAddressOfToken(tokenInfo: _ChainAsset): string;
|
|
16
17
|
/**
|
|
@@ -30,6 +31,7 @@ export declare function _isTokenTransferredByEvm(tokenInfo: _ChainAsset): boolea
|
|
|
30
31
|
export declare function _checkSmartContractSupportByChain(chainInfo: _ChainInfo, contractType: _AssetType): boolean;
|
|
31
32
|
export declare function _isJettonToken(tokenInfo: _ChainAsset): boolean;
|
|
32
33
|
export declare function _isTokenTransferredByTon(tokenInfo: _ChainAsset): boolean;
|
|
34
|
+
export declare function _isTokenTransferredByCardano(tokenInfo: _ChainAsset): boolean;
|
|
33
35
|
export declare function _getTokenOnChainAssetId(tokenInfo: _ChainAsset): string;
|
|
34
36
|
export declare function _getTokenOnChainInfo(tokenInfo: _ChainAsset): Record<string, any>;
|
|
35
37
|
export declare function _isBridgedToken(tokenInfo: _ChainAsset): boolean;
|
|
@@ -37,6 +39,7 @@ export declare function _getTokenMinAmount(tokenInfo: _ChainAsset): string;
|
|
|
37
39
|
export declare function _isChainEvmCompatible(chainInfo: _ChainInfo): boolean;
|
|
38
40
|
export declare function _isChainBitcoinCompatible(chainInfo: _ChainInfo): boolean;
|
|
39
41
|
export declare function _isChainTonCompatible(chainInfo: _ChainInfo): boolean;
|
|
42
|
+
export declare function _isChainCardanoCompatible(chainInfo: _ChainInfo): boolean;
|
|
40
43
|
export declare function _isNativeToken(tokenInfo: _ChainAsset): boolean;
|
|
41
44
|
export declare function _isNativeTokenBySlug(tokenSlug: string): boolean;
|
|
42
45
|
export declare function _isSmartContractToken(tokenInfo: _ChainAsset): boolean;
|
|
@@ -65,6 +68,7 @@ export declare function _getChainNativeTokenSlug(chainInfo: _ChainInfo): string;
|
|
|
65
68
|
export declare function _isLocalToken(tokenInfo: _ChainAsset): boolean;
|
|
66
69
|
export declare function _isTokenEvmSmartContract(tokenInfo: _ChainAsset): boolean;
|
|
67
70
|
export declare function _isTokenTonSmartContract(tokenInfo: _ChainAsset): boolean;
|
|
71
|
+
export declare function _isCIP26Token(tokenInfo: _ChainAsset): boolean;
|
|
68
72
|
export declare function _isTokenWasmSmartContract(tokenInfo: _ChainAsset): boolean;
|
|
69
73
|
export declare function _isAssetSmartContractNft(assetInfo: _ChainAsset): boolean;
|
|
70
74
|
export declare function _isTokenGearSmartContract(tokenInfo: _ChainAsset): boolean;
|
|
@@ -48,13 +48,16 @@ export function _isEqualSmartContractAsset(asset1, asset2) {
|
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
50
|
export function _isPureEvmChain(chainInfo) {
|
|
51
|
-
return !!chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo;
|
|
51
|
+
return !!chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo;
|
|
52
52
|
}
|
|
53
53
|
export function _isPureSubstrateChain(chainInfo) {
|
|
54
|
-
return !chainInfo.evmInfo && !!chainInfo.substrateInfo && !chainInfo.tonInfo;
|
|
54
|
+
return !chainInfo.evmInfo && !!chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo;
|
|
55
55
|
}
|
|
56
56
|
export function _isPureTonChain(chainInfo) {
|
|
57
|
-
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !!chainInfo.tonInfo;
|
|
57
|
+
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !!chainInfo.tonInfo && !chainInfo.cardanoInfo;
|
|
58
|
+
}
|
|
59
|
+
export function _isPureCardanoChain(chainInfo) {
|
|
60
|
+
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !!chainInfo.cardanoInfo;
|
|
58
61
|
}
|
|
59
62
|
export function _getOriginChainOfAsset(assetSlug) {
|
|
60
63
|
if (assetSlug.startsWith(_CUSTOM_PREFIX)) {
|
|
@@ -107,6 +110,9 @@ export function _isJettonToken(tokenInfo) {
|
|
|
107
110
|
export function _isTokenTransferredByTon(tokenInfo) {
|
|
108
111
|
return _isJettonToken(tokenInfo) || _isNativeToken(tokenInfo);
|
|
109
112
|
}
|
|
113
|
+
export function _isTokenTransferredByCardano(tokenInfo) {
|
|
114
|
+
return _isCIP26Token(tokenInfo) || _isNativeToken(tokenInfo);
|
|
115
|
+
}
|
|
110
116
|
|
|
111
117
|
// Utils for balance functions
|
|
112
118
|
export function _getTokenOnChainAssetId(tokenInfo) {
|
|
@@ -133,6 +139,9 @@ export function _isChainBitcoinCompatible(chainInfo) {
|
|
|
133
139
|
export function _isChainTonCompatible(chainInfo) {
|
|
134
140
|
return !!chainInfo.tonInfo;
|
|
135
141
|
}
|
|
142
|
+
export function _isChainCardanoCompatible(chainInfo) {
|
|
143
|
+
return !!chainInfo.cardanoInfo;
|
|
144
|
+
}
|
|
136
145
|
export function _isNativeToken(tokenInfo) {
|
|
137
146
|
return tokenInfo.assetType === _AssetType.NATIVE;
|
|
138
147
|
}
|
|
@@ -252,11 +261,12 @@ export function _getTokenTypesSupportedByChain(chainInfo) {
|
|
|
252
261
|
return result;
|
|
253
262
|
}
|
|
254
263
|
export function _getChainNativeTokenBasicInfo(chainInfo) {
|
|
264
|
+
const defaultTokenInfo = {
|
|
265
|
+
symbol: '',
|
|
266
|
+
decimals: -1
|
|
267
|
+
};
|
|
255
268
|
if (!chainInfo) {
|
|
256
|
-
return
|
|
257
|
-
symbol: '',
|
|
258
|
-
decimals: -1
|
|
259
|
-
};
|
|
269
|
+
return defaultTokenInfo;
|
|
260
270
|
}
|
|
261
271
|
if (chainInfo.substrateInfo) {
|
|
262
272
|
// substrate by default
|
|
@@ -274,11 +284,13 @@ export function _getChainNativeTokenBasicInfo(chainInfo) {
|
|
|
274
284
|
symbol: chainInfo.tonInfo.symbol,
|
|
275
285
|
decimals: chainInfo.tonInfo.decimals
|
|
276
286
|
};
|
|
287
|
+
} else if (chainInfo.cardanoInfo) {
|
|
288
|
+
return {
|
|
289
|
+
symbol: chainInfo.cardanoInfo.symbol,
|
|
290
|
+
decimals: chainInfo.cardanoInfo.decimals
|
|
291
|
+
};
|
|
277
292
|
}
|
|
278
|
-
return
|
|
279
|
-
symbol: '',
|
|
280
|
-
decimals: -1
|
|
281
|
-
};
|
|
293
|
+
return defaultTokenInfo;
|
|
282
294
|
}
|
|
283
295
|
export function _getChainNativeTokenSlug(chainInfo) {
|
|
284
296
|
if (_isCustomChain(chainInfo.slug)) {
|
|
@@ -296,6 +308,9 @@ export function _isTokenTonSmartContract(tokenInfo) {
|
|
|
296
308
|
return [_AssetType.TEP74].includes(tokenInfo.assetType); // add TEP-62 when supporting
|
|
297
309
|
}
|
|
298
310
|
|
|
311
|
+
export function _isCIP26Token(tokenInfo) {
|
|
312
|
+
return [_AssetType.CIP26].includes(tokenInfo.assetType);
|
|
313
|
+
}
|
|
299
314
|
export function _isTokenWasmSmartContract(tokenInfo) {
|
|
300
315
|
return [_AssetType.PSP22, _AssetType.PSP34].includes(tokenInfo.assetType);
|
|
301
316
|
}
|
|
@@ -384,6 +399,9 @@ export function _getBlockExplorerFromChain(chainInfo) {
|
|
|
384
399
|
if (_isPureEvmChain(chainInfo)) {
|
|
385
400
|
var _chainInfo$evmInfo5;
|
|
386
401
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$evmInfo5 = chainInfo.evmInfo) === null || _chainInfo$evmInfo5 === void 0 ? void 0 : _chainInfo$evmInfo5.blockExplorer;
|
|
402
|
+
} else if (_isPureCardanoChain(chainInfo)) {
|
|
403
|
+
var _chainInfo$cardanoInf;
|
|
404
|
+
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$cardanoInf = chainInfo.cardanoInfo) === null || _chainInfo$cardanoInf === void 0 ? void 0 : _chainInfo$cardanoInf.blockExplorer;
|
|
387
405
|
} else {
|
|
388
406
|
var _chainInfo$substrateI18;
|
|
389
407
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.blockExplorer;
|
|
@@ -551,6 +569,9 @@ export const _chainInfoToChainType = chainInfo => {
|
|
|
551
569
|
if (_isChainTonCompatible(chainInfo)) {
|
|
552
570
|
return AccountChainType.TON;
|
|
553
571
|
}
|
|
572
|
+
if (_isChainCardanoCompatible(chainInfo)) {
|
|
573
|
+
return AccountChainType.CARDANO;
|
|
574
|
+
}
|
|
554
575
|
if (_isChainBitcoinCompatible(chainInfo)) {
|
|
555
576
|
return AccountChainType.BITCOIN;
|
|
556
577
|
}
|
|
@@ -5,7 +5,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
|
5
5
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
6
6
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
7
7
|
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
8
|
-
const ChainListVersion = '0.2.
|
|
8
|
+
const ChainListVersion = '0.2.101'; // update this when build chainlist
|
|
9
9
|
|
|
10
10
|
// todo: move this interface to chainlist
|
|
11
11
|
|
|
@@ -17,7 +17,8 @@ export const _STAKING_CHAIN_GROUP = {
|
|
|
17
17
|
lending: ['interlay'],
|
|
18
18
|
krest_network: ['krest_network'],
|
|
19
19
|
manta: ['manta_network'],
|
|
20
|
-
bittensor: ['bittensor', 'bittensor_devnet']
|
|
20
|
+
bittensor: ['bittensor', 'bittensor_devnet'],
|
|
21
|
+
mythos: ['mythos', 'muse_testnet']
|
|
21
22
|
};
|
|
22
23
|
export const TON_CHAINS = ['ton', 'ton_testnet'];
|
|
23
24
|
export const MaxEraRewardPointsEras = 14;
|
|
@@ -124,7 +124,7 @@ export default class BifrostMantaLiquidStakingPoolHandler extends BifrostLiquidS
|
|
|
124
124
|
const chainApi = await this.substrateApi.isReady;
|
|
125
125
|
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
126
126
|
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
127
|
-
const extrinsic = chainApi.api.tx.vtokenMinting.redeem(_getTokenOnChainInfo(derivativeTokenInfo), amount);
|
|
127
|
+
const extrinsic = chainApi.api.tx.vtokenMinting.redeem(null, _getTokenOnChainInfo(derivativeTokenInfo), amount);
|
|
128
128
|
return [ExtrinsicType.UNSTAKE_VMANTA, extrinsic];
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -286,7 +286,7 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
286
286
|
const chainApi = await this.substrateApi.isReady;
|
|
287
287
|
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
288
288
|
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
289
|
-
const extrinsic = chainApi.api.tx.vtokenMinting.redeem(_getTokenOnChainInfo(derivativeTokenInfo), amount);
|
|
289
|
+
const extrinsic = chainApi.api.tx.vtokenMinting.redeem(null, _getTokenOnChainInfo(derivativeTokenInfo), amount);
|
|
290
290
|
return [ExtrinsicType.UNSTAKE_VDOT, extrinsic];
|
|
291
291
|
}
|
|
292
292
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
+
import { ExtrinsicType, NominationInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
+
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
4
|
+
import BaseParaStakingPoolHandler from '@subwallet/extension-base/services/earning-service/handlers/native-staking/base-para';
|
|
5
|
+
import { EarningRewardItem, EarningStatus, SubmitJoinNativeStaking, TransactionData, UnstakingInfo, ValidatorInfo, YieldPoolInfo, YieldPoolMethodInfo, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
6
|
+
import { SubmittableExtrinsic } from '@polkadot/api/types';
|
|
7
|
+
interface PalletCollatorStakingUserStakeInfo {
|
|
8
|
+
stake: string;
|
|
9
|
+
maybeLastUnstake: string[];
|
|
10
|
+
candidates: string[];
|
|
11
|
+
maybeLastRewardSession: string;
|
|
12
|
+
}
|
|
13
|
+
export default class MythosNativeStakingPoolHandler extends BaseParaStakingPoolHandler {
|
|
14
|
+
protected readonly availableMethod: YieldPoolMethodInfo;
|
|
15
|
+
subscribePoolInfo(callback: (data: YieldPoolInfo) => void): Promise<VoidFunction>;
|
|
16
|
+
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
17
|
+
parseCollatorMetadata(chainInfo: _ChainInfo, stakerAddress: string, substrateApi: _SubstrateApi, userStake: PalletCollatorStakingUserStakeInfo): Promise<{
|
|
18
|
+
status: EarningStatus;
|
|
19
|
+
balanceToken: string;
|
|
20
|
+
totalStake: string;
|
|
21
|
+
activeStake: string;
|
|
22
|
+
unstakeBalance: string;
|
|
23
|
+
isBondedBefore: boolean;
|
|
24
|
+
nominations: NominationInfo[];
|
|
25
|
+
unstakings: UnstakingInfo[];
|
|
26
|
+
}>;
|
|
27
|
+
getPoolTargets(): Promise<ValidatorInfo[]>;
|
|
28
|
+
createJoinExtrinsic(data: SubmitJoinNativeStaking, positionInfo?: YieldPositionInfo): Promise<[TransactionData, YieldTokenBaseInfo]>;
|
|
29
|
+
handleYieldUnstake(amount: string, address: string, selectedTarget?: string): Promise<[ExtrinsicType, TransactionData]>;
|
|
30
|
+
getPoolReward(useAddresses: string[], callback: (rs: EarningRewardItem) => void): Promise<VoidFunction>;
|
|
31
|
+
handleYieldCancelUnstake(): Promise<never>;
|
|
32
|
+
handleYieldWithdraw(address: string, unstakingInfo: UnstakingInfo): Promise<SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
33
|
+
handleYieldClaimReward(address: string, bondReward?: boolean): Promise<SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|