@subwallet/extension-base 1.3.71-0 → 1.3.73-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 +3 -1
- package/cjs/background/KoniTypes.js +3 -1
- package/cjs/core/logic-validation/recipientAddress.js +1 -1
- package/cjs/core/logic-validation/transfer.js +33 -10
- package/cjs/core/types.js +1 -0
- package/cjs/koni/background/handlers/Extension.js +81 -10
- package/cjs/koni/background/handlers/State.js +2 -4
- package/cjs/koni/background/subscription.js +2 -22
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +46 -2
- package/cjs/services/balance-service/transfer/token.js +13 -35
- package/cjs/services/balance-service/transfer/xcm/index.js +3 -8
- 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/index.js +1 -0
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +17 -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/substrate-proxy-service/constant.js +26 -0
- package/cjs/services/substrate-proxy-service/index.js +170 -0
- package/cjs/services/transaction-service/index.js +78 -10
- package/cjs/services/transaction-service/utils.js +8 -5
- 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/utils/account/transform.js +5 -4
- package/cjs/utils/fee/transfer.js +4 -2
- package/core/logic-validation/recipientAddress.js +1 -1
- package/core/logic-validation/transfer.d.ts +3 -3
- package/core/logic-validation/transfer.js +34 -11
- package/core/types.d.ts +2 -1
- package/core/types.js +1 -0
- package/koni/background/handlers/Extension.d.ts +3 -0
- package/koni/background/handlers/Extension.js +81 -10
- package/koni/background/handlers/State.d.ts +2 -1
- package/koni/background/handlers/State.js +2 -4
- package/koni/background/subscription.js +2 -22
- package/package.json +37 -7
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +47 -3
- package/services/balance-service/transfer/token.d.ts +0 -4
- package/services/balance-service/transfer/token.js +12 -33
- package/services/balance-service/transfer/xcm/index.js +3 -8
- 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/index.js +1 -0
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/native-staking/para-chain.js +17 -2
- 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/open-gov/interface.d.ts +4 -3
- 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/transaction-service/index.js +79 -11
- package/services/transaction-service/types.d.ts +2 -2
- package/services/transaction-service/utils.js +8 -5
- 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/transaction/request.d.ts +1 -0
- package/types/yield/actions/join/submit.d.ts +1 -1
- package/types/yield/info/pallet.d.ts +1 -1
- package/utils/account/transform.js +5 -4
- package/utils/fee/transfer.js +4 -2
|
@@ -127,18 +127,26 @@ class TransactionService {
|
|
|
127
127
|
const isNonNativeTokenPayFee = tokenPayFeeSlug && !(0, _utils2._isNativeTokenBySlug)(tokenPayFeeSlug);
|
|
128
128
|
const nonNativeTokenPayFeeInfo = isNonNativeTokenPayFee ? this.state.chainService.getAssetBySlug(tokenPayFeeSlug) : undefined;
|
|
129
129
|
const priceMap = (await this.state.priceService.getPrice()).priceMap;
|
|
130
|
+
|
|
131
|
+
// Get signer account
|
|
132
|
+
let signer = address;
|
|
133
|
+
const signerSubstrateProxyAddress = transactionInput.signerSubstrateProxyAddress;
|
|
130
134
|
if (!transactionInput.skipFeeRecalculation) {
|
|
131
|
-
validationResponse.estimateFee = await (0, _transfer.estimateFeeForTransaction)(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, transactionInput.isTransferLocalTokenAndPayThatTokenAsFee);
|
|
135
|
+
validationResponse.estimateFee = await (0, _transfer.estimateFeeForTransaction)(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, transactionInput.isTransferLocalTokenAndPayThatTokenAsFee, signerSubstrateProxyAddress);
|
|
132
136
|
}
|
|
133
137
|
const chainInfoMap = this.state.chainService.getChainInfoMap();
|
|
138
|
+
let substrateProxyAccountNativeTokenAvailable;
|
|
139
|
+
if (signerSubstrateProxyAddress && !(0, _utils4.isSameAddress)(signerSubstrateProxyAddress, address)) {
|
|
140
|
+
signer = signerSubstrateProxyAddress;
|
|
141
|
+
substrateProxyAccountNativeTokenAvailable = await this.state.balanceService.getTransferableBalance(signerSubstrateProxyAddress, chain, nativeTokenInfo.slug, extrinsicType);
|
|
142
|
+
}
|
|
134
143
|
|
|
135
144
|
// Check account signing transaction
|
|
136
|
-
|
|
137
|
-
(0, _transfer.checkSigningAccountForTransaction)(validationResponse, chainInfoMap);
|
|
145
|
+
(0, _transfer.checkSigningAccountForTransaction)(validationResponse, chainInfoMap, signer);
|
|
138
146
|
const nativeTokenAvailable = await this.state.balanceService.getBalanceByType(address, chain, nativeTokenInfo.slug, transactionInput.balanceType, extrinsicType);
|
|
139
147
|
|
|
140
148
|
// Check available balance against transaction fee
|
|
141
|
-
(0, _transfer.checkBalanceWithTransactionFee)(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable);
|
|
149
|
+
(0, _transfer.checkBalanceWithTransactionFee)(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable, substrateProxyAccountNativeTokenAvailable);
|
|
142
150
|
|
|
143
151
|
// Warnings Ton address if bounceable and not active
|
|
144
152
|
// if (transaction && isTonTransaction(transaction) && tonApi) {
|
|
@@ -753,8 +761,10 @@ class TransactionService {
|
|
|
753
761
|
// Will be added in next step
|
|
754
762
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
755
763
|
startBlock: startBlock || 0,
|
|
756
|
-
processId: (_transaction$step3 = transaction.step) === null || _transaction$step3 === void 0 ? void 0 : _transaction$step3.processId
|
|
764
|
+
processId: (_transaction$step3 = transaction.step) === null || _transaction$step3 === void 0 ? void 0 : _transaction$step3.processId,
|
|
765
|
+
substrateProxyAddresses: []
|
|
757
766
|
};
|
|
767
|
+
const substrateProxyHistories = [];
|
|
758
768
|
const nativeAsset = (0, _utils2._getChainNativeTokenBasicInfo)(chainInfo);
|
|
759
769
|
const baseNativeAmount = {
|
|
760
770
|
value: '0',
|
|
@@ -1121,6 +1131,55 @@ class TransactionService {
|
|
|
1121
1131
|
};
|
|
1122
1132
|
break;
|
|
1123
1133
|
}
|
|
1134
|
+
case _KoniTypes.ExtrinsicType.ADD_SUBSTRATE_PROXY_ACCOUNT:
|
|
1135
|
+
{
|
|
1136
|
+
const data = (0, _utils3.parseTransactionData)(transaction.data);
|
|
1137
|
+
const substrateProxyAddress = data.substrateProxyAddress;
|
|
1138
|
+
historyItem.substrateProxyAddresses = [substrateProxyAddress];
|
|
1139
|
+
substrateProxyHistories.push({
|
|
1140
|
+
...historyItem,
|
|
1141
|
+
substrateProxyAddresses: [substrateProxyAddress]
|
|
1142
|
+
});
|
|
1143
|
+
try {
|
|
1144
|
+
const substrateProxyAccount = _uiKeyring.default.getPair(substrateProxyAddress);
|
|
1145
|
+
if (substrateProxyAccount) {
|
|
1146
|
+
substrateProxyHistories.push({
|
|
1147
|
+
...historyItem,
|
|
1148
|
+
address: substrateProxyAccount.address,
|
|
1149
|
+
direction: _KoniTypes.TransactionDirection.RECEIVED,
|
|
1150
|
+
substrateProxyAddresses: [substrateProxyAddress]
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
} catch (e) {
|
|
1154
|
+
// skip
|
|
1155
|
+
}
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1158
|
+
case _KoniTypes.ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT:
|
|
1159
|
+
{
|
|
1160
|
+
const data = (0, _utils3.parseTransactionData)(transaction.data);
|
|
1161
|
+
for (const substrateProxyItem of data.selectedSubstrateProxyAccounts || []) {
|
|
1162
|
+
const substrateProxyAddress = substrateProxyItem.substrateProxyAddress;
|
|
1163
|
+
substrateProxyHistories.push({
|
|
1164
|
+
...historyItem,
|
|
1165
|
+
substrateProxyAddresses: [substrateProxyAddress]
|
|
1166
|
+
});
|
|
1167
|
+
try {
|
|
1168
|
+
const substrateProxyAccount = _uiKeyring.default.getPair(substrateProxyAddress);
|
|
1169
|
+
if (substrateProxyAccount) {
|
|
1170
|
+
substrateProxyHistories.push({
|
|
1171
|
+
...historyItem,
|
|
1172
|
+
address: substrateProxyAccount.address,
|
|
1173
|
+
direction: _KoniTypes.TransactionDirection.RECEIVED,
|
|
1174
|
+
substrateProxyAddresses: [substrateProxyAddress]
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
} catch (e) {
|
|
1178
|
+
// skip
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
break;
|
|
1182
|
+
}
|
|
1124
1183
|
case _KoniTypes.ExtrinsicType.UNKNOWN:
|
|
1125
1184
|
break;
|
|
1126
1185
|
}
|
|
@@ -1148,7 +1207,7 @@ class TransactionService {
|
|
|
1148
1207
|
} catch (e) {
|
|
1149
1208
|
console.warn(e);
|
|
1150
1209
|
}
|
|
1151
|
-
return [historyItem];
|
|
1210
|
+
return [historyItem, ...substrateProxyHistories];
|
|
1152
1211
|
}
|
|
1153
1212
|
onSigned(_ref) {
|
|
1154
1213
|
let {
|
|
@@ -1741,7 +1800,7 @@ class TransactionService {
|
|
|
1741
1800
|
});
|
|
1742
1801
|
return emitter;
|
|
1743
1802
|
}
|
|
1744
|
-
signAndSendSubstrateTransaction(_ref12) {
|
|
1803
|
+
async signAndSendSubstrateTransaction(_ref12) {
|
|
1745
1804
|
var _this$state$chainServ;
|
|
1746
1805
|
let {
|
|
1747
1806
|
address,
|
|
@@ -1749,6 +1808,7 @@ class TransactionService {
|
|
|
1749
1808
|
feeCustom,
|
|
1750
1809
|
id,
|
|
1751
1810
|
signAfterCreate,
|
|
1811
|
+
signerSubstrateProxyAddress,
|
|
1752
1812
|
step,
|
|
1753
1813
|
tokenPayFeeSlug,
|
|
1754
1814
|
transaction,
|
|
@@ -1764,7 +1824,15 @@ class TransactionService {
|
|
|
1764
1824
|
extrinsicHash: id,
|
|
1765
1825
|
processId: step === null || step === void 0 ? void 0 : step.processId
|
|
1766
1826
|
};
|
|
1767
|
-
|
|
1827
|
+
let extrinsic = transaction;
|
|
1828
|
+
let signer = address;
|
|
1829
|
+
if (signerSubstrateProxyAddress && signerSubstrateProxyAddress !== address) {
|
|
1830
|
+
const substrateApi = this.state.chainService.getSubstrateApi(chain);
|
|
1831
|
+
await substrateApi.isReady;
|
|
1832
|
+
signer = signerSubstrateProxyAddress;
|
|
1833
|
+
extrinsic = substrateApi.api.tx.proxy.proxy(address, null, transaction);
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1768
1836
|
// const registry = extrinsic.registry;
|
|
1769
1837
|
// const signedExtensions = registry.signedExtensions;
|
|
1770
1838
|
|
|
@@ -1774,7 +1842,7 @@ class TransactionService {
|
|
|
1774
1842
|
const {
|
|
1775
1843
|
signature,
|
|
1776
1844
|
signedTransaction
|
|
1777
|
-
} = await this.state.requestService.signInternalTransaction(id,
|
|
1845
|
+
} = await this.state.requestService.signInternalTransaction(id, signer, url || _constants2.EXTENSION_REQUEST_URL, payload, signAfterCreate);
|
|
1778
1846
|
return {
|
|
1779
1847
|
id: new Date().getTime(),
|
|
1780
1848
|
signature,
|
|
@@ -1796,7 +1864,7 @@ class TransactionService {
|
|
|
1796
1864
|
// }
|
|
1797
1865
|
// }
|
|
1798
1866
|
|
|
1799
|
-
extrinsic.signAsync(
|
|
1867
|
+
extrinsic.signAsync(signer, signerOption).then(async rs => {
|
|
1800
1868
|
// Emit signed event
|
|
1801
1869
|
emitter.emit('signed', eventData);
|
|
1802
1870
|
|
|
@@ -33,6 +33,9 @@ function getBlockExplorerAccountRoute(explorerLink) {
|
|
|
33
33
|
if (explorerLink.includes('devnet-explorer.mosaicchain.io')) {
|
|
34
34
|
return 'accounts';
|
|
35
35
|
}
|
|
36
|
+
if (explorerLink.includes('mainnet-gw2.mosaicchain.io')) {
|
|
37
|
+
return 'accounts';
|
|
38
|
+
}
|
|
36
39
|
if (explorerLink.includes('statescan.io')) {
|
|
37
40
|
return '#/accounts';
|
|
38
41
|
}
|
|
@@ -61,7 +64,7 @@ function getBlockExplorerAccountRoute(explorerLink) {
|
|
|
61
64
|
return 'account';
|
|
62
65
|
}
|
|
63
66
|
if (explorerLink.includes('node.xode.net')) {
|
|
64
|
-
return 'account';
|
|
67
|
+
return 'polkadot/account';
|
|
65
68
|
}
|
|
66
69
|
if (explorerLink.includes('tonviewer.com')) {
|
|
67
70
|
return '';
|
|
@@ -90,7 +93,10 @@ function getBlockExplorerTxRoute(chainInfo) {
|
|
|
90
93
|
if (['edgeware', 'commune'].includes(chainInfo.slug)) {
|
|
91
94
|
return 'extrinsics';
|
|
92
95
|
}
|
|
93
|
-
if (['
|
|
96
|
+
if (['xode'].includes(chainInfo.slug)) {
|
|
97
|
+
return 'polkadot/extrinsics';
|
|
98
|
+
}
|
|
99
|
+
if (['mosaicTest', 'polkadex', 'mosaic'].includes(chainInfo.slug)) {
|
|
94
100
|
return 'transactions';
|
|
95
101
|
}
|
|
96
102
|
const explorerLink = (0, _utils._getBlockExplorerFromChain)(chainInfo);
|
|
@@ -134,9 +140,6 @@ function getExplorerLink(chainInfo, value, type) {
|
|
|
134
140
|
if (chainInfo.slug === 'tangle') {
|
|
135
141
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}extrinsic/${value}${route}/${value}`;
|
|
136
142
|
}
|
|
137
|
-
if (chainInfo.slug === 'xode') {
|
|
138
|
-
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}polkadot-chain-transaction?search=${value}`;
|
|
139
|
-
}
|
|
140
143
|
if (['truth_network', 'aventus'].includes(chainInfo.slug)) {
|
|
141
144
|
// getTransactionId(value)
|
|
142
145
|
// .then((transactionId) => {
|
package/cjs/types/index.js
CHANGED
|
@@ -178,4 +178,15 @@ Object.keys(_bitcoin).forEach(function (key) {
|
|
|
178
178
|
return _bitcoin[key];
|
|
179
179
|
}
|
|
180
180
|
});
|
|
181
|
+
});
|
|
182
|
+
var _substrateProxyAccount = require("./substrateProxyAccount");
|
|
183
|
+
Object.keys(_substrateProxyAccount).forEach(function (key) {
|
|
184
|
+
if (key === "default" || key === "__esModule") return;
|
|
185
|
+
if (key in exports && exports[key] === _substrateProxyAccount[key]) return;
|
|
186
|
+
Object.defineProperty(exports, key, {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function () {
|
|
189
|
+
return _substrateProxyAccount[key];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
181
192
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -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
|
+
});
|
|
@@ -168,14 +168,15 @@ const EARN_VMANTA_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_VMANTA, _KoniTypes.Ex
|
|
|
168
168
|
const EVM_ACTIONS = [_KoniTypes.ExtrinsicType.TOKEN_SPENDING_APPROVAL, _KoniTypes.ExtrinsicType.EVM_EXECUTE];
|
|
169
169
|
const CLAIM_AVAIL_BRIDGE = [_KoniTypes.ExtrinsicType.CLAIM_BRIDGE];
|
|
170
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];
|
|
171
172
|
const OTHER_ACTIONS = [_KoniTypes.ExtrinsicType.TRANSFER_XCM, _KoniTypes.ExtrinsicType.SEND_NFT, _KoniTypes.ExtrinsicType.SWAP, _KoniTypes.ExtrinsicType.CROWDLOAN];
|
|
172
173
|
const getAccountTransactionActions = (signMode, networkType, type, _meta, _specialNetwork) => {
|
|
173
174
|
if ([_types2.AccountSignMode.PASSWORD, _types2.AccountSignMode.INJECTED].includes(signMode)) {
|
|
174
175
|
switch (networkType) {
|
|
175
176
|
case _types2.AccountChainType.SUBSTRATE:
|
|
176
|
-
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];
|
|
177
178
|
case _types2.AccountChainType.ETHEREUM:
|
|
178
|
-
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];
|
|
179
180
|
case _types2.AccountChainType.TON:
|
|
180
181
|
return [...BASE_TRANSFER_ACTIONS];
|
|
181
182
|
case _types2.AccountChainType.CARDANO:
|
|
@@ -186,7 +187,7 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
|
|
|
186
187
|
} else if (signMode === _types2.AccountSignMode.QR) {
|
|
187
188
|
switch (networkType) {
|
|
188
189
|
case _types2.AccountChainType.SUBSTRATE:
|
|
189
|
-
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];
|
|
190
191
|
case _types2.AccountChainType.ETHEREUM:
|
|
191
192
|
return [...(_constants.isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
|
|
192
193
|
case _types2.AccountChainType.TON:
|
|
@@ -201,7 +202,7 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
|
|
|
201
202
|
case _types2.AccountChainType.SUBSTRATE:
|
|
202
203
|
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS,
|
|
203
204
|
// ...EARN_QDOT_ACTIONS,
|
|
204
|
-
...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
|
|
205
|
+
...OPEN_GOV_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
|
|
205
206
|
case _types2.AccountChainType.ETHEREUM:
|
|
206
207
|
return [...BASE_TRANSFER_ACTIONS, ...EARN_STDOT_ACTIONS, ...EVM_ACTIONS, ...CLAIM_AVAIL_BRIDGE, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
|
|
207
208
|
// For liquid staking
|
|
@@ -329,7 +329,8 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
|
|
|
329
329
|
feeType: feeChainType,
|
|
330
330
|
id: id,
|
|
331
331
|
error,
|
|
332
|
-
isEvmRpcError: isEvmRpcError
|
|
332
|
+
isEvmRpcError: isEvmRpcError,
|
|
333
|
+
maxTransferableWithoutFee: freeBalance.value
|
|
333
334
|
};
|
|
334
335
|
};
|
|
335
336
|
exports.calculateTransferMaxTransferable = calculateTransferMaxTransferable;
|
|
@@ -521,7 +522,8 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
521
522
|
feeOptions: feeOptions,
|
|
522
523
|
feeType: feeChainType,
|
|
523
524
|
id: id,
|
|
524
|
-
error
|
|
525
|
+
error,
|
|
526
|
+
maxTransferableWithoutFee: freeBalance.value
|
|
525
527
|
};
|
|
526
528
|
};
|
|
527
529
|
exports.calculateXcmMaxTransferable = calculateXcmMaxTransferable;
|
|
@@ -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);
|
|
@@ -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
|
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
|
@@ -291,6 +291,9 @@ export default class KoniExtension {
|
|
|
291
291
|
private migrateUnifiedAndFetchEligibleSoloAccounts;
|
|
292
292
|
private migrateSoloAccount;
|
|
293
293
|
private pingSession;
|
|
294
|
+
private getSubstrateProxyAccountGroup;
|
|
295
|
+
private handleAddSubstrateProxyAccount;
|
|
296
|
+
private handleRemoveSubstrateProxyAccount;
|
|
294
297
|
private handleVote;
|
|
295
298
|
private handleRemoveVote;
|
|
296
299
|
private handleUnlockVote;
|