@subwallet/extension-base 1.3.66-0 → 1.3.68-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 +12 -1
- package/cjs/constants/environment.js +1 -3
- package/cjs/constants/index.js +4 -1
- package/cjs/core/substrate/system-pallet.js +4 -0
- package/cjs/core/substrate/xcm-parser.js +0 -176
- package/cjs/koni/api/nft/rari/index.js +1 -1
- package/cjs/koni/background/cron.js +16 -0
- package/cjs/koni/background/handlers/Extension.js +166 -90
- package/cjs/koni/background/handlers/State.js +25 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/group.js +31 -2
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +51 -13
- package/cjs/services/balance-service/helpers/subscribe/substrate/utils.js +69 -0
- package/cjs/services/balance-service/index.js +36 -11
- package/cjs/services/balance-service/transfer/smart-contract.js +56 -23
- package/cjs/services/balance-service/transfer/xcm/index.js +30 -44
- package/cjs/services/balance-service/transfer/xcm/utils.js +53 -18
- package/cjs/services/chain-service/constants.js +8 -46
- package/cjs/services/chain-service/handler/EvmChainHandler.js +6 -3
- package/cjs/services/earning-service/handlers/base.js +7 -1
- package/cjs/services/nft-service/index.js +173 -0
- package/cjs/services/swap-service/handler/base-handler.js +18 -21
- package/cjs/services/transaction-service/index.js +1 -1
- package/cjs/types/balance/index.js +26 -1
- package/cjs/utils/fee/transfer.js +5 -2
- package/cjs/utils/index.js +25 -2
- package/cjs/utils/setup-api-sdk.js +0 -5
- package/constants/environment.d.ts +0 -1
- package/constants/environment.js +0 -1
- package/constants/index.d.ts +1 -0
- package/constants/index.js +1 -0
- package/core/substrate/system-pallet.d.ts +1 -0
- package/core/substrate/system-pallet.js +3 -0
- package/core/substrate/types.d.ts +14 -0
- package/core/substrate/xcm-parser.d.ts +1 -49
- package/core/substrate/xcm-parser.js +1 -173
- package/koni/api/nft/rari/index.js +1 -1
- package/koni/background/cron.d.ts +1 -0
- package/koni/background/cron.js +17 -1
- package/koni/background/handlers/Extension.d.ts +3 -0
- package/koni/background/handlers/Extension.js +88 -14
- package/koni/background/handlers/State.d.ts +4 -0
- package/koni/background/handlers/State.js +25 -0
- package/package.json +16 -21
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/group.js +31 -2
- package/services/balance-service/helpers/subscribe/substrate/index.js +51 -13
- package/services/balance-service/helpers/subscribe/substrate/utils.d.ts +7 -0
- package/services/balance-service/helpers/subscribe/substrate/utils.js +58 -0
- package/services/balance-service/index.d.ts +4 -2
- package/services/balance-service/index.js +26 -6
- package/services/balance-service/transfer/smart-contract.d.ts +4 -0
- package/services/balance-service/transfer/smart-contract.js +54 -23
- package/services/balance-service/transfer/xcm/index.d.ts +2 -2
- package/services/balance-service/transfer/xcm/index.js +18 -32
- package/services/balance-service/transfer/xcm/utils.d.ts +1 -2
- package/services/balance-service/transfer/xcm/utils.js +51 -15
- package/services/chain-service/constants.d.ts +5 -24
- package/services/chain-service/constants.js +6 -35
- package/services/chain-service/handler/EvmChainHandler.js +6 -3
- package/services/earning-service/handlers/base.js +7 -1
- package/services/nft-service/index.d.ts +9 -0
- package/services/nft-service/index.js +165 -0
- package/services/swap-service/handler/base-handler.d.ts +0 -1
- package/services/swap-service/handler/base-handler.js +19 -22
- package/services/transaction-service/index.js +1 -1
- package/services/transaction-service/types.d.ts +2 -1
- package/types/balance/index.d.ts +14 -0
- package/types/balance/index.js +21 -1
- package/utils/fee/transfer.js +6 -3
- package/utils/index.js +25 -2
- package/utils/setup-api-sdk.js +1 -6
- package/cjs/services/balance-service/transfer/xcm/polkadotXcm.js +0 -30
- package/cjs/services/balance-service/transfer/xcm/xTokens.js +0 -32
- package/cjs/services/balance-service/transfer/xcm/xcmPallet.js +0 -23
- package/services/balance-service/transfer/xcm/polkadotXcm.d.ts +0 -3
- package/services/balance-service/transfer/xcm/polkadotXcm.js +0 -24
- package/services/balance-service/transfer/xcm/xTokens.d.ts +0 -3
- package/services/balance-service/transfer/xcm/xTokens.js +0 -26
- package/services/balance-service/transfer/xcm/xcmPallet.d.ts +0 -3
- package/services/balance-service/transfer/xcm/xcmPallet.js +0 -17
|
@@ -16,7 +16,7 @@ import { AuthUrls } from '@subwallet/extension-base/services/request-service/typ
|
|
|
16
16
|
import { CrowdloanContributionsResponse } from '@subwallet/extension-base/services/subscan-service/types';
|
|
17
17
|
import { BitcoinTransactionData, SWTransactionResponse, SWTransactionResult } from '@subwallet/extension-base/services/transaction-service/types';
|
|
18
18
|
import { WalletConnectNotSupportRequest, WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
|
|
19
|
-
import { AccountChainType, AccountJson, AccountsWithCurrentAddress, AddressJson, BalanceJson, BaseRequestSign, BuyServiceInfo, BuyTokenInfo, CommonOptimalTransferPath, CurrentAccountInfo, EarningRewardHistoryItem, EarningRewardJson, EarningStatus, HandleYieldStepParams, InternalRequestSign, LeavePoolAdditionalData, NominationPoolInfo, OptimalYieldPath, OptimalYieldPathParams, RequestAccountBatchExportV2, RequestAccountCreateSuriV2, RequestAccountNameValidate, RequestAccountProxyEdit, RequestAccountProxyForget, RequestBatchJsonGetAccountInfo, RequestBatchRestoreV2, RequestBounceableValidate, RequestChangeAllowOneSign, RequestChangeTonWalletContractVersion, RequestCheckCrossChainTransfer, RequestCheckPublicAndSecretKey, RequestCheckTransfer, RequestCrossChainTransfer, RequestDeriveCreateMultiple, RequestDeriveCreateV3, RequestDeriveValidateV2, RequestEarlyValidateYield, RequestEarningImpact, RequestExportAccountProxyMnemonic, RequestGetAllTonWalletContractVersion, RequestGetAmountForPair, RequestGetDeriveAccounts, RequestGetDeriveSuggestion, RequestGetTokensCanPayFee, RequestGetYieldPoolTargets, RequestInputAccountSubscribe, RequestJsonGetAccountInfo, RequestJsonRestoreV2, RequestMetadataHash, RequestMnemonicCreateV2, RequestMnemonicValidateV2, RequestPrivateKeyValidateV2, RequestShortenMetadata, RequestStakeCancelWithdrawal, RequestStakeClaimReward, RequestSubmitProcessTransaction, RequestSubscribeProcessById, RequestTransfer, RequestUnlockDotCheckCanMint, RequestUnlockDotSubscribeMintedData, RequestYieldLeave, RequestYieldStepSubmit, RequestYieldWithdrawal, ResponseAccountBatchExportV2, ResponseAccountCreateSuriV2, ResponseAccountNameValidate, ResponseBatchJsonGetAccountInfo, ResponseCheckPublicAndSecretKey, ResponseDeriveValidateV2, ResponseEarlyValidateYield, ResponseExportAccountProxyMnemonic, ResponseGetAllTonWalletContractVersion, ResponseGetDeriveAccounts, ResponseGetDeriveSuggestion, ResponseGetYieldPoolTargets, ResponseInputAccountSubscribe, ResponseJsonGetAccountInfo, ResponseMetadataHash, ResponseMnemonicCreateV2, ResponseMnemonicValidateV2, ResponsePrivateKeyValidateV2, ResponseShortenMetadata, ResponseSubscribeProcessAlive, ResponseSubscribeProcessById, StorageDataInterface, SubmitChangeValidatorStaking, SubmitYieldJoinData, SubmitYieldStepData, SubnetYieldPositionInfo, SwapPair, SwapQuoteResponse, SwapRequest, SwapRequestResult, SwapRequestV2, SwapSubmitParams, SwapTxData, TokenSpendingApprovalParams, UnlockDotTransactionNft, UnstakingStatus, ValidateSwapProcessParams, ValidateYieldProcessParams, YieldPoolInfo, YieldPoolType, YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
19
|
+
import { AccountChainType, AccountJson, AccountsWithCurrentAddress, AddressJson, BalanceJson, BalanceType, BaseRequestSign, BuyServiceInfo, BuyTokenInfo, CommonOptimalTransferPath, CurrentAccountInfo, EarningRewardHistoryItem, EarningRewardJson, EarningStatus, HandleYieldStepParams, InternalRequestSign, LeavePoolAdditionalData, NominationPoolInfo, OptimalYieldPath, OptimalYieldPathParams, RequestAccountBatchExportV2, RequestAccountCreateSuriV2, RequestAccountNameValidate, RequestAccountProxyEdit, RequestAccountProxyForget, RequestBatchJsonGetAccountInfo, RequestBatchRestoreV2, RequestBounceableValidate, RequestChangeAllowOneSign, RequestChangeTonWalletContractVersion, RequestCheckCrossChainTransfer, RequestCheckPublicAndSecretKey, RequestCheckTransfer, RequestCrossChainTransfer, RequestDeriveCreateMultiple, RequestDeriveCreateV3, RequestDeriveValidateV2, RequestEarlyValidateYield, RequestEarningImpact, RequestExportAccountProxyMnemonic, RequestGetAllTonWalletContractVersion, RequestGetAmountForPair, RequestGetDeriveAccounts, RequestGetDeriveSuggestion, RequestGetTokensCanPayFee, RequestGetYieldPoolTargets, RequestInputAccountSubscribe, RequestJsonGetAccountInfo, RequestJsonRestoreV2, RequestMetadataHash, RequestMnemonicCreateV2, RequestMnemonicValidateV2, RequestPrivateKeyValidateV2, RequestShortenMetadata, RequestStakeCancelWithdrawal, RequestStakeClaimReward, RequestSubmitProcessTransaction, RequestSubscribeProcessById, RequestTransfer, RequestUnlockDotCheckCanMint, RequestUnlockDotSubscribeMintedData, RequestYieldLeave, RequestYieldStepSubmit, RequestYieldWithdrawal, ResponseAccountBatchExportV2, ResponseAccountCreateSuriV2, ResponseAccountNameValidate, ResponseBatchJsonGetAccountInfo, ResponseCheckPublicAndSecretKey, ResponseDeriveValidateV2, ResponseEarlyValidateYield, ResponseExportAccountProxyMnemonic, ResponseGetAllTonWalletContractVersion, ResponseGetDeriveAccounts, ResponseGetDeriveSuggestion, ResponseGetYieldPoolTargets, ResponseInputAccountSubscribe, ResponseJsonGetAccountInfo, ResponseMetadataHash, ResponseMnemonicCreateV2, ResponseMnemonicValidateV2, ResponsePrivateKeyValidateV2, ResponseShortenMetadata, ResponseSubscribeProcessAlive, ResponseSubscribeProcessById, StorageDataInterface, SubmitChangeValidatorStaking, SubmitYieldJoinData, SubmitYieldStepData, SubnetYieldPositionInfo, SwapPair, SwapQuoteResponse, SwapRequest, SwapRequestResult, SwapRequestV2, SwapSubmitParams, SwapTxData, TokenSpendingApprovalParams, UnlockDotTransactionNft, UnstakingStatus, ValidateSwapProcessParams, ValidateYieldProcessParams, YieldPoolInfo, YieldPoolType, YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
20
20
|
import { RequestSubmitSignPsbtTransfer, RequestSubmitTransfer, RequestSubmitTransferWithId, RequestSubscribeTransfer, ResponseSubscribeTransfer, ResponseSubscribeTransferConfirmation } from '@subwallet/extension-base/types/balance/transfer';
|
|
21
21
|
import { RequestClaimBridge } from '@subwallet/extension-base/types/bridge';
|
|
22
22
|
import { GetNotificationParams, RequestIsClaimedPolygonBridge, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
|
|
@@ -767,6 +767,11 @@ export interface NftTransactionRequest {
|
|
|
767
767
|
params: Record<string, any>;
|
|
768
768
|
nftItem: NftItem;
|
|
769
769
|
}
|
|
770
|
+
export interface NftFullListRequest {
|
|
771
|
+
contractAddress: string;
|
|
772
|
+
owners: string[];
|
|
773
|
+
chainInfo: _ChainInfo;
|
|
774
|
+
}
|
|
770
775
|
export interface EvmNftTransaction extends ValidateTransactionResponse {
|
|
771
776
|
tx: Record<string, any> | null;
|
|
772
777
|
}
|
|
@@ -798,6 +803,9 @@ export interface RequestFreeBalance {
|
|
|
798
803
|
token?: string;
|
|
799
804
|
extrinsicType?: ExtrinsicType;
|
|
800
805
|
}
|
|
806
|
+
export interface RequestAvailableBalanceByType extends RequestFreeBalance {
|
|
807
|
+
balanceType?: BalanceType;
|
|
808
|
+
}
|
|
801
809
|
export interface RequestMaxTransferable {
|
|
802
810
|
address: string;
|
|
803
811
|
networkKey: string;
|
|
@@ -1821,6 +1829,7 @@ export interface KoniRequestSignatures {
|
|
|
1821
1829
|
'pri(nft.getSubscription)': [RequestSubscribeNft, NftJson, NftJson];
|
|
1822
1830
|
'pri(nftCollection.getNftCollection)': [null, NftCollectionJson];
|
|
1823
1831
|
'pri(nftCollection.getSubscription)': [null, NftCollection[], NftCollection[]];
|
|
1832
|
+
'pri(nft.getFullList)': [NftFullListRequest, boolean];
|
|
1824
1833
|
'pri(staking.getStaking)': [null, StakingJson];
|
|
1825
1834
|
'pri(staking.getSubscription)': [RequestSubscribeStaking, StakingJson, StakingJson];
|
|
1826
1835
|
'pri(stakingReward.getStakingReward)': [null, StakingRewardJson];
|
|
@@ -1952,6 +1961,8 @@ export interface KoniRequestSignatures {
|
|
|
1952
1961
|
'pri(subscription.cancel)': [string, boolean];
|
|
1953
1962
|
'pri(freeBalance.get)': [RequestFreeBalance, AmountData];
|
|
1954
1963
|
'pri(freeBalance.subscribe)': [RequestFreeBalance, AmountDataWithId, AmountDataWithId];
|
|
1964
|
+
'pri(availableBalance.getBalanceByType)': [RequestAvailableBalanceByType, AmountData];
|
|
1965
|
+
'pri(availableBalance.subscribeBalanceByType)': [RequestAvailableBalanceByType, AmountDataWithId, AmountDataWithId];
|
|
1955
1966
|
'pri(accounts.checkTransfer)': [RequestCheckTransfer, ValidateTransactionResponse];
|
|
1956
1967
|
'pri(accounts.transfer)': [RequestSubmitTransfer, SWTransactionResponse];
|
|
1957
1968
|
'pri(accounts.bitcoin.dapp.transfer.confirmation)': [RequestSubmitTransferWithId, SWTransactionResponse];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isProductionMode = exports.SW_EXTERNAL_SERVICES_API = exports.
|
|
6
|
+
exports.isProductionMode = exports.SW_EXTERNAL_SERVICES_API = exports.BACKEND_API_URL = exports.APP_VERSION = void 0;
|
|
7
7
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
|
|
@@ -15,7 +15,5 @@ const isProductionMode = PRODUCTION_BRANCHES.indexOf(branchName) > -1;
|
|
|
15
15
|
exports.isProductionMode = isProductionMode;
|
|
16
16
|
const BACKEND_API_URL = process.env.SUBWALLET_API || (isProductionMode ? 'https://sw-services.subwallet.app/api' : 'https://be-dev.subwallet.app/api');
|
|
17
17
|
exports.BACKEND_API_URL = BACKEND_API_URL;
|
|
18
|
-
const BACKEND_PRICE_HISTORY_URL = process.env.SUBWALLET_PRICE_HISTORY_API || (isProductionMode ? 'https://price-history.subwallet.app/api' : 'https://price-history-dev.subwallet.app/api');
|
|
19
|
-
exports.BACKEND_PRICE_HISTORY_URL = BACKEND_PRICE_HISTORY_URL;
|
|
20
18
|
const SW_EXTERNAL_SERVICES_API = process.env.SW_EXTERNAL_SERVICES_API || (isProductionMode ? 'https://external-services.subwallet.app' : 'https://external-services-dev.subwallet.app');
|
|
21
19
|
exports.SW_EXTERNAL_SERVICES_API = SW_EXTERNAL_SERVICES_API;
|
package/cjs/constants/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var _exportNames = {
|
|
|
20
20
|
CRON_REFRESH_HISTORY_INTERVAL: true,
|
|
21
21
|
CRON_GET_API_MAP_STATUS: true,
|
|
22
22
|
CRON_REFRESH_CHAIN_STAKING_METADATA: true,
|
|
23
|
+
CRON_NFT_DETECT_INTERVAL: true,
|
|
23
24
|
CRON_REFRESH_CHAIN_NOMINATOR_METADATA: true,
|
|
24
25
|
CRON_RECOVER_HISTORY_INTERVAL: true,
|
|
25
26
|
CRON_SYNC_MANTA_PAY: true,
|
|
@@ -46,7 +47,7 @@ var _exportNames = {
|
|
|
46
47
|
getSupportTokenPayFeeChain: true,
|
|
47
48
|
isChainSupportTokenPayFee: true
|
|
48
49
|
};
|
|
49
|
-
exports.isChainSupportTokenPayFee = exports.getSupportTokenPayFeeChain = exports._SUPPORT_TOKEN_PAY_FEE_GROUP = exports.XCM_MIN_AMOUNT_RATIO = exports.XCM_FEE_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.PERMISSIONS_TO_REVOKE = exports.ORDINAL_METHODS = exports.ORDINAL_COLLECTION = exports.NETWORK_MULTI_GAS_FEE = exports.MAX_COLLATERAL_AMOUNT = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.GAS_PRICE_RATIO = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_MKT_CAMPAIGN_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_LISTEN_AVAIL_BRIDGE_CLAIM = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.BITTENSOR_REFRESH_STAKE_INFO = exports.BITTENSOR_REFRESH_STAKE_APY = exports.BITCOIN_REFRESH_BALANCE_INTERVAL = exports.BASE_SECOND_INTERVAL = exports.BASE_MINUTE_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ALL_ACCOUNT_AUTH_TYPES = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
|
|
50
|
+
exports.isChainSupportTokenPayFee = exports.getSupportTokenPayFeeChain = exports._SUPPORT_TOKEN_PAY_FEE_GROUP = exports.XCM_MIN_AMOUNT_RATIO = exports.XCM_FEE_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.PERMISSIONS_TO_REVOKE = exports.ORDINAL_METHODS = exports.ORDINAL_COLLECTION = exports.NETWORK_MULTI_GAS_FEE = exports.MAX_COLLATERAL_AMOUNT = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.GAS_PRICE_RATIO = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_MKT_CAMPAIGN_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_NFT_DETECT_INTERVAL = exports.CRON_LISTEN_AVAIL_BRIDGE_CLAIM = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.BITTENSOR_REFRESH_STAKE_INFO = exports.BITTENSOR_REFRESH_STAKE_APY = exports.BITCOIN_REFRESH_BALANCE_INTERVAL = exports.BASE_SECOND_INTERVAL = exports.BASE_MINUTE_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ALL_ACCOUNT_AUTH_TYPES = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
|
|
50
51
|
var _blockedActions = require("./blocked-actions");
|
|
51
52
|
Object.keys(_blockedActions).forEach(function (key) {
|
|
52
53
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -166,6 +167,8 @@ const CRON_GET_API_MAP_STATUS = 10000;
|
|
|
166
167
|
exports.CRON_GET_API_MAP_STATUS = CRON_GET_API_MAP_STATUS;
|
|
167
168
|
const CRON_REFRESH_CHAIN_STAKING_METADATA = 90000;
|
|
168
169
|
exports.CRON_REFRESH_CHAIN_STAKING_METADATA = CRON_REFRESH_CHAIN_STAKING_METADATA;
|
|
170
|
+
const CRON_NFT_DETECT_INTERVAL = 7500000;
|
|
171
|
+
exports.CRON_NFT_DETECT_INTERVAL = CRON_NFT_DETECT_INTERVAL;
|
|
169
172
|
const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
|
|
170
173
|
exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = CRON_REFRESH_CHAIN_NOMINATOR_METADATA;
|
|
171
174
|
const CRON_RECOVER_HISTORY_INTERVAL = 30000;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports._canAccountBeReaped = _canAccountBeReaped;
|
|
7
7
|
exports._getAppliedExistentialDepositWithExtrinsicType = _getAppliedExistentialDepositWithExtrinsicType;
|
|
8
|
+
exports._getSystemPalletReservedBalance = _getSystemPalletReservedBalance;
|
|
8
9
|
exports._getSystemPalletTotalBalance = _getSystemPalletTotalBalance;
|
|
9
10
|
exports._getSystemPalletTransferable = _getSystemPalletTransferable;
|
|
10
11
|
exports._isAccountActive = _isAccountActive;
|
|
@@ -74,4 +75,7 @@ function _getSystemPalletTransferableV1(accountInfo, existentialDeposit, strictM
|
|
|
74
75
|
}
|
|
75
76
|
function _getSystemPalletTotalBalanceV1(accountInfo) {
|
|
76
77
|
return BigInt(accountInfo.data.free) + BigInt(accountInfo.data.reserved);
|
|
78
|
+
}
|
|
79
|
+
function _getSystemPalletReservedBalance(accountInfo) {
|
|
80
|
+
return BigInt(accountInfo.data.reserved);
|
|
77
81
|
}
|
|
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports._adaptX1Interior = _adaptX1Interior;
|
|
7
|
-
exports._getXcmBeneficiary = _getXcmBeneficiary;
|
|
8
|
-
exports._getXcmDestWeight = _getXcmDestWeight;
|
|
9
|
-
exports._getXcmMultiAssets = _getXcmMultiAssets;
|
|
10
|
-
exports._getXcmMultiLocation = _getXcmMultiLocation;
|
|
11
7
|
exports._getXcmUnstableWarning = _getXcmUnstableWarning;
|
|
12
8
|
exports._isAcrossBridgeXcm = _isAcrossBridgeXcm;
|
|
13
9
|
exports._isAvailBridgeXcm = _isAvailBridgeXcm;
|
|
@@ -23,52 +19,9 @@ var _availBridge = require("@subwallet/extension-base/services/balance-service/t
|
|
|
23
19
|
var _polygonBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge");
|
|
24
20
|
var _posBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge");
|
|
25
21
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
26
|
-
var _utilCrypto = require("@polkadot/util-crypto");
|
|
27
22
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
28
23
|
// SPDX-License-Identifier: Apache-2.0
|
|
29
24
|
|
|
30
|
-
const FOUR_INSTRUCTIONS_WEIGHT = 5000000000;
|
|
31
|
-
const UNLIMITED_WEIGHT = 'Unlimited';
|
|
32
|
-
function _getXcmDestWeight(originChainInfo) {
|
|
33
|
-
if (['pioneer'].includes(originChainInfo.slug)) {
|
|
34
|
-
return FOUR_INSTRUCTIONS_WEIGHT;
|
|
35
|
-
}
|
|
36
|
-
return UNLIMITED_WEIGHT;
|
|
37
|
-
}
|
|
38
|
-
function _getXcmBeneficiary(destChainInfo, recipient, version) {
|
|
39
|
-
const receiverLocation = version < 4 // from V4, X1 is also an array
|
|
40
|
-
? _getRecipientLocation(destChainInfo, recipient, version) : [_getRecipientLocation(destChainInfo, recipient, version)];
|
|
41
|
-
return {
|
|
42
|
-
[`V${version}`]: {
|
|
43
|
-
parents: 0,
|
|
44
|
-
interior: {
|
|
45
|
-
X1: receiverLocation
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function _getXcmMultiAssets(tokenInfo, value, version) {
|
|
51
|
-
const assetId = _getAssetIdentifier(tokenInfo, version);
|
|
52
|
-
return {
|
|
53
|
-
[`V${version}`]: [{
|
|
54
|
-
id: assetId,
|
|
55
|
-
fun: {
|
|
56
|
-
Fungible: value
|
|
57
|
-
}
|
|
58
|
-
}]
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function _getXcmMultiLocation(originChainInfo, destChainInfo, version, recipient) {
|
|
62
|
-
const isWithinSameConsensus = _isXcmWithinSameConsensus(originChainInfo, destChainInfo);
|
|
63
|
-
const parents = _getMultiLocationParent(originChainInfo, isWithinSameConsensus);
|
|
64
|
-
const interior = _getMultiLocationInterior(destChainInfo, isWithinSameConsensus, version, recipient);
|
|
65
|
-
return {
|
|
66
|
-
[`V${version}`]: {
|
|
67
|
-
parents,
|
|
68
|
-
interior
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
25
|
function _isXcmTransferUnstable(originChainInfo, destChainInfo, assetSlug) {
|
|
73
26
|
return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) || _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) || _isPolygonBridgeXcm(originChainInfo, destChainInfo) || _isPosBridgeXcm(originChainInfo, destChainInfo);
|
|
74
27
|
}
|
|
@@ -152,123 +105,6 @@ function _isAcrossBridgeXcm(originChainInfo, destChainInfo) {
|
|
|
152
105
|
}
|
|
153
106
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
154
107
|
|
|
155
|
-
function _getMultiLocationParent(originChainInfo, isWithinSameConsensus) {
|
|
156
|
-
let parent = 0; // how many hops up the hierarchy
|
|
157
|
-
|
|
158
|
-
if ((0, _utils._isSubstrateParaChain)(originChainInfo)) {
|
|
159
|
-
parent += 1;
|
|
160
|
-
}
|
|
161
|
-
if (!isWithinSameConsensus) {
|
|
162
|
-
parent += 1;
|
|
163
|
-
}
|
|
164
|
-
return parent;
|
|
165
|
-
}
|
|
166
|
-
function _getMultiLocationInterior(destChainInfo, isWithinSameConsensus, version, recipient) {
|
|
167
|
-
const junctions = [];
|
|
168
|
-
if (isWithinSameConsensus) {
|
|
169
|
-
if ((0, _utils._isSubstrateParaChain)(destChainInfo)) {
|
|
170
|
-
junctions.push({
|
|
171
|
-
Parachain: (0, _utils._getSubstrateParaId)(destChainInfo)
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
junctions.push({
|
|
176
|
-
GlobalConsensus: _getGlobalConsensusJunction(destChainInfo, version)
|
|
177
|
-
});
|
|
178
|
-
if ((0, _utils._isSubstrateParaChain)(destChainInfo)) {
|
|
179
|
-
junctions.push({
|
|
180
|
-
Parachain: (0, _utils._getSubstrateParaId)(destChainInfo)
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (recipient) {
|
|
185
|
-
junctions.push(_getRecipientLocation(destChainInfo, recipient, version));
|
|
186
|
-
}
|
|
187
|
-
if (junctions.length === 0 && !recipient) {
|
|
188
|
-
return 'Here';
|
|
189
|
-
}
|
|
190
|
-
if (version < 4 && junctions.length === 1) {
|
|
191
|
-
return {
|
|
192
|
-
X1: junctions[0]
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
[`X${junctions.length}`]: junctions
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
function _getGlobalConsensusJunction(destChainInfo, version) {
|
|
200
|
-
let chainSlug = destChainInfo.slug;
|
|
201
|
-
let evmChainId;
|
|
202
|
-
if ((0, _utils._isSubstrateParaChain)(destChainInfo)) {
|
|
203
|
-
const relaySlug = (0, _utils._getSubstrateRelayParent)(destChainInfo);
|
|
204
|
-
if (!relaySlug) {
|
|
205
|
-
throw Error('Parachain must have a parent chainSlug');
|
|
206
|
-
}
|
|
207
|
-
chainSlug = relaySlug;
|
|
208
|
-
} else {
|
|
209
|
-
evmChainId = (0, _utils._getEvmChainId)(destChainInfo);
|
|
210
|
-
}
|
|
211
|
-
if (evmChainId) {
|
|
212
|
-
return {
|
|
213
|
-
Ethereum: {
|
|
214
|
-
chainId: evmChainId
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
switch (chainSlug) {
|
|
219
|
-
case _chainList.COMMON_CHAIN_SLUGS.POLKADOT:
|
|
220
|
-
return version < 4 ? {
|
|
221
|
-
Polkadot: null
|
|
222
|
-
} : 'Polkadot';
|
|
223
|
-
case _chainList.COMMON_CHAIN_SLUGS.KUSAMA:
|
|
224
|
-
return version < 4 ? {
|
|
225
|
-
Kusama: null
|
|
226
|
-
} : 'Kusama';
|
|
227
|
-
default:
|
|
228
|
-
return version < 4 ? {
|
|
229
|
-
Rococo: null
|
|
230
|
-
} : 'Rococo';
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
function _getRecipientLocation(destChainInfo, recipient, version) {
|
|
234
|
-
const network = _getNetworkByVersion(version);
|
|
235
|
-
if (destChainInfo.slug === _chainList.COMMON_CHAIN_SLUGS.ASTAR_EVM) {
|
|
236
|
-
const ss58Address = (0, _utilCrypto.evmToAddress)(recipient, (0, _utils._getChainSubstrateAddressPrefix)(destChainInfo)); // TODO: shouldn't pass addressPrefix directly
|
|
237
|
-
|
|
238
|
-
return {
|
|
239
|
-
AccountId32: {
|
|
240
|
-
network,
|
|
241
|
-
id: (0, _utilCrypto.decodeAddress)(ss58Address)
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
if ((0, _utils._isChainEvmCompatible)(destChainInfo)) {
|
|
246
|
-
return {
|
|
247
|
-
AccountKey20: {
|
|
248
|
-
network,
|
|
249
|
-
key: recipient
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
return {
|
|
254
|
-
AccountId32: {
|
|
255
|
-
network,
|
|
256
|
-
id: (0, _utilCrypto.decodeAddress)(recipient)
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
function _getAssetIdentifier(tokenInfo, version) {
|
|
261
|
-
const _assetIdentifier = (0, _utils._getXcmAssetMultilocation)(tokenInfo);
|
|
262
|
-
if (!_assetIdentifier) {
|
|
263
|
-
throw new Error('Asset must have multilocation');
|
|
264
|
-
}
|
|
265
|
-
const assetIdentifier = ['statemint-LOCAL-KSM', 'statemine-LOCAL-DOT'].includes(tokenInfo.slug) // todo: hotfix for ksm statemint recheck all chain
|
|
266
|
-
? _assetIdentifier : _adaptX1Interior(_assetIdentifier, version);
|
|
267
|
-
return version >= 4 // from V4, Concrete is removed
|
|
268
|
-
? assetIdentifier : {
|
|
269
|
-
Concrete: assetIdentifier
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
108
|
function _adaptX1Interior(_assetIdentifier, version) {
|
|
273
109
|
const assetIdentifier = structuredClone(_assetIdentifier);
|
|
274
110
|
const interior = assetIdentifier.interior;
|
|
@@ -281,16 +117,4 @@ function _adaptX1Interior(_assetIdentifier, version) {
|
|
|
281
117
|
interior.X1 = interior.X1[0];
|
|
282
118
|
}
|
|
283
119
|
return assetIdentifier;
|
|
284
|
-
}
|
|
285
|
-
function _getNetworkByVersion(version) {
|
|
286
|
-
switch (version) {
|
|
287
|
-
case 1:
|
|
288
|
-
case 2:
|
|
289
|
-
return 'Any';
|
|
290
|
-
case 3:
|
|
291
|
-
case 4:
|
|
292
|
-
return undefined;
|
|
293
|
-
default:
|
|
294
|
-
return undefined;
|
|
295
|
-
}
|
|
296
120
|
}
|
|
@@ -99,6 +99,7 @@ class KoniCron {
|
|
|
99
99
|
// NFT
|
|
100
100
|
(commonReload || needUpdateNft) && this.resetNft(address);
|
|
101
101
|
(commonReload || needUpdateNft) && this.removeCron('refreshNft');
|
|
102
|
+
(commonReload || needUpdateNft) && this.removeCron('detectNft');
|
|
102
103
|
commonReload && this.removeCron('refreshPoolingStakingReward');
|
|
103
104
|
if (mktCampaignNeedReload) {
|
|
104
105
|
this.removeCron('fetchMktCampaignData');
|
|
@@ -114,6 +115,7 @@ class KoniCron {
|
|
|
114
115
|
if (this.checkNetworkAvailable(serviceInfo)) {
|
|
115
116
|
// only add cron jobs if there's at least 1 active network
|
|
116
117
|
(commonReload || needUpdateNft) && this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
118
|
+
(commonReload || needUpdateNft) && this.addCron('detectNft', this.detectEvmCollectionNft(address), _constants.CRON_NFT_DETECT_INTERVAL);
|
|
117
119
|
reloadMantaPay && this.addCron('syncMantaPay', this.syncMantaPay, _constants.CRON_SYNC_MANTA_PAY);
|
|
118
120
|
}
|
|
119
121
|
};
|
|
@@ -126,6 +128,7 @@ class KoniCron {
|
|
|
126
128
|
if (Object.keys(this.state.getSubstrateApiMap()).length !== 0 || Object.keys(this.state.getEvmApiMap()).length !== 0) {
|
|
127
129
|
this.resetNft(currentAccountInfo.proxyId);
|
|
128
130
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.proxyId, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
131
|
+
this.addCron('detectNft', this.detectEvmCollectionNft(currentAccountInfo.proxyId), _constants.CRON_NFT_DETECT_INTERVAL);
|
|
129
132
|
// this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
130
133
|
this.addCron('syncMantaPay', this.syncMantaPay, _constants.CRON_SYNC_MANTA_PAY);
|
|
131
134
|
}
|
|
@@ -175,12 +178,25 @@ class KoniCron {
|
|
|
175
178
|
checkNetworkAvailable = serviceInfo => {
|
|
176
179
|
return Object.keys(serviceInfo.chainApiMap.substrate).length > 0 || Object.keys(serviceInfo.chainApiMap.evm).length > 0;
|
|
177
180
|
};
|
|
181
|
+
detectEvmCollectionNft = address => {
|
|
182
|
+
return () => {
|
|
183
|
+
let addresses = [];
|
|
184
|
+
addresses = this.state.keyringService.context.getDecodedAddresses();
|
|
185
|
+
if (!addresses.length) {
|
|
186
|
+
console.warn('[Cron] No decoded addresses found for ALL_ACCOUNT_KEY');
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this.state.nftDetectionService.fetchEvmCollectionsWithPreview(addresses).catch(err => console.warn(`[Cron] NFT detection failed for ${address}:`, err));
|
|
190
|
+
};
|
|
191
|
+
};
|
|
178
192
|
async reloadNft() {
|
|
179
193
|
const address = this.state.keyringService.context.currentAccount.proxyId;
|
|
180
194
|
const serviceInfo = this.state.getServiceInfo();
|
|
181
195
|
this.resetNft(address);
|
|
182
196
|
this.removeCron('refreshNft');
|
|
197
|
+
this.removeCron('detectNft');
|
|
183
198
|
this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
199
|
+
this.addCron('detectNft', this.detectEvmCollectionNft(address), _constants.CRON_NFT_DETECT_INTERVAL);
|
|
184
200
|
await (0, _utils2.waitTimeout)(1800);
|
|
185
201
|
return true;
|
|
186
202
|
}
|