@subwallet/extension-base 1.3.73-0 → 1.3.74-1
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 +42 -5
- package/background/KoniTypes.js +14 -1
- package/cjs/background/KoniTypes.js +16 -2
- package/cjs/core/logic-validation/transfer.js +35 -57
- package/cjs/koni/background/handlers/Extension.js +599 -144
- package/cjs/koni/background/handlers/State.js +5 -2
- package/cjs/koni/background/handlers/Tabs.js +3 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +0 -2
- package/cjs/services/chain-service/handler/SubstrateApi.js +6 -1
- package/cjs/services/chain-service/index.js +1 -0
- package/cjs/services/chain-service/utils/index.js +4 -0
- package/cjs/services/event-service/index.js +1 -0
- package/cjs/services/fee-service/utils/index.js +4 -4
- package/cjs/services/inapp-notification-service/consts.js +4 -2
- package/cjs/services/inapp-notification-service/index.js +51 -6
- package/cjs/services/inapp-notification-service/interfaces.js +2 -0
- package/cjs/services/inapp-notification-service/utils/common.js +4 -0
- package/cjs/services/keyring-service/context/account-context.js +44 -0
- package/cjs/services/keyring-service/context/handlers/Multisig.js +186 -0
- package/cjs/services/keyring-service/context/state.js +12 -0
- package/cjs/services/multisig-service/index.js +627 -0
- package/cjs/services/multisig-service/utils.js +242 -0
- package/cjs/services/request-service/handler/SubstrateRequestHandler.js +25 -0
- package/cjs/services/request-service/index.js +5 -1
- package/cjs/services/storage-service/DatabaseService.js +5 -2
- package/cjs/services/storage-service/db-stores/InappNotification.js +20 -2
- package/cjs/services/substrate-proxy-service/index.js +22 -7
- package/cjs/services/transaction-service/helpers/index.js +8 -0
- package/cjs/services/transaction-service/index.js +348 -147
- package/cjs/services/transaction-service/types.js +18 -1
- package/cjs/types/account/info/keyring.js +5 -0
- package/cjs/types/account/info/proxy.js +1 -0
- package/cjs/types/multisig/index.js +14 -0
- package/cjs/types/transaction/error.js +9 -2
- package/cjs/utils/account/transform.js +28 -4
- package/cjs/utils/logger/Logger.js +294 -0
- package/cjs/utils/logger/index.js +42 -0
- package/cjs/utils/logger/types.js +1 -0
- package/core/logic-validation/transfer.d.ts +2 -2
- package/core/logic-validation/transfer.js +10 -32
- package/koni/background/handlers/Extension.d.ts +7 -0
- package/koni/background/handlers/Extension.js +498 -43
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +5 -2
- package/koni/background/handlers/Tabs.js +3 -2
- package/package.json +42 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +0 -2
- package/services/chain-service/handler/SubstrateApi.js +7 -2
- package/services/chain-service/index.js +1 -0
- package/services/chain-service/types.d.ts +1 -1
- package/services/chain-service/utils/index.js +4 -0
- package/services/event-service/index.d.ts +1 -0
- package/services/event-service/index.js +1 -0
- package/services/event-service/types.d.ts +1 -0
- package/services/fee-service/utils/index.js +4 -4
- package/services/inapp-notification-service/consts.d.ts +3 -1
- package/services/inapp-notification-service/consts.js +5 -3
- package/services/inapp-notification-service/index.d.ts +3 -2
- package/services/inapp-notification-service/index.js +51 -6
- package/services/inapp-notification-service/interfaces.d.ts +18 -2
- package/services/inapp-notification-service/interfaces.js +2 -0
- package/services/inapp-notification-service/utils/common.d.ts +1 -0
- package/services/inapp-notification-service/utils/common.js +3 -0
- package/services/keyring-service/context/account-context.d.ts +9 -1
- package/services/keyring-service/context/account-context.js +44 -0
- package/services/keyring-service/context/handlers/Multisig.d.ts +18 -0
- package/services/keyring-service/context/handlers/Multisig.js +180 -0
- package/services/keyring-service/context/state.d.ts +2 -0
- package/services/keyring-service/context/state.js +12 -0
- package/services/multisig-service/index.d.ts +245 -0
- package/services/multisig-service/index.js +620 -0
- package/services/multisig-service/utils.d.ts +95 -0
- package/services/multisig-service/utils.js +227 -0
- package/services/request-service/handler/SubstrateRequestHandler.d.ts +1 -0
- package/services/request-service/handler/SubstrateRequestHandler.js +25 -0
- package/services/request-service/index.d.ts +2 -1
- package/services/request-service/index.js +5 -1
- package/services/storage-service/DatabaseService.d.ts +3 -2
- package/services/storage-service/DatabaseService.js +5 -2
- package/services/storage-service/db-stores/InappNotification.d.ts +3 -2
- package/services/storage-service/db-stores/InappNotification.js +20 -2
- package/services/substrate-proxy-service/index.d.ts +4 -1
- package/services/substrate-proxy-service/index.js +22 -8
- package/services/transaction-service/helpers/index.js +8 -0
- package/services/transaction-service/index.d.ts +31 -0
- package/services/transaction-service/index.js +270 -69
- package/services/transaction-service/types.d.ts +28 -3
- package/services/transaction-service/types.js +12 -1
- package/types/account/info/keyring.d.ts +14 -1
- package/types/account/info/keyring.js +6 -0
- package/types/account/info/proxy.d.ts +1 -0
- package/types/account/info/proxy.js +1 -0
- package/types/multisig/index.d.ts +76 -0
- package/types/multisig/index.js +8 -0
- package/types/notification/index.d.ts +8 -0
- package/types/substrateProxyAccount/index.d.ts +26 -1
- package/types/transaction/error.d.ts +6 -1
- package/types/transaction/error.js +7 -1
- package/types/transaction/request.d.ts +0 -1
- package/utils/account/transform.js +28 -4
- package/utils/logger/Logger.d.ts +31 -0
- package/utils/logger/Logger.js +267 -0
- package/utils/logger/index.d.ts +15 -0
- package/utils/logger/index.js +29 -0
- package/utils/logger/types.d.ts +23 -0
- package/utils/logger/types.js +1 -0
|
@@ -1 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SubstrateTransactionWrappingStatus = void 0;
|
|
7
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
/**
|
|
10
|
+
* Describes how a transaction is related to wrapping (multisig / proxy).
|
|
11
|
+
*/
|
|
12
|
+
let SubstrateTransactionWrappingStatus;
|
|
13
|
+
exports.SubstrateTransactionWrappingStatus = SubstrateTransactionWrappingStatus;
|
|
14
|
+
(function (SubstrateTransactionWrappingStatus) {
|
|
15
|
+
SubstrateTransactionWrappingStatus["WRAPPABLE"] = "WRAPPABLE";
|
|
16
|
+
SubstrateTransactionWrappingStatus["WRAP_SOURCE"] = "WRAP_SOURCE";
|
|
17
|
+
SubstrateTransactionWrappingStatus["WRAP_RESULT"] = "WRAP_RESULT";
|
|
18
|
+
})(SubstrateTransactionWrappingStatus || (exports.SubstrateTransactionWrappingStatus = SubstrateTransactionWrappingStatus = {}));
|
|
@@ -35,6 +35,10 @@ exports.SUPPORTED_ACCOUNT_CHAIN_TYPES = exports.AccountSignMode = exports.Accoun
|
|
|
35
35
|
* @prop {string} [suri] - Substrate: Derivation path | Other: Brief for the derivation path
|
|
36
36
|
* @prop {string} [derivationPath] - Derivation path
|
|
37
37
|
* */
|
|
38
|
+
/**
|
|
39
|
+
* @interface AccountMultisigData
|
|
40
|
+
* @prop {boolean} [isMultisig] - Is multisig account
|
|
41
|
+
* */
|
|
38
42
|
/**
|
|
39
43
|
* Represents the comprehensive metadata associated with an account, combining various aspects of account data.
|
|
40
44
|
* This interface extends from multiple specific metadata interfaces to provide a unified view of an account's metadata.
|
|
@@ -57,6 +61,7 @@ exports.AccountSignMode = AccountSignMode;
|
|
|
57
61
|
AccountSignMode["GENERIC_LEDGER"] = "generic-ledger";
|
|
58
62
|
AccountSignMode["ECDSA_SUBSTRATE_LEDGER"] = "ecdsa-substrate-ledger";
|
|
59
63
|
AccountSignMode["READ_ONLY"] = "readonly";
|
|
64
|
+
AccountSignMode["MULTISIG"] = "multisig";
|
|
60
65
|
AccountSignMode["ALL_ACCOUNT"] = "all";
|
|
61
66
|
AccountSignMode["INJECTED"] = "injected";
|
|
62
67
|
AccountSignMode["UNKNOWN"] = "unknown";
|
|
@@ -42,6 +42,7 @@ exports.AccountProxyType = AccountProxyType;
|
|
|
42
42
|
AccountProxyType["SOLO"] = "solo";
|
|
43
43
|
AccountProxyType["UNIFIED"] = "unified";
|
|
44
44
|
AccountProxyType["QR"] = "qr";
|
|
45
|
+
AccountProxyType["MULTISIG"] = "multisig";
|
|
45
46
|
AccountProxyType["LEDGER"] = "ledger";
|
|
46
47
|
AccountProxyType["READ_ONLY"] = "readonly";
|
|
47
48
|
AccountProxyType["INJECTED"] = "injected";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SelectSignatoryErrorType = void 0;
|
|
7
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
let SelectSignatoryErrorType;
|
|
10
|
+
exports.SelectSignatoryErrorType = SelectSignatoryErrorType;
|
|
11
|
+
(function (SelectSignatoryErrorType) {
|
|
12
|
+
SelectSignatoryErrorType["NOT_ENOUGH_BALANCE"] = "NOT_ENOUGH_BALANCE";
|
|
13
|
+
SelectSignatoryErrorType["NOT_ENOUGH_DEPOSIT"] = "NOT_ENOUGH_DEPOSIT";
|
|
14
|
+
})(SelectSignatoryErrorType || (exports.SelectSignatoryErrorType = SelectSignatoryErrorType = {}));
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.YieldValidationStatus = exports.TransferTxErrorType = exports.StakingTxErrorType = exports.BasicTxErrorType = void 0;
|
|
6
|
+
exports.YieldValidationStatus = exports.TransferTxErrorType = exports.StakingTxErrorType = exports.MultisigTxErrorType = exports.BasicTxErrorType = void 0;
|
|
7
7
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
let YieldValidationStatus;
|
|
@@ -52,4 +52,11 @@ exports.TransferTxErrorType = TransferTxErrorType;
|
|
|
52
52
|
TransferTxErrorType["TRANSFER_ERROR"] = "TRANSFER_ERROR";
|
|
53
53
|
TransferTxErrorType["RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT"] = "RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT";
|
|
54
54
|
TransferTxErrorType["RECEIVER_ACCOUNT_INACTIVE"] = "RECEIVER_ACCOUNT_INACTIVE";
|
|
55
|
-
})(TransferTxErrorType || (exports.TransferTxErrorType = TransferTxErrorType = {}));
|
|
55
|
+
})(TransferTxErrorType || (exports.TransferTxErrorType = TransferTxErrorType = {}));
|
|
56
|
+
let MultisigTxErrorType;
|
|
57
|
+
exports.MultisigTxErrorType = MultisigTxErrorType;
|
|
58
|
+
(function (MultisigTxErrorType) {
|
|
59
|
+
MultisigTxErrorType["INVALID_PARAMS"] = "INVALID_PARAMS";
|
|
60
|
+
MultisigTxErrorType["LACK_MULTISIG_PALLET"] = "LACK_MULTISIG_PALLET";
|
|
61
|
+
MultisigTxErrorType["UNABLE_TO_CONSTRUCT_TX"] = "UNABLE_TO_CONSTRUCT_TX";
|
|
62
|
+
})(MultisigTxErrorType || (exports.MultisigTxErrorType = MultisigTxErrorType = {}));
|
|
@@ -80,6 +80,8 @@ const getAccountSignMode = (address, _meta) => {
|
|
|
80
80
|
}
|
|
81
81
|
} else if (meta.isReadOnly) {
|
|
82
82
|
return _types2.AccountSignMode.READ_ONLY;
|
|
83
|
+
} else if (meta.isMultisig) {
|
|
84
|
+
return _types2.AccountSignMode.MULTISIG;
|
|
83
85
|
} else {
|
|
84
86
|
return _types2.AccountSignMode.QR;
|
|
85
87
|
}
|
|
@@ -168,13 +170,14 @@ const EARN_VMANTA_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_VMANTA, _KoniTypes.Ex
|
|
|
168
170
|
const EVM_ACTIONS = [_KoniTypes.ExtrinsicType.TOKEN_SPENDING_APPROVAL, _KoniTypes.ExtrinsicType.EVM_EXECUTE];
|
|
169
171
|
const CLAIM_AVAIL_BRIDGE = [_KoniTypes.ExtrinsicType.CLAIM_BRIDGE];
|
|
170
172
|
const OPEN_GOV_ACTIONS = [_KoniTypes.ExtrinsicType.GOV_VOTE, _KoniTypes.ExtrinsicType.GOV_UNVOTE, _KoniTypes.ExtrinsicType.GOV_UNLOCK_VOTE];
|
|
171
|
-
const
|
|
173
|
+
const MULTISIG_ACTIONS = [_KoniTypes.ExtrinsicType.MULTISIG_APPROVE_TX, _KoniTypes.ExtrinsicType.MULTISIG_EXECUTE_TX, _KoniTypes.ExtrinsicType.MULTISIG_CANCEL_TX, _KoniTypes.ExtrinsicType.MULTISIG_INIT_TX];
|
|
174
|
+
const SUBSTRATE_PROXY_ACTION = [_KoniTypes.ExtrinsicType.ADD_SUBSTRATE_PROXY_ACCOUNT, _KoniTypes.ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT, _KoniTypes.ExtrinsicType.SUBSTRATE_PROXY_INIT_TX];
|
|
172
175
|
const OTHER_ACTIONS = [_KoniTypes.ExtrinsicType.TRANSFER_XCM, _KoniTypes.ExtrinsicType.SEND_NFT, _KoniTypes.ExtrinsicType.SWAP, _KoniTypes.ExtrinsicType.CROWDLOAN];
|
|
173
176
|
const getAccountTransactionActions = (signMode, networkType, type, _meta, _specialNetwork) => {
|
|
174
177
|
if ([_types2.AccountSignMode.PASSWORD, _types2.AccountSignMode.INJECTED].includes(signMode)) {
|
|
175
178
|
switch (networkType) {
|
|
176
179
|
case _types2.AccountChainType.SUBSTRATE:
|
|
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];
|
|
180
|
+
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, ...MULTISIG_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
|
|
178
181
|
case _types2.AccountChainType.ETHEREUM:
|
|
179
182
|
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...SUBSTRATE_PROXY_ACTION, ...EVM_ACTIONS];
|
|
180
183
|
case _types2.AccountChainType.TON:
|
|
@@ -187,7 +190,7 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
|
|
|
187
190
|
} else if (signMode === _types2.AccountSignMode.QR) {
|
|
188
191
|
switch (networkType) {
|
|
189
192
|
case _types2.AccountChainType.SUBSTRATE:
|
|
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];
|
|
193
|
+
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, ...MULTISIG_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
|
|
191
194
|
case _types2.AccountChainType.ETHEREUM:
|
|
192
195
|
return [...(_constants.isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
|
|
193
196
|
case _types2.AccountChainType.TON:
|
|
@@ -197,12 +200,31 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
|
|
|
197
200
|
case _types2.AccountChainType.BITCOIN:
|
|
198
201
|
return [];
|
|
199
202
|
}
|
|
203
|
+
} else if (signMode === _types2.AccountSignMode.MULTISIG) {
|
|
204
|
+
switch (networkType) {
|
|
205
|
+
case _types2.AccountChainType.SUBSTRATE:
|
|
206
|
+
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS,
|
|
207
|
+
// ...EARN_VDOT_ACTIONS, // todo: consider support this
|
|
208
|
+
// ...EARN_LDOT_ACTIONS,
|
|
209
|
+
// ...EARN_SDOT_ACTIONS,
|
|
210
|
+
// ...EARN_QDOT_ACTIONS,
|
|
211
|
+
// ...EARN_VMANTA_ACTIONS,
|
|
212
|
+
...OPEN_GOV_ACTIONS, ...SUBSTRATE_PROXY_ACTION, _KoniTypes.ExtrinsicType.SEND_NFT];
|
|
213
|
+
case _types2.AccountChainType.ETHEREUM:
|
|
214
|
+
return [];
|
|
215
|
+
case _types2.AccountChainType.TON:
|
|
216
|
+
return [];
|
|
217
|
+
case _types2.AccountChainType.CARDANO:
|
|
218
|
+
return [];
|
|
219
|
+
case _types2.AccountChainType.BITCOIN:
|
|
220
|
+
return [];
|
|
221
|
+
}
|
|
200
222
|
} else if (signMode === _types2.AccountSignMode.GENERIC_LEDGER) {
|
|
201
223
|
switch (networkType) {
|
|
202
224
|
case _types2.AccountChainType.SUBSTRATE:
|
|
203
225
|
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS,
|
|
204
226
|
// ...EARN_QDOT_ACTIONS,
|
|
205
|
-
...OPEN_GOV_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
|
|
227
|
+
...OPEN_GOV_ACTIONS, ...MULTISIG_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
|
|
206
228
|
case _types2.AccountChainType.ETHEREUM:
|
|
207
229
|
return [...BASE_TRANSFER_ACTIONS, ...EARN_STDOT_ACTIONS, ...EVM_ACTIONS, ...CLAIM_AVAIL_BRIDGE, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
|
|
208
230
|
// For liquid staking
|
|
@@ -394,6 +416,8 @@ const convertAccountProxyType = accountSignMode => {
|
|
|
394
416
|
return _types2.AccountProxyType.LEDGER;
|
|
395
417
|
case _types2.AccountSignMode.QR:
|
|
396
418
|
return _types2.AccountProxyType.QR;
|
|
419
|
+
case _types2.AccountSignMode.MULTISIG:
|
|
420
|
+
return _types2.AccountProxyType.MULTISIG;
|
|
397
421
|
case _types2.AccountSignMode.READ_ONLY:
|
|
398
422
|
return _types2.AccountProxyType.READ_ONLY;
|
|
399
423
|
case _types2.AccountSignMode.INJECTED:
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.Logger = void 0;
|
|
8
|
+
var _loglevel = _interopRequireDefault(require("loglevel"));
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
13
|
+
const branchName = process.env.BRANCH_NAME || 'koni-dev';
|
|
14
|
+
const isProduction = PRODUCTION_BRANCHES.indexOf(branchName) > -1;
|
|
15
|
+
const LOG_LEVELS = {
|
|
16
|
+
trace: 0,
|
|
17
|
+
debug: 1,
|
|
18
|
+
info: 2,
|
|
19
|
+
warn: 3,
|
|
20
|
+
error: 4
|
|
21
|
+
};
|
|
22
|
+
class Logger {
|
|
23
|
+
groupStack = [];
|
|
24
|
+
constructor(config) {
|
|
25
|
+
var _config$enableStructu;
|
|
26
|
+
this.name = config.name;
|
|
27
|
+
this.config = {
|
|
28
|
+
name: config.name,
|
|
29
|
+
level: config.level || (isProduction ? 'info' : 'debug'),
|
|
30
|
+
enableStructuredLogging: (_config$enableStructu = config.enableStructuredLogging) !== null && _config$enableStructu !== void 0 ? _config$enableStructu : false,
|
|
31
|
+
enableContextCapture: config.enableContextCapture || !isProduction
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Create a named logger instance
|
|
35
|
+
this.logInstance = _loglevel.default.getLogger(this.name);
|
|
36
|
+
this.logInstance.setLevel(this.getLogLevelNumber(this.config.level));
|
|
37
|
+
}
|
|
38
|
+
getLogLevelNumber(level) {
|
|
39
|
+
return LOG_LEVELS[level];
|
|
40
|
+
}
|
|
41
|
+
shouldLog(level) {
|
|
42
|
+
return LOG_LEVELS[level] >= this.getLogLevelNumber(this.config.level);
|
|
43
|
+
}
|
|
44
|
+
formatMessage(level, message) {
|
|
45
|
+
const prefix = `[${this.name}] [${level.toUpperCase()}]`;
|
|
46
|
+
return `${prefix} ${message}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Simple logging methods (drop-in console replacement)
|
|
50
|
+
error(message) {
|
|
51
|
+
if (!this.shouldLog('error')) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const formatted = this.formatMessage('error', message);
|
|
55
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
56
|
+
args[_key - 1] = arguments[_key];
|
|
57
|
+
}
|
|
58
|
+
this.logInstance.error(formatted, ...args);
|
|
59
|
+
|
|
60
|
+
// Add breadcrumb for errors
|
|
61
|
+
if (args.length > 0 && args[0] instanceof Error) {
|
|
62
|
+
// sentryAdapter.captureException(args[0] as Error, {
|
|
63
|
+
// message,
|
|
64
|
+
// logger: this.name
|
|
65
|
+
// });
|
|
66
|
+
} else {
|
|
67
|
+
// sentryAdapter.addBreadcrumb(message, 'error', {
|
|
68
|
+
// logger: this.name,
|
|
69
|
+
// args: args.length > 0 ? args : undefined
|
|
70
|
+
// });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
warn(message) {
|
|
74
|
+
if (!this.shouldLog('warn')) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const formatted = this.formatMessage('warn', message);
|
|
78
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
79
|
+
args[_key2 - 1] = arguments[_key2];
|
|
80
|
+
}
|
|
81
|
+
this.logInstance.warn(formatted, ...args);
|
|
82
|
+
// sentryAdapter.addBreadcrumb(message, 'warn', {
|
|
83
|
+
// logger: this.name,
|
|
84
|
+
// args: args.length > 0 ? args : undefined
|
|
85
|
+
// });
|
|
86
|
+
}
|
|
87
|
+
info(message) {
|
|
88
|
+
if (!this.shouldLog('info')) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const formatted = this.formatMessage('info', message);
|
|
92
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
93
|
+
args[_key3 - 1] = arguments[_key3];
|
|
94
|
+
}
|
|
95
|
+
this.logInstance.info(formatted, ...args);
|
|
96
|
+
// sentryAdapter.addBreadcrumb(message, 'info', {
|
|
97
|
+
// logger: this.name,
|
|
98
|
+
// args: args.length > 0 ? args : undefined
|
|
99
|
+
// });
|
|
100
|
+
}
|
|
101
|
+
log(message) {
|
|
102
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
103
|
+
args[_key4 - 1] = arguments[_key4];
|
|
104
|
+
}
|
|
105
|
+
this.info(message, ...args);
|
|
106
|
+
}
|
|
107
|
+
debug(message) {
|
|
108
|
+
if (!this.shouldLog('debug')) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const formatted = this.formatMessage('debug', message);
|
|
112
|
+
for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
|
|
113
|
+
args[_key5 - 1] = arguments[_key5];
|
|
114
|
+
}
|
|
115
|
+
this.logInstance.debug(formatted, ...args);
|
|
116
|
+
// sentryAdapter.addBreadcrumb(message, 'debug', {
|
|
117
|
+
// logger: this.name,
|
|
118
|
+
// args: args.length > 0 ? args : undefined
|
|
119
|
+
// });
|
|
120
|
+
}
|
|
121
|
+
trace(message) {
|
|
122
|
+
if (!this.shouldLog('trace')) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const formatted = this.formatMessage('trace', message);
|
|
126
|
+
for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
|
127
|
+
args[_key6 - 1] = arguments[_key6];
|
|
128
|
+
}
|
|
129
|
+
this.logInstance.trace(formatted, ...args);
|
|
130
|
+
// sentryAdapter.addBreadcrumb(message, 'trace', {
|
|
131
|
+
// logger: this.name,
|
|
132
|
+
// args: args.length > 0 ? args : undefined
|
|
133
|
+
// });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Group methods
|
|
137
|
+
group(label) {
|
|
138
|
+
const groupLabel = label || `Group ${this.groupStack.length + 1}`;
|
|
139
|
+
this.groupStack.push(groupLabel);
|
|
140
|
+
if (this.shouldLog('debug')) {
|
|
141
|
+
const indent = ' '.repeat(this.groupStack.length - 1);
|
|
142
|
+
const formatted = this.formatMessage('debug', `${indent}▼ ${groupLabel}`);
|
|
143
|
+
this.logInstance.debug(formatted);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
groupEnd() {
|
|
147
|
+
if (this.groupStack.length === 0) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const groupLabel = this.groupStack.pop();
|
|
151
|
+
if (!groupLabel) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (this.shouldLog('debug')) {
|
|
155
|
+
const indent = ' '.repeat(this.groupStack.length);
|
|
156
|
+
const formatted = this.formatMessage('debug', `${indent}▲ ${groupLabel}`);
|
|
157
|
+
this.logInstance.debug(formatted);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Utility methods
|
|
162
|
+
setLevel(level) {
|
|
163
|
+
this.config.level = level;
|
|
164
|
+
this.logInstance.setLevel(this.getLogLevelNumber(level));
|
|
165
|
+
}
|
|
166
|
+
getLevel() {
|
|
167
|
+
return this.config.level;
|
|
168
|
+
}
|
|
169
|
+
getName() {
|
|
170
|
+
return this.name;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Structured logging methods
|
|
174
|
+
// Noted: Capturing context is expensive due to Error creation and stack parsing; it should only be used when necessary.
|
|
175
|
+
createLogContext(level) {
|
|
176
|
+
const baseContext = {
|
|
177
|
+
timestamp: new Date().toISOString(),
|
|
178
|
+
level,
|
|
179
|
+
loggerName: this.name
|
|
180
|
+
};
|
|
181
|
+
if (this.config.enableContextCapture) {
|
|
182
|
+
const extracted = extractContext(3);
|
|
183
|
+
if (extracted) {
|
|
184
|
+
return {
|
|
185
|
+
...baseContext,
|
|
186
|
+
...extracted
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return baseContext;
|
|
191
|
+
}
|
|
192
|
+
logStructured(level, data) {
|
|
193
|
+
if (!this.shouldLog(level)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const context = this.createLogContext(level);
|
|
197
|
+
const logEntry = {
|
|
198
|
+
...context,
|
|
199
|
+
message: data.message,
|
|
200
|
+
context: data.context,
|
|
201
|
+
error: data.error instanceof Error ? {
|
|
202
|
+
name: data.error.name,
|
|
203
|
+
message: data.error.message,
|
|
204
|
+
stack: data.error.stack
|
|
205
|
+
} : data.error,
|
|
206
|
+
tags: data.tags,
|
|
207
|
+
extra: data.extra
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// Output structured JSON
|
|
211
|
+
const jsonOutput = JSON.stringify(logEntry, null, 2);
|
|
212
|
+
this.logInstance[level](jsonOutput);
|
|
213
|
+
|
|
214
|
+
// Add breadcrumb to Sentry
|
|
215
|
+
if (data.error instanceof Error) {
|
|
216
|
+
// sentryAdapter.captureException(data.error, {
|
|
217
|
+
// ...data.context,
|
|
218
|
+
// logger: this.name,
|
|
219
|
+
// tags: data.tags
|
|
220
|
+
// });
|
|
221
|
+
} else {
|
|
222
|
+
// sentryAdapter.addBreadcrumb(data.message, level, {
|
|
223
|
+
// ...data.context,
|
|
224
|
+
// logger: this.name,
|
|
225
|
+
// tags: data.tags
|
|
226
|
+
// });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
errorStructured(data) {
|
|
230
|
+
this.logStructured('error', data);
|
|
231
|
+
}
|
|
232
|
+
warnStructured(data) {
|
|
233
|
+
this.logStructured('warn', data);
|
|
234
|
+
}
|
|
235
|
+
infoStructured(data) {
|
|
236
|
+
this.logStructured('info', data);
|
|
237
|
+
}
|
|
238
|
+
debugStructured(data) {
|
|
239
|
+
this.logStructured('debug', data);
|
|
240
|
+
}
|
|
241
|
+
traceStructured(data) {
|
|
242
|
+
this.logStructured('trace', data);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Public alias for backward compatibility (calls infoStructured)
|
|
246
|
+
logStructuredPublic(data) {
|
|
247
|
+
this.infoStructured(data);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Polkadot compatibility - noop method
|
|
251
|
+
noop() {
|
|
252
|
+
// No operation - required by Polkadot Logger interface
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Extract context from Error stack trace
|
|
258
|
+
* @Todo: Use for structured log, re-test before using
|
|
259
|
+
*/
|
|
260
|
+
exports.Logger = Logger;
|
|
261
|
+
function extractContext() {
|
|
262
|
+
let skipFrames = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2;
|
|
263
|
+
try {
|
|
264
|
+
const stack = new Error().stack;
|
|
265
|
+
if (!stack) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
const lines = stack.split('\n');
|
|
269
|
+
// Skip Error constructor and extractContext call
|
|
270
|
+
const frame = lines[skipFrames + 1];
|
|
271
|
+
if (!frame) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Match patterns like: "at functionName (file://path/to/file.ts:123:45)"
|
|
276
|
+
const match = frame.match(/at\s+(?:async\s+)?(.+?)\s+\((.+?):(\d+):(\d+)\)/);
|
|
277
|
+
if (match) {
|
|
278
|
+
const [, functionName, filePath, line, column] = match;
|
|
279
|
+
const fileName = filePath.split('/').pop() || filePath;
|
|
280
|
+
return {
|
|
281
|
+
file: fileName,
|
|
282
|
+
function: functionName,
|
|
283
|
+
line: parseInt(line, 10),
|
|
284
|
+
column: parseInt(column, 10),
|
|
285
|
+
timestamp: new Date().toISOString(),
|
|
286
|
+
level: 'info',
|
|
287
|
+
loggerName: ''
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
} catch {
|
|
291
|
+
// Ignore errors in context extraction
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Logger", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Logger.Logger;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.createLogger = createLogger;
|
|
13
|
+
exports.defaultLogger = void 0;
|
|
14
|
+
var _Logger = require("./Logger");
|
|
15
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a named logger instance
|
|
20
|
+
* @param name - Logger name (typically the class or module name)
|
|
21
|
+
* @param config - Optional logger configuration
|
|
22
|
+
* @returns Logger instance
|
|
23
|
+
*/
|
|
24
|
+
function createLogger(name, config) {
|
|
25
|
+
return new _Logger.Logger({
|
|
26
|
+
name,
|
|
27
|
+
...config
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Default logger instance
|
|
33
|
+
*/
|
|
34
|
+
const defaultLogger = createLogger('SubWallet');
|
|
35
|
+
|
|
36
|
+
// Export types
|
|
37
|
+
|
|
38
|
+
// Export Logger class for advanced usage
|
|
39
|
+
|
|
40
|
+
// Export Sentry adapter for future integration
|
|
41
|
+
// export { sentryAdapter } from './sentry-adapter';
|
|
42
|
+
exports.defaultLogger = defaultLogger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -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
|
|
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
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
|
|
18
|
+
export declare function checkBalanceWithTransactionFee(validationResponse: SWTransactionResponse, transactionInput: SWTransactionInput, nativeTokenInfo: _ChainAsset, nativeTokenAvailable: 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;
|
|
@@ -12,8 +12,9 @@ import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-
|
|
|
12
12
|
import { _getAssetDecimals, _getAssetPriceId, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getTokenMinAmount, _isCIP26Token, _isNativeToken, _isNativeTokenBySlug, _isTokenEvmSmartContract, _isTokenTonSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
|
|
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
|
+
import { SubstrateTransactionWrappingStatus } from '@subwallet/extension-base/services/transaction-service/types';
|
|
15
16
|
import { AccountSignMode, BasicTxErrorType, BasicTxWarningCode, TransferTxErrorType } from '@subwallet/extension-base/types';
|
|
16
|
-
import { balanceFormatter, combineBitcoinFee, combineEthFee, formatNumber,
|
|
17
|
+
import { balanceFormatter, combineBitcoinFee, combineEthFee, formatNumber, getSizeInfo, pairToAccount } from '@subwallet/extension-base/utils';
|
|
17
18
|
import { isCardanoAddress, isTonAddress } from '@subwallet/keyring';
|
|
18
19
|
import { keyring } from '@subwallet/ui-keyring';
|
|
19
20
|
import BigN from 'bignumber.js';
|
|
@@ -310,7 +311,7 @@ export function checkSupportForTransaction(validationResponse, transaction) {
|
|
|
310
311
|
}
|
|
311
312
|
}
|
|
312
313
|
}
|
|
313
|
-
export async function estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, isTransferLocalTokenAndPayThatTokenAsFee
|
|
314
|
+
export async function estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, isTransferLocalTokenAndPayThatTokenAsFee) {
|
|
314
315
|
const estimateFee = {
|
|
315
316
|
symbol: '',
|
|
316
317
|
decimals: 0,
|
|
@@ -331,14 +332,8 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
|
|
|
331
332
|
if (transaction) {
|
|
332
333
|
try {
|
|
333
334
|
if (isSubstrateTransaction(transaction)) {
|
|
334
|
-
|
|
335
|
-
|
|
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
|
-
}
|
|
335
|
+
var _validationResponse$x;
|
|
336
|
+
estimateFee.value = (_validationResponse$x = validationResponse.xcmFeeDryRun) !== null && _validationResponse$x !== void 0 ? _validationResponse$x : (await transaction.paymentInfo(validationResponse.address)).partialFee.toString();
|
|
342
337
|
} else if (isTonTransaction(transaction)) {
|
|
343
338
|
estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
|
|
344
339
|
} else if (isCardanoTransaction(transaction)) {
|
|
@@ -431,7 +426,7 @@ export function checkSigningAccountForTransaction(validationResponse, chainInfoM
|
|
|
431
426
|
}
|
|
432
427
|
}
|
|
433
428
|
}
|
|
434
|
-
export function checkBalanceWithTransactionFee(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable
|
|
429
|
+
export function checkBalanceWithTransactionFee(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable) {
|
|
435
430
|
if (!validationResponse.estimateFee) {
|
|
436
431
|
// todo: estimateFee should be must-have, need to refactor interface
|
|
437
432
|
return;
|
|
@@ -440,10 +435,10 @@ export function checkBalanceWithTransactionFee(validationResponse, transactionIn
|
|
|
440
435
|
edAsWarning,
|
|
441
436
|
extrinsicType,
|
|
442
437
|
isTransferAll,
|
|
443
|
-
signerSubstrateProxyAddress,
|
|
444
438
|
skipFeeValidation,
|
|
445
439
|
tokenPayFeeSlug
|
|
446
440
|
} = transactionInput;
|
|
441
|
+
const isWrappable = validationResponse.wrappingStatus === SubstrateTransactionWrappingStatus.WRAPPABLE;
|
|
447
442
|
if (skipFeeValidation || tokenPayFeeSlug && !_isNativeTokenBySlug(tokenPayFeeSlug)) {
|
|
448
443
|
// todo: need improve: input should be balance of fee token and check this again
|
|
449
444
|
return;
|
|
@@ -451,29 +446,12 @@ export function checkBalanceWithTransactionFee(validationResponse, transactionIn
|
|
|
451
446
|
const bnFee = new BigN(validationResponse.estimateFee.value);
|
|
452
447
|
const bnNativeTokenAvailable = new BigN(nativeTokenAvailable.value);
|
|
453
448
|
const bnNativeTokenTransferAmount = new BigN(validationResponse.transferNativeAmount || '0');
|
|
454
|
-
if (!bnNativeTokenAvailable.gt(0) && !
|
|
449
|
+
if (!bnNativeTokenAvailable.gt(0) && !isWrappable) {
|
|
455
450
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
456
451
|
}
|
|
457
452
|
const isChainNotSupportTransferAll = [..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.genshiro, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.statemine].includes(nativeTokenInfo.originChain);
|
|
458
|
-
if (!
|
|
459
|
-
|
|
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
|
-
}
|
|
453
|
+
if (bnNativeTokenTransferAmount.plus(isWrappable ? '0' : bnFee).gt(bnNativeTokenAvailable) && (!isTransferAll || isChainNotSupportTransferAll)) {
|
|
454
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE)); // todo: should be generalized and reused in all features
|
|
477
455
|
}
|
|
478
456
|
|
|
479
457
|
// todo: only system.pallet has metadata, we should add for other pallets and mechanisms as well
|
|
@@ -158,6 +158,7 @@ export default class KoniExtension {
|
|
|
158
158
|
private accountsCreateHardwareV2;
|
|
159
159
|
private accountsCreateHardwareMultiple;
|
|
160
160
|
private accountsCreateWithSecret;
|
|
161
|
+
private accountsCreateMultisig;
|
|
161
162
|
private rejectExternalRequest;
|
|
162
163
|
private resolveQrTransfer;
|
|
163
164
|
private subscribeConfirmations;
|
|
@@ -183,6 +184,11 @@ export default class KoniExtension {
|
|
|
183
184
|
private submitCancelStakeWithdrawal;
|
|
184
185
|
private submitPoolBonding;
|
|
185
186
|
private submitPoolingUnbonding;
|
|
187
|
+
private approvePendingTx;
|
|
188
|
+
private executePendingTx;
|
|
189
|
+
private cancelPendingTx;
|
|
190
|
+
private initMultisigTx;
|
|
191
|
+
private handleSubstrateProxyWrappedTx;
|
|
186
192
|
private parseContractInput;
|
|
187
193
|
private submitTuringStakeCompounding;
|
|
188
194
|
private submitTuringCancelStakeCompound;
|
|
@@ -298,5 +304,6 @@ export default class KoniExtension {
|
|
|
298
304
|
private handleRemoveVote;
|
|
299
305
|
private handleUnlockVote;
|
|
300
306
|
private subscribeGovLockedInfo;
|
|
307
|
+
private subscribePendingMultisigTx;
|
|
301
308
|
handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
|
|
302
309
|
}
|