@subwallet/extension-base 1.3.7-0 → 1.3.9-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 +11 -5
- package/background/KoniTypes.js +1 -1
- package/cjs/background/KoniTypes.js +1 -1
- package/cjs/core/logic-validation/transfer.js +35 -24
- package/cjs/core/substrate/system-pallet.js +1 -1
- package/cjs/core/substrate/xcm-parser.js +16 -2
- package/cjs/core/utils.js +2 -2
- package/cjs/koni/api/contract-handler/utils/index.js +15 -1
- package/cjs/koni/background/handlers/Extension.js +158 -86
- package/cjs/koni/background/handlers/State.js +11 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/index.js +24 -2
- package/cjs/services/balance-service/transfer/smart-contract.js +16 -5
- package/cjs/services/balance-service/transfer/xcm/index.js +31 -1
- package/cjs/services/balance-service/transfer/xcm/polygonBridge.js +108 -0
- package/cjs/services/chain-online-service/constants.js +32 -0
- package/cjs/services/chain-online-service/index.js +190 -0
- package/cjs/services/chain-service/constants.js +3 -1
- package/cjs/services/chain-service/index.js +87 -127
- package/cjs/services/chain-service/utils/index.js +0 -2
- package/cjs/services/chain-service/utils/patch.js +7 -3
- package/cjs/services/fee-service/utils/index.js +14 -0
- package/cjs/services/inapp-notification-service/consts.js +6 -4
- package/cjs/services/inapp-notification-service/index.js +110 -6
- package/cjs/services/inapp-notification-service/interfaces.js +9 -1
- package/cjs/services/inapp-notification-service/utils/avail.js +88 -0
- package/cjs/services/inapp-notification-service/{utils.js → utils/common.js} +1 -84
- package/cjs/services/inapp-notification-service/utils/index.js +38 -0
- package/cjs/services/inapp-notification-service/utils/polygon.js +66 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBridge.js +37 -0
- package/cjs/services/migration-service/scripts/index.js +3 -1
- package/cjs/services/setting-service/SettingService.js +8 -0
- package/cjs/services/setting-service/constants.js +2 -1
- package/cjs/services/storage-service/DatabaseService.js +3 -0
- package/cjs/services/transaction-service/index.js +1 -1
- package/cjs/stores/ChainlistStore.js +18 -0
- package/cjs/types/index.js +11 -0
- package/cjs/types/transaction/error.js +1 -0
- package/cjs/utils/account/transform.js +1 -1
- package/core/logic-validation/transfer.d.ts +2 -1
- package/core/logic-validation/transfer.js +36 -25
- package/core/substrate/system-pallet.js +1 -1
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +15 -2
- package/core/types.d.ts +1 -0
- package/core/utils.js +2 -2
- package/koni/api/contract-handler/utils/index.d.ts +2 -0
- package/koni/api/contract-handler/utils/index.js +12 -0
- package/koni/api/contract-handler/utils/polygon_bridge_abi.json +1004 -0
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +93 -22
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +11 -2
- package/package.json +56 -14
- package/packageInfo.js +1 -1
- package/services/balance-service/index.d.ts +3 -0
- package/services/balance-service/index.js +21 -2
- package/services/balance-service/transfer/smart-contract.js +16 -5
- package/services/balance-service/transfer/xcm/index.d.ts +1 -0
- package/services/balance-service/transfer/xcm/index.js +29 -1
- package/services/balance-service/transfer/xcm/polygonBridge.d.ts +22 -0
- package/services/balance-service/transfer/xcm/polygonBridge.js +95 -0
- package/services/chain-online-service/constants.d.ts +4 -0
- package/services/chain-online-service/constants.js +23 -0
- package/services/chain-online-service/index.d.ts +22 -0
- package/services/chain-online-service/index.js +182 -0
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +1 -0
- package/services/chain-service/index.d.ts +6 -7
- package/services/chain-service/index.js +78 -116
- package/services/chain-service/utils/index.js +0 -2
- package/services/chain-service/utils/patch.d.ts +16 -1
- package/services/chain-service/utils/patch.js +7 -3
- package/services/fee-service/utils/index.js +14 -0
- package/services/inapp-notification-service/consts.d.ts +3 -1
- package/services/inapp-notification-service/consts.js +6 -4
- package/services/inapp-notification-service/index.d.ts +10 -2
- package/services/inapp-notification-service/index.js +111 -7
- package/services/inapp-notification-service/interfaces.d.ts +27 -3
- package/services/inapp-notification-service/interfaces.js +7 -0
- package/services/inapp-notification-service/utils/avail.d.ts +40 -0
- package/services/inapp-notification-service/utils/avail.js +73 -0
- package/services/inapp-notification-service/utils/common.d.ts +11 -0
- package/services/inapp-notification-service/{utils.js → utils/common.js} +1 -72
- package/services/inapp-notification-service/utils/index.d.ts +3 -0
- package/services/inapp-notification-service/utils/index.js +6 -0
- package/services/inapp-notification-service/utils/polygon.d.ts +71 -0
- package/services/inapp-notification-service/utils/polygon.js +54 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBridge.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBridge.js +29 -0
- package/services/migration-service/scripts/index.js +3 -1
- package/services/setting-service/SettingService.d.ts +4 -0
- package/services/setting-service/SettingService.js +8 -0
- package/services/setting-service/constants.js +2 -1
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +3 -0
- package/services/transaction-service/index.js +1 -1
- package/stores/ChainlistStore.d.ts +7 -0
- package/stores/ChainlistStore.js +10 -0
- package/types/{avail-bridge → bridge}/index.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/notification/index.d.ts +5 -0
- package/types/transaction/error.d.ts +2 -1
- package/types/transaction/error.js +1 -0
- package/utils/account/transform.js +1 -1
- package/services/inapp-notification-service/utils.d.ts +0 -55
- /package/cjs/types/{avail-bridge → bridge}/index.js +0 -0
- /package/types/{avail-bridge → bridge}/index.js +0 -0
|
@@ -14,8 +14,8 @@ import { CrowdloanContributionsResponse } from '@subwallet/extension-base/servic
|
|
|
14
14
|
import { SWTransactionResponse, SWTransactionResult } from '@subwallet/extension-base/services/transaction-service/types';
|
|
15
15
|
import { WalletConnectNotSupportRequest, WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
|
|
16
16
|
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, RequestChangeTonWalletContractVersion, RequestCheckCrossChainTransfer, RequestCheckPublicAndSecretKey, RequestCheckTransfer, RequestCrossChainTransfer, RequestDeriveCreateMultiple, RequestDeriveCreateV3, RequestDeriveValidateV2, RequestEarlyValidateYield, RequestExportAccountProxyMnemonic, RequestGetAllTonWalletContractVersion, RequestGetDeriveAccounts, RequestGetDeriveSuggestion, RequestGetYieldPoolTargets, RequestInputAccountSubscribe, RequestJsonGetAccountInfo, RequestJsonRestoreV2, RequestMetadataHash, RequestMnemonicCreateV2, RequestMnemonicValidateV2, RequestPrivateKeyValidateV2, RequestShortenMetadata, RequestStakeCancelWithdrawal, RequestStakeClaimReward, 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, StorageDataInterface, SubmitYieldStepData, SwapPair, SwapQuoteResponse, SwapRequest, SwapRequestResult, SwapSubmitParams, SwapTxData, TokenSpendingApprovalParams, UnlockDotTransactionNft, UnstakingStatus, ValidateSwapProcessParams, ValidateYieldProcessParams, YieldPoolInfo, YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
17
|
-
import {
|
|
18
|
-
import { GetNotificationParams, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
|
|
17
|
+
import { RequestClaimBridge } from '@subwallet/extension-base/types/bridge';
|
|
18
|
+
import { GetNotificationParams, RequestIsClaimedPolygonBridge, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
|
|
19
19
|
import { InjectedAccount, InjectedAccountWithMeta, MetadataDefBase } from '@subwallet/extension-inject/types';
|
|
20
20
|
import { KeyringPair$Meta } from '@subwallet/keyring/types';
|
|
21
21
|
import { KeyringOptions } from '@subwallet/ui-keyring/options/types';
|
|
@@ -395,7 +395,7 @@ export declare enum ExtrinsicType {
|
|
|
395
395
|
UNSTAKE_VMANTA = "earn.unstake_vmanta",
|
|
396
396
|
TOKEN_SPENDING_APPROVAL = "token.spending_approval",
|
|
397
397
|
SWAP = "swap",
|
|
398
|
-
|
|
398
|
+
CLAIM_BRIDGE = "claim.claim_bridge",
|
|
399
399
|
EVM_EXECUTE = "evm.execute",
|
|
400
400
|
UNKNOWN = "unknown"
|
|
401
401
|
}
|
|
@@ -435,7 +435,7 @@ export interface ExtrinsicDataTypeMap {
|
|
|
435
435
|
[ExtrinsicType.REDEEM_STDOT]: RequestYieldLeave;
|
|
436
436
|
[ExtrinsicType.REDEEM_VMANTA]: RequestYieldLeave;
|
|
437
437
|
[ExtrinsicType.TOKEN_SPENDING_APPROVAL]: TokenSpendingApprovalParams;
|
|
438
|
-
[ExtrinsicType.
|
|
438
|
+
[ExtrinsicType.CLAIM_BRIDGE]: RequestClaimBridge;
|
|
439
439
|
[ExtrinsicType.EVM_EXECUTE]: TransactionConfig;
|
|
440
440
|
[ExtrinsicType.CROWDLOAN]: any;
|
|
441
441
|
[ExtrinsicType.SWAP]: SwapTxData;
|
|
@@ -471,6 +471,10 @@ export interface BasicTokenInfo {
|
|
|
471
471
|
decimals: number;
|
|
472
472
|
symbol: string;
|
|
473
473
|
}
|
|
474
|
+
export interface SufficientMetadata {
|
|
475
|
+
isSufficient: boolean;
|
|
476
|
+
minBalance: number;
|
|
477
|
+
}
|
|
474
478
|
export interface AmountData extends BasicTokenInfo {
|
|
475
479
|
value: string;
|
|
476
480
|
metadata?: unknown;
|
|
@@ -1680,7 +1684,9 @@ export interface KoniRequestSignatures {
|
|
|
1680
1684
|
'pri(inappNotification.switchReadNotificationStatus)': [RequestSwitchStatusParams, null];
|
|
1681
1685
|
'pri(inappNotification.fetch)': [GetNotificationParams, _NotificationInfo[]];
|
|
1682
1686
|
'pri(inappNotification.get)': [string, _NotificationInfo];
|
|
1683
|
-
'pri(
|
|
1687
|
+
'pri(inappNotification.isClaimedPolygonBridge)': [RequestIsClaimedPolygonBridge, boolean];
|
|
1688
|
+
'pri(availBridge.submitClaimAvailBridgeOnAvail)': [RequestClaimBridge, SWTransactionResponse];
|
|
1689
|
+
'pri(polygonBridge.submitClaimPolygonBridge)': [RequestClaimBridge, SWTransactionResponse];
|
|
1684
1690
|
'pri(ledger.generic.allow)': [null, string[], string[]];
|
|
1685
1691
|
}
|
|
1686
1692
|
export interface ApplicationMetadataType {
|
package/background/KoniTypes.js
CHANGED
|
@@ -102,7 +102,7 @@ export let ExtrinsicType;
|
|
|
102
102
|
ExtrinsicType["UNSTAKE_VMANTA"] = "earn.unstake_vmanta";
|
|
103
103
|
ExtrinsicType["TOKEN_SPENDING_APPROVAL"] = "token.spending_approval";
|
|
104
104
|
ExtrinsicType["SWAP"] = "swap";
|
|
105
|
-
ExtrinsicType["
|
|
105
|
+
ExtrinsicType["CLAIM_BRIDGE"] = "claim.claim_bridge";
|
|
106
106
|
ExtrinsicType["EVM_EXECUTE"] = "evm.execute";
|
|
107
107
|
ExtrinsicType["UNKNOWN"] = "unknown";
|
|
108
108
|
})(ExtrinsicType || (ExtrinsicType = {}));
|
|
@@ -117,7 +117,7 @@ exports.ExtrinsicType = ExtrinsicType;
|
|
|
117
117
|
ExtrinsicType["UNSTAKE_VMANTA"] = "earn.unstake_vmanta";
|
|
118
118
|
ExtrinsicType["TOKEN_SPENDING_APPROVAL"] = "token.spending_approval";
|
|
119
119
|
ExtrinsicType["SWAP"] = "swap";
|
|
120
|
-
ExtrinsicType["
|
|
120
|
+
ExtrinsicType["CLAIM_BRIDGE"] = "claim.claim_bridge";
|
|
121
121
|
ExtrinsicType["EVM_EXECUTE"] = "evm.execute";
|
|
122
122
|
ExtrinsicType["UNKNOWN"] = "unknown";
|
|
123
123
|
})(ExtrinsicType || (exports.ExtrinsicType = ExtrinsicType = {}));
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.additionalValidateTransferForRecipient = additionalValidateTransferForRecipient;
|
|
8
8
|
exports.additionalValidateXcmTransfer = additionalValidateXcmTransfer;
|
|
9
9
|
exports.checkBalanceWithTransactionFee = checkBalanceWithTransactionFee;
|
|
10
10
|
exports.checkSigningAccountForTransaction = checkSigningAccountForTransaction;
|
|
@@ -59,44 +59,55 @@ function validateTransferRequest(tokenInfo, from, to, value, transferAll) {
|
|
|
59
59
|
}
|
|
60
60
|
return [errors, keypair, transferValue];
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
const
|
|
62
|
+
function additionalValidateTransferForRecipient(sendingTokenInfo, nativeTokenInfo, extrinsicType, receiverSendingTokenKeepAliveBalance, transferAmount, senderSendingTokenTransferable, receiverSystemAccountInfo, isSendingTokenSufficient) {
|
|
63
|
+
const sendingTokenMinAmount = BigInt((0, _utils2._getTokenMinAmount)(sendingTokenInfo));
|
|
64
|
+
const nativeTokenMinAmount = (0, _utils2._getTokenMinAmount)(nativeTokenInfo);
|
|
65
65
|
const warnings = [];
|
|
66
66
|
const errors = [];
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const remainingSendingTokenOfSenderEnoughED = senderSendingTokenTransferable ? senderSendingTokenTransferable - transferAmount >= sendingTokenMinAmount : false;
|
|
68
|
+
const isReceiverAliveByNativeToken = receiverSystemAccountInfo ? (0, _systemPallet._isAccountActive)(receiverSystemAccountInfo) : false;
|
|
69
|
+
const isReceivingAmountPassED = receiverSendingTokenKeepAliveBalance + transferAmount >= sendingTokenMinAmount;
|
|
70
|
+
if (extrinsicType === _KoniTypes.ExtrinsicType.TRANSFER_TOKEN) {
|
|
71
|
+
if (!remainingSendingTokenOfSenderEnoughED) {
|
|
71
72
|
const warning = new _TransactionWarning.TransactionWarning(_types.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT);
|
|
72
73
|
warnings.push(warning);
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('The recipient account has {{amount}} {{nativeSymbol}} which can lead to your {{localSymbol}} being lost. Change recipient account and try again', {
|
|
75
|
+
if (!isReceiverAliveByNativeToken && !isSendingTokenSufficient) {
|
|
76
|
+
const balanceKeepAlive = (0, _utils4.formatNumber)(nativeTokenMinAmount, (0, _utils2._getAssetDecimals)(nativeTokenInfo), _utils4.balanceFormatter, {
|
|
77
|
+
maxNumberFormat: (0, _utils2._getAssetDecimals)(nativeTokenInfo) || 6
|
|
78
|
+
});
|
|
79
|
+
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', {
|
|
80
80
|
replace: {
|
|
81
|
-
amount:
|
|
81
|
+
amount: balanceKeepAlive,
|
|
82
82
|
nativeSymbol: nativeTokenInfo.symbol,
|
|
83
|
-
localSymbol:
|
|
83
|
+
localSymbol: sendingTokenInfo.symbol
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
errors.push(error);
|
|
87
|
+
}
|
|
88
|
+
if (!isReceivingAmountPassED) {
|
|
89
|
+
const atLeast = sendingTokenMinAmount - receiverSendingTokenKeepAliveBalance;
|
|
90
|
+
const atLeastStr = (0, _utils4.formatNumber)(atLeast.toString(), (0, _utils2._getAssetDecimals)(sendingTokenInfo), _utils4.balanceFormatter, {
|
|
91
|
+
maxNumberFormat: (0, _utils2._getAssetDecimals)(sendingTokenInfo) || 6
|
|
92
|
+
});
|
|
93
|
+
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', {
|
|
94
|
+
replace: {
|
|
95
|
+
amount: atLeastStr,
|
|
96
|
+
symbol: sendingTokenInfo.symbol
|
|
84
97
|
}
|
|
85
98
|
}));
|
|
86
99
|
errors.push(error);
|
|
87
100
|
}
|
|
88
101
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const atLeastStr = (0, _utils4.formatNumber)(atLeast, tokenInfo.decimals || 0, _utils4.balanceFormatter, {
|
|
94
|
-
maxNumberFormat: tokenInfo.decimals || 6
|
|
102
|
+
if (!isReceivingAmountPassED) {
|
|
103
|
+
const atLeast = sendingTokenMinAmount - receiverSendingTokenKeepAliveBalance;
|
|
104
|
+
const atLeastStr = (0, _utils4.formatNumber)(atLeast.toString(), (0, _utils2._getAssetDecimals)(sendingTokenInfo), _utils4.balanceFormatter, {
|
|
105
|
+
maxNumberFormat: (0, _utils2._getAssetDecimals)(sendingTokenInfo) || 6
|
|
95
106
|
});
|
|
96
|
-
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
|
|
107
|
+
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', {
|
|
97
108
|
replace: {
|
|
98
109
|
amount: atLeastStr,
|
|
99
|
-
symbol:
|
|
110
|
+
symbol: sendingTokenInfo.symbol
|
|
100
111
|
}
|
|
101
112
|
}));
|
|
102
113
|
errors.push(error);
|
|
@@ -30,7 +30,7 @@ function _canAccountBeReaped(accountInfo) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function _isAccountActive(accountInfo) {
|
|
33
|
-
return accountInfo.providers === 0 && accountInfo.
|
|
33
|
+
return !(accountInfo.consumers === 0 && accountInfo.providers === 0 && accountInfo.sufficients === 0);
|
|
34
34
|
}
|
|
35
35
|
function _getSystemPalletTotalBalance(accountInfo) {
|
|
36
36
|
if (isV1(accountInfo)) {
|
|
@@ -11,11 +11,13 @@ exports._getXcmMultiLocation = _getXcmMultiLocation;
|
|
|
11
11
|
exports._getXcmUnstableWarning = _getXcmUnstableWarning;
|
|
12
12
|
exports._isAvailBridgeXcm = _isAvailBridgeXcm;
|
|
13
13
|
exports._isMythosFromHydrationToMythos = _isMythosFromHydrationToMythos;
|
|
14
|
+
exports._isPolygonBridgeXcm = _isPolygonBridgeXcm;
|
|
14
15
|
exports._isSnowBridgeXcm = _isSnowBridgeXcm;
|
|
15
16
|
exports._isXcmTransferUnstable = _isXcmTransferUnstable;
|
|
16
17
|
exports._isXcmWithinSameConsensus = _isXcmWithinSameConsensus;
|
|
17
18
|
var _chainList = require("@subwallet/chain-list");
|
|
18
19
|
var _availBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge");
|
|
20
|
+
var _polygonBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge");
|
|
19
21
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
20
22
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
21
23
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
@@ -64,7 +66,7 @@ function _getXcmMultiLocation(originChainInfo, destChainInfo, version, recipient
|
|
|
64
66
|
};
|
|
65
67
|
}
|
|
66
68
|
function _isXcmTransferUnstable(originChainInfo, destChainInfo, assetSlug) {
|
|
67
|
-
return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) || _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug);
|
|
69
|
+
return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) || _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) || _isPolygonBridgeXcm(originChainInfo, destChainInfo);
|
|
68
70
|
}
|
|
69
71
|
function getAssetHubBridgeUnstableWarning(originChainInfo) {
|
|
70
72
|
switch (originChainInfo.slug) {
|
|
@@ -92,8 +94,17 @@ function getMythosFromHydrationToMythosWarning() {
|
|
|
92
94
|
function getAvailBridgeWarning() {
|
|
93
95
|
return 'Cross-chain transfer of this token may take up to 90 minutes, and you’ll need to manually claim the funds on the destination network to complete the transfer. Do you still want to continue?';
|
|
94
96
|
}
|
|
97
|
+
function getPolygonBridgeWarning(originChainInfo) {
|
|
98
|
+
if (originChainInfo.slug === _chainList.COMMON_CHAIN_SLUGS.ETHEREUM || originChainInfo.slug === _chainList.COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
|
|
99
|
+
return 'Cross-chain transfer of this token may take up to 40 minutes. Do you still want to continue?';
|
|
100
|
+
} else {
|
|
101
|
+
return 'Cross-chain transfer of this token may take up to 3 hours, and you’ll need to manually claim the funds on the destination network to complete the transfer. Do you still want to continue?';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
95
104
|
function _getXcmUnstableWarning(originChainInfo, destChainInfo, assetSlug) {
|
|
96
|
-
if (
|
|
105
|
+
if (_isPolygonBridgeXcm(originChainInfo, destChainInfo)) {
|
|
106
|
+
return getPolygonBridgeWarning(originChainInfo);
|
|
107
|
+
} else if (_isAvailBridgeXcm(originChainInfo, destChainInfo)) {
|
|
97
108
|
return getAvailBridgeWarning();
|
|
98
109
|
} else if (_isSnowBridgeXcm(originChainInfo, destChainInfo)) {
|
|
99
110
|
return getSnowBridgeUnstableWarning(originChainInfo);
|
|
@@ -117,6 +128,9 @@ function _isAvailBridgeXcm(originChainInfo, destChainInfo) {
|
|
|
117
128
|
function _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) {
|
|
118
129
|
return originChainInfo.slug === 'hydradx_main' && destChainInfo.slug === 'mythos' && assetSlug === 'hydradx_main-LOCAL-MYTH';
|
|
119
130
|
}
|
|
131
|
+
function _isPolygonBridgeXcm(originChainInfo, destChainInfo) {
|
|
132
|
+
return (0, _polygonBridge._isPolygonChainBridge)(originChainInfo.slug, destChainInfo.slug);
|
|
133
|
+
}
|
|
120
134
|
|
|
121
135
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
122
136
|
|
package/cjs/core/utils.js
CHANGED
|
@@ -15,7 +15,6 @@ exports.getMaxBigInt = getMaxBigInt;
|
|
|
15
15
|
exports.getStrictMode = getStrictMode;
|
|
16
16
|
exports.ledgerMustCheckNetwork = ledgerMustCheckNetwork;
|
|
17
17
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
18
|
-
var _consts = require("@subwallet/extension-base/core/consts");
|
|
19
18
|
var _types = require("@subwallet/extension-base/core/substrate/types");
|
|
20
19
|
var _utils = require("@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils");
|
|
21
20
|
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
@@ -115,6 +114,7 @@ function _isNotDuplicateAddress(validateRecipientParams) {
|
|
|
115
114
|
function _isSupportLedgerAccount(validateRecipientParams) {
|
|
116
115
|
const {
|
|
117
116
|
account,
|
|
117
|
+
allowLedgerGenerics,
|
|
118
118
|
destChainInfo
|
|
119
119
|
} = validateRecipientParams;
|
|
120
120
|
if (account !== null && account !== void 0 && account.isHardware) {
|
|
@@ -129,7 +129,7 @@ function _isSupportLedgerAccount(validateRecipientParams) {
|
|
|
129
129
|
} else {
|
|
130
130
|
// For ledger generic
|
|
131
131
|
const ledgerCheck = ledgerMustCheckNetwork(account);
|
|
132
|
-
if (ledgerCheck !== 'unnecessary' && !
|
|
132
|
+
if (ledgerCheck !== 'unnecessary' && !allowLedgerGenerics.includes(destChainInfo.slug)) {
|
|
133
133
|
return `Ledger ${ledgerCheck === 'polkadot' ? 'Polkadot' : 'Migration'} address is not supported for this transfer`;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports._TEST_ERC721_ABI = exports._SNOWBRIDGE_GATEWAY_ABI = exports._PSP34_ABI = exports._PSP22_ABI = exports._PINK_PSP34_ABI = exports._NEUROGUNS_PSP34_ABI = exports._ERC721_ABI = exports._ERC20_ABI = exports._AZERO_DOMAIN_REGISTRY_ABI = exports._AVAIL_TEST_BRIDGE_GATEWAY_ABI = exports._AVAIL_BRIDGE_GATEWAY_ABI = void 0;
|
|
6
|
+
exports._TEST_ERC721_ABI = exports._SNOWBRIDGE_GATEWAY_ABI = exports._PSP34_ABI = exports._PSP22_ABI = exports._POLYGON_BRIDGE_ABI = exports._PINK_PSP34_ABI = exports._NEUROGUNS_PSP34_ABI = exports._ERC721_ABI = exports._ERC20_ABI = exports._AZERO_DOMAIN_REGISTRY_ABI = exports._AVAIL_TEST_BRIDGE_GATEWAY_ABI = exports._AVAIL_BRIDGE_GATEWAY_ABI = void 0;
|
|
7
7
|
exports.getAvailBridgeGatewayContract = getAvailBridgeGatewayContract;
|
|
8
|
+
exports.getPolygonBridgeContract = getPolygonBridgeContract;
|
|
8
9
|
exports.getSnowBridgeGatewayContract = getSnowBridgeGatewayContract;
|
|
9
10
|
exports.isAvailBridgeGatewayContract = isAvailBridgeGatewayContract;
|
|
10
11
|
exports.isSnowBridgeGatewayContract = isSnowBridgeGatewayContract;
|
|
@@ -44,7 +45,10 @@ const _AVAIL_BRIDGE_GATEWAY_ABI = require('./avail_bridge_abi.json');
|
|
|
44
45
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
45
46
|
exports._AVAIL_BRIDGE_GATEWAY_ABI = _AVAIL_BRIDGE_GATEWAY_ABI;
|
|
46
47
|
const _AVAIL_TEST_BRIDGE_GATEWAY_ABI = require('./avail_test_bridge_abi.json');
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
47
49
|
exports._AVAIL_TEST_BRIDGE_GATEWAY_ABI = _AVAIL_TEST_BRIDGE_GATEWAY_ABI;
|
|
50
|
+
const _POLYGON_BRIDGE_ABI = require('./polygon_bridge_abi.json');
|
|
51
|
+
exports._POLYGON_BRIDGE_ABI = _POLYGON_BRIDGE_ABI;
|
|
48
52
|
const SNOWBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x27ca963C279c93801941e1eB8799c23f407d68e7';
|
|
49
53
|
const SNOWBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x5B4909cE6Ca82d2CE23BD46738953c7959E710Cd';
|
|
50
54
|
function getSnowBridgeGatewayContract(chain) {
|
|
@@ -66,4 +70,14 @@ function getAvailBridgeGatewayContract(chain) {
|
|
|
66
70
|
}
|
|
67
71
|
function isAvailBridgeGatewayContract(contractAddress) {
|
|
68
72
|
return [AVAILBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS, AVAILBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS].includes(contractAddress);
|
|
73
|
+
}
|
|
74
|
+
const POLYGONBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe';
|
|
75
|
+
const POLYGONBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582';
|
|
76
|
+
function getPolygonBridgeContract(chain) {
|
|
77
|
+
if (chain === 'polygonzkEvm_cardona' || chain === _chainList.COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
|
|
78
|
+
return POLYGONBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS;
|
|
79
|
+
} else if (chain === 'polygonZkEvm' || chain === _chainList.COMMON_CHAIN_SLUGS.ETHEREUM) {
|
|
80
|
+
return POLYGONBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS;
|
|
81
|
+
}
|
|
82
|
+
throw new Error('Invalid chain');
|
|
69
83
|
}
|