@subwallet/extension-base 1.3.22-0 → 1.3.24-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 +77 -4
- package/background/KoniTypes.js +2 -0
- package/cjs/background/KoniTypes.js +2 -0
- package/cjs/constants/environment.js +4 -2
- package/cjs/constants/index.js +21 -4
- package/cjs/constants/signing.js +6 -2
- package/cjs/core/logic-validation/recipientAddress.js +9 -1
- package/cjs/core/logic-validation/transfer.js +57 -36
- 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 +343 -185
- package/cjs/koni/background/handlers/State.js +17 -2
- package/cjs/koni/background/handlers/Tabs.js +1 -1
- 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/smart-contract.js +24 -3
- 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 +40 -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/fee-service/utils/tokenPayFee.js +151 -0
- 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/handler/MetadataRequestHandler.js +5 -13
- package/cjs/services/request-service/index.js +22 -4
- 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 +286 -26
- 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 +87 -21
- 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/index.d.ts +6 -1
- package/constants/index.js +14 -1
- package/constants/signing.js +6 -2
- package/core/logic-validation/recipientAddress.js +11 -3
- package/core/logic-validation/transfer.d.ts +1 -1
- package/core/logic-validation/transfer.js +33 -12
- 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 +225 -69
- package/koni/background/handlers/State.d.ts +6 -2
- package/koni/background/handlers/State.js +18 -3
- package/koni/background/handlers/Tabs.js +1 -1
- package/package.json +76 -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/smart-contract.d.ts +4 -2
- package/services/balance-service/transfer/smart-contract.js +24 -3
- 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 +4 -1
- package/services/chain-service/index.js +41 -8
- 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/interfaces.d.ts +25 -0
- package/services/fee-service/service.js +19 -8
- package/services/fee-service/utils/tokenPayFee.d.ts +8 -0
- package/services/fee-service/utils/tokenPayFee.js +141 -0
- 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/handler/MetadataRequestHandler.d.ts +1 -1
- package/services/request-service/handler/MetadataRequestHandler.js +5 -13
- package/services/request-service/index.d.ts +7 -4
- package/services/request-service/index.js +21 -7
- 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 +273 -17
- 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/option.d.ts +1 -1
- 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 +3 -2
- package/utils/fee/transfer.js +90 -24
- 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
|
@@ -8,7 +8,7 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
8
8
|
import { withErrorLog } from '@subwallet/extension-base/background/handlers/helpers';
|
|
9
9
|
import { createSubscription } from '@subwallet/extension-base/background/handlers/subscriptions';
|
|
10
10
|
import { CampaignDataType, ChainType, ExternalRequestPromiseStatus, ExtrinsicType, MantaPayEnableMessage, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
11
|
-
import {
|
|
11
|
+
import { _SUPPORT_TOKEN_PAY_FEE_GROUP, ALL_ACCOUNT_KEY, LATEST_SESSION } from '@subwallet/extension-base/constants';
|
|
12
12
|
import { additionalValidateTransferForRecipient, additionalValidateXcmTransfer, validateTransferRequest, validateXcmTransferRequest } from '@subwallet/extension-base/core/logic-validation/transfer';
|
|
13
13
|
import { _isSnowBridgeXcm } from '@subwallet/extension-base/core/substrate/xcm-parser';
|
|
14
14
|
import { ALLOWED_PATH } from '@subwallet/extension-base/defaults';
|
|
@@ -22,9 +22,11 @@ import { getBondingExtrinsic, getCancelWithdrawalExtrinsic, getClaimRewardExtrin
|
|
|
22
22
|
import { getTuringCancelCompoundingExtrinsic, getTuringCompoundExtrinsic } from '@subwallet/extension-base/koni/api/staking/bonding/paraChain';
|
|
23
23
|
import { getPoolingBondingExtrinsic, getPoolingUnbondingExtrinsic, validatePoolBondingCondition, validateRelayUnbondingCondition } from '@subwallet/extension-base/koni/api/staking/bonding/relayChain';
|
|
24
24
|
import { YIELD_EXTRINSIC_TYPES } from '@subwallet/extension-base/koni/api/yield/helper/utils';
|
|
25
|
+
import { DEFAULT_CARDANO_TTL_OFFSET } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/consts';
|
|
25
26
|
import { isBounceableAddress } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils';
|
|
27
|
+
import { createCardanoTransaction } from '@subwallet/extension-base/services/balance-service/transfer/cardano-transfer';
|
|
26
28
|
import { getERC20TransactionObject, getERC721Transaction, getEVMTransactionObject, getPSP34TransferExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
|
|
27
|
-
import {
|
|
29
|
+
import { createSubstrateExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/token';
|
|
28
30
|
import { createTonTransaction } from '@subwallet/extension-base/services/balance-service/transfer/ton-transfer';
|
|
29
31
|
import { createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createPolygonBridgeExtrinsic, createSnowBridgeExtrinsic, createXcmExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
30
32
|
import { getClaimTxOnAvail, getClaimTxOnEthereum, isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
@@ -32,19 +34,19 @@ import { _isPolygonChainBridge, getClaimPolygonBridge, isClaimedPolygonBridge }
|
|
|
32
34
|
import { _isPosChainBridge, getClaimPosBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge';
|
|
33
35
|
import { _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX, SUFFICIENT_CHAIN } from '@subwallet/extension-base/services/chain-service/constants';
|
|
34
36
|
import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
|
|
35
|
-
import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getTokenOnChainAssetId, _getXcmAssetMultilocation, _isAssetSmartContractNft, _isBridgedToken, _isChainEvmCompatible, _isChainSubstrateCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
|
|
37
|
+
import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getTokenOnChainAssetId, _getXcmAssetMultilocation, _isAssetSmartContractNft, _isBridgedToken, _isChainEvmCompatible, _isChainSubstrateCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isNativeTokenBySlug, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByCardano, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
|
|
36
38
|
import { calculateToAmountByReservePool } from '@subwallet/extension-base/services/fee-service/utils';
|
|
39
|
+
import { batchExtrinsicSetFeeHydration, getAssetHubTokensCanPayFee, getHydrationTokensCanPayFee } from '@subwallet/extension-base/services/fee-service/utils/tokenPayFee';
|
|
37
40
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
38
41
|
import { DEFAULT_AUTO_LOCK_TIME } from '@subwallet/extension-base/services/setting-service/constants';
|
|
39
|
-
import { checkLiquidityForPool, estimateTokensForPool, getReserveForPool } from '@subwallet/extension-base/services/swap-service/handler/asset-hub/utils';
|
|
40
42
|
import { isProposalExpired, isSupportWalletConnectChain, isSupportWalletConnectNamespace } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
|
|
41
43
|
import { SWStorage } from '@subwallet/extension-base/storage';
|
|
42
44
|
import { AccountsStore } from '@subwallet/extension-base/stores';
|
|
43
|
-
import { AccountSignMode, BasicTxErrorType, BasicTxWarningCode, CommonStepType, EarningProcessType, ProcessType, StakingTxErrorType, StepStatus, SwapFeeType, SwapStepType, YieldPoolType, YieldStepType } from '@subwallet/extension-base/types';
|
|
45
|
+
import { AccountSignMode, BasicTxErrorType, BasicTxWarningCode, CommonStepType, EarningProcessType, ProcessType, StakingTxErrorType, StepStatus, SwapFeeType, SwapProviderId, SwapStepType, YieldPoolType, YieldStepType } from '@subwallet/extension-base/types';
|
|
44
46
|
import { _analyzeAddress, calculateMaxTransferable, combineAllAccountProxy, createTransactionFromRLP, detectTransferTxType, getAccountSignMode, isSameAddress, MODULE_SUPPORT, reformatAddress, signatureToHex, transformAccounts, transformAddresses, uniqueStringArray } from '@subwallet/extension-base/utils';
|
|
45
47
|
import { parseContractInput, parseEvmRlp } from '@subwallet/extension-base/utils/eth/parseTransaction';
|
|
46
48
|
import { getId } from '@subwallet/extension-base/utils/getId';
|
|
47
|
-
import { getKeypairTypeByAddress, isAddress, isSubstrateAddress, isTonAddress } from '@subwallet/keyring';
|
|
49
|
+
import { getKeypairTypeByAddress, isAddress, isCardanoAddress, isSubstrateAddress, isTonAddress } from '@subwallet/keyring';
|
|
48
50
|
import { EthereumKeypairTypes, SubstrateKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
|
|
49
51
|
import { keyring } from '@subwallet/ui-keyring';
|
|
50
52
|
import { getSdkError } from '@walletconnect/utils';
|
|
@@ -781,6 +783,22 @@ export default class KoniExtension {
|
|
|
781
783
|
this.#koniState.updateSetting('notificationSetup', request);
|
|
782
784
|
return true;
|
|
783
785
|
}
|
|
786
|
+
saveMigrationAcknowledgedStatus({
|
|
787
|
+
isAcknowledgedUnifiedAccountMigration
|
|
788
|
+
}) {
|
|
789
|
+
this.#koniState.updateSetting('isAcknowledgedUnifiedAccountMigration', isAcknowledgedUnifiedAccountMigration);
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
saveUnifiedAccountMigrationInProgress({
|
|
793
|
+
isUnifiedAccountMigrationInProgress
|
|
794
|
+
}) {
|
|
795
|
+
this.#koniState.updateSetting('isUnifiedAccountMigrationInProgress', isUnifiedAccountMigrationInProgress);
|
|
796
|
+
return true;
|
|
797
|
+
}
|
|
798
|
+
pingUnifiedAccountMigrationDone() {
|
|
799
|
+
this.#koniState.updateSetting('isUnifiedAccountMigrationInProgress', false);
|
|
800
|
+
return true;
|
|
801
|
+
}
|
|
784
802
|
setShowZeroBalance({
|
|
785
803
|
show
|
|
786
804
|
}) {
|
|
@@ -1113,8 +1131,8 @@ export default class KoniExtension {
|
|
|
1113
1131
|
feeCustom,
|
|
1114
1132
|
feeOption,
|
|
1115
1133
|
from,
|
|
1116
|
-
nonNativeTokenPayFeeSlug,
|
|
1117
1134
|
to,
|
|
1135
|
+
tokenPayFeeSlug,
|
|
1118
1136
|
tokenSlug,
|
|
1119
1137
|
transferAll,
|
|
1120
1138
|
transferBounceable,
|
|
@@ -1127,7 +1145,9 @@ export default class KoniExtension {
|
|
|
1127
1145
|
const nativeTokenInfo = this.#koniState.getNativeTokenInfo(chain);
|
|
1128
1146
|
const nativeTokenSlug = nativeTokenInfo.slug;
|
|
1129
1147
|
const isTransferNativeToken = nativeTokenSlug === tokenSlug;
|
|
1130
|
-
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNativeToken &&
|
|
1148
|
+
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNativeToken && tokenPayFeeSlug === tokenSlug;
|
|
1149
|
+
const isCustomTokenPayFeeAssetHub = tokenPayFeeSlug && !_isNativeTokenBySlug(tokenPayFeeSlug) && _SUPPORT_TOKEN_PAY_FEE_GROUP.assetHub.includes(chain);
|
|
1150
|
+
const isCustomTokenPayFeeHydration = tokenPayFeeSlug && !_isNativeTokenBySlug(tokenPayFeeSlug) && _SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain);
|
|
1131
1151
|
const extrinsicType = isTransferNativeToken ? ExtrinsicType.TRANSFER_BALANCE : ExtrinsicType.TRANSFER_TOKEN;
|
|
1132
1152
|
let chainType = ChainType.SUBSTRATE;
|
|
1133
1153
|
const transferAmount = {
|
|
@@ -1193,9 +1213,23 @@ export default class KoniExtension {
|
|
|
1193
1213
|
// currently not used
|
|
1194
1214
|
tonApi
|
|
1195
1215
|
});
|
|
1216
|
+
} else if (isCardanoAddress(from) && isCardanoAddress(to) && _isTokenTransferredByCardano(transferTokenInfo)) {
|
|
1217
|
+
chainType = ChainType.CARDANO;
|
|
1218
|
+
const cardanoApi = this.#koniState.getCardanoApi(chain);
|
|
1219
|
+
[transaction, transferAmount.value] = await createCardanoTransaction({
|
|
1220
|
+
tokenInfo: transferTokenInfo,
|
|
1221
|
+
from,
|
|
1222
|
+
to,
|
|
1223
|
+
networkKey: chain,
|
|
1224
|
+
value: value || '0',
|
|
1225
|
+
cardanoTtlOffset: DEFAULT_CARDANO_TTL_OFFSET,
|
|
1226
|
+
transferAll: !!transferAll,
|
|
1227
|
+
cardanoApi,
|
|
1228
|
+
nativeTokenInfo
|
|
1229
|
+
});
|
|
1196
1230
|
} else {
|
|
1197
1231
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
1198
|
-
[transaction, transferAmount.value] = await
|
|
1232
|
+
[transaction, transferAmount.value] = await createSubstrateExtrinsic({
|
|
1199
1233
|
transferAll: !!transferAll,
|
|
1200
1234
|
value: value || '0',
|
|
1201
1235
|
from: from,
|
|
@@ -1204,6 +1238,13 @@ export default class KoniExtension {
|
|
|
1204
1238
|
to: to,
|
|
1205
1239
|
substrateApi
|
|
1206
1240
|
});
|
|
1241
|
+
if (_SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain)) {
|
|
1242
|
+
var _this$koniState$chain, _substrateApi$api$que;
|
|
1243
|
+
const hydrationFeeAssetId = tokenPayFeeSlug && ((_this$koniState$chain = this.#koniState.chainService.getAssetBySlug(tokenPayFeeSlug).metadata) === null || _this$koniState$chain === void 0 ? void 0 : _this$koniState$chain.assetId);
|
|
1244
|
+
const _feeSetting = await ((_substrateApi$api$que = substrateApi.api.query.multiTransactionPayment) === null || _substrateApi$api$que === void 0 ? void 0 : _substrateApi$api$que.accountCurrencyMap(from));
|
|
1245
|
+
const feeSetting = _feeSetting.toPrimitive();
|
|
1246
|
+
transaction = batchExtrinsicSetFeeHydration(substrateApi, transaction, feeSetting, hydrationFeeAssetId);
|
|
1247
|
+
}
|
|
1207
1248
|
}
|
|
1208
1249
|
} catch (e) {
|
|
1209
1250
|
const error = e;
|
|
@@ -1221,11 +1262,11 @@ export default class KoniExtension {
|
|
|
1221
1262
|
}
|
|
1222
1263
|
|
|
1223
1264
|
// Check enough free local to pay fee local
|
|
1224
|
-
if (
|
|
1225
|
-
var _inputTransaction$est;
|
|
1265
|
+
if (isCustomTokenPayFeeAssetHub || isCustomTokenPayFeeHydration) {
|
|
1266
|
+
var _inputTransaction$est, _nonNativeTokenPayFee;
|
|
1226
1267
|
const nonNativeFee = BigInt(((_inputTransaction$est = inputTransaction.estimateFee) === null || _inputTransaction$est === void 0 ? void 0 : _inputTransaction$est.value) || '0'); // todo: estimateFee should be must-have, need to refactor interface
|
|
1227
|
-
const nonNativeTokenPayFeeInfo = await this.#koniState.balanceService.getTokensHasBalance(reformatAddress(from), chain,
|
|
1228
|
-
const nonNativeTokenPayFeeBalance = BigInt(nonNativeTokenPayFeeInfo[
|
|
1268
|
+
const nonNativeTokenPayFeeInfo = await this.#koniState.balanceService.getTokensHasBalance(reformatAddress(from), chain, tokenPayFeeSlug);
|
|
1269
|
+
const nonNativeTokenPayFeeBalance = BigInt(((_nonNativeTokenPayFee = nonNativeTokenPayFeeInfo[tokenPayFeeSlug]) === null || _nonNativeTokenPayFee === void 0 ? void 0 : _nonNativeTokenPayFee.free) || '0');
|
|
1229
1270
|
if (nonNativeFee > nonNativeTokenPayFeeBalance) {
|
|
1230
1271
|
inputTransaction.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
1231
1272
|
}
|
|
@@ -1277,7 +1318,7 @@ export default class KoniExtension {
|
|
|
1277
1318
|
chain,
|
|
1278
1319
|
feeCustom,
|
|
1279
1320
|
feeOption,
|
|
1280
|
-
|
|
1321
|
+
tokenPayFeeSlug,
|
|
1281
1322
|
chainType,
|
|
1282
1323
|
transferNativeAmount,
|
|
1283
1324
|
transaction,
|
|
@@ -1297,9 +1338,9 @@ export default class KoniExtension {
|
|
|
1297
1338
|
feeOption,
|
|
1298
1339
|
from,
|
|
1299
1340
|
isPassConfirmation,
|
|
1300
|
-
nonNativeTokenPayFeeSlug,
|
|
1301
1341
|
originNetworkKey,
|
|
1302
1342
|
to,
|
|
1343
|
+
tokenPayFeeSlug,
|
|
1303
1344
|
tokenSlug,
|
|
1304
1345
|
transferAll,
|
|
1305
1346
|
transferBounceable,
|
|
@@ -1319,7 +1360,7 @@ export default class KoniExtension {
|
|
|
1319
1360
|
const isPolygonBridgeTransfer = _isPolygonChainBridge(originNetworkKey, destinationNetworkKey);
|
|
1320
1361
|
const isPosBridgeTransfer = _isPosChainBridge(originNetworkKey, destinationNetworkKey);
|
|
1321
1362
|
const isTransferNative = this.#koniState.getNativeTokenInfo(originNetworkKey).slug === tokenSlug;
|
|
1322
|
-
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNative && tokenSlug ===
|
|
1363
|
+
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNative && tokenSlug === tokenPayFeeSlug;
|
|
1323
1364
|
let additionalValidator;
|
|
1324
1365
|
let eventsHandler;
|
|
1325
1366
|
if (fromKeyPair && destinationTokenInfo) {
|
|
@@ -1359,6 +1400,14 @@ export default class KoniExtension {
|
|
|
1359
1400
|
feeInfo
|
|
1360
1401
|
};
|
|
1361
1402
|
extrinsic = await funcCreateExtrinsic(params);
|
|
1403
|
+
if (_SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(originNetworkKey)) {
|
|
1404
|
+
var _this$koniState$chain2, _substrateApi$api$que2;
|
|
1405
|
+
const hydrationFeeAssetId = tokenPayFeeSlug && ((_this$koniState$chain2 = this.#koniState.chainService.getAssetBySlug(tokenPayFeeSlug).metadata) === null || _this$koniState$chain2 === void 0 ? void 0 : _this$koniState$chain2.assetId);
|
|
1406
|
+
const _feeSetting = await ((_substrateApi$api$que2 = substrateApi.api.query.multiTransactionPayment) === null || _substrateApi$api$que2 === void 0 ? void 0 : _substrateApi$api$que2.accountCurrencyMap(from));
|
|
1407
|
+
const feeSetting = _feeSetting.toPrimitive();
|
|
1408
|
+
const _extrinsic = extrinsic;
|
|
1409
|
+
extrinsic = batchExtrinsicSetFeeHydration(substrateApi, _extrinsic, feeSetting, hydrationFeeAssetId);
|
|
1410
|
+
}
|
|
1362
1411
|
additionalValidator = async inputTransaction => {
|
|
1363
1412
|
const {
|
|
1364
1413
|
value: senderTransferable
|
|
@@ -1417,7 +1466,7 @@ export default class KoniExtension {
|
|
|
1417
1466
|
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm && !isPolygonBridgeTransfer && !isPosBridgeTransfer ? ChainType.SUBSTRATE : ChainType.EVM,
|
|
1418
1467
|
transferNativeAmount: _isNativeToken(originTokenInfo) ? value : '0',
|
|
1419
1468
|
ignoreWarnings,
|
|
1420
|
-
|
|
1469
|
+
tokenPayFeeSlug,
|
|
1421
1470
|
isTransferAll: transferAll,
|
|
1422
1471
|
isTransferLocalTokenAndPayThatTokenAsFee,
|
|
1423
1472
|
isPassConfirmation,
|
|
@@ -1436,48 +1485,51 @@ export default class KoniExtension {
|
|
|
1436
1485
|
const chainService = this.#koniState.chainService;
|
|
1437
1486
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
1438
1487
|
const address = reformatAddress(_address);
|
|
1439
|
-
|
|
1440
|
-
// ensure nativeTokenInfo and localTokenInfo have multi-location metadata beforehand to improve performance.
|
|
1441
1488
|
const tokensHasBalanceInfoMap = await this.#koniState.balanceService.getTokensHasBalance(address, chain);
|
|
1442
|
-
const tokensHasBalanceSlug = Object.keys(tokensHasBalanceInfoMap);
|
|
1443
|
-
const tokenInfos = tokensHasBalanceSlug.map(tokenSlug => chainService.getAssetBySlug(tokenSlug)).filter(token => token.originChain === chain && token.assetType !== _AssetType.NATIVE && token.metadata && token.metadata.multilocation);
|
|
1444
1489
|
const nativeTokenInfo = chainService.getNativeTokenInfo(chain);
|
|
1445
|
-
const
|
|
1490
|
+
const nativeBalanceInfo = {
|
|
1446
1491
|
slug: nativeTokenInfo.slug,
|
|
1447
1492
|
free: ((_tokensHasBalanceInfo = tokensHasBalanceInfoMap[nativeTokenInfo.slug]) === null || _tokensHasBalanceInfo === void 0 ? void 0 : _tokensHasBalanceInfo.free) || '0',
|
|
1448
1493
|
rate: '1'
|
|
1449
1494
|
};
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
} else {
|
|
1470
|
-
const amount = estimateTokensForPool(feeAmount, reserve);
|
|
1471
|
-
const liquidityError = checkLiquidityForPool(amount, reserve[0], reserve[1]);
|
|
1472
|
-
if (!liquidityError) {
|
|
1473
|
-
tokensCanPayFee.push(tokenCanPayFee);
|
|
1474
|
-
}
|
|
1495
|
+
let tokensCanPayFee = [nativeBalanceInfo];
|
|
1496
|
+
let defaultTokenSlug = nativeBalanceInfo.slug;
|
|
1497
|
+
if (_SUPPORT_TOKEN_PAY_FEE_GROUP.assetHub.includes(chain)) {
|
|
1498
|
+
tokensCanPayFee = await getAssetHubTokensCanPayFee({
|
|
1499
|
+
substrateApi,
|
|
1500
|
+
chainService,
|
|
1501
|
+
nativeTokenInfo,
|
|
1502
|
+
nativeBalanceInfo,
|
|
1503
|
+
tokensHasBalanceInfoMap,
|
|
1504
|
+
feeAmount
|
|
1505
|
+
});
|
|
1506
|
+
} else if (_SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain)) {
|
|
1507
|
+
const _assetId = await substrateApi.api.query.multiTransactionPayment.accountCurrencyMap(address);
|
|
1508
|
+
const assetId = _assetId.toPrimitive();
|
|
1509
|
+
const hydrationAssets = this.#koniState.chainService.getHydrationAssetIdMap(chain);
|
|
1510
|
+
for (const [key, value] of Object.entries(hydrationAssets)) {
|
|
1511
|
+
if (assetId && assetId.toString() === value) {
|
|
1512
|
+
defaultTokenSlug = key;
|
|
1513
|
+
break;
|
|
1475
1514
|
}
|
|
1476
|
-
} catch (e) {
|
|
1477
|
-
console.error('error when fetching pool with token', tokenInfo.slug, e);
|
|
1478
1515
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1516
|
+
tokensCanPayFee = await getHydrationTokensCanPayFee({
|
|
1517
|
+
substrateApi,
|
|
1518
|
+
chainService,
|
|
1519
|
+
nativeTokenInfo,
|
|
1520
|
+
nativeBalanceInfo,
|
|
1521
|
+
tokensHasBalanceInfoMap,
|
|
1522
|
+
address,
|
|
1523
|
+
feeAmount
|
|
1524
|
+
});
|
|
1525
|
+
if (!tokensCanPayFee.map(token => token.slug).includes(defaultTokenSlug)) {
|
|
1526
|
+
defaultTokenSlug = nativeBalanceInfo.slug;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
return {
|
|
1530
|
+
tokensCanPayFee,
|
|
1531
|
+
defaultTokenSlug
|
|
1532
|
+
};
|
|
1481
1533
|
}
|
|
1482
1534
|
async getAmountForPair(request) {
|
|
1483
1535
|
const {
|
|
@@ -1674,13 +1726,13 @@ export default class KoniExtension {
|
|
|
1674
1726
|
destChain: _destChain,
|
|
1675
1727
|
feeCustom,
|
|
1676
1728
|
feeOption,
|
|
1677
|
-
|
|
1678
|
-
|
|
1729
|
+
token,
|
|
1730
|
+
tokenPayFeeSlug
|
|
1679
1731
|
} = request;
|
|
1680
1732
|
const cb = createSubscription(id, port);
|
|
1681
1733
|
const transferTokenInfo = this.#koniState.chainService.getAssetBySlug(token);
|
|
1682
|
-
const isTransferLocalTokenAndPayThatTokenAsFee = !_isNativeToken(transferTokenInfo) && !!
|
|
1683
|
-
const isTransferNativeTokenAndPayLocalTokenAsFee = _isNativeToken(transferTokenInfo) && !!
|
|
1734
|
+
const isTransferLocalTokenAndPayThatTokenAsFee = !_isNativeToken(transferTokenInfo) && !!tokenPayFeeSlug && tokenPayFeeSlug === token;
|
|
1735
|
+
const isTransferNativeTokenAndPayLocalTokenAsFee = _isNativeToken(transferTokenInfo) && !!tokenPayFeeSlug && !_isNativeTokenBySlug(tokenPayFeeSlug);
|
|
1684
1736
|
const srcToken = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(chain);
|
|
1685
1737
|
const destToken = _destChain !== chain ? this.#koniState.getXcmEqualAssetByChain(_destChain, srcToken.slug) : srcToken;
|
|
1686
1738
|
const srcChain = this.#koniState.chainService.getChainInfoByKey(chain);
|
|
@@ -1695,6 +1747,7 @@ export default class KoniExtension {
|
|
|
1695
1747
|
}
|
|
1696
1748
|
const _request = {
|
|
1697
1749
|
address: address,
|
|
1750
|
+
cardanoApi: this.#koniState.chainService.getCardanoApi(chain),
|
|
1698
1751
|
destChain,
|
|
1699
1752
|
destToken,
|
|
1700
1753
|
evmApi: this.#koniState.chainService.getEvmApi(chain),
|
|
@@ -1892,12 +1945,24 @@ export default class KoniExtension {
|
|
|
1892
1945
|
});
|
|
1893
1946
|
return this.#koniState.getConfirmationsQueueSubjectTon().getValue();
|
|
1894
1947
|
}
|
|
1948
|
+
subscribeConfirmationsCardano(id, port) {
|
|
1949
|
+
const cb = createSubscription(id, port);
|
|
1950
|
+
const subscription = this.#koniState.getConfirmationsQueueSubjectCardano().subscribe(cb);
|
|
1951
|
+
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
1952
|
+
port.onDisconnect.addListener(() => {
|
|
1953
|
+
this.cancelSubscription(id);
|
|
1954
|
+
});
|
|
1955
|
+
return this.#koniState.getConfirmationsQueueSubjectCardano().getValue();
|
|
1956
|
+
}
|
|
1895
1957
|
async completeConfirmation(request) {
|
|
1896
1958
|
return await this.#koniState.completeConfirmation(request);
|
|
1897
1959
|
}
|
|
1898
1960
|
async completeConfirmationTon(request) {
|
|
1899
1961
|
return await this.#koniState.completeConfirmationTon(request);
|
|
1900
1962
|
}
|
|
1963
|
+
async completeConfirmationCardano(request) {
|
|
1964
|
+
return await this.#koniState.completeConfirmationCardano(request);
|
|
1965
|
+
}
|
|
1901
1966
|
|
|
1902
1967
|
/// Sign Qr
|
|
1903
1968
|
|
|
@@ -2860,7 +2925,7 @@ export default class KoniExtension {
|
|
|
2860
2925
|
return new Promise(resolve => setTimeout(resolve, 1500));
|
|
2861
2926
|
}
|
|
2862
2927
|
try {
|
|
2863
|
-
var _this$koniState$
|
|
2928
|
+
var _this$koniState$chain3, _this$koniState$chain4;
|
|
2864
2929
|
await this.#koniState.chainService.enableChain(_DEFAULT_MANTA_ZK_CHAIN);
|
|
2865
2930
|
this.#koniState.chainService.setMantaZkAssetSettings(true);
|
|
2866
2931
|
const mnemonic = this.keyringExportMnemonic({
|
|
@@ -2879,7 +2944,7 @@ export default class KoniExtension {
|
|
|
2879
2944
|
await this.saveCurrentAccountProxy({
|
|
2880
2945
|
address
|
|
2881
2946
|
});
|
|
2882
|
-
const unsubSyncProgress = await ((_this$koniState$
|
|
2947
|
+
const unsubSyncProgress = await ((_this$koniState$chain3 = this.#koniState.chainService) === null || _this$koniState$chain3 === void 0 ? void 0 : (_this$koniState$chain4 = _this$koniState$chain3.mantaPay) === null || _this$koniState$chain4 === void 0 ? void 0 : _this$koniState$chain4.subscribeSyncProgress());
|
|
2883
2948
|
console.debug('Start initial sync for MantaPay');
|
|
2884
2949
|
this.#koniState.initialSyncMantaPay(address).then(() => {
|
|
2885
2950
|
console.debug('Finished initial sync for MantaPay');
|
|
@@ -2910,32 +2975,32 @@ export default class KoniExtension {
|
|
|
2910
2975
|
}
|
|
2911
2976
|
}
|
|
2912
2977
|
async initSyncMantaPay(address) {
|
|
2913
|
-
var _this$koniState$
|
|
2914
|
-
if ((_this$koniState$
|
|
2978
|
+
var _this$koniState$chain5, _this$koniState$chain6, _this$koniState$chain7, _this$koniState$chain8;
|
|
2979
|
+
if ((_this$koniState$chain5 = this.#koniState.chainService) !== null && _this$koniState$chain5 !== void 0 && (_this$koniState$chain6 = _this$koniState$chain5.mantaPay) !== null && _this$koniState$chain6 !== void 0 && _this$koniState$chain6.getSyncState().isSyncing || !MODULE_SUPPORT.MANTA_ZK) {
|
|
2915
2980
|
return;
|
|
2916
2981
|
}
|
|
2917
2982
|
this.#skipAutoLock = true;
|
|
2918
2983
|
await this.saveCurrentAccountProxy({
|
|
2919
2984
|
address
|
|
2920
2985
|
});
|
|
2921
|
-
const unsubSyncProgress = await ((_this$koniState$
|
|
2986
|
+
const unsubSyncProgress = await ((_this$koniState$chain7 = this.#koniState.chainService) === null || _this$koniState$chain7 === void 0 ? void 0 : (_this$koniState$chain8 = _this$koniState$chain7.mantaPay) === null || _this$koniState$chain8 === void 0 ? void 0 : _this$koniState$chain8.subscribeSyncProgress());
|
|
2922
2987
|
console.debug('Start initial sync for MantaPay');
|
|
2923
2988
|
this.#koniState.initialSyncMantaPay(address).then(() => {
|
|
2924
|
-
var _this$koniState$
|
|
2989
|
+
var _this$koniState$chain9, _this$koniState$chain10;
|
|
2925
2990
|
console.debug('Finished initial sync for MantaPay');
|
|
2926
2991
|
this.#skipAutoLock = false;
|
|
2927
2992
|
unsubSyncProgress && unsubSyncProgress();
|
|
2928
2993
|
// make sure the sync state is set, just in case it gets unsubscribed
|
|
2929
|
-
(_this$koniState$
|
|
2994
|
+
(_this$koniState$chain9 = this.#koniState.chainService) === null || _this$koniState$chain9 === void 0 ? void 0 : (_this$koniState$chain10 = _this$koniState$chain9.mantaPay) === null || _this$koniState$chain10 === void 0 ? void 0 : _this$koniState$chain10.setSyncState({
|
|
2930
2995
|
progress: 100,
|
|
2931
2996
|
isSyncing: false
|
|
2932
2997
|
});
|
|
2933
2998
|
}).catch(e => {
|
|
2934
|
-
var _this$koniState$
|
|
2999
|
+
var _this$koniState$chain11, _this$koniState$chain12;
|
|
2935
3000
|
console.error('Error syncing MantaPay', e);
|
|
2936
3001
|
this.#skipAutoLock = false;
|
|
2937
3002
|
unsubSyncProgress && unsubSyncProgress();
|
|
2938
|
-
(_this$koniState$
|
|
3003
|
+
(_this$koniState$chain11 = this.#koniState.chainService) === null || _this$koniState$chain11 === void 0 ? void 0 : (_this$koniState$chain12 = _this$koniState$chain11.mantaPay) === null || _this$koniState$chain12 === void 0 ? void 0 : _this$koniState$chain12.setSyncState({
|
|
2939
3004
|
progress: 0,
|
|
2940
3005
|
isSyncing: false
|
|
2941
3006
|
});
|
|
@@ -2973,7 +3038,7 @@ export default class KoniExtension {
|
|
|
2973
3038
|
return this.#koniState.getMantaPayConfig('calamari');
|
|
2974
3039
|
}
|
|
2975
3040
|
subscribeMantaPaySyncState(id, port) {
|
|
2976
|
-
var _this$koniState$subsc, _this$koniState$
|
|
3041
|
+
var _this$koniState$subsc, _this$koniState$chain13, _this$koniState$chain14;
|
|
2977
3042
|
const cb = createSubscription(id, port);
|
|
2978
3043
|
const syncingStateSubscription = (_this$koniState$subsc = this.#koniState.subscribeMantaPaySyncState()) === null || _this$koniState$subsc === void 0 ? void 0 : _this$koniState$subsc.subscribe({
|
|
2979
3044
|
next: rs => {
|
|
@@ -2984,7 +3049,7 @@ export default class KoniExtension {
|
|
|
2984
3049
|
port.onDisconnect.addListener(() => {
|
|
2985
3050
|
this.cancelSubscription(id);
|
|
2986
3051
|
});
|
|
2987
|
-
return ((_this$koniState$
|
|
3052
|
+
return ((_this$koniState$chain13 = this.#koniState.chainService) === null || _this$koniState$chain13 === void 0 ? void 0 : (_this$koniState$chain14 = _this$koniState$chain13.mantaPay) === null || _this$koniState$chain14 === void 0 ? void 0 : _this$koniState$chain14.getSyncState()) || {
|
|
2988
3053
|
isSyncing: false,
|
|
2989
3054
|
progress: 0,
|
|
2990
3055
|
needManualSync: false
|
|
@@ -3109,6 +3174,17 @@ export default class KoniExtension {
|
|
|
3109
3174
|
}
|
|
3110
3175
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(yieldValidation);
|
|
3111
3176
|
}
|
|
3177
|
+
let submitData;
|
|
3178
|
+
try {
|
|
3179
|
+
submitData = await this.#koniState.earningService.handleYieldJoin(inputData);
|
|
3180
|
+
} catch (e) {
|
|
3181
|
+
if (step) {
|
|
3182
|
+
this.#koniState.transactionService.updateProcessStepStatus(step, {
|
|
3183
|
+
status: StepStatus.FAILED
|
|
3184
|
+
});
|
|
3185
|
+
}
|
|
3186
|
+
throw e;
|
|
3187
|
+
}
|
|
3112
3188
|
|
|
3113
3189
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3114
3190
|
const {
|
|
@@ -3118,7 +3194,7 @@ export default class KoniExtension {
|
|
|
3118
3194
|
transferNativeAmount,
|
|
3119
3195
|
txChain,
|
|
3120
3196
|
txData
|
|
3121
|
-
} =
|
|
3197
|
+
} = submitData;
|
|
3122
3198
|
const isPoolSupportAlternativeFee = this.#koniState.earningService.isPoolSupportAlternativeFee(inputData.data.slug);
|
|
3123
3199
|
const poolHandler = this.#koniState.earningService.getPoolHandler(data.slug);
|
|
3124
3200
|
const isMintingStep = YIELD_EXTRINSIC_TYPES.includes(extrinsicType);
|
|
@@ -3527,6 +3603,9 @@ export default class KoniExtension {
|
|
|
3527
3603
|
ready = true;
|
|
3528
3604
|
return this.#koniState.swapService.getSwapPairs();
|
|
3529
3605
|
}
|
|
3606
|
+
async generateOptimalProcess(request) {
|
|
3607
|
+
return this.#koniState.swapService.generateOptimalProcess(request);
|
|
3608
|
+
}
|
|
3530
3609
|
async handleSwapRequest(request) {
|
|
3531
3610
|
return this.#koniState.swapService.handleSwapRequest(request);
|
|
3532
3611
|
}
|
|
@@ -3578,16 +3657,29 @@ export default class KoniExtension {
|
|
|
3578
3657
|
}
|
|
3579
3658
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(swapValidations);
|
|
3580
3659
|
}
|
|
3660
|
+
let submitData;
|
|
3661
|
+
try {
|
|
3662
|
+
submitData = await this.#koniState.swapService.handleSwapProcess(inputData);
|
|
3663
|
+
} catch (e) {
|
|
3664
|
+
if (step) {
|
|
3665
|
+
this.#koniState.transactionService.updateProcessStepStatus(step, {
|
|
3666
|
+
status: StepStatus.FAILED
|
|
3667
|
+
});
|
|
3668
|
+
}
|
|
3669
|
+
throw e;
|
|
3670
|
+
}
|
|
3581
3671
|
|
|
3582
3672
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3583
3673
|
const {
|
|
3584
3674
|
chainType,
|
|
3585
3675
|
extrinsic,
|
|
3586
3676
|
extrinsicType,
|
|
3677
|
+
isPermit,
|
|
3587
3678
|
transferNativeAmount,
|
|
3588
3679
|
txChain,
|
|
3589
3680
|
txData
|
|
3590
|
-
} =
|
|
3681
|
+
} = submitData;
|
|
3682
|
+
|
|
3591
3683
|
// const chosenFeeToken = process.steps.findIndex((step) => step.type === SwapStepType.SET_FEE_TOKEN) > -1;
|
|
3592
3684
|
// const allowSkipValidation = [ExtrinsicType.SET_FEE_TOKEN, ExtrinsicType.SWAP].includes(extrinsicType);
|
|
3593
3685
|
|
|
@@ -3670,6 +3762,24 @@ export default class KoniExtension {
|
|
|
3670
3762
|
await this.#koniState.transactionService.updateProcessInfo(processId, combineInfo, step);
|
|
3671
3763
|
}
|
|
3672
3764
|
}
|
|
3765
|
+
if (isPermit) {
|
|
3766
|
+
return await this.#koniState.transactionService.handlePermitTransaction({
|
|
3767
|
+
address,
|
|
3768
|
+
chain: txChain,
|
|
3769
|
+
transaction: extrinsic,
|
|
3770
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3771
|
+
data: txData,
|
|
3772
|
+
extrinsicType,
|
|
3773
|
+
// change this depends on step
|
|
3774
|
+
chainType,
|
|
3775
|
+
resolveOnDone: !isLastStep,
|
|
3776
|
+
transferNativeAmount,
|
|
3777
|
+
...this.createPassConfirmationParams(isPassConfirmation),
|
|
3778
|
+
errorOnTimeOut,
|
|
3779
|
+
eventsHandler,
|
|
3780
|
+
step
|
|
3781
|
+
});
|
|
3782
|
+
}
|
|
3673
3783
|
return await this.#koniState.transactionService.handleTransaction({
|
|
3674
3784
|
address,
|
|
3675
3785
|
chain: txChain,
|
|
@@ -3887,7 +3997,8 @@ export default class KoniExtension {
|
|
|
3887
3997
|
const onSend = callback
|
|
3888
3998
|
// eslint-disable-next-line node/no-callback-literal
|
|
3889
3999
|
? rs => callback(rs) : undefined;
|
|
3890
|
-
|
|
4000
|
+
const specialCaseForUniswap = data.quote.provider.id === SwapProviderId.UNISWAP && !!data.process.steps.find(step => step.type === SwapStepType.PERMIT);
|
|
4001
|
+
if (stepNums > 2 && isLastStep && !specialCaseForUniswap) {
|
|
3891
4002
|
const quote = data.quote;
|
|
3892
4003
|
const latestSwapQuote = await this.getLatestSwapQuote({
|
|
3893
4004
|
address: data.address,
|
|
@@ -4013,6 +4124,32 @@ export default class KoniExtension {
|
|
|
4013
4124
|
|
|
4014
4125
|
/* Multi process */
|
|
4015
4126
|
|
|
4127
|
+
/* Migrate Unified Account */
|
|
4128
|
+
async migrateUnifiedAndFetchEligibleSoloAccounts(request) {
|
|
4129
|
+
const setMigratingMode = () => {
|
|
4130
|
+
this.saveUnifiedAccountMigrationInProgress({
|
|
4131
|
+
isUnifiedAccountMigrationInProgress: true
|
|
4132
|
+
});
|
|
4133
|
+
};
|
|
4134
|
+
return await this.#koniState.keyringService.context.migrateUnifiedAndFetchEligibleSoloAccounts(request, setMigratingMode);
|
|
4135
|
+
}
|
|
4136
|
+
migrateSoloAccount(request) {
|
|
4137
|
+
const proxyIds = request.soloAccounts.map(account => account.proxyId);
|
|
4138
|
+
const response = this.#koniState.keyringService.context.migrateSoloAccount(request);
|
|
4139
|
+
const newProxyId = response.migratedUnifiedAccountId; // get from response to ensure account migration is done.
|
|
4140
|
+
const newName = request.accountName;
|
|
4141
|
+
try {
|
|
4142
|
+
this.#koniState.inappNotificationService.migrateNotificationProxyId(proxyIds, newProxyId, newName);
|
|
4143
|
+
} catch (error) {
|
|
4144
|
+
console.error('Error on migrating notification for unified account migration', error);
|
|
4145
|
+
}
|
|
4146
|
+
return response;
|
|
4147
|
+
}
|
|
4148
|
+
pingSession(request) {
|
|
4149
|
+
return this.#koniState.keyringService.context.pingSession(request);
|
|
4150
|
+
}
|
|
4151
|
+
/* Migrate Unified Account */
|
|
4152
|
+
|
|
4016
4153
|
// --------------------------------------------------------------
|
|
4017
4154
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
4018
4155
|
async handle(id, type, request, port) {
|
|
@@ -4098,6 +4235,12 @@ export default class KoniExtension {
|
|
|
4098
4235
|
return this.setEnableChainPatrol(request);
|
|
4099
4236
|
case 'pri(settings.saveNotificationSetup)':
|
|
4100
4237
|
return this.saveNotificationSetup(request);
|
|
4238
|
+
case 'pri(settings.saveMigrationAcknowledgedStatus)':
|
|
4239
|
+
return this.saveMigrationAcknowledgedStatus(request);
|
|
4240
|
+
case 'pri(settings.saveUnifiedAccountMigrationInProgress)':
|
|
4241
|
+
return this.saveUnifiedAccountMigrationInProgress(request);
|
|
4242
|
+
case 'pri(settings.pingUnifiedAccountMigrationDone)':
|
|
4243
|
+
return this.pingUnifiedAccountMigrationDone();
|
|
4101
4244
|
case 'pri(settings.saveShowZeroBalance)':
|
|
4102
4245
|
return this.setShowZeroBalance(request);
|
|
4103
4246
|
case 'pri(settings.saveLanguage)':
|
|
@@ -4375,10 +4518,14 @@ export default class KoniExtension {
|
|
|
4375
4518
|
return this.subscribeConfirmations(id, port);
|
|
4376
4519
|
case 'pri(confirmationsTon.subscribe)':
|
|
4377
4520
|
return this.subscribeConfirmationsTon(id, port);
|
|
4521
|
+
case 'pri(confirmationsCardano.subscribe)':
|
|
4522
|
+
return this.subscribeConfirmationsCardano(id, port);
|
|
4378
4523
|
case 'pri(confirmations.complete)':
|
|
4379
4524
|
return await this.completeConfirmation(request);
|
|
4380
4525
|
case 'pri(confirmationsTon.complete)':
|
|
4381
4526
|
return await this.completeConfirmationTon(request);
|
|
4527
|
+
case 'pri(confirmationsCardano.complete)':
|
|
4528
|
+
return await this.completeConfirmationCardano(request);
|
|
4382
4529
|
|
|
4383
4530
|
/// Stake
|
|
4384
4531
|
case 'pri(bonding.getBondingOptions)':
|
|
@@ -4569,6 +4716,8 @@ export default class KoniExtension {
|
|
|
4569
4716
|
/* Swap service */
|
|
4570
4717
|
case 'pri(swapService.subscribePairs)':
|
|
4571
4718
|
return this.subscribeSwapPairs(id, port);
|
|
4719
|
+
case 'pri(swapService.generateOptimalProcess)':
|
|
4720
|
+
return this.generateOptimalProcess(request);
|
|
4572
4721
|
case 'pri(swapService.handleSwapRequest)':
|
|
4573
4722
|
return this.handleSwapRequest(request);
|
|
4574
4723
|
case 'pri(swapService.getLatestQuote)':
|
|
@@ -4623,6 +4772,13 @@ export default class KoniExtension {
|
|
|
4623
4772
|
return this.subscribeProcessAlive(id, port);
|
|
4624
4773
|
/* Multi process */
|
|
4625
4774
|
|
|
4775
|
+
/* Migrate Unified Account */
|
|
4776
|
+
case 'pri(migrate.migrateUnifiedAndFetchEligibleSoloAccounts)':
|
|
4777
|
+
return await this.migrateUnifiedAndFetchEligibleSoloAccounts(request);
|
|
4778
|
+
case 'pri(migrate.migrateSoloAccount)':
|
|
4779
|
+
return this.migrateSoloAccount(request);
|
|
4780
|
+
case 'pri(migrate.pingSession)':
|
|
4781
|
+
return this.pingSession(request);
|
|
4626
4782
|
// Default
|
|
4627
4783
|
default:
|
|
4628
4784
|
throw new Error(`Unable to handle message of type ${type}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="chrome" />
|
|
2
2
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
3
|
-
import { AddTokenRequestExternal, AmountData, ApiMap, AuthRequestV2, ChainStakingMetadata, ConfirmationsQueue, ConfirmationsQueueTon, CrowdloanItem, CrowdloanJson, EvmSendTransactionParams, ExternalRequestPromise, MantaPayConfig, MantaPaySyncState, NftCollection, NftItem, NftJson, NominatorMetadata, RequestAccountExportPrivateKey, RequestConfirmationComplete, RequestConfirmationCompleteTon, RequestCrowdloanContributions, RequestSettingsType, ResponseAccountExportPrivateKey, ServiceInfo, SingleModeJson, StakingItem, StakingJson, StakingRewardItem, StakingRewardJson, StakingType, UiSettings } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
+
import { AddTokenRequestExternal, AmountData, ApiMap, AuthRequestV2, ChainStakingMetadata, ConfirmationsQueue, ConfirmationsQueueCardano, ConfirmationsQueueTon, CrowdloanItem, CrowdloanJson, EvmSendTransactionParams, ExternalRequestPromise, MantaPayConfig, MantaPaySyncState, NftCollection, NftItem, NftJson, NominatorMetadata, RequestAccountExportPrivateKey, RequestConfirmationComplete, RequestConfirmationCompleteCardano, RequestConfirmationCompleteTon, RequestCrowdloanContributions, RequestSettingsType, ResponseAccountExportPrivateKey, ServiceInfo, SingleModeJson, StakingItem, StakingJson, StakingRewardItem, StakingRewardJson, StakingType, UiSettings } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
4
|
import { RequestAuthorizeTab, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, RequestSign, ResponseRpcListProviders, ResponseSigning } from '@subwallet/extension-base/background/types';
|
|
5
5
|
import { EnvConfig } from '@subwallet/extension-base/constants';
|
|
6
6
|
import { BalanceService } from '@subwallet/extension-base/services/balance-service';
|
|
@@ -83,7 +83,7 @@ export default class KoniState {
|
|
|
83
83
|
private waitStarting;
|
|
84
84
|
constructor(providers?: Providers);
|
|
85
85
|
get knownMetadata(): MetadataDef[];
|
|
86
|
-
injectMetadata(
|
|
86
|
+
injectMetadata(request: MetadataDef): boolean;
|
|
87
87
|
getMetaRequest(id: string): MetaRequest;
|
|
88
88
|
getSignRequest(id: string): SignRequest | undefined;
|
|
89
89
|
rpcListProviders(): Promise<ResponseRpcListProviders>;
|
|
@@ -192,6 +192,8 @@ export default class KoniState {
|
|
|
192
192
|
getEvmApi(networkKey: string): import("../../../services/chain-service/handler/EvmApi").EvmApi;
|
|
193
193
|
getTonApiMap(): Record<string, import("../../../services/chain-service/handler/TonApi").TonApi>;
|
|
194
194
|
getTonApi(networkKey: string): import("../../../services/chain-service/handler/TonApi").TonApi;
|
|
195
|
+
getCardanoApiMap(): Record<string, import("../../../services/chain-service/handler/CardanoApi").CardanoApi>;
|
|
196
|
+
getCardanoApi(networkKey: string): import("../../../services/chain-service/handler/CardanoApi").CardanoApi;
|
|
195
197
|
getApiMap(): ApiMap;
|
|
196
198
|
refreshSubstrateApi(key: string): boolean;
|
|
197
199
|
refreshWeb3Api(key: string): void;
|
|
@@ -215,8 +217,10 @@ export default class KoniState {
|
|
|
215
217
|
evmSendTransaction(id: string, url: string, transactionParams: EvmSendTransactionParams, networkKeyInit?: string, topic?: string): Promise<string | undefined>;
|
|
216
218
|
getConfirmationsQueueSubject(): BehaviorSubject<ConfirmationsQueue>;
|
|
217
219
|
getConfirmationsQueueSubjectTon(): BehaviorSubject<ConfirmationsQueueTon>;
|
|
220
|
+
getConfirmationsQueueSubjectCardano(): BehaviorSubject<ConfirmationsQueueCardano>;
|
|
218
221
|
completeConfirmation(request: RequestConfirmationComplete): Promise<boolean>;
|
|
219
222
|
completeConfirmationTon(request: RequestConfirmationCompleteTon): Promise<boolean>;
|
|
223
|
+
completeConfirmationCardano(request: RequestConfirmationCompleteCardano): Promise<boolean>;
|
|
220
224
|
private onMV3Update;
|
|
221
225
|
private storePreviousVersionData;
|
|
222
226
|
migrateMV3LocalStorage(data: string): Promise<boolean>;
|