@subwallet/extension-base 1.3.22-0 → 1.3.23-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +75 -2
- package/background/KoniTypes.js +2 -0
- package/cjs/background/KoniTypes.js +2 -0
- package/cjs/constants/environment.js +4 -2
- package/cjs/constants/signing.js +6 -2
- package/cjs/core/logic-validation/recipientAddress.js +9 -1
- package/cjs/core/logic-validation/transfer.js +35 -29
- package/cjs/core/types.js +1 -0
- package/cjs/core/utils.js +12 -1
- package/cjs/defaults.js +1 -1
- package/cjs/koni/api/dotsama/crowdloan.js +1 -1
- package/cjs/koni/api/nft/index.js +9 -16
- package/cjs/koni/api/staking/index.js +3 -4
- package/cjs/koni/background/handlers/Extension.js +234 -96
- package/cjs/koni/background/handlers/State.js +15 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/cardano/consts.js +11 -0
- package/cjs/services/balance-service/helpers/subscribe/cardano/index.js +63 -0
- package/cjs/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
- package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +74 -0
- package/cjs/services/balance-service/helpers/subscribe/index.js +21 -7
- package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +2 -2
- package/cjs/services/balance-service/index.js +4 -2
- package/cjs/services/balance-service/transfer/cardano-transfer.js +122 -0
- package/cjs/services/balance-service/transfer/token.js +4 -4
- package/cjs/services/chain-service/handler/CardanoApi.js +176 -0
- package/cjs/services/chain-service/handler/CardanoChainHandler.js +83 -0
- package/cjs/services/chain-service/handler/TonApi.js +2 -5
- package/cjs/services/chain-service/index.js +29 -7
- package/cjs/services/chain-service/utils/index.js +40 -11
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
- package/cjs/services/earning-service/service.js +6 -12
- package/cjs/services/fee-service/service.js +19 -8
- package/cjs/services/history-service/index.js +4 -6
- package/cjs/services/inapp-notification-service/index.js +12 -4
- package/cjs/services/keyring-service/context/account-context.js +17 -2
- package/cjs/services/keyring-service/context/handlers/Derive.js +10 -7
- package/cjs/services/keyring-service/context/handlers/Migration.js +268 -0
- package/cjs/services/keyring-service/context/handlers/Mnemonic.js +2 -2
- package/cjs/services/keyring-service/context/handlers/Secret.js +1 -1
- package/cjs/services/keyring-service/utils.js +18 -0
- package/cjs/services/request-service/handler/CardanoRequestHandler.js +172 -0
- package/cjs/services/request-service/handler/EvmRequestHandler.js +1 -1
- package/cjs/services/request-service/index.js +20 -2
- package/cjs/services/setting-service/constants.js +10 -1
- package/cjs/services/storage-service/DatabaseService.js +3 -0
- package/cjs/services/storage-service/db-stores/InappNotification.js +6 -0
- package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -59
- package/cjs/services/swap-service/handler/chainflip-handler.js +33 -281
- package/cjs/services/swap-service/handler/hydradx-handler.js +23 -190
- package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -222
- package/cjs/services/swap-service/handler/uniswap-handler.js +331 -0
- package/cjs/services/swap-service/index.js +31 -22
- package/cjs/services/swap-service/utils.js +21 -38
- package/cjs/services/transaction-service/helpers/index.js +6 -1
- package/cjs/services/transaction-service/index.js +278 -21
- package/cjs/services/transaction-service/utils.js +5 -1
- package/cjs/types/account/info/keyring.js +12 -1
- package/cjs/types/fee/cardano.js +1 -0
- package/cjs/types/swap/index.js +7 -2
- package/cjs/utils/account/analyze.js +2 -1
- package/cjs/utils/account/common.js +29 -20
- package/cjs/utils/account/derive/info/solo.js +9 -4
- package/cjs/utils/account/derive/validate.js +36 -2
- package/cjs/utils/account/transform.js +38 -13
- package/cjs/utils/fee/transfer.js +40 -7
- package/cjs/utils/index.js +2 -2
- package/cjs/utils/staticData/index.js +7 -2
- package/constants/environment.d.ts +1 -0
- package/constants/environment.js +2 -1
- package/constants/signing.js +6 -2
- package/core/logic-validation/recipientAddress.js +11 -3
- package/core/logic-validation/transfer.js +9 -3
- package/core/substrate/xcm-parser.d.ts +1 -1
- package/core/types.d.ts +1 -0
- package/core/types.js +1 -0
- package/core/utils.d.ts +1 -0
- package/core/utils.js +13 -3
- package/defaults.d.ts +1 -1
- package/defaults.js +1 -1
- package/koni/api/dotsama/crowdloan.js +3 -3
- package/koni/api/nft/index.js +10 -16
- package/koni/api/nft/story_odyssey_nft/index.d.ts +1 -1
- package/koni/api/staking/index.js +4 -5
- package/koni/background/handlers/Extension.d.ts +9 -0
- package/koni/background/handlers/Extension.js +144 -8
- package/koni/background/handlers/State.d.ts +5 -1
- package/koni/background/handlers/State.js +16 -1
- package/package.json +71 -9
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/cardano/consts.d.ts +1 -0
- package/services/balance-service/helpers/subscribe/cardano/consts.js +4 -0
- package/services/balance-service/helpers/subscribe/cardano/index.d.ts +2 -0
- package/services/balance-service/helpers/subscribe/cardano/index.js +57 -0
- package/services/balance-service/helpers/subscribe/cardano/types.d.ts +34 -0
- package/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
- package/services/balance-service/helpers/subscribe/cardano/utils.d.ts +15 -0
- package/services/balance-service/helpers/subscribe/cardano/utils.js +62 -0
- package/services/balance-service/helpers/subscribe/index.d.ts +2 -2
- package/services/balance-service/helpers/subscribe/index.js +23 -9
- package/services/balance-service/helpers/subscribe/ton/utils.d.ts +1 -1
- package/services/balance-service/helpers/subscribe/ton/utils.js +1 -1
- package/services/balance-service/index.js +4 -2
- package/services/balance-service/transfer/cardano-transfer.d.ts +24 -0
- package/services/balance-service/transfer/cardano-transfer.js +114 -0
- package/services/balance-service/transfer/token.d.ts +1 -1
- package/services/balance-service/transfer/token.js +2 -2
- package/services/chain-service/handler/CardanoApi.d.ts +38 -0
- package/services/chain-service/handler/CardanoApi.js +167 -0
- package/services/chain-service/handler/CardanoChainHandler.d.ts +17 -0
- package/services/chain-service/handler/CardanoChainHandler.js +75 -0
- package/services/chain-service/handler/TonApi.js +3 -6
- package/services/chain-service/handler/types.d.ts +1 -0
- package/services/chain-service/index.d.ts +3 -1
- package/services/chain-service/index.js +29 -7
- package/services/chain-service/types.d.ts +9 -1
- package/services/chain-service/utils/index.d.ts +4 -0
- package/services/chain-service/utils/index.js +32 -11
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
- package/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
- package/services/earning-service/service.js +8 -14
- package/services/fee-service/service.js +19 -8
- package/services/history-service/index.js +6 -8
- package/services/inapp-notification-service/index.d.ts +3 -4
- package/services/inapp-notification-service/index.js +14 -6
- package/services/keyring-service/context/account-context.d.ts +6 -2
- package/services/keyring-service/context/account-context.js +17 -2
- package/services/keyring-service/context/handlers/Derive.d.ts +1 -1
- package/services/keyring-service/context/handlers/Derive.js +10 -8
- package/services/keyring-service/context/handlers/Migration.d.ts +17 -0
- package/services/keyring-service/context/handlers/Migration.js +258 -0
- package/services/keyring-service/context/handlers/Mnemonic.js +2 -2
- package/services/keyring-service/context/handlers/Secret.js +2 -2
- package/services/keyring-service/utils.d.ts +2 -0
- package/services/keyring-service/utils.js +11 -0
- package/services/request-service/handler/CardanoRequestHandler.d.ts +16 -0
- package/services/request-service/handler/CardanoRequestHandler.js +163 -0
- package/services/request-service/handler/EvmRequestHandler.js +1 -1
- package/services/request-service/index.d.ts +6 -3
- package/services/request-service/index.js +19 -5
- package/services/setting-service/constants.d.ts +3 -0
- package/services/setting-service/constants.js +6 -0
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +3 -0
- package/services/storage-service/db-stores/InappNotification.d.ts +1 -0
- package/services/storage-service/db-stores/InappNotification.js +6 -0
- package/services/swap-service/handler/asset-hub/handler.d.ts +1 -4
- package/services/swap-service/handler/asset-hub/handler.js +2 -61
- package/services/swap-service/handler/base-handler.d.ts +1 -4
- package/services/swap-service/handler/chainflip-handler.d.ts +2 -9
- package/services/swap-service/handler/chainflip-handler.js +31 -280
- package/services/swap-service/handler/hydradx-handler.d.ts +1 -6
- package/services/swap-service/handler/hydradx-handler.js +13 -180
- package/services/swap-service/handler/simpleswap-handler.d.ts +1 -4
- package/services/swap-service/handler/simpleswap-handler.js +5 -226
- package/services/swap-service/handler/uniswap-handler.d.ts +41 -0
- package/services/swap-service/handler/uniswap-handler.js +323 -0
- package/services/swap-service/index.js +30 -22
- package/services/swap-service/utils.d.ts +1 -5
- package/services/swap-service/utils.js +7 -21
- package/services/transaction-service/helpers/index.d.ts +2 -0
- package/services/transaction-service/helpers/index.js +4 -0
- package/services/transaction-service/index.d.ts +8 -2
- package/services/transaction-service/index.js +263 -10
- package/services/transaction-service/types.d.ts +7 -0
- package/services/transaction-service/utils.js +7 -2
- package/types/account/info/keyring.d.ts +4 -1
- package/types/account/info/keyring.js +9 -0
- package/types/account/info/proxy.d.ts +2 -0
- package/types/balance/index.d.ts +4 -1
- package/types/fee/base.d.ts +1 -1
- package/types/fee/cardano.d.ts +18 -0
- package/types/fee/cardano.js +1 -0
- package/types/fee/subscription.d.ts +4 -3
- package/types/swap/index.d.ts +11 -3
- package/types/swap/index.js +7 -2
- package/utils/account/analyze.js +2 -1
- package/utils/account/common.d.ts +11 -6
- package/utils/account/common.js +28 -19
- package/utils/account/derive/info/solo.js +10 -5
- package/utils/account/derive/validate.d.ts +1 -0
- package/utils/account/derive/validate.js +34 -1
- package/utils/account/transform.d.ts +2 -1
- package/utils/account/transform.js +37 -13
- package/utils/fee/transfer.d.ts +2 -1
- package/utils/fee/transfer.js +44 -11
- package/utils/index.js +4 -4
- package/utils/staticData/index.d.ts +4 -1
- package/utils/staticData/index.js +5 -1
- package/utils/staticData/oldChainPrefix.json +1 -0
|
@@ -4,6 +4,7 @@ import { Resolver } from '@subwallet/extension-base/background/handlers/State';
|
|
|
4
4
|
import { AccountAuthType, AuthorizeRequest, ConfirmationRequestBase, RequestAccountList, RequestAccountSubscribe, RequestAccountUnsubscribe, RequestAuthorizeCancel, RequestAuthorizeReject, RequestAuthorizeSubscribe, RequestAuthorizeTab, RequestCurrentAccountAddress, ResponseAuthorizeList } from '@subwallet/extension-base/background/types';
|
|
5
5
|
import { AppConfig, BrowserConfig, OSConfig } from '@subwallet/extension-base/constants';
|
|
6
6
|
import { RequestOptimalTransferProcess } from '@subwallet/extension-base/services/balance-service/helpers';
|
|
7
|
+
import { CardanoTransactionConfig } from '@subwallet/extension-base/services/balance-service/transfer/cardano-transfer';
|
|
7
8
|
import { TonTransactionConfig } from '@subwallet/extension-base/services/balance-service/transfer/ton-transfer';
|
|
8
9
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
9
10
|
import { _ChainState, _EvmApi, _NetworkUpsertParams, _SubstrateApi, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse, EnableChainParams, EnableMultiChainParams } from '@subwallet/extension-base/services/chain-service/types';
|
|
@@ -14,7 +15,7 @@ import { AuthUrls } from '@subwallet/extension-base/services/request-service/typ
|
|
|
14
15
|
import { CrowdloanContributionsResponse } from '@subwallet/extension-base/services/subscan-service/types';
|
|
15
16
|
import { SWTransactionResponse, SWTransactionResult } from '@subwallet/extension-base/services/transaction-service/types';
|
|
16
17
|
import { WalletConnectNotSupportRequest, WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
|
|
17
|
-
import { AccountJson, AccountsWithCurrentAddress, AddressJson, BalanceJson, BaseRequestSign, BuyServiceInfo, BuyTokenInfo, CommonOptimalPath, 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, 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, SubmitYieldStepData, SwapPair, SwapQuoteResponse, SwapRequest, SwapRequestResult, SwapSubmitParams, SwapTxData, TokenSpendingApprovalParams, UnlockDotTransactionNft, UnstakingStatus, ValidateSwapProcessParams, ValidateYieldProcessParams, YieldPoolInfo, YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
18
|
+
import { AccountChainType, AccountJson, AccountsWithCurrentAddress, AddressJson, BalanceJson, BaseRequestSign, BuyServiceInfo, BuyTokenInfo, CommonOptimalPath, CurrentAccountInfo, EarningRewardHistoryItem, EarningRewardJson, EarningStatus, HandleYieldStepParams, InternalRequestSign, LeavePoolAdditionalData, NominationPoolInfo, OptimalSwapPathParams, OptimalYieldPath, OptimalYieldPathParams, RequestAccountBatchExportV2, RequestAccountCreateSuriV2, RequestAccountNameValidate, RequestAccountProxyEdit, RequestAccountProxyForget, RequestBatchJsonGetAccountInfo, RequestBatchRestoreV2, RequestBounceableValidate, RequestChangeAllowOneSign, RequestChangeTonWalletContractVersion, RequestCheckCrossChainTransfer, RequestCheckPublicAndSecretKey, RequestCheckTransfer, RequestCrossChainTransfer, RequestDeriveCreateMultiple, RequestDeriveCreateV3, RequestDeriveValidateV2, RequestEarlyValidateYield, 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, SubmitYieldStepData, SwapPair, SwapQuoteResponse, SwapRequest, SwapRequestResult, SwapSubmitParams, SwapTxData, TokenSpendingApprovalParams, UnlockDotTransactionNft, UnstakingStatus, ValidateSwapProcessParams, ValidateYieldProcessParams, YieldPoolInfo, YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
18
19
|
import { RequestSubmitTransfer, RequestSubscribeTransfer, ResponseSubscribeTransfer } from '@subwallet/extension-base/types/balance/transfer';
|
|
19
20
|
import { RequestClaimBridge } from '@subwallet/extension-base/types/bridge';
|
|
20
21
|
import { GetNotificationParams, RequestIsClaimedPolygonBridge, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
|
|
@@ -320,6 +321,9 @@ export interface UiSettings {
|
|
|
320
321
|
unlockType: WalletUnlockType;
|
|
321
322
|
enableChainPatrol: boolean;
|
|
322
323
|
notificationSetup: NotificationSetup;
|
|
324
|
+
isAcknowledgedUnifiedAccountMigration: boolean;
|
|
325
|
+
isUnifiedAccountMigrationInProgress: boolean;
|
|
326
|
+
isUnifiedAccountMigrationDone: boolean;
|
|
323
327
|
walletReference: string;
|
|
324
328
|
allowOneSign: boolean;
|
|
325
329
|
}
|
|
@@ -369,7 +373,9 @@ export declare enum TransactionDirection {
|
|
|
369
373
|
export declare enum ChainType {
|
|
370
374
|
EVM = "evm",
|
|
371
375
|
SUBSTRATE = "substrate",
|
|
372
|
-
|
|
376
|
+
BITCOIN = "bitcoin",
|
|
377
|
+
TON = "ton",
|
|
378
|
+
CARDANO = "cardano"
|
|
373
379
|
}
|
|
374
380
|
export declare enum ExtrinsicType {
|
|
375
381
|
TRANSFER_BALANCE = "transfer.balance",
|
|
@@ -839,6 +845,11 @@ export interface TonSignRequest {
|
|
|
839
845
|
hashPayload: string;
|
|
840
846
|
canSign: boolean;
|
|
841
847
|
}
|
|
848
|
+
export interface CardanoSignRequest {
|
|
849
|
+
account: AccountJson;
|
|
850
|
+
hashPayload: string;
|
|
851
|
+
canSign: boolean;
|
|
852
|
+
}
|
|
842
853
|
export interface ErrorValidation {
|
|
843
854
|
message: string;
|
|
844
855
|
name: string;
|
|
@@ -848,12 +859,18 @@ export interface EvmSignatureRequest extends EvmSignRequest {
|
|
|
848
859
|
type: string;
|
|
849
860
|
payload: unknown;
|
|
850
861
|
errors?: ErrorValidation[];
|
|
862
|
+
processId?: string;
|
|
851
863
|
}
|
|
852
864
|
export interface TonSignatureRequest extends TonSignRequest {
|
|
853
865
|
id: string;
|
|
854
866
|
type: string;
|
|
855
867
|
payload: unknown;
|
|
856
868
|
}
|
|
869
|
+
export interface CardanoSignatureRequest extends CardanoSignRequest {
|
|
870
|
+
id: string;
|
|
871
|
+
type: string;
|
|
872
|
+
payload: unknown;
|
|
873
|
+
}
|
|
857
874
|
export interface EvmSendTransactionRequest extends TransactionConfig, EvmSignRequest {
|
|
858
875
|
estimateGas: string;
|
|
859
876
|
parseData: EvmTransactionData;
|
|
@@ -861,8 +878,10 @@ export interface EvmSendTransactionRequest extends TransactionConfig, EvmSignReq
|
|
|
861
878
|
errors?: ErrorValidation[];
|
|
862
879
|
}
|
|
863
880
|
export declare type TonSendTransactionRequest = TonTransactionConfig;
|
|
881
|
+
export declare type CardanoSendTransactionRequest = CardanoTransactionConfig;
|
|
864
882
|
export declare type EvmWatchTransactionRequest = EvmSendTransactionRequest;
|
|
865
883
|
export declare type TonWatchTransactionRequest = TonSendTransactionRequest;
|
|
884
|
+
export declare type CardanoWatchTransactionRequest = CardanoSendTransactionRequest;
|
|
866
885
|
export interface ConfirmationsQueueItemOptions {
|
|
867
886
|
requiredPassword?: boolean;
|
|
868
887
|
address?: string;
|
|
@@ -919,22 +938,35 @@ export interface ConfirmationDefinitionsTon {
|
|
|
919
938
|
tonSendTransactionRequest: [ConfirmationsQueueItem<TonSendTransactionRequest>, ConfirmationResult<string>];
|
|
920
939
|
tonWatchTransactionRequest: [ConfirmationsQueueItem<TonWatchTransactionRequest>, ConfirmationResult<string>];
|
|
921
940
|
}
|
|
941
|
+
export interface ConfirmationDefinitionsCardano {
|
|
942
|
+
cardanoSignatureRequest: [ConfirmationsQueueItem<CardanoSignatureRequest>, ConfirmationResult<string>];
|
|
943
|
+
cardanoSendTransactionRequest: [ConfirmationsQueueItem<CardanoSendTransactionRequest>, ConfirmationResult<string>];
|
|
944
|
+
cardanoWatchTransactionRequest: [ConfirmationsQueueItem<CardanoWatchTransactionRequest>, ConfirmationResult<string>];
|
|
945
|
+
}
|
|
922
946
|
export declare type ConfirmationType = keyof ConfirmationDefinitions;
|
|
923
947
|
export declare type ConfirmationTypeTon = keyof ConfirmationDefinitionsTon;
|
|
948
|
+
export declare type ConfirmationTypeCardano = keyof ConfirmationDefinitionsCardano;
|
|
924
949
|
export declare type ConfirmationsQueue = {
|
|
925
950
|
[CT in ConfirmationType]: Record<string, ConfirmationDefinitions[CT][0]>;
|
|
926
951
|
};
|
|
927
952
|
export declare type ConfirmationsQueueTon = {
|
|
928
953
|
[CT in ConfirmationTypeTon]: Record<string, ConfirmationDefinitionsTon[CT][0]>;
|
|
929
954
|
};
|
|
955
|
+
export declare type ConfirmationsQueueCardano = {
|
|
956
|
+
[CT in ConfirmationTypeCardano]: Record<string, ConfirmationDefinitionsCardano[CT][0]>;
|
|
957
|
+
};
|
|
930
958
|
export declare type RequestConfirmationsSubscribe = null;
|
|
931
959
|
export declare type RequestConfirmationsSubscribeTon = null;
|
|
960
|
+
export declare type RequestConfirmationsSubscribeCardano = null;
|
|
932
961
|
export declare type RequestConfirmationComplete = {
|
|
933
962
|
[CT in ConfirmationType]?: ConfirmationDefinitions[CT][1];
|
|
934
963
|
};
|
|
935
964
|
export declare type RequestConfirmationCompleteTon = {
|
|
936
965
|
[CT in ConfirmationTypeTon]?: ConfirmationDefinitionsTon[CT][1];
|
|
937
966
|
};
|
|
967
|
+
export declare type RequestConfirmationCompleteCardano = {
|
|
968
|
+
[CT in ConfirmationTypeCardano]?: ConfirmationDefinitionsCardano[CT][1];
|
|
969
|
+
};
|
|
938
970
|
export interface BondingOptionParams {
|
|
939
971
|
chain: string;
|
|
940
972
|
type: StakingType;
|
|
@@ -1451,6 +1483,38 @@ export interface ResponseNftImport {
|
|
|
1451
1483
|
success: boolean;
|
|
1452
1484
|
error: string;
|
|
1453
1485
|
}
|
|
1486
|
+
export interface RequestSaveMigrationAcknowledgedStatus {
|
|
1487
|
+
isAcknowledgedUnifiedAccountMigration: boolean;
|
|
1488
|
+
}
|
|
1489
|
+
export interface RequestSaveUnifiedAccountMigrationInProgress {
|
|
1490
|
+
isUnifiedAccountMigrationInProgress: boolean;
|
|
1491
|
+
}
|
|
1492
|
+
export interface RequestMigrateUnifiedAndFetchEligibleSoloAccounts {
|
|
1493
|
+
password: string;
|
|
1494
|
+
}
|
|
1495
|
+
export interface ResponseMigrateUnifiedAndFetchEligibleSoloAccounts {
|
|
1496
|
+
migratedUnifiedAccountIds: string[];
|
|
1497
|
+
soloAccounts: Record<string, SoloAccountToBeMigrated[]>;
|
|
1498
|
+
sessionId: string;
|
|
1499
|
+
}
|
|
1500
|
+
export interface SoloAccountToBeMigrated {
|
|
1501
|
+
upcomingProxyId: string;
|
|
1502
|
+
proxyId: string;
|
|
1503
|
+
address: string;
|
|
1504
|
+
name: string;
|
|
1505
|
+
chainType: AccountChainType;
|
|
1506
|
+
}
|
|
1507
|
+
export interface RequestMigrateSoloAccount {
|
|
1508
|
+
soloAccounts: SoloAccountToBeMigrated[];
|
|
1509
|
+
accountName: string;
|
|
1510
|
+
sessionId: string;
|
|
1511
|
+
}
|
|
1512
|
+
export interface ResponseMigrateSoloAccount {
|
|
1513
|
+
migratedUnifiedAccountId: string;
|
|
1514
|
+
}
|
|
1515
|
+
export interface RequestPingSession {
|
|
1516
|
+
sessionId: string;
|
|
1517
|
+
}
|
|
1454
1518
|
export declare type _Address = string;
|
|
1455
1519
|
export declare type _BalanceMetadata = unknown;
|
|
1456
1520
|
export interface KoniRequestSignatures {
|
|
@@ -1583,6 +1647,9 @@ export interface KoniRequestSignatures {
|
|
|
1583
1647
|
'pri(settings.saveUnlockType)': [RequestUnlockType, boolean];
|
|
1584
1648
|
'pri(settings.saveEnableChainPatrol)': [RequestChangeEnableChainPatrol, boolean];
|
|
1585
1649
|
'pri(settings.saveNotificationSetup)': [NotificationSetup, boolean];
|
|
1650
|
+
'pri(settings.saveUnifiedAccountMigrationInProgress)': [RequestSaveUnifiedAccountMigrationInProgress, boolean];
|
|
1651
|
+
'pri(settings.pingUnifiedAccountMigrationDone)': [null, boolean];
|
|
1652
|
+
'pri(settings.saveMigrationAcknowledgedStatus)': [RequestSaveMigrationAcknowledgedStatus, boolean];
|
|
1586
1653
|
'pri(settings.saveLanguage)': [RequestChangeLanguage, boolean];
|
|
1587
1654
|
'pri(settings.savePriceCurrency)': [RequestChangePriceCurrency, boolean];
|
|
1588
1655
|
'pri(settings.saveShowZeroBalance)': [RequestChangeShowZeroBalance, boolean];
|
|
@@ -1629,8 +1696,10 @@ export interface KoniRequestSignatures {
|
|
|
1629
1696
|
'pri(customFee.getAmountForPair)': [RequestGetAmountForPair, string];
|
|
1630
1697
|
'pri(confirmations.subscribe)': [RequestConfirmationsSubscribe, ConfirmationsQueue, ConfirmationsQueue];
|
|
1631
1698
|
'pri(confirmationsTon.subscribe)': [RequestConfirmationsSubscribeTon, ConfirmationsQueueTon, ConfirmationsQueueTon];
|
|
1699
|
+
'pri(confirmationsCardano.subscribe)': [RequestConfirmationsSubscribeCardano, ConfirmationsQueueCardano, ConfirmationsQueueCardano];
|
|
1632
1700
|
'pri(confirmations.complete)': [RequestConfirmationComplete, boolean];
|
|
1633
1701
|
'pri(confirmationsTon.complete)': [RequestConfirmationCompleteTon, boolean];
|
|
1702
|
+
'pri(confirmationsCardano.complete)': [RequestConfirmationCompleteCardano, boolean];
|
|
1634
1703
|
'pub(utils.getRandom)': [RandomTestRequest, number];
|
|
1635
1704
|
'pub(accounts.listV2)': [RequestAccountList, InjectedAccount[]];
|
|
1636
1705
|
'pub(accounts.subscribeV2)': [RequestAccountSubscribe, string, InjectedAccount[]];
|
|
@@ -1701,6 +1770,7 @@ export interface KoniRequestSignatures {
|
|
|
1701
1770
|
'pri(database.setLocalStorage)': [StorageDataInterface, boolean];
|
|
1702
1771
|
'pri(database.getLocalStorage)': [string, string | null];
|
|
1703
1772
|
'pri(swapService.subscribePairs)': [null, SwapPair[], SwapPair[]];
|
|
1773
|
+
'pri(swapService.generateOptimalProcess)': [OptimalSwapPathParams, CommonOptimalPath];
|
|
1704
1774
|
'pri(swapService.handleSwapRequest)': [SwapRequest, SwapRequestResult];
|
|
1705
1775
|
'pri(swapService.handleSwapStep)': [SwapSubmitParams, SWTransactionResponse];
|
|
1706
1776
|
'pri(swapService.getLatestQuote)': [SwapRequest, SwapQuoteResponse];
|
|
@@ -1718,6 +1788,9 @@ export interface KoniRequestSignatures {
|
|
|
1718
1788
|
'pri(process.transaction.submit)': [RequestSubmitProcessTransaction, SWTransactionResponse];
|
|
1719
1789
|
'pri(process.subscribe.id)': [RequestSubscribeProcessById, ResponseSubscribeProcessById, ResponseSubscribeProcessById];
|
|
1720
1790
|
'pri(process.subscribe.alive)': [null, ResponseSubscribeProcessAlive, ResponseSubscribeProcessAlive];
|
|
1791
|
+
'pri(migrate.migrateUnifiedAndFetchEligibleSoloAccounts)': [RequestMigrateUnifiedAndFetchEligibleSoloAccounts, ResponseMigrateUnifiedAndFetchEligibleSoloAccounts];
|
|
1792
|
+
'pri(migrate.migrateSoloAccount)': [RequestMigrateSoloAccount, ResponseMigrateSoloAccount];
|
|
1793
|
+
'pri(migrate.pingSession)': [RequestPingSession, boolean];
|
|
1721
1794
|
}
|
|
1722
1795
|
export interface ApplicationMetadataType {
|
|
1723
1796
|
version: string;
|
package/background/KoniTypes.js
CHANGED
|
@@ -62,7 +62,9 @@ export let ChainType;
|
|
|
62
62
|
(function (ChainType) {
|
|
63
63
|
ChainType["EVM"] = "evm";
|
|
64
64
|
ChainType["SUBSTRATE"] = "substrate";
|
|
65
|
+
ChainType["BITCOIN"] = "bitcoin";
|
|
65
66
|
ChainType["TON"] = "ton";
|
|
67
|
+
ChainType["CARDANO"] = "cardano";
|
|
66
68
|
})(ChainType || (ChainType = {}));
|
|
67
69
|
export let ExtrinsicType;
|
|
68
70
|
(function (ExtrinsicType) {
|
|
@@ -76,7 +76,9 @@ exports.ChainType = ChainType;
|
|
|
76
76
|
(function (ChainType) {
|
|
77
77
|
ChainType["EVM"] = "evm";
|
|
78
78
|
ChainType["SUBSTRATE"] = "substrate";
|
|
79
|
+
ChainType["BITCOIN"] = "bitcoin";
|
|
79
80
|
ChainType["TON"] = "ton";
|
|
81
|
+
ChainType["CARDANO"] = "cardano";
|
|
80
82
|
})(ChainType || (exports.ChainType = ChainType = {}));
|
|
81
83
|
let ExtrinsicType;
|
|
82
84
|
exports.ExtrinsicType = ExtrinsicType;
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isProductionMode = void 0;
|
|
6
|
+
exports.isProductionMode = exports.BACKEND_API_URL = void 0;
|
|
7
7
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
|
|
10
10
|
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
11
11
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
12
12
|
const isProductionMode = PRODUCTION_BRANCHES.indexOf(branchName) > -1;
|
|
13
|
-
exports.isProductionMode = isProductionMode;
|
|
13
|
+
exports.isProductionMode = isProductionMode;
|
|
14
|
+
const BACKEND_API_URL = process.env.SUBWALLET_API || (isProductionMode ? 'https://sw-services.subwallet.app/api' : 'https://sw-services.subwallet.app/api'); // TODO: Rollback dev URL
|
|
15
|
+
exports.BACKEND_API_URL = BACKEND_API_URL;
|
package/cjs/constants/signing.js
CHANGED
|
@@ -12,12 +12,16 @@ var _types = require("@subwallet/extension-base/types");
|
|
|
12
12
|
const SIGNING_COMPATIBLE_MAP = {
|
|
13
13
|
[_KoniTypes.ChainType.SUBSTRATE]: [_types.AccountChainType.SUBSTRATE, _types.AccountChainType.ETHEREUM],
|
|
14
14
|
[_KoniTypes.ChainType.EVM]: [_types.AccountChainType.ETHEREUM],
|
|
15
|
-
[_KoniTypes.ChainType.
|
|
15
|
+
[_KoniTypes.ChainType.BITCOIN]: [_types.AccountChainType.BITCOIN],
|
|
16
|
+
[_KoniTypes.ChainType.TON]: [_types.AccountChainType.TON],
|
|
17
|
+
[_KoniTypes.ChainType.CARDANO]: [_types.AccountChainType.CARDANO]
|
|
16
18
|
};
|
|
17
19
|
exports.SIGNING_COMPATIBLE_MAP = SIGNING_COMPATIBLE_MAP;
|
|
18
20
|
const LEDGER_SIGNING_COMPATIBLE_MAP = {
|
|
19
21
|
[_KoniTypes.ChainType.SUBSTRATE]: [_types.AccountChainType.SUBSTRATE],
|
|
20
22
|
[_KoniTypes.ChainType.EVM]: [_types.AccountChainType.ETHEREUM],
|
|
21
|
-
[_KoniTypes.ChainType.
|
|
23
|
+
[_KoniTypes.ChainType.BITCOIN]: [_types.AccountChainType.BITCOIN],
|
|
24
|
+
[_KoniTypes.ChainType.TON]: [_types.AccountChainType.TON],
|
|
25
|
+
[_KoniTypes.ChainType.CARDANO]: [_types.AccountChainType.CARDANO]
|
|
22
26
|
};
|
|
23
27
|
exports.LEDGER_SIGNING_COMPATIBLE_MAP = LEDGER_SIGNING_COMPATIBLE_MAP;
|
|
@@ -33,7 +33,10 @@ function getConditions(validateRecipientParams) {
|
|
|
33
33
|
if ((0, _keyring.isTonAddress)(toAddress)) {
|
|
34
34
|
conditions.push(_types.ValidationCondition.IS_VALID_TON_ADDRESS_FORMAT);
|
|
35
35
|
}
|
|
36
|
-
if (
|
|
36
|
+
if ((0, _keyring.isCardanoAddress)(toAddress)) {
|
|
37
|
+
conditions.push(_types.ValidationCondition.IS_VALID_CARDANO_ADDRESS_FORMAT);
|
|
38
|
+
}
|
|
39
|
+
if (srcChain === destChainInfo.slug && isSendAction && !destChainInfo.tonInfo && !destChainInfo.cardanoInfo) {
|
|
37
40
|
conditions.push(_types.ValidationCondition.IS_NOT_DUPLICATE_ADDRESS);
|
|
38
41
|
}
|
|
39
42
|
if (account !== null && account !== void 0 && account.isHardware) {
|
|
@@ -73,6 +76,11 @@ function getValidationFunctions(conditions) {
|
|
|
73
76
|
validationFunctions.push(_utils._isValidTonAddressFormat);
|
|
74
77
|
break;
|
|
75
78
|
}
|
|
79
|
+
case _types.ValidationCondition.IS_VALID_CARDANO_ADDRESS_FORMAT:
|
|
80
|
+
{
|
|
81
|
+
validationFunctions.push(_utils._isValidCardanoAddressFormat);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
76
84
|
case _types.ValidationCondition.IS_NOT_DUPLICATE_ADDRESS:
|
|
77
85
|
{
|
|
78
86
|
validationFunctions.push(_utils._isNotDuplicateAddress);
|
|
@@ -20,13 +20,14 @@ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
|
20
20
|
var _TransactionWarning = require("@subwallet/extension-base/background/warnings/TransactionWarning");
|
|
21
21
|
var _constants = require("@subwallet/extension-base/constants");
|
|
22
22
|
var _systemPallet = require("@subwallet/extension-base/core/substrate/system-pallet");
|
|
23
|
-
var _utils = require("@subwallet/extension-base/services/balance-service/helpers/subscribe/
|
|
23
|
+
var _utils = require("@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/utils");
|
|
24
|
+
var _utils2 = require("@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils");
|
|
24
25
|
var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
|
|
25
|
-
var
|
|
26
|
-
var
|
|
26
|
+
var _utils3 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
27
|
+
var _utils4 = require("@subwallet/extension-base/services/fee-service/utils");
|
|
27
28
|
var _helpers = require("@subwallet/extension-base/services/transaction-service/helpers");
|
|
28
29
|
var _types = require("@subwallet/extension-base/types");
|
|
29
|
-
var
|
|
30
|
+
var _utils5 = require("@subwallet/extension-base/utils");
|
|
30
31
|
var _keyring = require("@subwallet/keyring");
|
|
31
32
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
32
33
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
@@ -46,17 +47,20 @@ function validateTransferRequest(tokenInfo, from, to, value, transferAll) {
|
|
|
46
47
|
if (!tokenInfo) {
|
|
47
48
|
errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found token from registry')));
|
|
48
49
|
}
|
|
49
|
-
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0,
|
|
50
|
+
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils3._isTokenEvmSmartContract)(tokenInfo) && (0, _utils3._getContractAddressOfToken)(tokenInfo).length === 0) {
|
|
50
51
|
errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found ERC20 address for this token')));
|
|
51
52
|
}
|
|
52
|
-
if ((0, _keyring.isTonAddress)(from) && (0, _keyring.isTonAddress)(to) && (0,
|
|
53
|
+
if ((0, _keyring.isTonAddress)(from) && (0, _keyring.isTonAddress)(to) && (0, _utils3._isTokenTonSmartContract)(tokenInfo) && (0, _utils3._getContractAddressOfToken)(tokenInfo).length === 0) {
|
|
53
54
|
errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found TEP74 address for this token')));
|
|
54
55
|
}
|
|
56
|
+
if ((0, _keyring.isCardanoAddress)(from) && (0, _keyring.isCardanoAddress)(to) && (0, _utils3._isCIP26Token)(tokenInfo) && (0, _utils.getCardanoAssetId)(tokenInfo).length === 0) {
|
|
57
|
+
errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found policy id of this token')));
|
|
58
|
+
}
|
|
55
59
|
return errors;
|
|
56
60
|
}
|
|
57
61
|
function additionalValidateTransferForRecipient(sendingTokenInfo, nativeTokenInfo, extrinsicType, receiverSendingTokenKeepAliveBalance, transferAmount, senderSendingTokenTransferable, receiverSystemAccountInfo, isSendingTokenSufficient) {
|
|
58
|
-
const sendingTokenMinAmount = BigInt((0,
|
|
59
|
-
const nativeTokenMinAmount = (0,
|
|
62
|
+
const sendingTokenMinAmount = BigInt((0, _utils3._getTokenMinAmount)(sendingTokenInfo));
|
|
63
|
+
const nativeTokenMinAmount = (0, _utils3._getTokenMinAmount)(nativeTokenInfo);
|
|
60
64
|
const warnings = [];
|
|
61
65
|
const errors = [];
|
|
62
66
|
const remainingSendingTokenOfSenderEnoughED = senderSendingTokenTransferable ? senderSendingTokenTransferable - transferAmount >= sendingTokenMinAmount : false;
|
|
@@ -68,8 +72,8 @@ function additionalValidateTransferForRecipient(sendingTokenInfo, nativeTokenInf
|
|
|
68
72
|
warnings.push(warning);
|
|
69
73
|
}
|
|
70
74
|
if (!isReceiverAliveByNativeToken && !isSendingTokenSufficient) {
|
|
71
|
-
const balanceKeepAlive = (0,
|
|
72
|
-
maxNumberFormat: (0,
|
|
75
|
+
const balanceKeepAlive = (0, _utils5.formatNumber)(nativeTokenMinAmount, (0, _utils3._getAssetDecimals)(nativeTokenInfo), _utils5.balanceFormatter, {
|
|
76
|
+
maxNumberFormat: (0, _utils3._getAssetDecimals)(nativeTokenInfo) || 6
|
|
73
77
|
});
|
|
74
78
|
const error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('The recipient account has less than {{amount}} {{nativeSymbol}}, which can lead to your {{localSymbol}} being lost. Change recipient account and try again', {
|
|
75
79
|
replace: {
|
|
@@ -82,8 +86,8 @@ function additionalValidateTransferForRecipient(sendingTokenInfo, nativeTokenInf
|
|
|
82
86
|
}
|
|
83
87
|
if (!isReceivingAmountPassED) {
|
|
84
88
|
const atLeast = sendingTokenMinAmount - receiverSendingTokenKeepAliveBalance;
|
|
85
|
-
const atLeastStr = (0,
|
|
86
|
-
maxNumberFormat: (0,
|
|
89
|
+
const atLeastStr = (0, _utils5.formatNumber)(atLeast.toString(), (0, _utils3._getAssetDecimals)(sendingTokenInfo), _utils5.balanceFormatter, {
|
|
90
|
+
maxNumberFormat: (0, _utils3._getAssetDecimals)(sendingTokenInfo) || 6
|
|
87
91
|
});
|
|
88
92
|
const error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to avoid losing funds on the recipient account. Increase amount and try again', {
|
|
89
93
|
replace: {
|
|
@@ -96,8 +100,8 @@ function additionalValidateTransferForRecipient(sendingTokenInfo, nativeTokenInf
|
|
|
96
100
|
}
|
|
97
101
|
if (!isReceivingAmountPassED) {
|
|
98
102
|
const atLeast = sendingTokenMinAmount - receiverSendingTokenKeepAliveBalance;
|
|
99
|
-
const atLeastStr = (0,
|
|
100
|
-
maxNumberFormat: (0,
|
|
103
|
+
const atLeastStr = (0, _utils5.formatNumber)(atLeast.toString(), (0, _utils3._getAssetDecimals)(sendingTokenInfo), _utils5.balanceFormatter, {
|
|
104
|
+
maxNumberFormat: (0, _utils3._getAssetDecimals)(sendingTokenInfo) || 6
|
|
101
105
|
});
|
|
102
106
|
const error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the recipient account alive. Increase amount and try again', {
|
|
103
107
|
replace: {
|
|
@@ -121,14 +125,14 @@ function validateXcmTransferRequest(destTokenInfo, sender, sendingValue) {
|
|
|
121
125
|
}
|
|
122
126
|
function additionalValidateXcmTransfer(originTokenInfo, destinationTokenInfo, sendingAmount, senderTransferable, receiverNativeBalance, destChainInfo) {
|
|
123
127
|
let isSnowBridge = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
124
|
-
const destMinAmount = (0,
|
|
128
|
+
const destMinAmount = (0, _utils3._getTokenMinAmount)(destinationTokenInfo);
|
|
125
129
|
const minSendingRequired = new _bignumber.default(destMinAmount).multipliedBy(_constants.XCM_MIN_AMOUNT_RATIO);
|
|
126
130
|
let error;
|
|
127
131
|
let warning;
|
|
128
132
|
|
|
129
133
|
// Check sending token ED for receiver
|
|
130
134
|
if (new _bignumber.default(sendingAmount).lt(minSendingRequired)) {
|
|
131
|
-
const atLeastStr = (0,
|
|
135
|
+
const atLeastStr = (0, _utils5.formatNumber)(minSendingRequired, destinationTokenInfo.decimals || 0, _utils5.balanceFormatter, {
|
|
132
136
|
maxNumberFormat: destinationTokenInfo.decimals || 6
|
|
133
137
|
});
|
|
134
138
|
error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
|
|
@@ -140,13 +144,13 @@ function additionalValidateXcmTransfer(originTokenInfo, destinationTokenInfo, se
|
|
|
140
144
|
}
|
|
141
145
|
|
|
142
146
|
// check native token ED on dest chain for receiver
|
|
143
|
-
const bnKeepAliveBalance = (0,
|
|
144
|
-
if (isSnowBridge && bnKeepAliveBalance.lt((0,
|
|
147
|
+
const bnKeepAliveBalance = (0, _utils3._isNativeToken)(destinationTokenInfo) ? new _bignumber.default(receiverNativeBalance).plus(sendingAmount) : new _bignumber.default(receiverNativeBalance);
|
|
148
|
+
if (isSnowBridge && bnKeepAliveBalance.lt((0, _utils3._getChainExistentialDeposit)(destChainInfo))) {
|
|
145
149
|
const {
|
|
146
150
|
decimals,
|
|
147
151
|
symbol
|
|
148
|
-
} = (0,
|
|
149
|
-
const atLeastStr = (0,
|
|
152
|
+
} = (0, _utils3._getChainNativeTokenBasicInfo)(destChainInfo);
|
|
153
|
+
const atLeastStr = (0, _utils5.formatNumber)((0, _utils3._getChainExistentialDeposit)(destChainInfo), decimals || 0, _utils5.balanceFormatter, {
|
|
150
154
|
maxNumberFormat: 6
|
|
151
155
|
});
|
|
152
156
|
error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)(' Insufficient {{symbol}} on {{chain}} to cover min balance ({{amount}} {{symbol}})', {
|
|
@@ -159,8 +163,8 @@ function additionalValidateXcmTransfer(originTokenInfo, destinationTokenInfo, se
|
|
|
159
163
|
}
|
|
160
164
|
|
|
161
165
|
// Check ed for sender
|
|
162
|
-
if (!(0,
|
|
163
|
-
if (new _bignumber.default(senderTransferable).minus(sendingAmount).lt((0,
|
|
166
|
+
if (!(0, _utils3._isNativeToken)(originTokenInfo)) {
|
|
167
|
+
if (new _bignumber.default(senderTransferable).minus(sendingAmount).lt((0, _utils3._getTokenMinAmount)(originTokenInfo))) {
|
|
164
168
|
warning = new _TransactionWarning.TransactionWarning(_types.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT);
|
|
165
169
|
}
|
|
166
170
|
}
|
|
@@ -354,7 +358,7 @@ async function estimateFeeForTransaction(validationResponse, transaction, chainI
|
|
|
354
358
|
const {
|
|
355
359
|
decimals,
|
|
356
360
|
symbol
|
|
357
|
-
} = (0,
|
|
361
|
+
} = (0, _utils3._getChainNativeTokenBasicInfo)(chainInfo);
|
|
358
362
|
estimateFee.decimals = decimals;
|
|
359
363
|
estimateFee.symbol = symbol;
|
|
360
364
|
if (transaction) {
|
|
@@ -363,9 +367,11 @@ async function estimateFeeForTransaction(validationResponse, transaction, chainI
|
|
|
363
367
|
estimateFee.value = (await transaction.paymentInfo(validationResponse.address)).partialFee.toString();
|
|
364
368
|
} else if ((0, _helpers.isTonTransaction)(transaction)) {
|
|
365
369
|
estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
|
|
370
|
+
} else if ((0, _helpers.isCardanoTransaction)(transaction)) {
|
|
371
|
+
estimateFee.value = transaction.estimateCardanoFee;
|
|
366
372
|
} else {
|
|
367
373
|
const gasLimit = transaction.gas || (await evmApi.api.eth.estimateGas(transaction));
|
|
368
|
-
const feeCombine = (0,
|
|
374
|
+
const feeCombine = (0, _utils5.combineEthFee)(feeInfo, validationResponse.feeOption, validationResponse.feeCustom);
|
|
369
375
|
if (transaction.maxFeePerGas) {
|
|
370
376
|
estimateFee.value = new _bignumber.default(transaction.maxFeePerGas.toString()).multipliedBy(gasLimit).toFixed(0);
|
|
371
377
|
} else if (transaction.gasPrice) {
|
|
@@ -389,10 +395,10 @@ async function estimateFeeForTransaction(validationResponse, transaction, chainI
|
|
|
389
395
|
}
|
|
390
396
|
}
|
|
391
397
|
if (tokenPayFeeInfo) {
|
|
392
|
-
const estimatedFeeAmount = isTransferLocalTokenAndPayThatTokenAsFee ? (BigInt(estimateFee.value) * BigInt(
|
|
398
|
+
const estimatedFeeAmount = isTransferLocalTokenAndPayThatTokenAsFee ? (BigInt(estimateFee.value) * BigInt(_utils4.FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE) / BigInt(100)).toString() : estimateFee.value;
|
|
393
399
|
estimateFee.decimals = tokenPayFeeInfo.decimals || 0;
|
|
394
400
|
estimateFee.symbol = tokenPayFeeInfo.symbol;
|
|
395
|
-
estimateFee.value = await (0,
|
|
401
|
+
estimateFee.value = await (0, _utils4.calculateToAmountByReservePool)(substrateApi.api, nativeTokenInfo, tokenPayFeeInfo, estimatedFeeAmount);
|
|
396
402
|
}
|
|
397
403
|
return estimateFee;
|
|
398
404
|
}
|
|
@@ -407,7 +413,7 @@ function checkSigningAccountForTransaction(validationResponse, chainInfoMap) {
|
|
|
407
413
|
if (!pair) {
|
|
408
414
|
validationResponse.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.INTERNAL_ERROR, (0, _i18next.t)('Unable to find account')));
|
|
409
415
|
} else {
|
|
410
|
-
const accountJson = (0,
|
|
416
|
+
const accountJson = (0, _utils5.pairToAccount)(pair, chainInfoMap);
|
|
411
417
|
if (!accountJson.transactionActions.includes(extrinsicType)) {
|
|
412
418
|
// check if the account can sign the transaction type
|
|
413
419
|
validationResponse.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('This feature is not available with this account')));
|
|
@@ -451,7 +457,7 @@ function checkBalanceWithTransactionFee(validationResponse, transactionInput, na
|
|
|
451
457
|
|
|
452
458
|
// todo: only system.pallet has metadata, we should add for other pallets and mechanisms as well
|
|
453
459
|
const isNeedCheckRemainingBalance = !isTransferAll && extrinsicType === _KoniTypes.ExtrinsicType.TRANSFER_BALANCE && nativeTokenAvailable.metadata && (0, _systemPallet._canAccountBeReaped)(nativeTokenAvailable.metadata);
|
|
454
|
-
const isRemainingBalanceValid = bnNativeTokenAvailable.minus(bnNativeTokenTransferAmount).minus(bnFee).lt((0,
|
|
460
|
+
const isRemainingBalanceValid = bnNativeTokenAvailable.minus(bnNativeTokenTransferAmount).minus(bnFee).lt((0, _utils3._getTokenMinAmount)(nativeTokenInfo));
|
|
455
461
|
if (isNeedCheckRemainingBalance && isRemainingBalanceValid) {
|
|
456
462
|
edAsWarning ? validationResponse.warnings.push(new _TransactionWarning.TransactionWarning(_types.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT)) : validationResponse.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
457
463
|
}
|
|
@@ -466,7 +472,7 @@ async function checkTonAddressBounceableAndAccountNotActive(tonApi, validationRe
|
|
|
466
472
|
}
|
|
467
473
|
}
|
|
468
474
|
function isTonAddressBounceable(address) {
|
|
469
|
-
return (0,
|
|
475
|
+
return (0, _utils2.isBounceableAddress)(address);
|
|
470
476
|
}
|
|
471
477
|
async function isAccountActive(tonApi, address) {
|
|
472
478
|
const state = await tonApi.getAccountState(address);
|
package/cjs/core/types.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.ValidationCondition = ValidationCondition;
|
|
|
14
14
|
ValidationCondition["IS_VALID_ADDRESS_FOR_ECOSYSTEM"] = "IS_VALID_ADDRESS_FOR_ECOSYSTEM";
|
|
15
15
|
ValidationCondition["IS_VALID_SUBSTRATE_ADDRESS_FORMAT"] = "IS_VALID_SUBSTRATE_ADDRESS_FORMAT";
|
|
16
16
|
ValidationCondition["IS_VALID_TON_ADDRESS_FORMAT"] = "IS_VALID_TON_ADDRESS_FORMAT";
|
|
17
|
+
ValidationCondition["IS_VALID_CARDANO_ADDRESS_FORMAT"] = "IS_VALID_CARDANO_ADDRESS_FORMAT";
|
|
17
18
|
ValidationCondition["IS_NOT_DUPLICATE_ADDRESS"] = "IS_NOT_DUPLICATE_ADDRESS";
|
|
18
19
|
ValidationCondition["IS_SUPPORT_LEDGER_ACCOUNT"] = "IS_SUPPORT_LEDGER_ACCOUNT";
|
|
19
20
|
})(ValidationCondition || (exports.ValidationCondition = ValidationCondition = {}));
|
package/cjs/core/utils.js
CHANGED
|
@@ -9,6 +9,7 @@ exports._isNotDuplicateAddress = _isNotDuplicateAddress;
|
|
|
9
9
|
exports._isNotNull = _isNotNull;
|
|
10
10
|
exports._isSupportLedgerAccount = _isSupportLedgerAccount;
|
|
11
11
|
exports._isValidAddressForEcosystem = _isValidAddressForEcosystem;
|
|
12
|
+
exports._isValidCardanoAddressFormat = _isValidCardanoAddressFormat;
|
|
12
13
|
exports._isValidSubstrateAddressFormat = _isValidSubstrateAddressFormat;
|
|
13
14
|
exports._isValidTonAddressFormat = _isValidTonAddressFormat;
|
|
14
15
|
exports.getMaxBigInt = getMaxBigInt;
|
|
@@ -70,7 +71,7 @@ function _isValidAddressForEcosystem(validateRecipientParams) {
|
|
|
70
71
|
toAddress
|
|
71
72
|
} = validateRecipientParams;
|
|
72
73
|
if (!(0, _utils3.isAddressAndChainCompatible)(toAddress, destChainInfo)) {
|
|
73
|
-
if ((0, _utils2._isChainEvmCompatible)(destChainInfo) || (0, _utils2._isChainSubstrateCompatible)(destChainInfo) || (0, _utils2._isChainTonCompatible)(destChainInfo)) {
|
|
74
|
+
if ((0, _utils2._isChainEvmCompatible)(destChainInfo) || (0, _utils2._isChainSubstrateCompatible)(destChainInfo) || (0, _utils2._isChainTonCompatible)(destChainInfo) || (0, _utils2._isChainCardanoCompatible)(destChainInfo)) {
|
|
74
75
|
return 'Recipient address must be the same type as sender address';
|
|
75
76
|
}
|
|
76
77
|
return 'Unknown chain type';
|
|
@@ -101,6 +102,16 @@ function _isValidTonAddressFormat(validateRecipientParams) {
|
|
|
101
102
|
}
|
|
102
103
|
return '';
|
|
103
104
|
}
|
|
105
|
+
function _isValidCardanoAddressFormat(validateRecipientParams) {
|
|
106
|
+
const {
|
|
107
|
+
destChainInfo,
|
|
108
|
+
toAddress
|
|
109
|
+
} = validateRecipientParams;
|
|
110
|
+
if ((0, _keyring.isCardanoTestnetAddress)(toAddress) !== destChainInfo.isTestnet) {
|
|
111
|
+
return `Recipient address must be a valid ${destChainInfo.name} address`;
|
|
112
|
+
}
|
|
113
|
+
return '';
|
|
114
|
+
}
|
|
104
115
|
function _isNotDuplicateAddress(validateRecipientParams) {
|
|
105
116
|
const {
|
|
106
117
|
fromAddress,
|
package/cjs/defaults.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.PORT_MOBILE = exports.PORT_EXTENSION = exports.PORT_CONTENT = exports.PH
|
|
|
7
7
|
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
|
|
10
|
-
const ALLOWED_PATH = ['/', '/settings/security', '/transaction-submission', '/accounts/connect-ledger', '/accounts/restore-json', '/accounts/detail', '/accounts/new-seed-phrase'];
|
|
10
|
+
const ALLOWED_PATH = ['/', '/settings/security', '/transaction-submission', '/accounts/connect-ledger', '/accounts/restore-json', '/accounts/detail', '/accounts/new-seed-phrase', '/migrate-account'];
|
|
11
11
|
exports.ALLOWED_PATH = ALLOWED_PATH;
|
|
12
12
|
const PHISHING_PAGE_REDIRECT = '/phishing-page-detected';
|
|
13
13
|
exports.PHISHING_PAGE_REDIRECT = PHISHING_PAGE_REDIRECT;
|
|
@@ -172,7 +172,7 @@ async function subscribeCrowdloan(addresses, substrateApiMap, callback) {
|
|
|
172
172
|
const now = Date.now();
|
|
173
173
|
const polkadotAPI = await substrateApiMap[_chainList.COMMON_CHAIN_SLUGS.POLKADOT].isReady;
|
|
174
174
|
const kusamaAPI = await substrateApiMap[_chainList.COMMON_CHAIN_SLUGS.KUSAMA].isReady;
|
|
175
|
-
const substrateAddresses = (0, _utils.
|
|
175
|
+
const substrateAddresses = (0, _utils.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
176
176
|
const hexAddresses = substrateAddresses.map(address => {
|
|
177
177
|
return _typeRegistry.default.createType('AccountId', address).toHex();
|
|
178
178
|
});
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.NftHandler = void 0;
|
|
8
|
+
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
9
|
var _acala_nft = require("@subwallet/extension-base/koni/api/nft/acala_nft");
|
|
9
10
|
var _assethub_unique = _interopRequireDefault(require("@subwallet/extension-base/koni/api/nft/assethub_unique"));
|
|
10
11
|
var _bit = require("@subwallet/extension-base/koni/api/nft/bit.country");
|
|
@@ -26,13 +27,9 @@ var _ternoa_nft = require("./ternoa_nft");
|
|
|
26
27
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
27
28
|
// SPDX-License-Identifier: Apache-2.0
|
|
28
29
|
|
|
29
|
-
// import UniqueNftApi from '@subwallet/extension-base/koni/api/nft/unique_nft';
|
|
30
|
-
|
|
31
30
|
function createSubstrateNftApi(chain, substrateApi, addresses) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
substrate: substrateAddresses
|
|
35
|
-
} = (0, _utils2.categoryAddresses)(addresses);
|
|
31
|
+
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
32
|
+
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
36
33
|
if (_constants._NFT_CHAIN_GROUP.acala.includes(chain)) {
|
|
37
34
|
return [new _acala_nft.AcalaNftApi(substrateApi, substrateAddresses, chain)];
|
|
38
35
|
} else if (_constants._NFT_CHAIN_GROUP.karura.includes(chain)) {
|
|
@@ -63,11 +60,11 @@ function createSubstrateNftApi(chain, substrateApi, addresses) {
|
|
|
63
60
|
return null;
|
|
64
61
|
}
|
|
65
62
|
function createWasmNftApi(chain, apiProps, addresses) {
|
|
66
|
-
const substrateAddresses = (0, _utils2.
|
|
63
|
+
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
67
64
|
return new _wasm_nft.WasmNftApi(apiProps, substrateAddresses, chain);
|
|
68
65
|
}
|
|
69
66
|
function createWeb3NftApi(chain, evmApi, addresses) {
|
|
70
|
-
const evmAddresses = (0, _utils2.
|
|
67
|
+
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
71
68
|
return new _evm_nft.EvmNftApi(evmApi, evmAddresses, chain);
|
|
72
69
|
}
|
|
73
70
|
const createOrdinalApi = (chain, subscanChain, addresses) => {
|
|
@@ -101,10 +98,8 @@ class NftHandler {
|
|
|
101
98
|
}
|
|
102
99
|
setAddresses(addresses) {
|
|
103
100
|
this.addresses = addresses;
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
substrate: substrateAddresses
|
|
107
|
-
} = (0, _utils2.categoryAddresses)(addresses);
|
|
101
|
+
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
102
|
+
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
108
103
|
for (const handler of this.handlers) {
|
|
109
104
|
const useAddresses = handler.isEthereum ? evmAddresses : substrateAddresses;
|
|
110
105
|
handler.setAddresses(useAddresses);
|
|
@@ -129,10 +124,8 @@ class NftHandler {
|
|
|
129
124
|
if (this.needSetupApi) {
|
|
130
125
|
// setup connections for first time use
|
|
131
126
|
this.handlers = [];
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
substrate: substrateAddresses
|
|
135
|
-
} = (0, _utils2.categoryAddresses)(this.addresses);
|
|
127
|
+
const evmAddresses = (0, _utils2.getAddressesByChainType)(this.addresses, [_KoniTypes.ChainType.EVM]);
|
|
128
|
+
const substrateAddresses = (0, _utils2.getAddressesByChainType)(this.addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
136
129
|
Object.entries(this.chainInfoMap).forEach(_ref => {
|
|
137
130
|
let [chain, chainInfo] = _ref;
|
|
138
131
|
if ((0, _utils._isChainSupportNativeNft)(chainInfo)) {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getNominationStakingRewardData = getNominationStakingRewardData;
|
|
7
7
|
exports.getPoolingStakingRewardData = getPoolingStakingRewardData;
|
|
8
8
|
exports.stakingOnChainApi = stakingOnChainApi;
|
|
9
|
+
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
9
10
|
var _paraChain = require("@subwallet/extension-base/koni/api/staking/paraChain");
|
|
10
11
|
var _relayChain = require("@subwallet/extension-base/koni/api/staking/relayChain");
|
|
11
12
|
var _subsquidStaking = require("@subwallet/extension-base/koni/api/staking/subsquidStaking");
|
|
@@ -18,10 +19,8 @@ var _utils2 = require("@subwallet/extension-base/utils");
|
|
|
18
19
|
|
|
19
20
|
function stakingOnChainApi(addresses, substrateApiMap, chainInfoMap, stakingCallback, nominatorStateCallback) {
|
|
20
21
|
const filteredApiMap = [];
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
substrate: substrateAddresses
|
|
24
|
-
} = (0, _utils2.categoryAddresses)(addresses);
|
|
22
|
+
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
23
|
+
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
25
24
|
Object.entries(chainInfoMap).forEach(_ref => {
|
|
26
25
|
let [networkKey, chainInfo] = _ref;
|
|
27
26
|
if (_constants._PURE_EVM_CHAINS.indexOf(networkKey) < 0 && (0, _utils._isChainSupportSubstrateStaking)(chainInfo)) {
|