@subwallet/extension-base 1.3.73-0 → 1.3.74-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 +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
|
@@ -47,29 +47,32 @@ var _types3 = require("@subwallet/extension-base/services/chain-service/types");
|
|
|
47
47
|
var _utils6 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
48
48
|
var _utils7 = require("@subwallet/extension-base/services/fee-service/utils");
|
|
49
49
|
var _tokenPayFee = require("@subwallet/extension-base/services/fee-service/utils/tokenPayFee");
|
|
50
|
+
var _utils8 = require("@subwallet/extension-base/services/multisig-service/utils");
|
|
50
51
|
var _constants3 = require("@subwallet/extension-base/services/request-service/constants");
|
|
51
52
|
var _constants4 = require("@subwallet/extension-base/services/setting-service/constants");
|
|
53
|
+
var _substrateProxyService = require("@subwallet/extension-base/services/substrate-proxy-service");
|
|
54
|
+
var _types4 = require("@subwallet/extension-base/services/transaction-service/types");
|
|
52
55
|
var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
|
|
53
56
|
var _storage = require("@subwallet/extension-base/storage");
|
|
54
57
|
var _stores = require("@subwallet/extension-base/stores");
|
|
55
|
-
var
|
|
56
|
-
var
|
|
58
|
+
var _types5 = require("@subwallet/extension-base/types");
|
|
59
|
+
var _utils9 = require("@subwallet/extension-base/utils");
|
|
57
60
|
var _parseTransaction2 = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
58
61
|
var _getId = require("@subwallet/extension-base/utils/getId");
|
|
59
62
|
var _keyring = require("@subwallet/keyring");
|
|
60
|
-
var
|
|
61
|
-
var
|
|
63
|
+
var _types6 = require("@subwallet/keyring/types");
|
|
64
|
+
var _utils0 = require("@subwallet/keyring/utils");
|
|
62
65
|
var _validate = require("@subwallet/keyring/utils/address/validate");
|
|
63
66
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
64
|
-
var
|
|
67
|
+
var _utils1 = require("@walletconnect/utils");
|
|
65
68
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
66
69
|
var bitcoin = _interopRequireWildcard(require("bitcoinjs-lib"));
|
|
67
70
|
var _i18next = require("i18next");
|
|
68
71
|
var _rxjs = require("rxjs");
|
|
69
|
-
var
|
|
72
|
+
var _types7 = require("@polkadot/types");
|
|
70
73
|
var _util = require("@polkadot/util");
|
|
71
74
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
72
|
-
var
|
|
75
|
+
var _utils10 = require("../utils");
|
|
73
76
|
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); }
|
|
74
77
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
75
78
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -217,7 +220,7 @@ class KoniExtension {
|
|
|
217
220
|
const {
|
|
218
221
|
reject
|
|
219
222
|
} = queued;
|
|
220
|
-
reject(new _TransactionError.TransactionError(
|
|
223
|
+
reject(new _TransactionError.TransactionError(_types5.BasicTxErrorType.USER_REJECT_REQUEST));
|
|
221
224
|
return true;
|
|
222
225
|
}
|
|
223
226
|
|
|
@@ -285,7 +288,7 @@ class KoniExtension {
|
|
|
285
288
|
const accounts = keyringService.context.accounts;
|
|
286
289
|
const transformedAccounts = Object.values(accounts);
|
|
287
290
|
const responseData = {
|
|
288
|
-
accounts: transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [(0,
|
|
291
|
+
accounts: transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [(0, _utils9.combineAllAccountProxy)(transformedAccounts), ...transformedAccounts] : [],
|
|
289
292
|
currentAccountProxy: currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.proxyId
|
|
290
293
|
};
|
|
291
294
|
const accountProxyMapObservable = keyringService.context.observable.accounts;
|
|
@@ -299,7 +302,7 @@ class KoniExtension {
|
|
|
299
302
|
currentAccount
|
|
300
303
|
} = _ref7;
|
|
301
304
|
const transformedAccounts = Object.values(accountProxies);
|
|
302
|
-
responseData.accounts = transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [(0,
|
|
305
|
+
responseData.accounts = transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [(0, _utils9.combineAllAccountProxy)(transformedAccounts), ...transformedAccounts] : [];
|
|
303
306
|
responseData.currentAccountProxy = currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.proxyId;
|
|
304
307
|
cb(responseData);
|
|
305
308
|
});
|
|
@@ -321,29 +324,29 @@ class KoniExtension {
|
|
|
321
324
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
322
325
|
const combineFunction = async (chainInfoMap, tokenInfoMap, accountProxyMap, _contacts) => {
|
|
323
326
|
const accountProxies = Object.values(accountProxyMap);
|
|
324
|
-
const contacts = (0,
|
|
327
|
+
const contacts = (0, _utils9.transformAddresses)(_contacts);
|
|
325
328
|
const chainInfo = chainInfoMap[chain];
|
|
326
329
|
const tokenInfo = tokenInfoMap[token || ''];
|
|
327
330
|
const substrateApi = this.#koniState.chainService.getSubstrateApi(chain);
|
|
328
331
|
const accountProxiesFiltered = accountProxies.filter(accountProxy => {
|
|
329
332
|
var _accountProxy$account;
|
|
330
333
|
const signMode = (_accountProxy$account = accountProxy.accounts[0]) === null || _accountProxy$account === void 0 ? void 0 : _accountProxy$account.signMode;
|
|
331
|
-
if (signMode ===
|
|
332
|
-
if (accountProxy.chainTypes.includes(
|
|
334
|
+
if (signMode === _types5.AccountSignMode.GENERIC_LEDGER) {
|
|
335
|
+
if (accountProxy.chainTypes.includes(_types5.AccountChainType.ETHEREUM)) {
|
|
333
336
|
return (0, _utils6._isChainCompatibleLedgerEvm)(chainInfo);
|
|
334
337
|
}
|
|
335
338
|
}
|
|
336
|
-
if (signMode ===
|
|
339
|
+
if (signMode === _types5.AccountSignMode.ECDSA_SUBSTRATE_LEDGER) {
|
|
337
340
|
if (actionType === _types2.ActionType.SEND_NFT) {
|
|
338
341
|
return false;
|
|
339
342
|
}
|
|
340
343
|
if (tokenInfo) {
|
|
341
|
-
return (0,
|
|
344
|
+
return (0, _utils9.isSubstrateEcdsaLedgerAssetSupported)(tokenInfo, chainInfo);
|
|
342
345
|
}
|
|
343
346
|
}
|
|
344
347
|
return true;
|
|
345
348
|
});
|
|
346
|
-
const rs = await (0,
|
|
349
|
+
const rs = await (0, _utils9._analyzeAddress)(data, accountProxiesFiltered, contacts, chainInfo, substrateApi);
|
|
347
350
|
return {
|
|
348
351
|
id,
|
|
349
352
|
...rs
|
|
@@ -387,7 +390,7 @@ class KoniExtension {
|
|
|
387
390
|
const _cb = (0, _subscriptions.createSubscription)(id, port);
|
|
388
391
|
let old = '';
|
|
389
392
|
const subscription = this.#koniState.keyringService.context.observable.contacts.subscribe(subjectInfo => {
|
|
390
|
-
const addresses = (0,
|
|
393
|
+
const addresses = (0, _utils9.transformAddresses)(subjectInfo);
|
|
391
394
|
const _new = JSON.stringify(addresses);
|
|
392
395
|
if (old !== _new) {
|
|
393
396
|
_cb({
|
|
@@ -404,7 +407,7 @@ class KoniExtension {
|
|
|
404
407
|
});
|
|
405
408
|
const subjectInfo = this.#koniState.keyringService.context.contacts;
|
|
406
409
|
return {
|
|
407
|
-
addresses: (0,
|
|
410
|
+
addresses: (0, _utils9.transformAccounts)(subjectInfo)
|
|
408
411
|
};
|
|
409
412
|
}
|
|
410
413
|
|
|
@@ -417,7 +420,7 @@ class KoniExtension {
|
|
|
417
420
|
chain
|
|
418
421
|
} = _ref9;
|
|
419
422
|
if ((0, _keyring.isAddress)(accountId)) {
|
|
420
|
-
const address = (0,
|
|
423
|
+
const address = (0, _utils9.reformatAddress)(accountId);
|
|
421
424
|
const account = _uiKeyring.keyring.getAccount(address);
|
|
422
425
|
const contact = _uiKeyring.keyring.getAddress(address, 'address');
|
|
423
426
|
if (account) {
|
|
@@ -463,7 +466,7 @@ class KoniExtension {
|
|
|
463
466
|
meta
|
|
464
467
|
} = _ref0;
|
|
465
468
|
if ((0, _keyring.isAddress)(address)) {
|
|
466
|
-
const _address = (0,
|
|
469
|
+
const _address = (0, _utils9.reformatAddress)(address);
|
|
467
470
|
_uiKeyring.keyring.saveAddress(_address, meta);
|
|
468
471
|
return true;
|
|
469
472
|
} else {
|
|
@@ -479,7 +482,7 @@ class KoniExtension {
|
|
|
479
482
|
address
|
|
480
483
|
} = _ref1;
|
|
481
484
|
if ((0, _keyring.isAddress)(address)) {
|
|
482
|
-
const _address = (0,
|
|
485
|
+
const _address = (0, _utils9.reformatAddress)(address);
|
|
483
486
|
_uiKeyring.keyring.forgetAddress(_address);
|
|
484
487
|
return true;
|
|
485
488
|
} else {
|
|
@@ -608,16 +611,16 @@ class KoniExtension {
|
|
|
608
611
|
}
|
|
609
612
|
getPairs() {
|
|
610
613
|
const storedAccounts = this.#koniState.keyringService.context.pairs;
|
|
611
|
-
return (0,
|
|
614
|
+
return (0, _utils9.transformAccounts)(storedAccounts);
|
|
612
615
|
}
|
|
613
616
|
isAddressValidWithAuthType(address, accountAuthTypes) {
|
|
614
617
|
const type = (0, _keyring.getKeypairTypeByAddress)(address);
|
|
615
618
|
const validTypes = {
|
|
616
|
-
evm:
|
|
617
|
-
substrate:
|
|
618
|
-
ton:
|
|
619
|
-
cardano:
|
|
620
|
-
bitcoin:
|
|
619
|
+
evm: _types6.EthereumKeypairTypes,
|
|
620
|
+
substrate: _types6.AllSubstrateKeypairTypes,
|
|
621
|
+
ton: _types6.TonKeypairTypes,
|
|
622
|
+
cardano: _types6.CardanoKeypairTypes,
|
|
623
|
+
bitcoin: _types6.BitcoinKeypairTypes
|
|
621
624
|
};
|
|
622
625
|
return !!accountAuthTypes && accountAuthTypes.some(authType => {
|
|
623
626
|
var _validTypes$authType;
|
|
@@ -727,7 +730,7 @@ class KoniExtension {
|
|
|
727
730
|
const {
|
|
728
731
|
promise,
|
|
729
732
|
resolve
|
|
730
|
-
} = (0,
|
|
733
|
+
} = (0, _utils9.createPromiseHandler)();
|
|
731
734
|
const typeInfoMap = {
|
|
732
735
|
substrate: 'substrateInfo',
|
|
733
736
|
evm: 'evmInfo',
|
|
@@ -1238,7 +1241,7 @@ class KoniExtension {
|
|
|
1238
1241
|
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
|
|
1239
1242
|
|
|
1240
1243
|
// Re-filter
|
|
1241
|
-
cb(histories.filter(item => addresses.some(address => (0,
|
|
1244
|
+
cb(histories.filter(item => addresses.some(address => (0, _utils9.isSameAddress)(item.address, address))));
|
|
1242
1245
|
});
|
|
1243
1246
|
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
1244
1247
|
port.onDisconnect.addListener(() => {
|
|
@@ -1247,7 +1250,7 @@ class KoniExtension {
|
|
|
1247
1250
|
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
|
|
1248
1251
|
|
|
1249
1252
|
// Re-filter
|
|
1250
|
-
return historySubject.getValue().filter(item => addresses.some(address => (0,
|
|
1253
|
+
return historySubject.getValue().filter(item => addresses.some(address => (0, _utils9.isSameAddress)(item.address, address)));
|
|
1251
1254
|
}
|
|
1252
1255
|
subscribeHistoryByChainAndAddress(_ref30, id, port) {
|
|
1253
1256
|
let {
|
|
@@ -1304,7 +1307,6 @@ class KoniExtension {
|
|
|
1304
1307
|
feeCustom,
|
|
1305
1308
|
feeOption,
|
|
1306
1309
|
from,
|
|
1307
|
-
signerSubstrateProxyAddress,
|
|
1308
1310
|
to,
|
|
1309
1311
|
tokenPayFeeSlug,
|
|
1310
1312
|
tokenSlug,
|
|
@@ -1474,10 +1476,10 @@ class KoniExtension {
|
|
|
1474
1476
|
if (isCustomTokenPayFeeAssetHub || isCustomTokenPayFeeHydration) {
|
|
1475
1477
|
var _inputTransaction$est, _nonNativeTokenPayFee;
|
|
1476
1478
|
const nonNativeFee = BigInt(((_inputTransaction$est = inputTransaction.estimateFee) === null || _inputTransaction$est === void 0 ? void 0 : _inputTransaction$est.value) || '0'); // todo: estimateFee should be must-have, need to refactor interface
|
|
1477
|
-
const nonNativeTokenPayFeeInfo = await this.#koniState.balanceService.getTokensHasBalance((0,
|
|
1479
|
+
const nonNativeTokenPayFeeInfo = await this.#koniState.balanceService.getTokensHasBalance((0, _utils9.reformatAddress)(from), chain, tokenPayFeeSlug);
|
|
1478
1480
|
const nonNativeTokenPayFeeBalance = BigInt(((_nonNativeTokenPayFee = nonNativeTokenPayFeeInfo[tokenPayFeeSlug]) === null || _nonNativeTokenPayFee === void 0 ? void 0 : _nonNativeTokenPayFee.free) || '0');
|
|
1479
1481
|
if (nonNativeFee > nonNativeTokenPayFeeBalance) {
|
|
1480
|
-
inputTransaction.errors.push(new _TransactionError.TransactionError(
|
|
1482
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_types5.BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
1481
1483
|
}
|
|
1482
1484
|
}
|
|
1483
1485
|
|
|
@@ -1516,10 +1518,10 @@ class KoniExtension {
|
|
|
1516
1518
|
};
|
|
1517
1519
|
const ignoreWarnings = [];
|
|
1518
1520
|
if (transferAll) {
|
|
1519
|
-
ignoreWarnings.push(
|
|
1521
|
+
ignoreWarnings.push(_types5.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT);
|
|
1520
1522
|
}
|
|
1521
1523
|
if (transferBounceable) {
|
|
1522
|
-
ignoreWarnings.push(
|
|
1524
|
+
ignoreWarnings.push(_types5.BasicTxWarningCode.IS_BOUNCEABLE_ADDRESS);
|
|
1523
1525
|
}
|
|
1524
1526
|
return this.#koniState.transactionService.handleTransaction({
|
|
1525
1527
|
errors,
|
|
@@ -1538,7 +1540,6 @@ class KoniExtension {
|
|
|
1538
1540
|
isTransferAll: isTransferNativeToken ? transferAll : false,
|
|
1539
1541
|
isTransferLocalTokenAndPayThatTokenAsFee,
|
|
1540
1542
|
edAsWarning: isTransferNativeToken,
|
|
1541
|
-
signerSubstrateProxyAddress,
|
|
1542
1543
|
additionalValidator: additionalValidator
|
|
1543
1544
|
});
|
|
1544
1545
|
}
|
|
@@ -1550,7 +1551,6 @@ class KoniExtension {
|
|
|
1550
1551
|
from,
|
|
1551
1552
|
isPassConfirmation,
|
|
1552
1553
|
originNetworkKey,
|
|
1553
|
-
signerSubstrateProxyAddress,
|
|
1554
1554
|
to,
|
|
1555
1555
|
tokenPayFeeSlug,
|
|
1556
1556
|
tokenSlug,
|
|
@@ -1701,7 +1701,7 @@ class KoniExtension {
|
|
|
1701
1701
|
if (isSubstrateXcm) {
|
|
1702
1702
|
const isDryRunSuccess = await (0, _xcm.dryRunXcmExtrinsicV2)(params, false);
|
|
1703
1703
|
if (!isDryRunSuccess) {
|
|
1704
|
-
inputTransaction.errors.push(new _TransactionError.TransactionError(
|
|
1704
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_types5.BasicTxErrorType.UNABLE_TO_SEND, 'Unable to perform transaction. Select another token or destination chain and try again'));
|
|
1705
1705
|
}
|
|
1706
1706
|
}
|
|
1707
1707
|
};
|
|
@@ -1724,10 +1724,10 @@ class KoniExtension {
|
|
|
1724
1724
|
}
|
|
1725
1725
|
const ignoreWarnings = [];
|
|
1726
1726
|
if (transferAll) {
|
|
1727
|
-
ignoreWarnings.push(
|
|
1727
|
+
ignoreWarnings.push(_types5.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT);
|
|
1728
1728
|
}
|
|
1729
1729
|
if (transferBounceable) {
|
|
1730
|
-
ignoreWarnings.push(
|
|
1730
|
+
ignoreWarnings.push(_types5.BasicTxWarningCode.IS_BOUNCEABLE_ADDRESS);
|
|
1731
1731
|
}
|
|
1732
1732
|
return await this.#koniState.transactionService.handleTransaction({
|
|
1733
1733
|
url: _constants3.EXTENSION_REQUEST_URL,
|
|
@@ -1746,8 +1746,7 @@ class KoniExtension {
|
|
|
1746
1746
|
xcmFeeDryRun,
|
|
1747
1747
|
errors,
|
|
1748
1748
|
additionalValidator: additionalValidator,
|
|
1749
|
-
eventsHandler: eventsHandler
|
|
1750
|
-
signerSubstrateProxyAddress
|
|
1749
|
+
eventsHandler: eventsHandler
|
|
1751
1750
|
});
|
|
1752
1751
|
}
|
|
1753
1752
|
async makeBitcoinDappTransferConfirmation(inputData) {
|
|
@@ -1862,7 +1861,7 @@ class KoniExtension {
|
|
|
1862
1861
|
if (!address || !amount) {
|
|
1863
1862
|
return total;
|
|
1864
1863
|
}
|
|
1865
|
-
if ((0,
|
|
1864
|
+
if ((0, _utils9.isSameAddress)(address, from)) {
|
|
1866
1865
|
inputAmount = new _bignumber.default(amount);
|
|
1867
1866
|
}
|
|
1868
1867
|
return total.plus(new _bignumber.default(amount || 0));
|
|
@@ -1945,7 +1944,7 @@ class KoniExtension {
|
|
|
1945
1944
|
} = request;
|
|
1946
1945
|
const chainService = this.#koniState.chainService;
|
|
1947
1946
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
1948
|
-
const address = (0,
|
|
1947
|
+
const address = (0, _utils9.reformatAddress)(_address);
|
|
1949
1948
|
const tokensHasBalanceInfoMap = await this.#koniState.balanceService.getTokensHasBalance(address, chain);
|
|
1950
1949
|
const nativeTokenInfo = chainService.getNativeTokenInfo(chain);
|
|
1951
1950
|
const nativeBalanceInfo = {
|
|
@@ -2234,7 +2233,7 @@ class KoniExtension {
|
|
|
2234
2233
|
const extrinsicType = srcChain.slug !== destChain.slug ? _KoniTypes.ExtrinsicType.TRANSFER_XCM : _KoniTypes.ExtrinsicType.TRANSFER_BALANCE;
|
|
2235
2234
|
const freeBalanceSubject = new _rxjs.Subject();
|
|
2236
2235
|
const feeSubject = new _rxjs.Subject();
|
|
2237
|
-
const feeChainType = (0,
|
|
2236
|
+
const feeChainType = (0, _utils9.detectTransferTxType)(srcToken, srcChain, destChain);
|
|
2238
2237
|
if (!destToken) {
|
|
2239
2238
|
throw new Error('Destination token not found');
|
|
2240
2239
|
}
|
|
@@ -2268,12 +2267,12 @@ class KoniExtension {
|
|
|
2268
2267
|
fee,
|
|
2269
2268
|
freeBalance
|
|
2270
2269
|
} = _ref39;
|
|
2271
|
-
(0,
|
|
2270
|
+
(0, _utils9.calculateMaxTransferable)(id, _request, freeBalance, fee).then(cb).catch(console.error);
|
|
2272
2271
|
}
|
|
2273
2272
|
});
|
|
2274
2273
|
const [unsubBalance, freeBalance] = await (async () => {
|
|
2275
2274
|
try {
|
|
2276
|
-
return await this.#koniState.balanceService.subscribeBalance(address, chain, token,
|
|
2275
|
+
return await this.#koniState.balanceService.subscribeBalance(address, chain, token, _types5.BalanceType.TRANSFERABLE, extrinsicType, data => {
|
|
2277
2276
|
freeBalanceSubject.next(data); // Must be called after subscription
|
|
2278
2277
|
});
|
|
2279
2278
|
} catch (e) {
|
|
@@ -2298,7 +2297,7 @@ class KoniExtension {
|
|
|
2298
2297
|
port.onDisconnect.addListener(() => {
|
|
2299
2298
|
this.cancelSubscription(id);
|
|
2300
2299
|
});
|
|
2301
|
-
return (0,
|
|
2300
|
+
return (0, _utils9.calculateMaxTransferable)(id, _request, freeBalance, fee);
|
|
2302
2301
|
}
|
|
2303
2302
|
async subscribeTransferableWhenConfirmation(_ref40, id, port) {
|
|
2304
2303
|
let {
|
|
@@ -2325,19 +2324,19 @@ class KoniExtension {
|
|
|
2325
2324
|
try {
|
|
2326
2325
|
const _fee = fee;
|
|
2327
2326
|
const _feeCustom = feeCustom;
|
|
2328
|
-
const combineFee = (0,
|
|
2327
|
+
const combineFee = (0, _utils9.combineBitcoinFee)(_fee, _feeOptions, _feeCustom);
|
|
2329
2328
|
const bitcoinApi = this.#koniState.chainService.getBitcoinApi(chain);
|
|
2330
|
-
let utxos = await (0,
|
|
2329
|
+
let utxos = await (0, _utils9.getTransferableBitcoinUtxos)(bitcoinApi, address);
|
|
2331
2330
|
const recipients = [address, to || address];
|
|
2332
2331
|
utxos = utxos.sort((a, b) => b.value - a.value);
|
|
2333
|
-
const filteredUtxos = (0,
|
|
2332
|
+
const filteredUtxos = (0, _utils9.filterUneconomicalUtxos)({
|
|
2334
2333
|
utxos,
|
|
2335
2334
|
feeRate: combineFee.feeRate,
|
|
2336
2335
|
recipients,
|
|
2337
2336
|
sender: address
|
|
2338
2337
|
});
|
|
2339
2338
|
for (const utxo of filteredUtxos) {
|
|
2340
|
-
sizeInfo = (0,
|
|
2339
|
+
sizeInfo = (0, _utils9.getSizeInfo)({
|
|
2341
2340
|
inputLength: neededUtxos.length,
|
|
2342
2341
|
sender: address,
|
|
2343
2342
|
recipients
|
|
@@ -2351,13 +2350,13 @@ class KoniExtension {
|
|
|
2351
2350
|
}
|
|
2352
2351
|
|
|
2353
2352
|
// re calculate
|
|
2354
|
-
sizeInfo = (0,
|
|
2353
|
+
sizeInfo = (0, _utils9.getSizeInfo)({
|
|
2355
2354
|
inputLength: neededUtxos.length,
|
|
2356
2355
|
sender: address,
|
|
2357
2356
|
recipients
|
|
2358
2357
|
});
|
|
2359
2358
|
if (!sizeInfo) {
|
|
2360
|
-
sizeInfo = (0,
|
|
2359
|
+
sizeInfo = (0, _utils9.getSizeInfo)({
|
|
2361
2360
|
inputLength: utxos.length || 1,
|
|
2362
2361
|
sender: address,
|
|
2363
2362
|
recipients
|
|
@@ -2368,10 +2367,10 @@ class KoniExtension {
|
|
|
2368
2367
|
if (amountLeft.lte(0)) {
|
|
2369
2368
|
error = 'Insufficient balance';
|
|
2370
2369
|
} else {
|
|
2371
|
-
const senderAddressInfo = (0,
|
|
2370
|
+
const senderAddressInfo = (0, _utils0.getBitcoinAddressInfo)(address);
|
|
2372
2371
|
const dustLimit = _constants.BTC_DUST_AMOUNT[senderAddressInfo.type] || 546;
|
|
2373
2372
|
if (amountLeft.lte(dustLimit)) {
|
|
2374
|
-
sizeInfo = (0,
|
|
2373
|
+
sizeInfo = (0, _utils9.getSizeInfo)({
|
|
2375
2374
|
inputLength: neededUtxos.length,
|
|
2376
2375
|
sender: address,
|
|
2377
2376
|
recipients: [to || address]
|
|
@@ -2413,7 +2412,7 @@ class KoniExtension {
|
|
|
2413
2412
|
convertData(freeBalance, fee, _feeOptions, feeCustom).then(cb).catch(console.error);
|
|
2414
2413
|
}
|
|
2415
2414
|
});
|
|
2416
|
-
const [unsubBalance, freeBalance] = await this.#koniState.balanceService.subscribeBalance(address, chain, token,
|
|
2415
|
+
const [unsubBalance, freeBalance] = await this.#koniState.balanceService.subscribeBalance(address, chain, token, _types5.BalanceType.TRANSFERABLE, _KoniTypes.ExtrinsicType.TRANSFER_BALANCE, data => {
|
|
2417
2416
|
freeBalanceSubject.next(data); // Must be called after subscription
|
|
2418
2417
|
});
|
|
2419
2418
|
const fee = await this.#koniState.feeService.subscribeChainFee(id, chain, feeType, data => {
|
|
@@ -2485,8 +2484,7 @@ class KoniExtension {
|
|
|
2485
2484
|
const {
|
|
2486
2485
|
params,
|
|
2487
2486
|
recipientAddress,
|
|
2488
|
-
senderAddress
|
|
2489
|
-
signerSubstrateProxyAddress
|
|
2487
|
+
senderAddress
|
|
2490
2488
|
} = inputData;
|
|
2491
2489
|
const isSendingSelf = (0, _transfer2.isRecipientSelf)(senderAddress, recipientAddress);
|
|
2492
2490
|
|
|
@@ -2507,8 +2505,7 @@ class KoniExtension {
|
|
|
2507
2505
|
isSendingSelf
|
|
2508
2506
|
},
|
|
2509
2507
|
extrinsicType: _KoniTypes.ExtrinsicType.SEND_NFT,
|
|
2510
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
2511
|
-
signerSubstrateProxyAddress
|
|
2508
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
2512
2509
|
});
|
|
2513
2510
|
return {
|
|
2514
2511
|
...rs,
|
|
@@ -2546,6 +2543,9 @@ class KoniExtension {
|
|
|
2546
2543
|
}
|
|
2547
2544
|
return result;
|
|
2548
2545
|
}
|
|
2546
|
+
async accountsCreateMultisig(request) {
|
|
2547
|
+
return this.#koniState.keyringService.context.accountsCreateMultisig(request);
|
|
2548
|
+
}
|
|
2549
2549
|
|
|
2550
2550
|
/// External account
|
|
2551
2551
|
|
|
@@ -2732,7 +2732,7 @@ class KoniExtension {
|
|
|
2732
2732
|
signed = await pair.evm.signMessage(data, 'personal_sign');
|
|
2733
2733
|
} else {
|
|
2734
2734
|
var _signedTranaction$r, _signedTranaction$s, _signedTranaction$v;
|
|
2735
|
-
const tx = (0,
|
|
2735
|
+
const tx = (0, _utils9.createTransactionFromRLP)(message);
|
|
2736
2736
|
if (!tx) {
|
|
2737
2737
|
throw new Error((0, _i18next.t)('bg.koni.handler.Extension.failedToDecodeQr'));
|
|
2738
2738
|
}
|
|
@@ -2757,7 +2757,7 @@ class KoniExtension {
|
|
|
2757
2757
|
common
|
|
2758
2758
|
});
|
|
2759
2759
|
const signedTranaction = _tx.LegacyTransaction.fromSerializedTx((0, _util.hexToU8a)(pair.evm.signTransaction(transaction)));
|
|
2760
|
-
signed = (0,
|
|
2760
|
+
signed = (0, _utils9.signatureToHex)({
|
|
2761
2761
|
r: ((_signedTranaction$r = signedTranaction.r) === null || _signedTranaction$r === void 0 ? void 0 : _signedTranaction$r.toString(16)) || '',
|
|
2762
2762
|
s: ((_signedTranaction$s = signedTranaction.s) === null || _signedTranaction$s === void 0 ? void 0 : _signedTranaction$s.toString(16)) || '',
|
|
2763
2763
|
v: ((_signedTranaction$v = signedTranaction.v) === null || _signedTranaction$v === void 0 ? void 0 : _signedTranaction$v.toString(16)) || ''
|
|
@@ -2829,7 +2829,7 @@ class KoniExtension {
|
|
|
2829
2829
|
chainName: chainInfo.name
|
|
2830
2830
|
}
|
|
2831
2831
|
});
|
|
2832
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
2832
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.StakingTxErrorType.CAN_NOT_GET_METADATA, errMessage)]);
|
|
2833
2833
|
}
|
|
2834
2834
|
const bondingValidation = (0, _bonding.validateBondingCondition)(chainInfo, amount, selectedValidators, address, chainStakingMetadata, nominatorMetadata);
|
|
2835
2835
|
if (!amount || !selectedValidators || bondingValidation.length > 0) {
|
|
@@ -2857,7 +2857,7 @@ class KoniExtension {
|
|
|
2857
2857
|
} = inputData;
|
|
2858
2858
|
const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, _KoniTypes.StakingType.NOMINATED);
|
|
2859
2859
|
if (!chainStakingMetadata || !nominatorMetadata) {
|
|
2860
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
2860
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INTERNAL_ERROR)]);
|
|
2861
2861
|
}
|
|
2862
2862
|
const unbondingValidation = (0, _bonding.validateUnbondingCondition)(nominatorMetadata, amount, chain, chainStakingMetadata, validatorAddress);
|
|
2863
2863
|
if (!amount || unbondingValidation.length > 0) {
|
|
@@ -2882,10 +2882,10 @@ class KoniExtension {
|
|
|
2882
2882
|
} = inputData;
|
|
2883
2883
|
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
2884
2884
|
if (!address || !poolHandler) {
|
|
2885
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
2885
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INVALID_PARAMS)]);
|
|
2886
2886
|
}
|
|
2887
2887
|
const chain = poolHandler.chain;
|
|
2888
|
-
const stakingType = poolHandler.type ===
|
|
2888
|
+
const stakingType = poolHandler.type === _types5.YieldPoolType.NOMINATION_POOL ? _KoniTypes.StakingType.POOLED : _KoniTypes.StakingType.NOMINATED;
|
|
2889
2889
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2890
2890
|
const extrinsic = await (0, _bonding.getClaimRewardExtrinsic)(substrateApi, chain, address, stakingType, bondReward);
|
|
2891
2891
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -2906,7 +2906,7 @@ class KoniExtension {
|
|
|
2906
2906
|
} = inputData;
|
|
2907
2907
|
const chain = (_this$koniState$earni = this.#koniState.earningService.getPoolHandler(slug)) === null || _this$koniState$earni === void 0 ? void 0 : _this$koniState$earni.chain;
|
|
2908
2908
|
if (!chain || !selectedUnstaking) {
|
|
2909
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
2909
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INVALID_PARAMS)]);
|
|
2910
2910
|
}
|
|
2911
2911
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2912
2912
|
// @ts-ignore
|
|
@@ -2936,7 +2936,7 @@ class KoniExtension {
|
|
|
2936
2936
|
chainName: chainInfo.name
|
|
2937
2937
|
}
|
|
2938
2938
|
});
|
|
2939
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
2939
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.StakingTxErrorType.CAN_NOT_GET_METADATA, errMessage)]);
|
|
2940
2940
|
}
|
|
2941
2941
|
const bondingValidation = (0, _relayChain.validatePoolBondingCondition)(chainInfo, amount, selectedPool, address, chainStakingMetadata, nominatorMetadata);
|
|
2942
2942
|
if (!amount || bondingValidation.length > 0) {
|
|
@@ -2968,7 +2968,7 @@ class KoniExtension {
|
|
|
2968
2968
|
chainName: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.name
|
|
2969
2969
|
}
|
|
2970
2970
|
});
|
|
2971
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
2971
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.StakingTxErrorType.CAN_NOT_GET_METADATA, errMessage)]);
|
|
2972
2972
|
}
|
|
2973
2973
|
const unbondingValidation = (0, _relayChain.validateRelayUnbondingCondition)(amount, chainStakingMetadata, nominatorMetadata);
|
|
2974
2974
|
if (!amount || unbondingValidation.length > 0) {
|
|
@@ -2986,6 +2986,439 @@ class KoniExtension {
|
|
|
2986
2986
|
});
|
|
2987
2987
|
}
|
|
2988
2988
|
|
|
2989
|
+
// Multisig handlers
|
|
2990
|
+
async approvePendingTx(inputData) {
|
|
2991
|
+
const {
|
|
2992
|
+
address,
|
|
2993
|
+
callHash,
|
|
2994
|
+
chain,
|
|
2995
|
+
multisigMetadata,
|
|
2996
|
+
timepoint
|
|
2997
|
+
} = inputData;
|
|
2998
|
+
if (!address || !chain || !multisigMetadata || !callHash || !timepoint) {
|
|
2999
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.MultisigTxErrorType.INVALID_PARAMS)]);
|
|
3000
|
+
}
|
|
3001
|
+
const api = this.#koniState.getSubstrateApi(chain).api;
|
|
3002
|
+
if (!api || !api.tx || !api.tx.multisig) {
|
|
3003
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.MultisigTxErrorType.LACK_MULTISIG_PALLET)]);
|
|
3004
|
+
}
|
|
3005
|
+
const otherSignatories = multisigMetadata.signers.filter(s => !(0, _utils9.isSameAddress)(s, address));
|
|
3006
|
+
const extrinsic = api.tx.multisig.approveAsMulti(multisigMetadata.threshold, (0, _utilCrypto.sortAddresses)(otherSignatories), timepoint, callHash, _utils8.DEFAULT_MAX_WEIGHT);
|
|
3007
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3008
|
+
address,
|
|
3009
|
+
chain,
|
|
3010
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
3011
|
+
data: inputData,
|
|
3012
|
+
extrinsicType: _KoniTypes.ExtrinsicType.MULTISIG_APPROVE_TX,
|
|
3013
|
+
transaction: extrinsic,
|
|
3014
|
+
url: _constants3.EXTENSION_REQUEST_URL
|
|
3015
|
+
});
|
|
3016
|
+
}
|
|
3017
|
+
async executePendingTx(inputData) {
|
|
3018
|
+
const {
|
|
3019
|
+
address,
|
|
3020
|
+
call,
|
|
3021
|
+
chain,
|
|
3022
|
+
decodedCallData,
|
|
3023
|
+
multisigMetadata,
|
|
3024
|
+
timepoint
|
|
3025
|
+
} = inputData;
|
|
3026
|
+
if (!address || !chain || !multisigMetadata || !timepoint || !call || !decodedCallData) {
|
|
3027
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.MultisigTxErrorType.INVALID_PARAMS)]);
|
|
3028
|
+
}
|
|
3029
|
+
try {
|
|
3030
|
+
const api = this.#koniState.getSubstrateApi(chain).api;
|
|
3031
|
+
if (!api || !api.tx || !api.tx.multisig) {
|
|
3032
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.MultisigTxErrorType.LACK_MULTISIG_PALLET)]);
|
|
3033
|
+
}
|
|
3034
|
+
const otherSignatories = multisigMetadata.signers.filter(s => !(0, _utils9.isSameAddress)(s, address));
|
|
3035
|
+
const originalCall = api.createType('Call', call);
|
|
3036
|
+
const originalExtrinsic = api.tx(originalCall);
|
|
3037
|
+
const {
|
|
3038
|
+
weight
|
|
3039
|
+
} = await originalExtrinsic.paymentInfo(otherSignatories[0]); // estimate max weight for execute multisig tx
|
|
3040
|
+
|
|
3041
|
+
const extrinsic = api.tx.multisig.asMulti(multisigMetadata.threshold, (0, _utilCrypto.sortAddresses)(otherSignatories), timepoint, call, weight);
|
|
3042
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3043
|
+
address,
|
|
3044
|
+
chain,
|
|
3045
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
3046
|
+
data: inputData,
|
|
3047
|
+
extrinsicType: _KoniTypes.ExtrinsicType.MULTISIG_EXECUTE_TX,
|
|
3048
|
+
transaction: extrinsic,
|
|
3049
|
+
url: _constants3.EXTENSION_REQUEST_URL
|
|
3050
|
+
});
|
|
3051
|
+
} catch (e) {
|
|
3052
|
+
const errMsg = e.message;
|
|
3053
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.MultisigTxErrorType.UNABLE_TO_CONSTRUCT_TX, errMsg)]);
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
async cancelPendingTx(inputData) {
|
|
3057
|
+
const {
|
|
3058
|
+
address,
|
|
3059
|
+
callHash,
|
|
3060
|
+
chain,
|
|
3061
|
+
multisigMetadata,
|
|
3062
|
+
timepoint
|
|
3063
|
+
} = inputData;
|
|
3064
|
+
if (!address || !chain || !multisigMetadata || !callHash) {
|
|
3065
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.MultisigTxErrorType.INVALID_PARAMS)]);
|
|
3066
|
+
}
|
|
3067
|
+
const api = this.#koniState.getSubstrateApi(chain).api;
|
|
3068
|
+
if (!api || !api.tx || !api.tx.multisig) {
|
|
3069
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.MultisigTxErrorType.LACK_MULTISIG_PALLET)]);
|
|
3070
|
+
}
|
|
3071
|
+
const otherSignatories = multisigMetadata.signers.filter(s => !(0, _utils9.isSameAddress)(s, address));
|
|
3072
|
+
const extrinsic = api.tx.multisig.cancelAsMulti(multisigMetadata.threshold, (0, _utilCrypto.sortAddresses)(otherSignatories), timepoint, callHash);
|
|
3073
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3074
|
+
address,
|
|
3075
|
+
chain,
|
|
3076
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
3077
|
+
data: inputData,
|
|
3078
|
+
extrinsicType: _KoniTypes.ExtrinsicType.MULTISIG_CANCEL_TX,
|
|
3079
|
+
transaction: extrinsic,
|
|
3080
|
+
url: _constants3.EXTENSION_REQUEST_URL
|
|
3081
|
+
});
|
|
3082
|
+
}
|
|
3083
|
+
|
|
3084
|
+
// Multisig Account
|
|
3085
|
+
async initMultisigTx(request) {
|
|
3086
|
+
const {
|
|
3087
|
+
chain,
|
|
3088
|
+
multisigMetadata: {
|
|
3089
|
+
signers,
|
|
3090
|
+
threshold
|
|
3091
|
+
},
|
|
3092
|
+
signer,
|
|
3093
|
+
transactionId
|
|
3094
|
+
} = request;
|
|
3095
|
+
|
|
3096
|
+
/**
|
|
3097
|
+
* ─────────────────────────────
|
|
3098
|
+
* Prepare original transaction
|
|
3099
|
+
* ─────────────────────────────
|
|
3100
|
+
*/
|
|
3101
|
+
const substrateApi = await this.#koniState.chainService.getSubstrateApi(chain).isReady;
|
|
3102
|
+
const originTransaction = this.#koniState.transactionService.getTransaction(transactionId);
|
|
3103
|
+
if (!(originTransaction !== null && originTransaction !== void 0 && originTransaction.transaction)) {
|
|
3104
|
+
throw new Error(`[initMultisigTx] Origin transaction not found: ${transactionId}`);
|
|
3105
|
+
}
|
|
3106
|
+
const extrinsicOriginTransaction = originTransaction.transaction;
|
|
3107
|
+
const callData = extrinsicOriginTransaction.method.toHex();
|
|
3108
|
+
|
|
3109
|
+
/**
|
|
3110
|
+
* ─────────────────────────────
|
|
3111
|
+
* Create multisig wrapped extrinsic
|
|
3112
|
+
* ─────────────────────────────
|
|
3113
|
+
*/
|
|
3114
|
+
const multisigExtrinsic = (0, _utils8.createInitMultisigExtrinsic)(substrateApi.api, threshold, signers, signer, extrinsicOriginTransaction);
|
|
3115
|
+
const decodedCallData = (0, _utils8.decodeCallData)({
|
|
3116
|
+
api: substrateApi.api,
|
|
3117
|
+
callData
|
|
3118
|
+
});
|
|
3119
|
+
|
|
3120
|
+
/**
|
|
3121
|
+
* ─────────────────────────────
|
|
3122
|
+
* Fee & deposit calculation
|
|
3123
|
+
* ─────────────────────────────
|
|
3124
|
+
*/
|
|
3125
|
+
const networkFee = (await multisigExtrinsic.paymentInfo(signer)).partialFee.toString();
|
|
3126
|
+
const depositBase = substrateApi.api.consts.multisig.depositBase.toString();
|
|
3127
|
+
const depositFactor = substrateApi.api.consts.multisig.depositFactor.toString();
|
|
3128
|
+
const depositAmount = (0, _utils8.calcDepositAmount)(depositBase, threshold, depositFactor);
|
|
3129
|
+
|
|
3130
|
+
/**
|
|
3131
|
+
* ─────────────────────────────
|
|
3132
|
+
* Additional validation
|
|
3133
|
+
* ─────────────────────────────
|
|
3134
|
+
* Validate signer balance:
|
|
3135
|
+
* - multisig deposit
|
|
3136
|
+
* - network fee
|
|
3137
|
+
*/
|
|
3138
|
+
const additionalValidator = async inputTransaction => {
|
|
3139
|
+
const signerBalance = await this.getAddressTransferableBalance({
|
|
3140
|
+
address: signer,
|
|
3141
|
+
networkKey: chain,
|
|
3142
|
+
token: this.#koniState.chainService.getNativeTokenInfo(chain).slug,
|
|
3143
|
+
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_TOKEN
|
|
3144
|
+
});
|
|
3145
|
+
|
|
3146
|
+
// Hydration: token fee setting is not supported
|
|
3147
|
+
// todo: check and return better error for the case set token fee on hydration
|
|
3148
|
+
if (_constants._SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain)) {
|
|
3149
|
+
var _substrateApi$api$que3;
|
|
3150
|
+
const setTokenPayFee = await ((_substrateApi$api$que3 = substrateApi.api.query.multiTransactionPayment) === null || _substrateApi$api$que3 === void 0 ? void 0 : _substrateApi$api$que3.accountCurrencyMap(signer));
|
|
3151
|
+
if (setTokenPayFee.toPrimitive()) {
|
|
3152
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_types5.BasicTxErrorType.NOT_ENOUGH_BALANCE, (0, _i18next.t)('bg.koni.handler.Extension.notEnoughBalanceForMultisigDepositAndFee')));
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
const requiredBalance = BigInt(depositAmount) + BigInt(networkFee);
|
|
3156
|
+
if (BigInt(signerBalance.value) < requiredBalance) {
|
|
3157
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_types5.BasicTxErrorType.NOT_ENOUGH_BALANCE, (0, _i18next.t)('bg.koni.handler.Extension.notEnoughBalanceForMultisigDepositAndFee')));
|
|
3158
|
+
}
|
|
3159
|
+
};
|
|
3160
|
+
|
|
3161
|
+
/**
|
|
3162
|
+
* ─────────────────────────────
|
|
3163
|
+
* Event forwarding
|
|
3164
|
+
* ─────────────────────────────
|
|
3165
|
+
* Multisig INIT transaction:
|
|
3166
|
+
* - `signed` is forwarded to notify that the multisig initialization
|
|
3167
|
+
* has been successfully submitted.
|
|
3168
|
+
* - `error` / `timeout` are forwarded to propagate failures.
|
|
3169
|
+
*
|
|
3170
|
+
* Note:
|
|
3171
|
+
* Multisig execution requires collecting enough approvals,
|
|
3172
|
+
* so the transaction is not finalized at this stage.
|
|
3173
|
+
* These forwarded events are only used to resolve
|
|
3174
|
+
* the original wrapped transaction promise.
|
|
3175
|
+
*/
|
|
3176
|
+
const eventsHandler = eventEmitter => {
|
|
3177
|
+
const originEmitter = originTransaction === null || originTransaction === void 0 ? void 0 : originTransaction.emitterTransaction;
|
|
3178
|
+
if (!originEmitter) {
|
|
3179
|
+
return;
|
|
3180
|
+
}
|
|
3181
|
+
eventEmitter.on('signed', data => {
|
|
3182
|
+
originEmitter.emit('signed', data);
|
|
3183
|
+
});
|
|
3184
|
+
eventEmitter.on('error', data => {
|
|
3185
|
+
if (data.errors.length > 0) {
|
|
3186
|
+
originEmitter.emit('error', data);
|
|
3187
|
+
}
|
|
3188
|
+
});
|
|
3189
|
+
eventEmitter.on('timeout', data => {
|
|
3190
|
+
if (data.errors.length > 0 && data.errors.some(e => e.errorType === _types5.BasicTxErrorType.TIMEOUT)) {
|
|
3191
|
+
originEmitter.emit('timeout', data);
|
|
3192
|
+
}
|
|
3193
|
+
});
|
|
3194
|
+
};
|
|
3195
|
+
|
|
3196
|
+
/**
|
|
3197
|
+
* ─────────────────────────────
|
|
3198
|
+
* Submit wrapped transaction
|
|
3199
|
+
* ─────────────────────────────
|
|
3200
|
+
*/
|
|
3201
|
+
return this.#koniState.transactionService.handleWrappedTransaction({
|
|
3202
|
+
address: signer,
|
|
3203
|
+
chain,
|
|
3204
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
3205
|
+
extrinsicType: _KoniTypes.ExtrinsicType.MULTISIG_INIT_TX,
|
|
3206
|
+
transaction: multisigExtrinsic,
|
|
3207
|
+
skipFeeValidation: true,
|
|
3208
|
+
wrappingStatus: _types4.SubstrateTransactionWrappingStatus.WRAP_RESULT,
|
|
3209
|
+
data: {
|
|
3210
|
+
// input
|
|
3211
|
+
...request,
|
|
3212
|
+
// output
|
|
3213
|
+
submittedCallData: multisigExtrinsic.toHex(),
|
|
3214
|
+
callData,
|
|
3215
|
+
decodedCallData,
|
|
3216
|
+
depositAmount,
|
|
3217
|
+
networkFee
|
|
3218
|
+
},
|
|
3219
|
+
additionalValidator,
|
|
3220
|
+
eventsHandler
|
|
3221
|
+
});
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
// Substrate Proxy Account
|
|
3225
|
+
async handleSubstrateProxyWrappedTx(request) {
|
|
3226
|
+
const {
|
|
3227
|
+
chain,
|
|
3228
|
+
proxyMetadata,
|
|
3229
|
+
signer,
|
|
3230
|
+
transactionId
|
|
3231
|
+
} = request;
|
|
3232
|
+
const {
|
|
3233
|
+
proxiedAddress
|
|
3234
|
+
} = proxyMetadata;
|
|
3235
|
+
|
|
3236
|
+
/**
|
|
3237
|
+
* ─────────────────────────────
|
|
3238
|
+
* Prepare original transaction
|
|
3239
|
+
* ─────────────────────────────
|
|
3240
|
+
*/
|
|
3241
|
+
const substrateApi = await this.#koniState.chainService.getSubstrateApi(chain).isReady;
|
|
3242
|
+
const originTransaction = this.#koniState.transactionService.getTransaction(transactionId);
|
|
3243
|
+
const extrinsicOriginTransaction = originTransaction === null || originTransaction === void 0 ? void 0 : originTransaction.transaction;
|
|
3244
|
+
const callData = extrinsicOriginTransaction.method.toHex();
|
|
3245
|
+
const decodedCallData = (0, _utils8.decodeCallData)({
|
|
3246
|
+
api: substrateApi.api,
|
|
3247
|
+
callData
|
|
3248
|
+
});
|
|
3249
|
+
|
|
3250
|
+
/**
|
|
3251
|
+
* ─────────────────────────────
|
|
3252
|
+
* Determine proxy execution
|
|
3253
|
+
* ─────────────────────────────
|
|
3254
|
+
* If signer is the proxied address itself,
|
|
3255
|
+
* a substrate proxy transaction is NOT required.
|
|
3256
|
+
*/
|
|
3257
|
+
const isSignerProxiedAccount = (0, _utils9.isSameAddress)(signer, proxiedAddress);
|
|
3258
|
+
|
|
3259
|
+
/**
|
|
3260
|
+
* ─────────────────────────────
|
|
3261
|
+
* Fee calculation
|
|
3262
|
+
* ─────────────────────────────
|
|
3263
|
+
*/
|
|
3264
|
+
|
|
3265
|
+
const substrateProxyExtrinsic = isSignerProxiedAccount ? extrinsicOriginTransaction : (0, _substrateProxyService.createInitSubstrateProxyExtrinsic)(substrateApi.api, proxiedAddress, extrinsicOriginTransaction);
|
|
3266
|
+
const networkFee = (await substrateProxyExtrinsic.paymentInfo(signer)).partialFee.toString();
|
|
3267
|
+
|
|
3268
|
+
/**
|
|
3269
|
+
* ─────────────────────────────
|
|
3270
|
+
* Additional validation
|
|
3271
|
+
* ─────────────────────────────
|
|
3272
|
+
* Validate signer balance for proxy execution fee.
|
|
3273
|
+
*/
|
|
3274
|
+
const additionalValidator = async inputTransaction => {
|
|
3275
|
+
const signerBalance = await this.getAddressTransferableBalance({
|
|
3276
|
+
address: signer,
|
|
3277
|
+
networkKey: chain,
|
|
3278
|
+
token: this.#koniState.chainService.getNativeTokenInfo(chain).slug,
|
|
3279
|
+
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_TOKEN
|
|
3280
|
+
});
|
|
3281
|
+
|
|
3282
|
+
// todo: check and return better error for the case set token fee on hydration
|
|
3283
|
+
if (_constants._SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain)) {
|
|
3284
|
+
var _substrateApi$api$que4;
|
|
3285
|
+
const setTokenPayFee = await ((_substrateApi$api$que4 = substrateApi.api.query.multiTransactionPayment) === null || _substrateApi$api$que4 === void 0 ? void 0 : _substrateApi$api$que4.accountCurrencyMap(signer));
|
|
3286
|
+
if (setTokenPayFee.toPrimitive()) {
|
|
3287
|
+
const account = (0, _utils9.getAccountJsonByAddress)(signer);
|
|
3288
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_types5.BasicTxErrorType.NOT_ENOUGH_BALANCE, (0, _i18next.t)('bg.koni.handler.Extension.proxyAccountNotEnoughBalance', {
|
|
3289
|
+
replace: {
|
|
3290
|
+
accountName: account === null || account === void 0 ? void 0 : account.name
|
|
3291
|
+
}
|
|
3292
|
+
})));
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
if (BigInt(signerBalance.value) < BigInt(networkFee)) {
|
|
3296
|
+
const account = (0, _utils9.getAccountJsonByAddress)(signer);
|
|
3297
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_types5.BasicTxErrorType.NOT_ENOUGH_BALANCE, (0, _i18next.t)('bg.koni.handler.Extension.proxyAccountNotEnoughBalance', {
|
|
3298
|
+
replace: {
|
|
3299
|
+
accountName: account === null || account === void 0 ? void 0 : account.name
|
|
3300
|
+
}
|
|
3301
|
+
})));
|
|
3302
|
+
}
|
|
3303
|
+
};
|
|
3304
|
+
|
|
3305
|
+
/**
|
|
3306
|
+
* ─────────────────────────────
|
|
3307
|
+
* Event forwarding
|
|
3308
|
+
* ─────────────────────────────
|
|
3309
|
+
* The substrate proxy transaction acts as a wrapper.
|
|
3310
|
+
* Its lifecycle events are forwarded to the original
|
|
3311
|
+
* transaction to resolve the wrapped transaction promise.
|
|
3312
|
+
* update history transaction accordingly.
|
|
3313
|
+
*/
|
|
3314
|
+
const eventsHandler = eventEmitter => {
|
|
3315
|
+
if (!(originTransaction !== null && originTransaction !== void 0 && originTransaction.emitterTransaction)) {
|
|
3316
|
+
return;
|
|
3317
|
+
}
|
|
3318
|
+
const originEmitter = originTransaction.emitterTransaction;
|
|
3319
|
+
eventEmitter.on('send', data => {
|
|
3320
|
+
originEmitter.emit('send', {
|
|
3321
|
+
...data,
|
|
3322
|
+
id: originTransaction.id
|
|
3323
|
+
});
|
|
3324
|
+
});
|
|
3325
|
+
eventEmitter.on('signed', data => {
|
|
3326
|
+
originEmitter.emit('signed', {
|
|
3327
|
+
...data,
|
|
3328
|
+
id: originTransaction.id
|
|
3329
|
+
});
|
|
3330
|
+
});
|
|
3331
|
+
eventEmitter.on('extrinsicHash', data => {
|
|
3332
|
+
originEmitter.emit('extrinsicHash', {
|
|
3333
|
+
...data,
|
|
3334
|
+
id: originTransaction.id
|
|
3335
|
+
});
|
|
3336
|
+
});
|
|
3337
|
+
eventEmitter.on('success', data => {
|
|
3338
|
+
originEmitter.emit('success', {
|
|
3339
|
+
...data,
|
|
3340
|
+
id: originTransaction.id
|
|
3341
|
+
});
|
|
3342
|
+
});
|
|
3343
|
+
eventEmitter.on('error', data => {
|
|
3344
|
+
if (data.errors.length > 0) {
|
|
3345
|
+
originEmitter.emit('error', {
|
|
3346
|
+
...data,
|
|
3347
|
+
id: originTransaction.id
|
|
3348
|
+
});
|
|
3349
|
+
}
|
|
3350
|
+
});
|
|
3351
|
+
eventEmitter.on('timeout', data => {
|
|
3352
|
+
if (data.errors.some(error => error.errorType === _types5.BasicTxErrorType.TIMEOUT)) {
|
|
3353
|
+
originEmitter.emit('timeout', {
|
|
3354
|
+
...data,
|
|
3355
|
+
id: originTransaction.id
|
|
3356
|
+
});
|
|
3357
|
+
}
|
|
3358
|
+
});
|
|
3359
|
+
};
|
|
3360
|
+
|
|
3361
|
+
/**
|
|
3362
|
+
* ─────────────────────────────
|
|
3363
|
+
* Execute wrapped transaction
|
|
3364
|
+
* ─────────────────────────────
|
|
3365
|
+
*/
|
|
3366
|
+
|
|
3367
|
+
// Case 1: signer === proxied address → handle original transaction
|
|
3368
|
+
if (isSignerProxiedAccount) {
|
|
3369
|
+
let callDataFinal = callData;
|
|
3370
|
+
let decodedCallDataFinal = decodedCallData;
|
|
3371
|
+
const pendingMultisigTxRequest = originTransaction.data;
|
|
3372
|
+
if (pendingMultisigTxRequest.call && pendingMultisigTxRequest.decodedCallData) {
|
|
3373
|
+
callDataFinal = pendingMultisigTxRequest.call;
|
|
3374
|
+
decodedCallDataFinal = pendingMultisigTxRequest.decodedCallData;
|
|
3375
|
+
}
|
|
3376
|
+
const response = await this.#koniState.transactionService.handleWrappedTransaction({
|
|
3377
|
+
...originTransaction,
|
|
3378
|
+
skipFeeValidation: false,
|
|
3379
|
+
data: {
|
|
3380
|
+
...originTransaction.data,
|
|
3381
|
+
// output
|
|
3382
|
+
decodedCallData: decodedCallDataFinal,
|
|
3383
|
+
submittedCallData: substrateProxyExtrinsic.toHex(),
|
|
3384
|
+
callData: callDataFinal,
|
|
3385
|
+
networkFee
|
|
3386
|
+
},
|
|
3387
|
+
errors: [],
|
|
3388
|
+
// Clear previous errors
|
|
3389
|
+
wrappingStatus: _types4.SubstrateTransactionWrappingStatus.WRAP_RESULT,
|
|
3390
|
+
eventsHandler
|
|
3391
|
+
});
|
|
3392
|
+
|
|
3393
|
+
// Clear wrappingStatus since no wrapping is needed
|
|
3394
|
+
delete response.wrappingStatus;
|
|
3395
|
+
return response;
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3398
|
+
// Case 2: create and handle substrate proxy transaction
|
|
3399
|
+
return await this.#koniState.transactionService.handleWrappedTransaction({
|
|
3400
|
+
address: signer,
|
|
3401
|
+
chain,
|
|
3402
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
3403
|
+
extrinsicType: _KoniTypes.ExtrinsicType.SUBSTRATE_PROXY_INIT_TX,
|
|
3404
|
+
transaction: substrateProxyExtrinsic,
|
|
3405
|
+
skipFeeValidation: true,
|
|
3406
|
+
transferNativeAmount: originTransaction.transferNativeAmount,
|
|
3407
|
+
data: {
|
|
3408
|
+
// input
|
|
3409
|
+
...request,
|
|
3410
|
+
// output
|
|
3411
|
+
decodedCallData,
|
|
3412
|
+
submittedCallData: substrateProxyExtrinsic.toHex(),
|
|
3413
|
+
callData,
|
|
3414
|
+
networkFee
|
|
3415
|
+
},
|
|
3416
|
+
wrappingStatus: _types4.SubstrateTransactionWrappingStatus.WRAP_RESULT,
|
|
3417
|
+
additionalValidator,
|
|
3418
|
+
eventsHandler
|
|
3419
|
+
});
|
|
3420
|
+
}
|
|
3421
|
+
|
|
2989
3422
|
// EVM Transaction
|
|
2990
3423
|
async parseContractInput(_ref50) {
|
|
2991
3424
|
let {
|
|
@@ -3005,7 +3438,7 @@ class KoniExtension {
|
|
|
3005
3438
|
networkKey
|
|
3006
3439
|
} = inputData;
|
|
3007
3440
|
if (!address) {
|
|
3008
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
3441
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INVALID_PARAMS)]);
|
|
3009
3442
|
}
|
|
3010
3443
|
const dotSamaApi = this.#koniState.getSubstrateApi(networkKey);
|
|
3011
3444
|
const chainInfo = this.#koniState.getChainInfo(networkKey);
|
|
@@ -3188,15 +3621,15 @@ class KoniExtension {
|
|
|
3188
3621
|
const {
|
|
3189
3622
|
payload
|
|
3190
3623
|
} = request;
|
|
3191
|
-
let registry = new
|
|
3624
|
+
let registry = new _types7.TypeRegistry();
|
|
3192
3625
|
if (isJsonPayload(payload)) {
|
|
3193
3626
|
const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
|
|
3194
|
-
const registries = await Promise.all([(0,
|
|
3627
|
+
const registries = await Promise.all([(0, _utils10.setupApiRegistry)(chainInfo, this.#koniState), (0, _utils10.setupDatabaseRegistry)(chainInfo, payload, this.#koniState), (0, _utils10.setupDappRegistry)(payload, this.#koniState)]);
|
|
3195
3628
|
const validRegistries = registries.filter(item => !!(item !== null && item !== void 0 && item.registry));
|
|
3196
3629
|
if (validRegistries.length === 0) {
|
|
3197
3630
|
registry.setSignedExtensions(payload.signedExtensions);
|
|
3198
3631
|
} else {
|
|
3199
|
-
registry = (0,
|
|
3632
|
+
registry = (0, _utils10.getSuitableRegistry)(validRegistries, payload);
|
|
3200
3633
|
}
|
|
3201
3634
|
}
|
|
3202
3635
|
const result = request.sign(registry, pair);
|
|
@@ -3493,12 +3926,12 @@ class KoniExtension {
|
|
|
3493
3926
|
if (namespace.chains) {
|
|
3494
3927
|
const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
|
|
3495
3928
|
if (unSupportChains.length) {
|
|
3496
|
-
throw new Error((0,
|
|
3929
|
+
throw new Error((0, _utils1.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + unSupportChains.toString());
|
|
3497
3930
|
}
|
|
3498
3931
|
availableNamespaces[key] = namespace;
|
|
3499
3932
|
}
|
|
3500
3933
|
} else {
|
|
3501
|
-
throw new Error((0,
|
|
3934
|
+
throw new Error((0, _utils1.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
|
|
3502
3935
|
}
|
|
3503
3936
|
});
|
|
3504
3937
|
Object.entries(optionalNamespaces).forEach(_ref63 => {
|
|
@@ -3533,7 +3966,7 @@ class KoniExtension {
|
|
|
3533
3966
|
const [_namespace] = address.split(':');
|
|
3534
3967
|
return _namespace === key;
|
|
3535
3968
|
});
|
|
3536
|
-
const chains = (0,
|
|
3969
|
+
const chains = (0, _utils9.uniqueStringArray)(namespace.chains);
|
|
3537
3970
|
namespaces[key] = {
|
|
3538
3971
|
accounts,
|
|
3539
3972
|
methods: namespace.methods,
|
|
@@ -3672,7 +4105,7 @@ class KoniExtension {
|
|
|
3672
4105
|
}
|
|
3673
4106
|
async initSyncMantaPay(address) {
|
|
3674
4107
|
var _this$koniState$chain5, _this$koniState$chain6, _this$koniState$chain7, _this$koniState$chain8;
|
|
3675
|
-
if ((_this$koniState$chain5 = this.#koniState.chainService) !== null && _this$koniState$chain5 !== void 0 && (_this$koniState$chain6 = _this$koniState$chain5.mantaPay) !== null && _this$koniState$chain6 !== void 0 && _this$koniState$chain6.getSyncState().isSyncing || !
|
|
4108
|
+
if ((_this$koniState$chain5 = this.#koniState.chainService) !== null && _this$koniState$chain5 !== void 0 && (_this$koniState$chain6 = _this$koniState$chain5.mantaPay) !== null && _this$koniState$chain6 !== void 0 && _this$koniState$chain6.getSyncState().isSyncing || !_utils9.MODULE_SUPPORT.MANTA_ZK) {
|
|
3676
4109
|
return;
|
|
3677
4110
|
}
|
|
3678
4111
|
this.#skipAutoLock = true;
|
|
@@ -3839,8 +4272,7 @@ class KoniExtension {
|
|
|
3839
4272
|
isPassConfirmation,
|
|
3840
4273
|
onSend,
|
|
3841
4274
|
path,
|
|
3842
|
-
processId
|
|
3843
|
-
signerSubstrateProxyAddress
|
|
4275
|
+
processId
|
|
3844
4276
|
} = inputData;
|
|
3845
4277
|
const {
|
|
3846
4278
|
address
|
|
@@ -3856,10 +4288,10 @@ class KoniExtension {
|
|
|
3856
4288
|
if (!data) {
|
|
3857
4289
|
if (step) {
|
|
3858
4290
|
this.#koniState.transactionService.updateProcessStepStatus(step, {
|
|
3859
|
-
status:
|
|
4291
|
+
status: _types5.StepStatus.FAILED
|
|
3860
4292
|
});
|
|
3861
4293
|
}
|
|
3862
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
4294
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INTERNAL_ERROR)]);
|
|
3863
4295
|
}
|
|
3864
4296
|
const isLastStep = inputData.currentStep + 1 === path.steps.length;
|
|
3865
4297
|
const yieldValidation = await this.#koniState.earningService.validateYieldJoin({
|
|
@@ -3870,7 +4302,7 @@ class KoniExtension {
|
|
|
3870
4302
|
if (yieldValidation.length > 0) {
|
|
3871
4303
|
if (step) {
|
|
3872
4304
|
this.#koniState.transactionService.updateProcessStepStatus(step, {
|
|
3873
|
-
status:
|
|
4305
|
+
status: _types5.StepStatus.FAILED
|
|
3874
4306
|
});
|
|
3875
4307
|
}
|
|
3876
4308
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(yieldValidation);
|
|
@@ -3881,7 +4313,7 @@ class KoniExtension {
|
|
|
3881
4313
|
} catch (e) {
|
|
3882
4314
|
if (step) {
|
|
3883
4315
|
this.#koniState.transactionService.updateProcessStepStatus(step, {
|
|
3884
|
-
status:
|
|
4316
|
+
status: _types5.StepStatus.FAILED
|
|
3885
4317
|
});
|
|
3886
4318
|
}
|
|
3887
4319
|
throw e;
|
|
@@ -3910,7 +4342,7 @@ class KoniExtension {
|
|
|
3910
4342
|
feeComponent: [{
|
|
3911
4343
|
amount: fee.amount || '0',
|
|
3912
4344
|
// TODO: Add fee type
|
|
3913
|
-
feeType:
|
|
4345
|
+
feeType: _types5.SwapFeeType.NETWORK_FEE,
|
|
3914
4346
|
tokenSlug: fee.slug
|
|
3915
4347
|
}],
|
|
3916
4348
|
defaultFeeToken: fee.slug,
|
|
@@ -3921,7 +4353,7 @@ class KoniExtension {
|
|
|
3921
4353
|
const lastStep = path.steps[path.steps.length - 1];
|
|
3922
4354
|
const combineInfo = {
|
|
3923
4355
|
// In real case, only `YIELD` have multiple steps
|
|
3924
|
-
type: lastStep.type ===
|
|
4356
|
+
type: lastStep.type === _types5.YieldStepType.JOIN_NOMINATION_POOL ? _types5.EarningProcessType.NOMINATION_POOL : lastStep.type === _types5.YieldStepType.NOMINATE ? _types5.EarningProcessType.NATIVE_STAKING : _types5.EarningProcessType.YIELD,
|
|
3925
4357
|
data,
|
|
3926
4358
|
brief: {
|
|
3927
4359
|
amount: data.amount,
|
|
@@ -3932,17 +4364,17 @@ class KoniExtension {
|
|
|
3932
4364
|
};
|
|
3933
4365
|
await this.#koniState.transactionService.createProcessIfNeed({
|
|
3934
4366
|
id: processId,
|
|
3935
|
-
address: (0,
|
|
3936
|
-
type:
|
|
4367
|
+
address: (0, _utils9.reformatAddress)(address),
|
|
4368
|
+
type: _types5.ProcessType.EARNING,
|
|
3937
4369
|
combineInfo,
|
|
3938
4370
|
currentStepId: step.stepId,
|
|
3939
4371
|
steps: path.steps.map((step, index) => {
|
|
3940
4372
|
const fee = convertFee(path.totalFee[index]);
|
|
3941
|
-
if (![
|
|
4373
|
+
if (![_types5.YieldStepType.XCM, _types5.YieldStepType.DEFAULT, _types5.YieldStepType.TOKEN_APPROVAL].includes(step.type)) {
|
|
3942
4374
|
const metadata = data;
|
|
3943
4375
|
return {
|
|
3944
4376
|
...step,
|
|
3945
|
-
status:
|
|
4377
|
+
status: _types5.StepStatus.QUEUED,
|
|
3946
4378
|
fee,
|
|
3947
4379
|
metadata: metadata
|
|
3948
4380
|
};
|
|
@@ -3950,16 +4382,16 @@ class KoniExtension {
|
|
|
3950
4382
|
return {
|
|
3951
4383
|
...step,
|
|
3952
4384
|
fee,
|
|
3953
|
-
status:
|
|
4385
|
+
status: _types5.StepStatus.QUEUED
|
|
3954
4386
|
};
|
|
3955
|
-
}).filter(step => step.type !==
|
|
3956
|
-
status:
|
|
4387
|
+
}).filter(step => step.type !== _types5.YieldStepType.DEFAULT),
|
|
4388
|
+
status: _types5.StepStatus.QUEUED
|
|
3957
4389
|
});
|
|
3958
4390
|
}
|
|
3959
4391
|
}
|
|
3960
|
-
let balanceTypeForPool =
|
|
3961
|
-
if (!!poolHandler && [
|
|
3962
|
-
balanceTypeForPool =
|
|
4392
|
+
let balanceTypeForPool = _types5.BalanceType.TRANSFERABLE;
|
|
4393
|
+
if (!!poolHandler && [_types5.YieldPoolType.NATIVE_STAKING, _types5.YieldPoolType.NOMINATION_POOL].includes(poolHandler.type)) {
|
|
4394
|
+
balanceTypeForPool = _types5.BalanceType.TOTAL_MINUS_RESERVED;
|
|
3963
4395
|
}
|
|
3964
4396
|
return await this.#koniState.transactionService.handleTransaction({
|
|
3965
4397
|
address,
|
|
@@ -3971,7 +4403,6 @@ class KoniExtension {
|
|
|
3971
4403
|
// change this depends on step
|
|
3972
4404
|
chainType,
|
|
3973
4405
|
resolveOnDone: !isLastStep,
|
|
3974
|
-
signerSubstrateProxyAddress,
|
|
3975
4406
|
transferNativeAmount,
|
|
3976
4407
|
balanceType: balanceTypeForPool,
|
|
3977
4408
|
skipFeeValidation: isMintingStep && isPoolSupportAlternativeFee,
|
|
@@ -3984,7 +4415,6 @@ class KoniExtension {
|
|
|
3984
4415
|
async handleYieldLeave(params) {
|
|
3985
4416
|
const {
|
|
3986
4417
|
address,
|
|
3987
|
-
signerSubstrateProxyAddress,
|
|
3988
4418
|
slug
|
|
3989
4419
|
} = params;
|
|
3990
4420
|
const leaveValidation = await this.#koniState.earningService.validateYieldLeave(params);
|
|
@@ -4000,7 +4430,6 @@ class KoniExtension {
|
|
|
4000
4430
|
data: params,
|
|
4001
4431
|
// TODO
|
|
4002
4432
|
extrinsicType,
|
|
4003
|
-
signerSubstrateProxyAddress,
|
|
4004
4433
|
chainType: (handler === null || handler === void 0 ? void 0 : handler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
4005
4434
|
});
|
|
4006
4435
|
}
|
|
@@ -4077,12 +4506,11 @@ class KoniExtension {
|
|
|
4077
4506
|
async yieldSubmitWithdrawal(params) {
|
|
4078
4507
|
const {
|
|
4079
4508
|
address,
|
|
4080
|
-
signerSubstrateProxyAddress,
|
|
4081
4509
|
slug
|
|
4082
4510
|
} = params;
|
|
4083
4511
|
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
4084
4512
|
if (!poolHandler) {
|
|
4085
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
4513
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INVALID_PARAMS)]);
|
|
4086
4514
|
}
|
|
4087
4515
|
const extrinsic = await this.#koniState.earningService.handleYieldWithdraw(params);
|
|
4088
4516
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -4091,7 +4519,6 @@ class KoniExtension {
|
|
|
4091
4519
|
transaction: extrinsic,
|
|
4092
4520
|
data: params,
|
|
4093
4521
|
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
|
|
4094
|
-
signerSubstrateProxyAddress,
|
|
4095
4522
|
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
4096
4523
|
});
|
|
4097
4524
|
}
|
|
@@ -4099,12 +4526,11 @@ class KoniExtension {
|
|
|
4099
4526
|
const {
|
|
4100
4527
|
address,
|
|
4101
4528
|
selectedUnstaking,
|
|
4102
|
-
signerSubstrateProxyAddress,
|
|
4103
4529
|
slug
|
|
4104
4530
|
} = params;
|
|
4105
4531
|
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
4106
4532
|
if (!poolHandler || !selectedUnstaking) {
|
|
4107
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
4533
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INVALID_PARAMS)]);
|
|
4108
4534
|
}
|
|
4109
4535
|
const chain = poolHandler.chain;
|
|
4110
4536
|
const extrinsic = await this.#koniState.earningService.handleYieldCancelUnstake(params);
|
|
@@ -4114,19 +4540,17 @@ class KoniExtension {
|
|
|
4114
4540
|
transaction: extrinsic,
|
|
4115
4541
|
data: params,
|
|
4116
4542
|
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE,
|
|
4117
|
-
signerSubstrateProxyAddress,
|
|
4118
4543
|
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
4119
4544
|
});
|
|
4120
4545
|
}
|
|
4121
4546
|
async yieldSubmitClaimReward(params) {
|
|
4122
4547
|
const {
|
|
4123
4548
|
address,
|
|
4124
|
-
signerSubstrateProxyAddress,
|
|
4125
4549
|
slug
|
|
4126
4550
|
} = params;
|
|
4127
4551
|
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
4128
4552
|
if (!address || !poolHandler) {
|
|
4129
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
4553
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INVALID_PARAMS)]);
|
|
4130
4554
|
}
|
|
4131
4555
|
const extrinsic = await this.#koniState.earningService.handleYieldClaimReward(params);
|
|
4132
4556
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -4134,7 +4558,6 @@ class KoniExtension {
|
|
|
4134
4558
|
chain: poolHandler.chain,
|
|
4135
4559
|
transaction: extrinsic,
|
|
4136
4560
|
data: params,
|
|
4137
|
-
signerSubstrateProxyAddress,
|
|
4138
4561
|
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD,
|
|
4139
4562
|
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
4140
4563
|
});
|
|
@@ -4145,7 +4568,7 @@ class KoniExtension {
|
|
|
4145
4568
|
} = params;
|
|
4146
4569
|
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
4147
4570
|
if (!poolHandler) {
|
|
4148
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
4571
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INVALID_PARAMS)]);
|
|
4149
4572
|
}
|
|
4150
4573
|
const slippage = await this.#koniState.earningService.yieldGetEarningImpact(params);
|
|
4151
4574
|
return slippage;
|
|
@@ -4153,12 +4576,11 @@ class KoniExtension {
|
|
|
4153
4576
|
async handleYieldChangeValidator(params) {
|
|
4154
4577
|
const {
|
|
4155
4578
|
address,
|
|
4156
|
-
signerSubstrateProxyAddress,
|
|
4157
4579
|
slug
|
|
4158
4580
|
} = params;
|
|
4159
4581
|
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
4160
4582
|
if (!poolHandler) {
|
|
4161
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
4583
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INVALID_PARAMS)]);
|
|
4162
4584
|
}
|
|
4163
4585
|
const extrinsic = await this.#koniState.earningService.handleYieldChangeValidator(params);
|
|
4164
4586
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -4166,7 +4588,6 @@ class KoniExtension {
|
|
|
4166
4588
|
chain: poolHandler.chain,
|
|
4167
4589
|
transaction: extrinsic,
|
|
4168
4590
|
data: params,
|
|
4169
|
-
signerSubstrateProxyAddress,
|
|
4170
4591
|
extrinsicType: _KoniTypes.ExtrinsicType.CHANGE_EARNING_VALIDATOR,
|
|
4171
4592
|
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4172
4593
|
});
|
|
@@ -4391,10 +4812,10 @@ class KoniExtension {
|
|
|
4391
4812
|
if (!quote || !address || !process) {
|
|
4392
4813
|
if (step) {
|
|
4393
4814
|
this.#koniState.transactionService.updateProcessStepStatus(step, {
|
|
4394
|
-
status:
|
|
4815
|
+
status: _types5.StepStatus.FAILED
|
|
4395
4816
|
});
|
|
4396
4817
|
}
|
|
4397
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(
|
|
4818
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INTERNAL_ERROR)]);
|
|
4398
4819
|
}
|
|
4399
4820
|
const isLastStep = inputData.currentStep + 1 === process.steps.length;
|
|
4400
4821
|
const swapValidations = await this.#koniState.swapService.validateSwapProcessV2({
|
|
@@ -4407,7 +4828,7 @@ class KoniExtension {
|
|
|
4407
4828
|
if (swapValidations.length > 0) {
|
|
4408
4829
|
if (step) {
|
|
4409
4830
|
this.#koniState.transactionService.updateProcessStepStatus(step, {
|
|
4410
|
-
status:
|
|
4831
|
+
status: _types5.StepStatus.FAILED
|
|
4411
4832
|
});
|
|
4412
4833
|
}
|
|
4413
4834
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(swapValidations);
|
|
@@ -4418,7 +4839,7 @@ class KoniExtension {
|
|
|
4418
4839
|
} catch (e) {
|
|
4419
4840
|
if (step) {
|
|
4420
4841
|
this.#koniState.transactionService.updateProcessStepStatus(step, {
|
|
4421
|
-
status:
|
|
4842
|
+
status: _types5.StepStatus.FAILED
|
|
4422
4843
|
});
|
|
4423
4844
|
}
|
|
4424
4845
|
console.log('Error handling process step', e);
|
|
@@ -4453,8 +4874,8 @@ class KoniExtension {
|
|
|
4453
4874
|
};
|
|
4454
4875
|
await this.#koniState.transactionService.createProcessIfNeed({
|
|
4455
4876
|
id: processId,
|
|
4456
|
-
address: (0,
|
|
4457
|
-
type:
|
|
4877
|
+
address: (0, _utils9.reformatAddress)(address),
|
|
4878
|
+
type: _types5.ProcessType.SWAP,
|
|
4458
4879
|
currentStepId: step.stepId,
|
|
4459
4880
|
combineInfo,
|
|
4460
4881
|
steps: inputData.process.steps.map((step, index) => {
|
|
@@ -4462,10 +4883,10 @@ class KoniExtension {
|
|
|
4462
4883
|
return {
|
|
4463
4884
|
...step,
|
|
4464
4885
|
fee,
|
|
4465
|
-
status:
|
|
4886
|
+
status: _types5.StepStatus.QUEUED
|
|
4466
4887
|
};
|
|
4467
|
-
}).filter(step => step.type !==
|
|
4468
|
-
status:
|
|
4888
|
+
}).filter(step => step.type !== _types5.CommonStepType.DEFAULT),
|
|
4889
|
+
status: _types5.StepStatus.QUEUED
|
|
4469
4890
|
});
|
|
4470
4891
|
}
|
|
4471
4892
|
}
|
|
@@ -4539,8 +4960,8 @@ class KoniExtension {
|
|
|
4539
4960
|
});
|
|
4540
4961
|
return await this.#koniState.inappNotificationService.getUnreadNotificationsCountMap();
|
|
4541
4962
|
}
|
|
4542
|
-
markAllReadNotification(
|
|
4543
|
-
return this.#koniState.inappNotificationService.markAllRead(
|
|
4963
|
+
markAllReadNotification(params) {
|
|
4964
|
+
return this.#koniState.inappNotificationService.markAllRead(params);
|
|
4544
4965
|
}
|
|
4545
4966
|
switchReadNotificationStatus(params) {
|
|
4546
4967
|
return this.#koniState.inappNotificationService.switchReadStatus(params);
|
|
@@ -4661,8 +5082,8 @@ class KoniExtension {
|
|
|
4661
5082
|
if (!pair) {
|
|
4662
5083
|
throw new Error('Pair not found');
|
|
4663
5084
|
}
|
|
4664
|
-
const signMode = (0,
|
|
4665
|
-
if (signMode !==
|
|
5085
|
+
const signMode = (0, _utils9.getAccountSignMode)(address, pair.meta);
|
|
5086
|
+
if (signMode !== _types5.AccountSignMode.PASSWORD) {
|
|
4666
5087
|
throw new Error('Account can not use this feature');
|
|
4667
5088
|
}
|
|
4668
5089
|
const setting = await new Promise(resolve => this.#koniState.settingService.getSettings(resolve));
|
|
@@ -4670,16 +5091,16 @@ class KoniExtension {
|
|
|
4670
5091
|
throw new Error('Wallet not enable this feature');
|
|
4671
5092
|
}
|
|
4672
5093
|
switch (type) {
|
|
4673
|
-
case
|
|
5094
|
+
case _types5.ProcessType.EARNING:
|
|
4674
5095
|
|
|
4675
5096
|
// eslint-disable-next-line no-fallthrough
|
|
4676
|
-
case
|
|
5097
|
+
case _types5.ProcessType.SWAP:
|
|
4677
5098
|
{
|
|
4678
5099
|
const currentStep = requestData.currentStep;
|
|
4679
5100
|
let stepNums;
|
|
4680
5101
|
let submitData;
|
|
4681
5102
|
let waitXcmData;
|
|
4682
|
-
if (type ===
|
|
5103
|
+
if (type === _types5.ProcessType.EARNING) {
|
|
4683
5104
|
const data = requestData;
|
|
4684
5105
|
const poolHandler = this.#koniState.earningService.getPoolHandler(data.data.slug);
|
|
4685
5106
|
if (poolHandler) {
|
|
@@ -4859,10 +5280,9 @@ class KoniExtension {
|
|
|
4859
5280
|
async handleAddSubstrateProxyAccount(params) {
|
|
4860
5281
|
const {
|
|
4861
5282
|
address,
|
|
4862
|
-
chain
|
|
4863
|
-
signerSubstrateProxyAddress
|
|
5283
|
+
chain
|
|
4864
5284
|
} = params;
|
|
4865
|
-
const validationErrors = await this.#koniState.substrateProxyAccountService.validateAddSubstrateProxyAccount(params
|
|
5285
|
+
const validationErrors = await this.#koniState.substrateProxyAccountService.validateAddSubstrateProxyAccount(params);
|
|
4866
5286
|
if (validationErrors.length > 0) {
|
|
4867
5287
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(validationErrors);
|
|
4868
5288
|
}
|
|
@@ -4873,15 +5293,13 @@ class KoniExtension {
|
|
|
4873
5293
|
transaction: extrinsic,
|
|
4874
5294
|
data: params,
|
|
4875
5295
|
extrinsicType: _KoniTypes.ExtrinsicType.ADD_SUBSTRATE_PROXY_ACCOUNT,
|
|
4876
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4877
|
-
signerSubstrateProxyAddress
|
|
5296
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4878
5297
|
});
|
|
4879
5298
|
}
|
|
4880
5299
|
async handleRemoveSubstrateProxyAccount(params) {
|
|
4881
5300
|
const {
|
|
4882
5301
|
address,
|
|
4883
|
-
chain
|
|
4884
|
-
signerSubstrateProxyAddress
|
|
5302
|
+
chain
|
|
4885
5303
|
} = params;
|
|
4886
5304
|
const extrinsic = await this.#koniState.substrateProxyAccountService.removeSubstrateProxyAccounts(params);
|
|
4887
5305
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -4890,8 +5308,7 @@ class KoniExtension {
|
|
|
4890
5308
|
transaction: extrinsic,
|
|
4891
5309
|
data: params,
|
|
4892
5310
|
extrinsicType: _KoniTypes.ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT,
|
|
4893
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4894
|
-
signerSubstrateProxyAddress
|
|
5311
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4895
5312
|
});
|
|
4896
5313
|
}
|
|
4897
5314
|
|
|
@@ -4907,8 +5324,7 @@ class KoniExtension {
|
|
|
4907
5324
|
transaction: extrinsic,
|
|
4908
5325
|
data: request,
|
|
4909
5326
|
extrinsicType: _KoniTypes.ExtrinsicType.GOV_VOTE,
|
|
4910
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4911
|
-
signerSubstrateProxyAddress: request.signerSubstrateProxyAddress
|
|
5327
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4912
5328
|
});
|
|
4913
5329
|
}
|
|
4914
5330
|
async handleRemoveVote(request) {
|
|
@@ -4919,8 +5335,7 @@ class KoniExtension {
|
|
|
4919
5335
|
transaction: extrinsic,
|
|
4920
5336
|
data: request,
|
|
4921
5337
|
extrinsicType: _KoniTypes.ExtrinsicType.GOV_UNVOTE,
|
|
4922
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4923
|
-
signerSubstrateProxyAddress: request.signerSubstrateProxyAddress
|
|
5338
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4924
5339
|
});
|
|
4925
5340
|
}
|
|
4926
5341
|
async handleUnlockVote(request) {
|
|
@@ -4931,8 +5346,7 @@ class KoniExtension {
|
|
|
4931
5346
|
transaction: extrinsic,
|
|
4932
5347
|
data: request,
|
|
4933
5348
|
extrinsicType: _KoniTypes.ExtrinsicType.GOV_UNLOCK_VOTE,
|
|
4934
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4935
|
-
signerSubstrateProxyAddress: request.signerSubstrateProxyAddress
|
|
5349
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4936
5350
|
});
|
|
4937
5351
|
}
|
|
4938
5352
|
async subscribeGovLockedInfo(id, port) {
|
|
@@ -4952,6 +5366,25 @@ class KoniExtension {
|
|
|
4952
5366
|
|
|
4953
5367
|
/* Open Gov */
|
|
4954
5368
|
|
|
5369
|
+
/* Multisig Acocunt */
|
|
5370
|
+
|
|
5371
|
+
async subscribePendingMultisigTx(id, port) {
|
|
5372
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
5373
|
+
await this.#koniState.multisigService.waitForStarted();
|
|
5374
|
+
const pendingTxSubscription = this.#koniState.multisigService.subscribePendingMultisigTxMap().subscribe({
|
|
5375
|
+
next: rs => {
|
|
5376
|
+
cb(rs);
|
|
5377
|
+
}
|
|
5378
|
+
});
|
|
5379
|
+
this.createUnsubscriptionHandle(id, pendingTxSubscription.unsubscribe);
|
|
5380
|
+
port.onDisconnect.addListener(() => {
|
|
5381
|
+
this.cancelSubscription(id);
|
|
5382
|
+
});
|
|
5383
|
+
return this.#koniState.multisigService.getPendingMultisigTxMap();
|
|
5384
|
+
}
|
|
5385
|
+
|
|
5386
|
+
/* Multisig Acocunt */
|
|
5387
|
+
|
|
4955
5388
|
// --------------------------------------------------------------
|
|
4956
5389
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
4957
5390
|
async handle(id, type, request, port) {
|
|
@@ -5158,6 +5591,8 @@ class KoniExtension {
|
|
|
5158
5591
|
return this.accountsCreateSuriV2(request);
|
|
5159
5592
|
case 'pri(accounts.create.externalV2)':
|
|
5160
5593
|
return await this.accountsCreateExternalV2(request);
|
|
5594
|
+
case 'pri(accounts.create.multisig)':
|
|
5595
|
+
return await this.accountsCreateMultisig(request);
|
|
5161
5596
|
case 'pri(accounts.create.hardwareV2)':
|
|
5162
5597
|
return await this.accountsCreateHardwareV2(request);
|
|
5163
5598
|
case 'pri(accounts.create.hardwareMultiple)':
|
|
@@ -5610,6 +6045,7 @@ class KoniExtension {
|
|
|
5610
6045
|
return this.migrateSoloAccount(request);
|
|
5611
6046
|
case 'pri(migrate.pingSession)':
|
|
5612
6047
|
return this.pingSession(request);
|
|
6048
|
+
/* Migrate Unified Account */
|
|
5613
6049
|
|
|
5614
6050
|
/* Gov */
|
|
5615
6051
|
case 'pri(openGov.vote)':
|
|
@@ -5620,6 +6056,24 @@ class KoniExtension {
|
|
|
5620
6056
|
return this.handleUnlockVote(request);
|
|
5621
6057
|
case 'pri(openGov.subscribeGovLockedInfo)':
|
|
5622
6058
|
return this.subscribeGovLockedInfo(id, port);
|
|
6059
|
+
/* Gov */
|
|
6060
|
+
|
|
6061
|
+
/* Multisig Account */
|
|
6062
|
+
case 'pri(multisig.subscribePendingMultisigTxs)':
|
|
6063
|
+
return await this.subscribePendingMultisigTx(id, port);
|
|
6064
|
+
case 'pri(multisig.getPendingMultisigTxs)':
|
|
6065
|
+
return this.#koniState.multisigService.getPendingTxsForMultisigAddress(request);
|
|
6066
|
+
case 'pri(multisig.approvePendingTx)':
|
|
6067
|
+
return await this.approvePendingTx(request);
|
|
6068
|
+
case 'pri(multisig.executePendingTx)':
|
|
6069
|
+
return await this.executePendingTx(request);
|
|
6070
|
+
case 'pri(multisig.cancelPendingTx)':
|
|
6071
|
+
return await this.cancelPendingTx(request);
|
|
6072
|
+
case 'pri(multisig.initMultisigTx)':
|
|
6073
|
+
return await this.initMultisigTx(request);
|
|
6074
|
+
case 'pri(multisig.getSignableAccountInfos)':
|
|
6075
|
+
return this.#koniState.keyringService.context.getSignableAccountInfos(request);
|
|
6076
|
+
/* Multisig Account */
|
|
5623
6077
|
|
|
5624
6078
|
// Proxy
|
|
5625
6079
|
case 'pri(substrateProxyAccount.getGroupInfo)':
|
|
@@ -5628,7 +6082,8 @@ class KoniExtension {
|
|
|
5628
6082
|
return this.handleAddSubstrateProxyAccount(request);
|
|
5629
6083
|
case 'pri(substrateProxyAccount.remove)':
|
|
5630
6084
|
return this.handleRemoveSubstrateProxyAccount(request);
|
|
5631
|
-
|
|
6085
|
+
case 'pri(substrateProxyAccount.handleProxyWrappedTx)':
|
|
6086
|
+
return this.handleSubstrateProxyWrappedTx(request);
|
|
5632
6087
|
// Default
|
|
5633
6088
|
default:
|
|
5634
6089
|
throw new Error(`Unable to handle message of type ${type}`);
|