@subwallet/extension-base 1.3.70-2 → 1.3.72-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 +13 -2
- package/background/KoniTypes.js +68 -9
- package/cjs/background/KoniTypes.js +68 -9
- package/cjs/constants/blocked-actions.js +3 -0
- package/cjs/core/logic-validation/recipientAddress.js +1 -1
- package/cjs/core/logic-validation/swap.js +0 -3
- package/cjs/core/logic-validation/transfer.js +33 -10
- package/cjs/core/substrate/system-pallet.js +0 -2
- package/cjs/core/types.js +1 -0
- package/cjs/koni/api/nft/wasm_nft/index.js +0 -1
- package/cjs/koni/api/staking/bonding/astar.js +0 -2
- package/cjs/koni/api/staking/bonding/paraChain.js +0 -3
- package/cjs/koni/api/staking/bonding/relayChain.js +2 -4
- package/cjs/koni/api/staking/bonding/utils.js +0 -4
- package/cjs/koni/background/cron.js +0 -1
- package/cjs/koni/background/handlers/Extension.js +235 -166
- package/cjs/koni/background/handlers/State.js +56 -52
- package/cjs/koni/background/handlers/Tabs.js +39 -34
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/index.js +7 -0
- package/cjs/page/substrate/PostMessageProvider.js +3 -0
- package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +48 -5
- package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
- package/cjs/services/balance-service/index.js +103 -7
- package/cjs/services/balance-service/transfer/bitcoin-transfer.js +0 -1
- package/cjs/services/balance-service/transfer/cardano-transfer.js +1 -2
- package/cjs/services/balance-service/transfer/smart-contract.js +0 -1
- package/cjs/services/balance-service/transfer/token.js +13 -37
- package/cjs/services/balance-service/transfer/ton-transfer.js +0 -1
- package/cjs/services/balance-service/transfer/xcm/index.js +3 -8
- package/cjs/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- package/cjs/services/balance-service/transfer/xcm/utils.js +1 -1
- package/cjs/services/chain-service/constants.js +6 -5
- package/cjs/services/chain-service/handler/CardanoApi.js +3 -1
- package/cjs/services/chain-service/handler/SubstrateApi.js +0 -2
- package/cjs/services/chain-service/handler/light-client/index.js +1 -2
- package/cjs/services/chain-service/health-check/index.js +0 -1
- package/cjs/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
- package/cjs/services/chain-service/index.js +19 -26
- package/cjs/services/chain-service/utils/index.js +21 -25
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/base.js +32 -0
- package/cjs/services/earning-service/handlers/lending/base.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -1
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +43 -2
- package/cjs/services/earning-service/handlers/native-staking/energy.js +0 -1
- package/cjs/services/earning-service/handlers/native-staking/mythos.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
- package/cjs/services/earning-service/handlers/special.js +7 -0
- package/cjs/services/history-service/subsquid-multi-chain-history.js +0 -1
- package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
- package/cjs/services/keyring-service/context/handlers/Migration.js +11 -9
- package/cjs/services/keyring-service/context/handlers/Mnemonic.js +18 -13
- package/cjs/services/keyring-service/context/state.js +21 -3
- package/cjs/services/keyring-service/utils.js +12 -2
- package/cjs/services/migration-service/index.js +1 -2
- package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +55 -0
- package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +41 -0
- package/cjs/services/migration-service/scripts/index.js +17 -13
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
- package/cjs/services/nft-service/index.js +5 -0
- package/cjs/services/open-gov/handler.js +0 -2
- package/cjs/services/open-gov/interface.js +4 -1
- package/cjs/services/request-service/handler/BitcoinRequestHandler.js +1 -2
- package/cjs/services/request-service/handler/CardanoRequestHandler.js +0 -1
- package/cjs/services/request-service/handler/EvmRequestHandler.js +0 -1
- package/cjs/services/request-service/handler/TonRequestHandler.js +0 -1
- package/cjs/services/request-service/helper/index.js +1 -2
- package/cjs/services/storage-service/DatabaseService.js +0 -2
- package/cjs/services/storage-service/databases/index.js +2 -0
- package/cjs/services/substrate-proxy-service/constant.js +26 -0
- package/cjs/services/substrate-proxy-service/index.js +170 -0
- package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -1
- package/cjs/services/swap-service/handler/asset-hub/router.js +0 -1
- package/cjs/services/swap-service/handler/chainflip-handler.js +1 -4
- package/cjs/services/swap-service/handler/hydradx-handler.js +0 -1
- package/cjs/services/swap-service/handler/kyber-handler.js +0 -1
- package/cjs/services/swap-service/handler/optimex-handler.js +1 -2
- package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -3
- package/cjs/services/swap-service/handler/uniswap-handler.js +0 -3
- package/cjs/services/transaction-service/event-parser/index.js +6 -6
- package/cjs/services/transaction-service/index.js +105 -37
- package/cjs/services/transaction-service/utils.js +8 -5
- package/cjs/services/wallet-connect-service/index.js +21 -18
- package/cjs/services/wallet-connect-service/types.js +1 -1
- package/cjs/types/account/info/keyring.js +9 -1
- package/cjs/types/balance/index.js +5 -1
- package/cjs/types/index.js +11 -0
- package/cjs/types/substrateProxyAccount/actions/index.js +1 -0
- package/cjs/types/substrateProxyAccount/index.js +16 -0
- package/cjs/types/swap/index.js +2 -1
- package/cjs/types/transaction/process.js +2 -0
- package/cjs/types/yield/actions/join/step.js +17 -1
- package/cjs/utils/account/common.js +0 -26
- package/cjs/utils/account/derive/info/solo.js +7 -4
- package/cjs/utils/account/derive/validate.js +1 -1
- package/cjs/utils/account/transform.js +10 -5
- package/cjs/utils/auth.js +1 -1
- package/cjs/utils/bitcoin/utxo-management.js +0 -1
- package/cjs/utils/environment.js +2 -1
- package/cjs/utils/fee/transfer.js +5 -4
- package/cjs/utils/index.js +1 -2
- package/constants/blocked-actions.js +3 -0
- package/core/logic-validation/recipientAddress.js +1 -1
- package/core/logic-validation/swap.js +0 -3
- package/core/logic-validation/transfer.d.ts +3 -3
- package/core/logic-validation/transfer.js +34 -11
- package/core/substrate/system-pallet.js +0 -2
- package/core/types.d.ts +2 -1
- package/core/types.js +1 -0
- package/koni/api/nft/wasm_nft/index.js +0 -1
- package/koni/api/staking/bonding/astar.js +0 -2
- package/koni/api/staking/bonding/paraChain.js +0 -3
- package/koni/api/staking/bonding/relayChain.js +2 -4
- package/koni/api/staking/bonding/utils.js +0 -4
- package/koni/background/cron.js +0 -1
- package/koni/background/handlers/Extension.d.ts +3 -0
- package/koni/background/handlers/Extension.js +89 -19
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +43 -38
- package/koni/background/handlers/Tabs.js +9 -3
- package/package.json +50 -21
- package/packageInfo.js +1 -1
- package/page/substrate/PostMessageProvider.js +3 -0
- package/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
- package/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
- package/services/balance-service/helpers/subscribe/substrate/index.js +47 -4
- package/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
- package/services/balance-service/index.d.ts +8 -0
- package/services/balance-service/index.js +105 -9
- package/services/balance-service/transfer/bitcoin-transfer.js +0 -1
- package/services/balance-service/transfer/smart-contract.js +0 -1
- package/services/balance-service/transfer/token.d.ts +0 -4
- package/services/balance-service/transfer/token.js +12 -35
- package/services/balance-service/transfer/ton-transfer.js +0 -1
- package/services/balance-service/transfer/xcm/index.js +3 -8
- package/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- package/services/balance-service/transfer/xcm/utils.d.ts +0 -2
- package/services/balance-service/transfer/xcm/utils.js +1 -1
- package/services/chain-service/constants.d.ts +1 -1
- package/services/chain-service/constants.js +4 -4
- package/services/chain-service/handler/CardanoApi.js +3 -1
- package/services/chain-service/handler/SubstrateApi.js +0 -2
- package/services/chain-service/health-check/index.js +0 -1
- package/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
- package/services/chain-service/index.d.ts +0 -1
- package/services/chain-service/index.js +16 -23
- package/services/chain-service/utils/index.js +22 -26
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/base.js +32 -0
- package/services/earning-service/handlers/lending/base.js +0 -2
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -1
- package/services/earning-service/handlers/liquid-staking/base.js +0 -2
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
- package/services/earning-service/handlers/native-staking/astar.js +0 -2
- package/services/earning-service/handlers/native-staking/dtao.js +43 -0
- package/services/earning-service/handlers/native-staking/energy.js +0 -1
- package/services/earning-service/handlers/native-staking/mythos.js +0 -2
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -2
- package/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
- package/services/earning-service/handlers/special.js +7 -0
- package/services/history-service/subsquid-multi-chain-history.js +0 -1
- package/services/keyring-service/context/handlers/Derive.js +2 -2
- package/services/keyring-service/context/handlers/Migration.js +3 -1
- package/services/keyring-service/context/handlers/Mnemonic.d.ts +1 -1
- package/services/keyring-service/context/handlers/Mnemonic.js +16 -10
- package/services/keyring-service/context/state.d.ts +3 -0
- package/services/keyring-service/context/state.js +21 -3
- package/services/keyring-service/utils.d.ts +1 -0
- package/services/keyring-service/utils.js +9 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +46 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +33 -0
- package/services/migration-service/scripts/index.js +8 -4
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
- package/services/nft-service/index.js +6 -0
- package/services/open-gov/handler.js +0 -2
- package/services/open-gov/interface.d.ts +4 -3
- package/services/open-gov/interface.js +4 -1
- package/services/request-service/handler/CardanoRequestHandler.js +0 -1
- package/services/request-service/handler/EvmRequestHandler.js +0 -1
- package/services/request-service/handler/TonRequestHandler.js +0 -1
- package/services/setting-service/constants.js +0 -1
- package/services/storage-service/DatabaseService.js +0 -2
- package/services/storage-service/databases/index.js +3 -0
- package/services/substrate-proxy-service/constant.d.ts +3 -0
- package/services/substrate-proxy-service/constant.js +19 -0
- package/services/substrate-proxy-service/index.d.ts +13 -0
- package/services/substrate-proxy-service/index.js +159 -0
- package/services/swap-service/handler/asset-hub/handler.js +0 -1
- package/services/swap-service/handler/asset-hub/router.js +0 -1
- package/services/swap-service/handler/chainflip-handler.js +0 -2
- package/services/swap-service/handler/hydradx-handler.js +0 -1
- package/services/swap-service/handler/kyber-handler.js +0 -1
- package/services/swap-service/handler/simpleswap-handler.js +0 -1
- package/services/swap-service/handler/uniswap-handler.js +0 -3
- package/services/transaction-service/event-parser/index.js +6 -6
- package/services/transaction-service/index.js +79 -11
- package/services/transaction-service/types.d.ts +2 -2
- package/services/transaction-service/utils.js +8 -5
- package/services/wallet-connect-service/index.js +21 -18
- package/services/wallet-connect-service/types.js +1 -1
- package/types/account/action/add/mnemonic.d.ts +3 -2
- package/types/account/info/keyring.js +9 -1
- package/types/balance/index.js +5 -1
- package/types/balance/transfer.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/substrateProxyAccount/actions/index.d.ts +17 -0
- package/types/substrateProxyAccount/actions/index.js +1 -0
- package/types/substrateProxyAccount/index.d.ts +23 -0
- package/types/substrateProxyAccount/index.js +8 -0
- package/types/swap/index.js +2 -1
- package/types/transaction/process.js +3 -1
- package/types/transaction/request.d.ts +1 -0
- package/types/yield/actions/join/step.js +17 -1
- package/types/yield/actions/join/submit.d.ts +1 -1
- package/utils/account/common.d.ts +0 -3
- package/utils/account/common.js +0 -24
- package/utils/account/derive/info/solo.js +8 -5
- package/utils/account/derive/validate.d.ts +2 -2
- package/utils/account/derive/validate.js +1 -1
- package/utils/account/transform.js +10 -5
- package/utils/auth.js +2 -2
- package/utils/bitcoin/utxo-management.js +0 -1
- package/utils/fee/transfer.js +4 -2
- package/utils/index.js +2 -5
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _actions = require("./actions");
|
|
7
|
+
Object.keys(_actions).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _actions[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _actions[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
package/cjs/types/swap/index.js
CHANGED
|
@@ -55,7 +55,8 @@ exports.SwapFeeType = SwapFeeType;
|
|
|
55
55
|
SwapFeeType["PLATFORM_FEE"] = "PLATFORM_FEE";
|
|
56
56
|
SwapFeeType["NETWORK_FEE"] = "NETWORK_FEE";
|
|
57
57
|
SwapFeeType["WALLET_FEE"] = "WALLET_FEE";
|
|
58
|
-
})(SwapFeeType || (exports.SwapFeeType = SwapFeeType = {}));
|
|
58
|
+
})(SwapFeeType || (exports.SwapFeeType = SwapFeeType = {})); // todo: will be more
|
|
59
|
+
// parameters & responses
|
|
59
60
|
let DynamicSwapType;
|
|
60
61
|
exports.DynamicSwapType = DynamicSwapType;
|
|
61
62
|
(function (DynamicSwapType) {
|
|
@@ -25,4 +25,6 @@ exports.StepStatus = StepStatus;
|
|
|
25
25
|
StepStatus["TIMEOUT"] = "TIMEOUT";
|
|
26
26
|
})(StepStatus || (exports.StepStatus = StepStatus = {}));
|
|
27
27
|
const PROCESSING_STEP_STATUS = [StepStatus.PREPARE, StepStatus.SUBMITTING, StepStatus.PROCESSING];
|
|
28
|
+
|
|
29
|
+
// temp for avoid conflict // todo: recheck to refactor BriefXcmStepV2 and BriefSwapStepV2 later;
|
|
28
30
|
exports.PROCESSING_STEP_STATUS = PROCESSING_STEP_STATUS;
|
|
@@ -45,4 +45,20 @@ exports.YieldStepType = YieldStepType;
|
|
|
45
45
|
YieldStepType["MINT_SDOT"] = "MINT_SDOT";
|
|
46
46
|
YieldStepType["MINT_STDOT"] = "MINT_STDOT";
|
|
47
47
|
YieldStepType["TOKEN_APPROVAL"] = "TOKEN_APPROVAL";
|
|
48
|
-
})(YieldStepType || (exports.YieldStepType = YieldStepType = {}));
|
|
48
|
+
})(YieldStepType || (exports.YieldStepType = YieldStepType = {}));
|
|
49
|
+
/**
|
|
50
|
+
* @interface YieldStepDetail
|
|
51
|
+
* @extends BaseYieldStepDetail
|
|
52
|
+
* @description Detail of a step
|
|
53
|
+
* @prop {number} id - Step's id
|
|
54
|
+
* */
|
|
55
|
+
/**
|
|
56
|
+
* @interface YieldTokenBaseInfo
|
|
57
|
+
* @prop {string} slug - Token's slug
|
|
58
|
+
* @prop {string} [amount] - Token's amount
|
|
59
|
+
* */
|
|
60
|
+
/** Base info and fee of a step */
|
|
61
|
+
/**
|
|
62
|
+
* @interface OptimalYieldPath
|
|
63
|
+
* @description Result after generate steps
|
|
64
|
+
* */
|
|
@@ -7,7 +7,6 @@ exports.getAccountJsonByAddress = exports.getAccountChainTypeForAddress = export
|
|
|
7
7
|
exports.getAddressesByChainType = getAddressesByChainType;
|
|
8
8
|
exports.getAddressesByChainTypeMap = getAddressesByChainTypeMap;
|
|
9
9
|
exports.isAccountAll = isAccountAll;
|
|
10
|
-
exports.modifyAccountName = void 0;
|
|
11
10
|
exports.quickFormatAddressToCompare = quickFormatAddressToCompare;
|
|
12
11
|
exports.reformatAddress = reformatAddress;
|
|
13
12
|
var _constants = require("@subwallet/extension-base/constants");
|
|
@@ -80,7 +79,6 @@ function getAddressesByChainType(addresses, chainTypes, chainInfo) {
|
|
|
80
79
|
return addressByChainTypeMap[chainType];
|
|
81
80
|
}).flat(); // todo: recheck
|
|
82
81
|
}
|
|
83
|
-
|
|
84
82
|
function getAddressesByChainTypeMap(addresses, chainInfo) {
|
|
85
83
|
const addressByChainType = {
|
|
86
84
|
substrate: [],
|
|
@@ -120,29 +118,6 @@ function quickFormatAddressToCompare(address) {
|
|
|
120
118
|
return reformatAddress(address, 42).toLowerCase();
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
/** @deprecated */
|
|
124
|
-
const modifyAccountName = (type, name, modify) => {
|
|
125
|
-
if (!modify) {
|
|
126
|
-
return name;
|
|
127
|
-
}
|
|
128
|
-
let network = '';
|
|
129
|
-
switch (type) {
|
|
130
|
-
case 'sr25519':
|
|
131
|
-
case 'ed25519':
|
|
132
|
-
case 'ecdsa':
|
|
133
|
-
network = 'Substrate';
|
|
134
|
-
break;
|
|
135
|
-
case 'ethereum':
|
|
136
|
-
network = 'EVM';
|
|
137
|
-
break;
|
|
138
|
-
case 'ton':
|
|
139
|
-
case 'ton-native':
|
|
140
|
-
network = 'Ton';
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
return network ? [name, network].join(' - ') : name;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
121
|
/**
|
|
147
122
|
* @function getAccountJsonByAddress
|
|
148
123
|
* @desc Get account info by address
|
|
@@ -152,7 +127,6 @@ const modifyAccountName = (type, name, modify) => {
|
|
|
152
127
|
* @param {string} address - Address
|
|
153
128
|
* @returns {AccountJson|null} - Account info or null if not found
|
|
154
129
|
*/
|
|
155
|
-
exports.modifyAccountName = modifyAccountName;
|
|
156
130
|
const getAccountJsonByAddress = address => {
|
|
157
131
|
try {
|
|
158
132
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
@@ -59,7 +59,7 @@ const parseUnifiedSuriToDerivationPath = (suri, type) => {
|
|
|
59
59
|
return path.replace('{firstIndex}', firstIndex);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
if (_types.
|
|
62
|
+
if (_types.DefaultSubstrateKeypairTypes.includes(type)) {
|
|
63
63
|
return suri;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -120,7 +120,7 @@ const getSoloDerivationInfo = function (type) {
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
} else {
|
|
123
|
-
if (_types.
|
|
123
|
+
if (_types.DefaultSubstrateKeypairTypes.includes(type)) {
|
|
124
124
|
const _type = type;
|
|
125
125
|
const validateTypeFunc = _type === 'sr25519' ? _validate.validateSr25519DerivationPath : raw => (0, _validate.validateOtherSubstrateDerivationPath)(raw, _type);
|
|
126
126
|
const validateTypeRs = validateTypeFunc(suri);
|
|
@@ -256,7 +256,7 @@ const findSoloNextDerive = parentAddress => {
|
|
|
256
256
|
break;
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
const isSubstrate = _types.
|
|
259
|
+
const isSubstrate = _types.DefaultSubstrateKeypairTypes.includes(parentPair.type);
|
|
260
260
|
const indexes = currentDepth > 0 ? deriveInfo.autoIndexes || [] : [];
|
|
261
261
|
indexes.push(index);
|
|
262
262
|
const suri = isSubstrate ? [deriveInfo.suri || '', index].join('//') : '//'.concat(indexes.join('//'));
|
|
@@ -296,7 +296,10 @@ const derivePair = (parentPair, name, suri, derivationPath) => {
|
|
|
296
296
|
};
|
|
297
297
|
exports.derivePair = derivePair;
|
|
298
298
|
const getSuri = (seed, type) => {
|
|
299
|
-
|
|
299
|
+
if (!type) {
|
|
300
|
+
return seed;
|
|
301
|
+
}
|
|
302
|
+
const extraPath = (0, _keyring.getDerivePath)(type)(0);
|
|
300
303
|
return seed + (extraPath ? '/' + extraPath : '');
|
|
301
304
|
};
|
|
302
305
|
exports.getSuri = getSuri;
|
|
@@ -259,7 +259,7 @@ const validateDerivationPath = (raw, type) => {
|
|
|
259
259
|
return validateTonDerivationPath(raw);
|
|
260
260
|
} else if (type === 'sr25519') {
|
|
261
261
|
return validateSr25519DerivationPath(raw);
|
|
262
|
-
} else if (type === 'ed25519' || type === 'ecdsa') {
|
|
262
|
+
} else if (type === 'ed25519' || type === 'ed25519-tw' || type === 'ecdsa') {
|
|
263
263
|
return validateOtherSubstrateDerivationPath(raw, type);
|
|
264
264
|
} else if (type === 'cardano') {
|
|
265
265
|
return validateCardanoDerivationPath(raw);
|
|
@@ -115,7 +115,10 @@ const getAccountActions = (signMode, networkType, type, _meta, parentAccount) =>
|
|
|
115
115
|
// QR
|
|
116
116
|
if (signMode === _types2.AccountSignMode.PASSWORD) {
|
|
117
117
|
if (networkType === _types2.AccountChainType.ETHEREUM || networkType === _types2.AccountChainType.SUBSTRATE) {
|
|
118
|
-
|
|
118
|
+
if (type !== 'ed25519-tw') {
|
|
119
|
+
// todo: recheck if can export this account type
|
|
120
|
+
result.push(_types2.AccountActions.EXPORT_QR);
|
|
121
|
+
}
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
|
|
@@ -165,14 +168,15 @@ const EARN_VMANTA_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_VMANTA, _KoniTypes.Ex
|
|
|
165
168
|
const EVM_ACTIONS = [_KoniTypes.ExtrinsicType.TOKEN_SPENDING_APPROVAL, _KoniTypes.ExtrinsicType.EVM_EXECUTE];
|
|
166
169
|
const CLAIM_AVAIL_BRIDGE = [_KoniTypes.ExtrinsicType.CLAIM_BRIDGE];
|
|
167
170
|
const OPEN_GOV_ACTIONS = [_KoniTypes.ExtrinsicType.GOV_VOTE, _KoniTypes.ExtrinsicType.GOV_UNVOTE, _KoniTypes.ExtrinsicType.GOV_UNLOCK_VOTE];
|
|
171
|
+
const SUBSTRATE_PROXY_ACTION = [_KoniTypes.ExtrinsicType.ADD_SUBSTRATE_PROXY_ACCOUNT, _KoniTypes.ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT];
|
|
168
172
|
const OTHER_ACTIONS = [_KoniTypes.ExtrinsicType.TRANSFER_XCM, _KoniTypes.ExtrinsicType.SEND_NFT, _KoniTypes.ExtrinsicType.SWAP, _KoniTypes.ExtrinsicType.CROWDLOAN];
|
|
169
173
|
const getAccountTransactionActions = (signMode, networkType, type, _meta, _specialNetwork) => {
|
|
170
174
|
if ([_types2.AccountSignMode.PASSWORD, _types2.AccountSignMode.INJECTED].includes(signMode)) {
|
|
171
175
|
switch (networkType) {
|
|
172
176
|
case _types2.AccountChainType.SUBSTRATE:
|
|
173
|
-
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
|
|
177
|
+
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OPEN_GOV_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
|
|
174
178
|
case _types2.AccountChainType.ETHEREUM:
|
|
175
|
-
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...EVM_ACTIONS];
|
|
179
|
+
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...SUBSTRATE_PROXY_ACTION, ...EVM_ACTIONS];
|
|
176
180
|
case _types2.AccountChainType.TON:
|
|
177
181
|
return [...BASE_TRANSFER_ACTIONS];
|
|
178
182
|
case _types2.AccountChainType.CARDANO:
|
|
@@ -183,7 +187,7 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
|
|
|
183
187
|
} else if (signMode === _types2.AccountSignMode.QR) {
|
|
184
188
|
switch (networkType) {
|
|
185
189
|
case _types2.AccountChainType.SUBSTRATE:
|
|
186
|
-
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
|
|
190
|
+
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OPEN_GOV_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
|
|
187
191
|
case _types2.AccountChainType.ETHEREUM:
|
|
188
192
|
return [...(_constants.isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
|
|
189
193
|
case _types2.AccountChainType.TON:
|
|
@@ -198,7 +202,7 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
|
|
|
198
202
|
case _types2.AccountChainType.SUBSTRATE:
|
|
199
203
|
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS,
|
|
200
204
|
// ...EARN_QDOT_ACTIONS,
|
|
201
|
-
...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
|
|
205
|
+
...OPEN_GOV_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
|
|
202
206
|
case _types2.AccountChainType.ETHEREUM:
|
|
203
207
|
return [...BASE_TRANSFER_ACTIONS, ...EARN_STDOT_ACTIONS, ...EVM_ACTIONS, ...CLAIM_AVAIL_BRIDGE, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
|
|
204
208
|
// For liquid staking
|
|
@@ -259,6 +263,7 @@ const getAccountTokenTypes = type => {
|
|
|
259
263
|
return [_types._AssetType.NATIVE, _types._AssetType.LOCAL, _types._AssetType.ERC20, _types._AssetType.ERC721];
|
|
260
264
|
case 'sr25519':
|
|
261
265
|
case 'ed25519':
|
|
266
|
+
case 'ed25519-tw':
|
|
262
267
|
case 'ecdsa':
|
|
263
268
|
return [_types._AssetType.NATIVE, _types._AssetType.LOCAL, _types._AssetType.PSP22, _types._AssetType.PSP34, _types._AssetType.GRC20, _types._AssetType.ERC721, _types._AssetType.VFT];
|
|
264
269
|
case 'ton':
|
package/cjs/utils/auth.js
CHANGED
|
@@ -13,7 +13,7 @@ const isAddressValidWithAuthType = (address, accountAuthTypes) => {
|
|
|
13
13
|
const keypairType = (0, _keyring.getKeypairTypeByAddress)(address);
|
|
14
14
|
const validTypes = {
|
|
15
15
|
evm: _types.EthereumKeypairTypes,
|
|
16
|
-
substrate: _types.
|
|
16
|
+
substrate: _types.AllSubstrateKeypairTypes,
|
|
17
17
|
ton: _types.TonKeypairTypes,
|
|
18
18
|
cardano: _types.CardanoKeypairTypes,
|
|
19
19
|
bitcoin: _types.BitcoinKeypairTypes
|
package/cjs/utils/environment.js
CHANGED
|
@@ -11,7 +11,8 @@ var _mv = require("@subwallet/extension-base/utils/mv3");
|
|
|
11
11
|
var _bowser = _interopRequireDefault(require("bowser"));
|
|
12
12
|
var _KoniTypes = require("../background/KoniTypes");
|
|
13
13
|
var _constants = require("../constants");
|
|
14
|
-
var _navigator3;
|
|
14
|
+
var _navigator3; // Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
15
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
15
16
|
function detectRuntimeEnvironment() {
|
|
16
17
|
if (_mv.isSupportWindow && typeof document !== 'undefined') {
|
|
17
18
|
var _navigator, _window$location, _window$location2;
|
|
@@ -31,8 +31,7 @@ var bitcoin = _interopRequireWildcard(require("bitcoinjs-lib"));
|
|
|
31
31
|
var _util = require("@polkadot/util");
|
|
32
32
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
33
33
|
var _combine = require("./combine");
|
|
34
|
-
function
|
|
35
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
34
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
36
35
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
37
36
|
// SPDX-License-Identifier: Apache-2.0
|
|
38
37
|
|
|
@@ -330,7 +329,8 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
|
|
|
330
329
|
feeType: feeChainType,
|
|
331
330
|
id: id,
|
|
332
331
|
error,
|
|
333
|
-
isEvmRpcError: isEvmRpcError
|
|
332
|
+
isEvmRpcError: isEvmRpcError,
|
|
333
|
+
maxTransferableWithoutFee: freeBalance.value
|
|
334
334
|
};
|
|
335
335
|
};
|
|
336
336
|
exports.calculateTransferMaxTransferable = calculateTransferMaxTransferable;
|
|
@@ -522,7 +522,8 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
522
522
|
feeOptions: feeOptions,
|
|
523
523
|
feeType: feeChainType,
|
|
524
524
|
id: id,
|
|
525
|
-
error
|
|
525
|
+
error,
|
|
526
|
+
maxTransferableWithoutFee: freeBalance.value
|
|
526
527
|
};
|
|
527
528
|
};
|
|
528
529
|
exports.calculateXcmMaxTransferable = calculateXcmMaxTransferable;
|
package/cjs/utils/index.js
CHANGED
|
@@ -602,7 +602,6 @@ function isSameAddress(address1, address2) {
|
|
|
602
602
|
}
|
|
603
603
|
return (0, _account.reformatAddress)(address1, 0) === (0, _account.reformatAddress)(address2, 0); // TODO: maybe there's a better way
|
|
604
604
|
}
|
|
605
|
-
|
|
606
605
|
function isSameAddressType(address1, address2) {
|
|
607
606
|
const isSameEvmAddress = (0, _utilCrypto.isEthereumAddress)(address1) && (0, _utilCrypto.isEthereumAddress)(address2);
|
|
608
607
|
const isSameTonAddress = (0, _keyring.isTonAddress)(address1) && (0, _keyring.isTonAddress)(address2);
|
|
@@ -614,7 +613,7 @@ function isAddressAndChainCompatible(address, chain) {
|
|
|
614
613
|
const keypairType = (0, _keyring.getKeypairTypeByAddress)(address);
|
|
615
614
|
const isEvmCompatible = (0, _utils._isChainEvmCompatible)(chain) && _types.EthereumKeypairTypes.includes(keypairType); // some chains compatible to substrate and evm, and use evm-address
|
|
616
615
|
const isTonCompatible = (0, _utils._isPureTonChain)(chain) && _types.TonKeypairTypes.includes(keypairType);
|
|
617
|
-
const isSubstrateCompatible = (0, _utils._isPureSubstrateChain)(chain) && _types.
|
|
616
|
+
const isSubstrateCompatible = (0, _utils._isPureSubstrateChain)(chain) && _types.AllSubstrateKeypairTypes.includes(keypairType);
|
|
618
617
|
const isCardanoCompatible = (0, _utils._isPureCardanoChain)(chain) && _types.CardanoKeypairTypes.includes(keypairType);
|
|
619
618
|
const isBitcoinCompatible = (0, _utils._isPureBitcoinChain)(chain) && _types.BitcoinKeypairTypes.includes(keypairType);
|
|
620
619
|
return isEvmCompatible || isSubstrateCompatible || isTonCompatible || isCardanoCompatible || isBitcoinCompatible;
|
|
@@ -9,6 +9,9 @@ export const APP_VER = packageInfo.version;
|
|
|
9
9
|
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
10
10
|
const branchName = process.env.BRANCH_NAME || 'koni-dev';
|
|
11
11
|
const targetFolder = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list' : 'preview';
|
|
12
|
+
|
|
13
|
+
// todo: check if can check exactly App Environment, Browser Type, OS Type
|
|
14
|
+
|
|
12
15
|
export async function fetchBlockedConfigObjects() {
|
|
13
16
|
const targetFile = `${targetFolder}/envConfig.json`;
|
|
14
17
|
return await fetchStaticData('blocked-actions', targetFile);
|
|
@@ -17,7 +17,7 @@ function getConditions(validateRecipientParams) {
|
|
|
17
17
|
toAddress
|
|
18
18
|
} = validateRecipientParams;
|
|
19
19
|
const conditions = [];
|
|
20
|
-
const isSendAction = [ActionType.SEND_FUND, ActionType.SEND_NFT].includes(actionType);
|
|
20
|
+
const isSendAction = [ActionType.SEND_FUND, ActionType.SEND_NFT, ActionType.MANAGE_SUBSTRATE_PROXY_ACCOUNT].includes(actionType);
|
|
21
21
|
conditions.push(ValidationCondition.IS_NOT_NULL);
|
|
22
22
|
conditions.push(ValidationCondition.IS_ADDRESS);
|
|
23
23
|
conditions.push(ValidationCondition.IS_VALID_ADDRESS_FOR_ECOSYSTEM);
|
|
@@ -34,7 +34,6 @@ export function _validateBalanceToSwapOnAssetHub(fromToken, feeToken, feeTokenCh
|
|
|
34
34
|
return new TransactionError(SwapErrorType.SWAP_NOT_ENOUGH_BALANCE, `Insufficient balance. You need more than ${parsedMinSwapValue} ${fromToken.symbol} to start swapping. Deposit ${fromToken.symbol} and try again.`); // todo: min swap or amount?
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
38
37
|
if (new BigN(swapAmount).gte(fromTokenBalance)) {
|
|
39
38
|
const parsedMaxBalanceSwap = formatNumber(fromTokenBalance, _getAssetDecimals(fromToken));
|
|
40
39
|
return new TransactionError(SwapErrorType.SWAP_EXCEED_ALLOWANCE, `Amount too high. Lower your amount ${bnFromTokenBalance.gt(0) ? `below ${parsedMaxBalanceSwap} ${fromToken.symbol}` : ''} and try again`);
|
|
@@ -62,7 +61,6 @@ export function _validateBalanceToSwap(fromToken, feeToken, feeTokenChainInfo, f
|
|
|
62
61
|
return new TransactionError(SwapErrorType.SWAP_NOT_ENOUGH_BALANCE, `Insufficient balance. You need more than ${parsedMinSwapValue} ${fromToken.symbol} to start swapping. Deposit ${fromToken.symbol} and try again.`); // todo: min swap or amount?
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
|
-
|
|
66
64
|
if (new BigN(swapAmount).gte(fromTokenBalance)) {
|
|
67
65
|
const parsedMaxBalanceSwap = formatNumber(fromTokenBalance, _getAssetDecimals(fromToken));
|
|
68
66
|
return new TransactionError(SwapErrorType.SWAP_EXCEED_ALLOWANCE, `Amount too high. Lower your amount ${bnFromTokenBalance.gt(0) ? `below ${parsedMaxBalanceSwap} ${fromToken.symbol}` : ''} and try again`);
|
|
@@ -206,7 +204,6 @@ export function _validateBalanceToSwapV2(request) {
|
|
|
206
204
|
return new TransactionError(SwapErrorType.SWAP_NOT_ENOUGH_BALANCE, `Insufficient balance. You need more than ${parsedMinSwapValue} ${fromToken.symbol} to start swapping. Deposit ${fromToken.symbol} and try again.`); // todo: min swap or amount?
|
|
207
205
|
}
|
|
208
206
|
}
|
|
209
|
-
|
|
210
207
|
return undefined;
|
|
211
208
|
}
|
|
212
209
|
export function _validateSwapRecipientV2(destChainInfo, recipient) {
|
|
@@ -13,8 +13,8 @@ export declare function validateXcmTransferRequest(destTokenInfo: _ChainAsset |
|
|
|
13
13
|
export declare function checkSupportForFeature(validationResponse: SWTransactionResponse, blockedFeaturesList: string[], chainInfo: _ChainInfo): void;
|
|
14
14
|
export declare function checkSupportForAction(validationResponse: SWTransactionResponse, blockedActionsMap: Record<ExtrinsicType, string[]>): void;
|
|
15
15
|
export declare function checkSupportForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction): void;
|
|
16
|
-
export declare function estimateFeeForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction, chainInfo: _ChainInfo, evmApi: _EvmApi, substrateApi: _SubstrateApi, priceMap: Record<string, number>, feeInfo: FeeInfo, nativeTokenInfo: _ChainAsset, nonNativeTokenPayFeeInfo: _ChainAsset | undefined, isTransferLocalTokenAndPayThatTokenAsFee: boolean | undefined): Promise<FeeData>;
|
|
17
|
-
export declare function checkSigningAccountForTransaction(validationResponse: SWTransactionResponse, chainInfoMap: Record<string, _ChainInfo
|
|
18
|
-
export declare function checkBalanceWithTransactionFee(validationResponse: SWTransactionResponse, transactionInput: SWTransactionInput, nativeTokenInfo: _ChainAsset, nativeTokenAvailable: AmountData): void;
|
|
16
|
+
export declare function estimateFeeForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction, chainInfo: _ChainInfo, evmApi: _EvmApi, substrateApi: _SubstrateApi, priceMap: Record<string, number>, feeInfo: FeeInfo, nativeTokenInfo: _ChainAsset, nonNativeTokenPayFeeInfo: _ChainAsset | undefined, isTransferLocalTokenAndPayThatTokenAsFee: boolean | undefined, signerSubstrateProxyAddress?: string): Promise<FeeData>;
|
|
17
|
+
export declare function checkSigningAccountForTransaction(validationResponse: SWTransactionResponse, chainInfoMap: Record<string, _ChainInfo>, signer: string): void;
|
|
18
|
+
export declare function checkBalanceWithTransactionFee(validationResponse: SWTransactionResponse, transactionInput: SWTransactionInput, nativeTokenInfo: _ChainAsset, nativeTokenAvailable: AmountData, substrateProxyAccountNativeTokenAvailable?: AmountData): void;
|
|
19
19
|
export declare function checkTonAddressBounceableAndAccountNotActive(tonApi: _TonApi, validationResponse: SWTransactionResponse): Promise<void>;
|
|
20
20
|
export declare function validateXcmMinAmountToMythos(destChain: string, destToken: string, amount: string): TransactionError | undefined;
|
|
@@ -13,7 +13,7 @@ import { _getAssetDecimals, _getAssetPriceId, _getAssetSymbol, _getChainNativeTo
|
|
|
13
13
|
import { calculateToAmountByReservePool, FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE } from '@subwallet/extension-base/services/fee-service/utils';
|
|
14
14
|
import { isBitcoinTransaction, isCardanoTransaction, isSubstrateTransaction, isTonTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
|
|
15
15
|
import { AccountSignMode, BasicTxErrorType, BasicTxWarningCode, TransferTxErrorType } from '@subwallet/extension-base/types';
|
|
16
|
-
import { balanceFormatter, combineBitcoinFee, combineEthFee, formatNumber, getSizeInfo, pairToAccount } from '@subwallet/extension-base/utils';
|
|
16
|
+
import { balanceFormatter, combineBitcoinFee, combineEthFee, formatNumber, getAccountJsonByAddress, getSizeInfo, isSameAddress, pairToAccount } from '@subwallet/extension-base/utils';
|
|
17
17
|
import { isCardanoAddress, isTonAddress } from '@subwallet/keyring';
|
|
18
18
|
import { keyring } from '@subwallet/ui-keyring';
|
|
19
19
|
import BigN from 'bignumber.js';
|
|
@@ -310,7 +310,7 @@ export function checkSupportForTransaction(validationResponse, transaction) {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
export async function estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, isTransferLocalTokenAndPayThatTokenAsFee) {
|
|
313
|
+
export async function estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, isTransferLocalTokenAndPayThatTokenAsFee, signerSubstrateProxyAddress) {
|
|
314
314
|
const estimateFee = {
|
|
315
315
|
symbol: '',
|
|
316
316
|
decimals: 0,
|
|
@@ -331,8 +331,14 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
|
|
|
331
331
|
if (transaction) {
|
|
332
332
|
try {
|
|
333
333
|
if (isSubstrateTransaction(transaction)) {
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
if (signerSubstrateProxyAddress && !isSameAddress(signerSubstrateProxyAddress, address)) {
|
|
335
|
+
await substrateApi.isReady;
|
|
336
|
+
const estimateExtrinsic = substrateApi.api.tx.proxy.proxy(address, null, transaction);
|
|
337
|
+
estimateFee.value = (await estimateExtrinsic.paymentInfo(signerSubstrateProxyAddress)).partialFee.toString();
|
|
338
|
+
} else {
|
|
339
|
+
var _validationResponse$x;
|
|
340
|
+
estimateFee.value = (_validationResponse$x = validationResponse.xcmFeeDryRun) !== null && _validationResponse$x !== void 0 ? _validationResponse$x : (await transaction.paymentInfo(validationResponse.address)).partialFee.toString();
|
|
341
|
+
}
|
|
336
342
|
} else if (isTonTransaction(transaction)) {
|
|
337
343
|
estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
|
|
338
344
|
} else if (isCardanoTransaction(transaction)) {
|
|
@@ -399,14 +405,13 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
|
|
|
399
405
|
}
|
|
400
406
|
return estimateFee;
|
|
401
407
|
}
|
|
402
|
-
export function checkSigningAccountForTransaction(validationResponse, chainInfoMap) {
|
|
408
|
+
export function checkSigningAccountForTransaction(validationResponse, chainInfoMap, signer) {
|
|
403
409
|
const {
|
|
404
|
-
address,
|
|
405
410
|
chain,
|
|
406
411
|
chainType,
|
|
407
412
|
extrinsicType
|
|
408
413
|
} = validationResponse;
|
|
409
|
-
const pair = keyring.getPair(
|
|
414
|
+
const pair = keyring.getPair(signer);
|
|
410
415
|
if (!pair) {
|
|
411
416
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, t('bg.TRANSACTION.core.validation.transfer.unableToFindAccount')));
|
|
412
417
|
} else {
|
|
@@ -426,7 +431,7 @@ export function checkSigningAccountForTransaction(validationResponse, chainInfoM
|
|
|
426
431
|
}
|
|
427
432
|
}
|
|
428
433
|
}
|
|
429
|
-
export function checkBalanceWithTransactionFee(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable) {
|
|
434
|
+
export function checkBalanceWithTransactionFee(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable, substrateProxyAccountNativeTokenAvailable) {
|
|
430
435
|
if (!validationResponse.estimateFee) {
|
|
431
436
|
// todo: estimateFee should be must-have, need to refactor interface
|
|
432
437
|
return;
|
|
@@ -435,6 +440,7 @@ export function checkBalanceWithTransactionFee(validationResponse, transactionIn
|
|
|
435
440
|
edAsWarning,
|
|
436
441
|
extrinsicType,
|
|
437
442
|
isTransferAll,
|
|
443
|
+
signerSubstrateProxyAddress,
|
|
438
444
|
skipFeeValidation,
|
|
439
445
|
tokenPayFeeSlug
|
|
440
446
|
} = transactionInput;
|
|
@@ -445,12 +451,29 @@ export function checkBalanceWithTransactionFee(validationResponse, transactionIn
|
|
|
445
451
|
const bnFee = new BigN(validationResponse.estimateFee.value);
|
|
446
452
|
const bnNativeTokenAvailable = new BigN(nativeTokenAvailable.value);
|
|
447
453
|
const bnNativeTokenTransferAmount = new BigN(validationResponse.transferNativeAmount || '0');
|
|
448
|
-
if (!bnNativeTokenAvailable.gt(0)) {
|
|
454
|
+
if (!bnNativeTokenAvailable.gt(0) && !substrateProxyAccountNativeTokenAvailable) {
|
|
449
455
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
450
456
|
}
|
|
451
457
|
const isChainNotSupportTransferAll = [..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.genshiro, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.statemine].includes(nativeTokenInfo.originChain);
|
|
452
|
-
if (
|
|
453
|
-
|
|
458
|
+
if (!substrateProxyAccountNativeTokenAvailable) {
|
|
459
|
+
if (bnNativeTokenTransferAmount.plus(bnFee).gt(bnNativeTokenAvailable) && (!isTransferAll || isChainNotSupportTransferAll)) {
|
|
460
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE)); // todo: should be generalized and reused in all features
|
|
461
|
+
}
|
|
462
|
+
} else {
|
|
463
|
+
const bnSubstrateProxyAccountNativeTokenAvailable = new BigN(substrateProxyAccountNativeTokenAvailable.value);
|
|
464
|
+
if (bnNativeTokenTransferAmount.gt(bnNativeTokenAvailable) && (!isTransferAll || isChainNotSupportTransferAll) || bnFee.gt(bnSubstrateProxyAccountNativeTokenAvailable)) {
|
|
465
|
+
if (signerSubstrateProxyAddress) {
|
|
466
|
+
const account = getAccountJsonByAddress(signerSubstrateProxyAddress);
|
|
467
|
+
const accountName = account === null || account === void 0 ? void 0 : account.name;
|
|
468
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE, t('bg.TRANSACTION.core.validation.transfer.proxyAccountNotEnoughBalance', {
|
|
469
|
+
replace: {
|
|
470
|
+
accountName: accountName || signerSubstrateProxyAddress
|
|
471
|
+
}
|
|
472
|
+
})));
|
|
473
|
+
} else {
|
|
474
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
475
|
+
}
|
|
476
|
+
}
|
|
454
477
|
}
|
|
455
478
|
|
|
456
479
|
// todo: only system.pallet has metadata, we should add for other pallets and mechanisms as well
|
|
@@ -18,7 +18,6 @@ export function _getSystemPalletTransferable(accountInfo, existentialDeposit, ex
|
|
|
18
18
|
export function _canAccountBeReaped(accountInfo) {
|
|
19
19
|
return accountInfo.consumers === 0; // might need to check refCount
|
|
20
20
|
}
|
|
21
|
-
|
|
22
21
|
export function _isAccountActive(accountInfo) {
|
|
23
22
|
return !(accountInfo.consumers === 0 && accountInfo.providers === 0 && accountInfo.sufficients === 0);
|
|
24
23
|
}
|
|
@@ -46,7 +45,6 @@ function _getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMo
|
|
|
46
45
|
}
|
|
47
46
|
return _canAccountBeReaped(accountInfo) ? BigInt(0) : bnExistentialDeposit; // account for ED here will go better with max transfer logic
|
|
48
47
|
}
|
|
49
|
-
|
|
50
48
|
function _getSystemPalletTransferableV2(accountInfo, existentialDeposit, strictMode) {
|
|
51
49
|
const bnLocked = BigInt(accountInfo.data.frozen) - BigInt(accountInfo.data.reserved); // locked can go below 0 but this shouldn't matter
|
|
52
50
|
const bnAppliedExistentialDeposit = _getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMode);
|
package/core/types.d.ts
CHANGED
|
@@ -15,7 +15,8 @@ export declare enum ValidationCondition {
|
|
|
15
15
|
export declare enum ActionType {
|
|
16
16
|
SEND_FUND = "SEND_FUND",
|
|
17
17
|
SEND_NFT = "SEND_NFT",
|
|
18
|
-
SWAP = "SWAP"
|
|
18
|
+
SWAP = "SWAP",
|
|
19
|
+
MANAGE_SUBSTRATE_PROXY_ACCOUNT = "MANAGE_SUBSTRATE_PROXY_ACCOUNT"
|
|
19
20
|
}
|
|
20
21
|
export interface ValidateRecipientParams {
|
|
21
22
|
srcChain: string;
|
package/core/types.js
CHANGED
|
@@ -114,7 +114,6 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
|
|
118
117
|
const unlockingChunks = ledger.unbondingInfo.unlockingChunks;
|
|
119
118
|
if (unlockingChunks.length > 0) {
|
|
120
119
|
for (const unlockingChunk of unlockingChunks) {
|
|
@@ -200,7 +199,6 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
|
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
|
-
|
|
204
202
|
const unlockingChunks = ledger.unbondingInfo.unlockingChunks;
|
|
205
203
|
if (unlockingChunks.length > 0) {
|
|
206
204
|
for (const unlockingChunk of unlockingChunks) {
|
|
@@ -132,7 +132,6 @@ export async function getParaChainStakingMetadata(chain, substrateApi) {
|
|
|
132
132
|
if (unvestedAllocation) {
|
|
133
133
|
totalIssuance.add(unvestedAllocation); // for Turing network, read more at https://hackmd.io/@sbAqOuXkRvyiZPOB3Ryn6Q/Sypr3ZJh5
|
|
134
134
|
}
|
|
135
|
-
|
|
136
135
|
const inflationConfig = _inflation.toHuman();
|
|
137
136
|
const inflation = getParaCurrentInflation(parseRawNumber(totalStake.toString()), inflationConfig);
|
|
138
137
|
const unstakingPeriod = parseInt(unstakingDelay) * _STAKING_ERA_LENGTH_MAP[chain];
|
|
@@ -185,7 +184,6 @@ export async function subscribeParaChainNominatorMetadata(chainInfo, address, su
|
|
|
185
184
|
}
|
|
186
185
|
}
|
|
187
186
|
}
|
|
188
|
-
|
|
189
187
|
const bnStake = new BN(delegation.amount);
|
|
190
188
|
const bnUnstakeBalance = unstakingMap[delegation.owner] ? new BN(unstakingMap[delegation.owner].claimable) : BN_ZERO;
|
|
191
189
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
@@ -279,7 +277,6 @@ export async function getParaChainNominatorMetadata(chainInfo, address, substrat
|
|
|
279
277
|
}
|
|
280
278
|
}
|
|
281
279
|
}
|
|
282
|
-
|
|
283
280
|
const bnStake = new BN(delegation.amount);
|
|
284
281
|
const bnUnstakeBalance = unstakingMap[delegation.owner] ? new BN(unstakingMap[delegation.owner].claimable) : BN_ZERO;
|
|
285
282
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
@@ -221,7 +221,6 @@ export async function subscribeRelayChainNominatorMetadata(chainInfo, address, s
|
|
|
221
221
|
});
|
|
222
222
|
}));
|
|
223
223
|
}
|
|
224
|
-
|
|
225
224
|
let stakingStatus = EarningStatus.NOT_EARNING;
|
|
226
225
|
const bnActiveStake = new BN(activeStake);
|
|
227
226
|
let waitingNominationCount = 0;
|
|
@@ -273,13 +272,13 @@ export async function subscribeRelayChainNominatorMetadata(chainInfo, address, s
|
|
|
273
272
|
* Deprecated
|
|
274
273
|
* */
|
|
275
274
|
export async function getRelayChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
276
|
-
var _chainApi$api$
|
|
275
|
+
var _chainApi$api$query0, _chainApi$api$query0$, _chainApi$api$query1, _chainApi$api$query1$, _chainApi$api$query10, _chainApi$api$query11, _chainApi$api$query12, _chainApi$api$query13, _chainApi$api$query14, _chainApi$api$query15, _chainApi$api$query16, _chainApi$api$query17, _chainApi$api$query18, _chainApi$api$query19;
|
|
277
276
|
if (isEthereumAddress(address)) {
|
|
278
277
|
return;
|
|
279
278
|
}
|
|
280
279
|
const chain = chainInfo.slug;
|
|
281
280
|
const chainApi = await substrateApi.isReady;
|
|
282
|
-
const [_ledger, _nominations, _currentEra, _bonded, _minimumActiveStake, _minNominatorBond] = await Promise.all([(_chainApi$api$
|
|
281
|
+
const [_ledger, _nominations, _currentEra, _bonded, _minimumActiveStake, _minNominatorBond] = await Promise.all([(_chainApi$api$query0 = chainApi.api.query) === null || _chainApi$api$query0 === void 0 ? void 0 : (_chainApi$api$query0$ = _chainApi$api$query0.staking) === null || _chainApi$api$query0$ === void 0 ? void 0 : _chainApi$api$query0$.ledger(address), (_chainApi$api$query1 = chainApi.api.query) === null || _chainApi$api$query1 === void 0 ? void 0 : (_chainApi$api$query1$ = _chainApi$api$query1.staking) === null || _chainApi$api$query1$ === void 0 ? void 0 : _chainApi$api$query1$.nominators(address), (_chainApi$api$query10 = chainApi.api.query) === null || _chainApi$api$query10 === void 0 ? void 0 : (_chainApi$api$query11 = _chainApi$api$query10.staking) === null || _chainApi$api$query11 === void 0 ? void 0 : _chainApi$api$query11.currentEra(), (_chainApi$api$query12 = chainApi.api.query) === null || _chainApi$api$query12 === void 0 ? void 0 : (_chainApi$api$query13 = _chainApi$api$query12.staking) === null || _chainApi$api$query13 === void 0 ? void 0 : _chainApi$api$query13.bonded(address), ((_chainApi$api$query14 = chainApi.api.query) === null || _chainApi$api$query14 === void 0 ? void 0 : (_chainApi$api$query15 = _chainApi$api$query14.staking) === null || _chainApi$api$query15 === void 0 ? void 0 : _chainApi$api$query15.minimumActiveStake) && ((_chainApi$api$query16 = chainApi.api.query) === null || _chainApi$api$query16 === void 0 ? void 0 : (_chainApi$api$query17 = _chainApi$api$query16.staking) === null || _chainApi$api$query17 === void 0 ? void 0 : _chainApi$api$query17.minimumActiveStake()), (_chainApi$api$query18 = chainApi.api.query) === null || _chainApi$api$query18 === void 0 ? void 0 : (_chainApi$api$query19 = _chainApi$api$query18.staking) === null || _chainApi$api$query19 === void 0 ? void 0 : _chainApi$api$query19.minNominatorBond()]);
|
|
283
282
|
const minActiveStake = (_minimumActiveStake === null || _minimumActiveStake === void 0 ? void 0 : _minimumActiveStake.toString()) || '0';
|
|
284
283
|
const minNominatorBond = _minNominatorBond.toString();
|
|
285
284
|
const bnMinActiveStake = new BN(minActiveStake);
|
|
@@ -334,7 +333,6 @@ export async function getRelayChainNominatorMetadata(chainInfo, address, substra
|
|
|
334
333
|
});
|
|
335
334
|
}));
|
|
336
335
|
}
|
|
337
|
-
|
|
338
336
|
let stakingStatus = EarningStatus.NOT_EARNING;
|
|
339
337
|
const bnActiveStake = new BN(activeStake);
|
|
340
338
|
let waitingNominationCount = 0;
|
|
@@ -69,7 +69,6 @@ export function calculateChainStakedReturn(inflation, totalEraStake, totalIssuan
|
|
|
69
69
|
if (_STAKING_CHAIN_GROUP.aleph.includes(networkKey)) {
|
|
70
70
|
stakedReturn *= 0.9; // 10% goes to treasury
|
|
71
71
|
}
|
|
72
|
-
|
|
73
72
|
return stakedReturn;
|
|
74
73
|
}
|
|
75
74
|
export async function calculateChainStakedReturnV2(chainInfo, totalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, inflation, isCompound) {
|
|
@@ -136,11 +135,9 @@ export function calculateValidatorStakedReturn(chainStakedReturn, totalValidator
|
|
|
136
135
|
const stakedReturn = (adjusted > Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : adjusted) / 100;
|
|
137
136
|
return stakedReturn * (100 - commission) / 100; // Deduct commission
|
|
138
137
|
}
|
|
139
|
-
|
|
140
138
|
export function getCommission(commissionString) {
|
|
141
139
|
return parseFloat(commissionString.split('%')[0]); // Example: 12%
|
|
142
140
|
}
|
|
143
|
-
|
|
144
141
|
export function getParaCurrentInflation(totalStaked, inflationConfig) {
|
|
145
142
|
// read more at https://hackmd.io/@sbAqOuXkRvyiZPOB3Ryn6Q/Sypr3ZJh5
|
|
146
143
|
const expectMin = parseRawNumber(inflationConfig.expect.min);
|
|
@@ -263,7 +260,6 @@ export function getYieldAvailableActionsByPosition(yieldPosition, yieldPoolInfo,
|
|
|
263
260
|
result.push(YieldAction.START_EARNING);
|
|
264
261
|
result.push(YieldAction.WITHDRAW_EARNING); // TODO
|
|
265
262
|
}
|
|
266
|
-
|
|
267
263
|
return result;
|
|
268
264
|
}
|
|
269
265
|
export let StakingAction;
|