@subwallet/extension-base 1.2.2-0 → 1.2.3-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 +4 -0
- package/cjs/core/logic-validation/earning.js +47 -0
- package/cjs/core/logic-validation/swap.js +99 -0
- package/cjs/core/logic-validation/transfer.js +219 -0
- package/cjs/core/substrate/nominationpools-pallet.js +12 -0
- package/cjs/core/substrate/system-pallet.js +78 -0
- package/cjs/koni/api/dotsama/transfer.js +49 -4
- package/cjs/koni/api/staking/bonding/utils.js +1 -1
- package/cjs/koni/api/xcm/index.js +30 -2
- package/cjs/koni/background/handlers/Extension.js +135 -245
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/group.js +4 -27
- package/cjs/services/balance-service/helpers/subscribe/index.js +2 -30
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +41 -80
- package/cjs/services/balance-service/index.js +11 -9
- package/cjs/services/chain-service/index.js +0 -1
- package/cjs/services/chain-service/utils/index.js +6 -0
- package/cjs/services/earning-service/handlers/base.js +1 -1
- package/cjs/services/earning-service/handlers/special.js +11 -12
- package/cjs/services/swap-service/handler/base-handler.js +28 -44
- package/cjs/services/swap-service/handler/chainflip-handler.js +23 -21
- package/cjs/services/swap-service/handler/hydradx-handler.js +40 -38
- package/cjs/services/swap-service/index.js +6 -0
- package/cjs/services/swap-service/utils.js +8 -49
- package/cjs/services/transaction-service/index.js +66 -155
- package/core/logic-validation/earning.d.ts +10 -0
- package/core/logic-validation/earning.js +37 -0
- package/core/logic-validation/swap.d.ts +8 -0
- package/core/logic-validation/swap.js +89 -0
- package/core/logic-validation/transfer.d.ts +16 -0
- package/core/logic-validation/transfer.js +206 -0
- package/core/substrate/nominationpools-pallet.d.ts +7 -0
- package/core/substrate/nominationpools-pallet.js +6 -0
- package/core/substrate/system-pallet.d.ts +27 -0
- package/core/substrate/system-pallet.js +71 -0
- package/koni/api/dotsama/transfer.d.ts +3 -1
- package/koni/api/dotsama/transfer.js +44 -1
- package/koni/api/staking/bonding/relayChain.d.ts +2 -1
- package/koni/api/staking/bonding/utils.js +1 -1
- package/koni/api/xcm/index.d.ts +2 -0
- package/koni/api/xcm/index.js +27 -1
- package/koni/background/handlers/Extension.d.ts +5 -5
- package/koni/background/handlers/Extension.js +111 -221
- package/package.json +34 -9
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/group.js +4 -27
- package/services/balance-service/helpers/subscribe/index.d.ts +2 -1
- package/services/balance-service/helpers/subscribe/index.js +2 -30
- package/services/balance-service/helpers/subscribe/substrate/index.d.ts +2 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +26 -64
- package/services/balance-service/index.d.ts +7 -6
- package/services/balance-service/index.js +12 -10
- package/services/chain-service/index.js +0 -1
- package/services/chain-service/utils/index.d.ts +1 -0
- package/services/chain-service/utils/index.js +4 -0
- package/services/earning-service/handlers/base.js +1 -1
- package/services/earning-service/handlers/nomination-pool/index.d.ts +2 -1
- package/services/earning-service/handlers/special.js +11 -12
- package/services/swap-service/handler/base-handler.d.ts +3 -2
- package/services/swap-service/handler/base-handler.js +26 -42
- package/services/swap-service/handler/chainflip-handler.d.ts +2 -1
- package/services/swap-service/handler/chainflip-handler.js +4 -2
- package/services/swap-service/handler/hydradx-handler.d.ts +2 -1
- package/services/swap-service/handler/hydradx-handler.js +7 -5
- package/services/swap-service/index.js +7 -1
- package/services/swap-service/utils.d.ts +2 -4
- package/services/swap-service/utils.js +7 -47
- package/services/transaction-service/index.d.ts +1 -1
- package/services/transaction-service/index.js +30 -119
- package/services/transaction-service/types.d.ts +1 -0
- package/types/balance/index.d.ts +6 -10
- package/types/yield/info/pallet.d.ts +0 -6
|
@@ -8,45 +8,42 @@ exports.default = exports.SEED_LENGTHS = exports.SEED_DEFAULT_LENGTH = void 0;
|
|
|
8
8
|
exports.isJsonPayload = isJsonPayload;
|
|
9
9
|
var _common = require("@ethereumjs/common");
|
|
10
10
|
var _tx = require("@ethereumjs/tx");
|
|
11
|
-
var _types = require("@subwallet/chain-list/types");
|
|
12
11
|
var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
|
|
13
12
|
var _helpers = require("@subwallet/extension-base/background/handlers/helpers");
|
|
14
13
|
var _subscriptions = require("@subwallet/extension-base/background/handlers/subscriptions");
|
|
15
14
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
16
|
-
var _TransactionWarning = require("@subwallet/extension-base/background/warnings/TransactionWarning");
|
|
17
15
|
var _constants = require("@subwallet/extension-base/constants");
|
|
16
|
+
var _transfer = require("@subwallet/extension-base/core/logic-validation/transfer");
|
|
18
17
|
var _defaults = require("@subwallet/extension-base/defaults");
|
|
19
18
|
var _domain = require("@subwallet/extension-base/koni/api/dotsama/domain");
|
|
20
19
|
var _parseTransaction = require("@subwallet/extension-base/koni/api/dotsama/parseTransaction");
|
|
21
|
-
var
|
|
22
|
-
var
|
|
20
|
+
var _transfer2 = require("@subwallet/extension-base/koni/api/dotsama/transfer");
|
|
21
|
+
var _transfer3 = require("@subwallet/extension-base/koni/api/nft/transfer");
|
|
23
22
|
var _bonding = require("@subwallet/extension-base/koni/api/staking/bonding");
|
|
24
23
|
var _paraChain = require("@subwallet/extension-base/koni/api/staking/bonding/paraChain");
|
|
25
24
|
var _relayChain = require("@subwallet/extension-base/koni/api/staking/bonding/relayChain");
|
|
26
|
-
var
|
|
25
|
+
var _transfer4 = require("@subwallet/extension-base/koni/api/tokens/evm/transfer");
|
|
27
26
|
var _wasm = require("@subwallet/extension-base/koni/api/tokens/wasm");
|
|
28
27
|
var _xcm = require("@subwallet/extension-base/koni/api/xcm");
|
|
29
28
|
var _utils = require("@subwallet/extension-base/koni/api/yield/helper/utils");
|
|
30
29
|
var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
|
|
31
|
-
var
|
|
30
|
+
var _types = require("@subwallet/extension-base/services/chain-service/types");
|
|
32
31
|
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
33
|
-
var _utils3 = require("@subwallet/extension-base/services/fee-service/utils");
|
|
34
32
|
var _constants3 = require("@subwallet/extension-base/services/request-service/constants");
|
|
35
33
|
var _constants4 = require("@subwallet/extension-base/services/setting-service/constants");
|
|
36
34
|
var _constants5 = require("@subwallet/extension-base/services/wallet-connect-service/constants");
|
|
37
35
|
var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
|
|
38
36
|
var _storage = require("@subwallet/extension-base/storage");
|
|
39
37
|
var _stores = require("@subwallet/extension-base/stores");
|
|
40
|
-
var
|
|
41
|
-
var
|
|
38
|
+
var _types2 = require("@subwallet/extension-base/types");
|
|
39
|
+
var _utils3 = require("@subwallet/extension-base/utils");
|
|
42
40
|
var _parseTransaction2 = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
43
|
-
var _number = require("@subwallet/extension-base/utils/number");
|
|
44
41
|
var _keyring = require("@subwallet/keyring");
|
|
45
42
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
46
|
-
var
|
|
43
|
+
var _utils4 = require("@walletconnect/utils");
|
|
47
44
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
48
45
|
var _i18next = require("i18next");
|
|
49
|
-
var
|
|
46
|
+
var _types3 = require("@polkadot/types");
|
|
50
47
|
var _util = require("@polkadot/util");
|
|
51
48
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
52
49
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -566,7 +563,7 @@ class KoniExtension {
|
|
|
566
563
|
const _cb = (0, _subscriptions.createSubscription)(id, port);
|
|
567
564
|
let old = '';
|
|
568
565
|
const subscription = this.#koniState.keyringService.addressesSubject.subscribe(subjectInfo => {
|
|
569
|
-
const addresses = (0,
|
|
566
|
+
const addresses = (0, _utils3.convertSubjectInfoToAddresses)(subjectInfo);
|
|
570
567
|
const _new = JSON.stringify(addresses);
|
|
571
568
|
if (old !== _new) {
|
|
572
569
|
_cb({
|
|
@@ -581,7 +578,7 @@ class KoniExtension {
|
|
|
581
578
|
});
|
|
582
579
|
const subjectInfo = this.#koniState.keyringService.addresses;
|
|
583
580
|
return {
|
|
584
|
-
addresses: (0,
|
|
581
|
+
addresses: (0, _utils3.convertSubjectInfoToAddresses)(subjectInfo)
|
|
585
582
|
};
|
|
586
583
|
}
|
|
587
584
|
saveRecentAccount(_ref22) {
|
|
@@ -590,7 +587,7 @@ class KoniExtension {
|
|
|
590
587
|
chain
|
|
591
588
|
} = _ref22;
|
|
592
589
|
if ((0, _utilCrypto.isAddress)(accountId)) {
|
|
593
|
-
const address = (0,
|
|
590
|
+
const address = (0, _utils3.reformatAddress)(accountId);
|
|
594
591
|
const account = _uiKeyring.keyring.getAccount(address);
|
|
595
592
|
const contact = _uiKeyring.keyring.getAddress(address, 'address');
|
|
596
593
|
if (account) {
|
|
@@ -632,7 +629,7 @@ class KoniExtension {
|
|
|
632
629
|
meta
|
|
633
630
|
} = _ref23;
|
|
634
631
|
if ((0, _utilCrypto.isAddress)(address)) {
|
|
635
|
-
const _address = (0,
|
|
632
|
+
const _address = (0, _utils3.reformatAddress)(address);
|
|
636
633
|
_uiKeyring.keyring.saveAddress(_address, meta);
|
|
637
634
|
return true;
|
|
638
635
|
} else {
|
|
@@ -644,7 +641,7 @@ class KoniExtension {
|
|
|
644
641
|
address
|
|
645
642
|
} = _ref24;
|
|
646
643
|
if ((0, _utilCrypto.isAddress)(address)) {
|
|
647
|
-
const _address = (0,
|
|
644
|
+
const _address = (0, _utils3.reformatAddress)(address);
|
|
648
645
|
_uiKeyring.keyring.forgetAddress(_address);
|
|
649
646
|
return true;
|
|
650
647
|
} else {
|
|
@@ -1574,7 +1571,7 @@ class KoniExtension {
|
|
|
1574
1571
|
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
|
|
1575
1572
|
|
|
1576
1573
|
// Re-filter
|
|
1577
|
-
cb(histories.filter(item => addresses.some(address => (0,
|
|
1574
|
+
cb(histories.filter(item => addresses.some(address => (0, _utils3.isSameAddress)(item.address, address))));
|
|
1578
1575
|
});
|
|
1579
1576
|
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
1580
1577
|
port.onDisconnect.addListener(() => {
|
|
@@ -1583,7 +1580,7 @@ class KoniExtension {
|
|
|
1583
1580
|
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
|
|
1584
1581
|
|
|
1585
1582
|
// Re-filter
|
|
1586
|
-
return historySubject.getValue().filter(item => addresses.some(address => (0,
|
|
1583
|
+
return historySubject.getValue().filter(item => addresses.some(address => (0, _utils3.isSameAddress)(item.address, address)));
|
|
1587
1584
|
}
|
|
1588
1585
|
subscribeHistoryByChainAndAddress(_ref46, id, port) {
|
|
1589
1586
|
let {
|
|
@@ -1601,39 +1598,6 @@ class KoniExtension {
|
|
|
1601
1598
|
items: subscribeHistoriesResponse.value
|
|
1602
1599
|
};
|
|
1603
1600
|
}
|
|
1604
|
-
|
|
1605
|
-
// Save address to contact
|
|
1606
|
-
// private addContact (to: string) {
|
|
1607
|
-
// const toAddress = reformatAddress(to);
|
|
1608
|
-
// const account = keyring.getAccount(toAddress);
|
|
1609
|
-
// const contact = keyring.getAddress(toAddress);
|
|
1610
|
-
//
|
|
1611
|
-
// if (!account && (!contact || contact.meta.isRecent)) {
|
|
1612
|
-
// keyring.saveAddress(toAddress, {});
|
|
1613
|
-
// }
|
|
1614
|
-
// }
|
|
1615
|
-
|
|
1616
|
-
validateTransfer(tokenSlug, from, to, value, transferAll) {
|
|
1617
|
-
const errors = [];
|
|
1618
|
-
const keypair = _uiKeyring.keyring.getPair(from);
|
|
1619
|
-
let transferValue;
|
|
1620
|
-
if (!transferAll) {
|
|
1621
|
-
if (value === undefined) {
|
|
1622
|
-
errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Transfer amount is required')));
|
|
1623
|
-
}
|
|
1624
|
-
if (value) {
|
|
1625
|
-
transferValue = new _util.BN(value);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
|
|
1629
|
-
if (!tokenInfo) {
|
|
1630
|
-
errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found token from registry')));
|
|
1631
|
-
}
|
|
1632
|
-
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils2._isTokenEvmSmartContract)(tokenInfo) && (0, _utils2._getContractAddressOfToken)(tokenInfo).length === 0) {
|
|
1633
|
-
errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found ERC20 address for this token')));
|
|
1634
|
-
}
|
|
1635
|
-
return [errors, keypair, transferValue, tokenInfo];
|
|
1636
|
-
}
|
|
1637
1601
|
async makeTransfer(inputData) {
|
|
1638
1602
|
const {
|
|
1639
1603
|
from,
|
|
@@ -1643,55 +1607,51 @@ class KoniExtension {
|
|
|
1643
1607
|
transferAll,
|
|
1644
1608
|
value
|
|
1645
1609
|
} = inputData;
|
|
1646
|
-
const
|
|
1610
|
+
const transferTokenInfo = this.#koniState.chainService.getAssetBySlug(tokenSlug);
|
|
1611
|
+
const [errors,,] = (0, _transfer.validateTransferRequest)(transferTokenInfo, from, to, value, transferAll);
|
|
1647
1612
|
const warnings = [];
|
|
1648
1613
|
const evmApiMap = this.#koniState.getEvmApiMap();
|
|
1649
1614
|
const chainInfo = this.#koniState.getChainInfo(networkKey);
|
|
1650
1615
|
const nativeTokenInfo = this.#koniState.getNativeTokenInfo(networkKey);
|
|
1651
1616
|
const nativeTokenSlug = nativeTokenInfo.slug;
|
|
1652
1617
|
const isTransferNativeToken = nativeTokenSlug === tokenSlug;
|
|
1618
|
+
const extrinsicType = isTransferNativeToken ? _KoniTypes.ExtrinsicType.TRANSFER_BALANCE : _KoniTypes.ExtrinsicType.TRANSFER_TOKEN;
|
|
1653
1619
|
let chainType = _KoniTypes.ChainType.SUBSTRATE;
|
|
1654
|
-
const tokenBaseAmount = {
|
|
1655
|
-
value: '0',
|
|
1656
|
-
symbol: tokenInfo.symbol,
|
|
1657
|
-
decimals: tokenInfo.decimals || 0
|
|
1658
|
-
};
|
|
1659
1620
|
const transferAmount = {
|
|
1660
|
-
|
|
1621
|
+
value: '0',
|
|
1622
|
+
symbol: (0, _utils2._getAssetSymbol)(transferTokenInfo),
|
|
1623
|
+
decimals: (0, _utils2._getAssetDecimals)(transferTokenInfo)
|
|
1661
1624
|
};
|
|
1662
1625
|
let transaction;
|
|
1663
|
-
|
|
1664
|
-
// Get native token amount
|
|
1665
|
-
const freeBalance = await this.getAddressFreeBalance({
|
|
1626
|
+
const transferTokenAvailable = await this.getAddressTransferableBalance({
|
|
1666
1627
|
address: from,
|
|
1667
1628
|
networkKey,
|
|
1668
|
-
token: tokenSlug
|
|
1629
|
+
token: tokenSlug,
|
|
1630
|
+
extrinsicType
|
|
1669
1631
|
});
|
|
1670
1632
|
try {
|
|
1671
|
-
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils2._isTokenTransferredByEvm)(
|
|
1672
|
-
// TODO: review this
|
|
1633
|
+
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils2._isTokenTransferredByEvm)(transferTokenInfo)) {
|
|
1673
1634
|
chainType = _KoniTypes.ChainType.EVM;
|
|
1674
|
-
const txVal = transferAll ?
|
|
1635
|
+
const txVal = transferAll ? transferTokenAvailable.value : value || '0';
|
|
1675
1636
|
const evmApi = evmApiMap[networkKey];
|
|
1676
1637
|
|
|
1677
1638
|
// Estimate with EVM API
|
|
1678
|
-
if ((0, _utils2._isTokenEvmSmartContract)(
|
|
1679
|
-
[transaction, transferAmount.value] = await (0,
|
|
1639
|
+
if ((0, _utils2._isTokenEvmSmartContract)(transferTokenInfo) || (0, _utils2._isLocalToken)(transferTokenInfo)) {
|
|
1640
|
+
[transaction, transferAmount.value] = await (0, _transfer4.getERC20TransactionObject)((0, _utils2._getContractAddressOfToken)(transferTokenInfo), chainInfo, from, to, txVal, !!transferAll, evmApi);
|
|
1680
1641
|
} else {
|
|
1681
|
-
[transaction, transferAmount.value] = await (0,
|
|
1642
|
+
[transaction, transferAmount.value] = await (0, _transfer4.getEVMTransactionObject)(chainInfo, from, to, txVal, !!transferAll, evmApi);
|
|
1682
1643
|
}
|
|
1683
|
-
} else if ((0, _utils2._isMantaZkAsset)(
|
|
1684
|
-
// TODO
|
|
1644
|
+
} else if ((0, _utils2._isMantaZkAsset)(transferTokenInfo)) {
|
|
1685
1645
|
transaction = undefined;
|
|
1686
1646
|
transferAmount.value = '0';
|
|
1687
1647
|
} else {
|
|
1688
1648
|
const substrateApi = this.#koniState.getSubstrateApi(networkKey);
|
|
1689
|
-
[transaction, transferAmount.value] = await (0,
|
|
1649
|
+
[transaction, transferAmount.value] = await (0, _transfer2.createTransferExtrinsic)({
|
|
1690
1650
|
transferAll: !!transferAll,
|
|
1691
1651
|
value: value || '0',
|
|
1692
1652
|
from: from,
|
|
1693
1653
|
networkKey,
|
|
1694
|
-
tokenInfo,
|
|
1654
|
+
tokenInfo: transferTokenInfo,
|
|
1695
1655
|
to: to,
|
|
1696
1656
|
substrateApi
|
|
1697
1657
|
});
|
|
@@ -1704,46 +1664,33 @@ class KoniExtension {
|
|
|
1704
1664
|
throw error;
|
|
1705
1665
|
}
|
|
1706
1666
|
const transferNativeAmount = isTransferNativeToken ? transferAmount.value : '0';
|
|
1707
|
-
|
|
1708
|
-
// this.addContact(to);
|
|
1709
|
-
|
|
1710
1667
|
const additionalValidator = async inputTransaction => {
|
|
1711
|
-
|
|
1668
|
+
let senderTransferTokenTransferable;
|
|
1712
1669
|
|
|
1713
1670
|
// Check ed for sender
|
|
1714
1671
|
if (!isTransferNativeToken) {
|
|
1715
1672
|
const {
|
|
1716
|
-
value
|
|
1717
|
-
} = await this.
|
|
1673
|
+
value
|
|
1674
|
+
} = await this.getAddressTransferableBalance({
|
|
1718
1675
|
address: from,
|
|
1719
1676
|
networkKey,
|
|
1720
|
-
token: tokenSlug
|
|
1677
|
+
token: tokenSlug,
|
|
1678
|
+
extrinsicType
|
|
1721
1679
|
});
|
|
1722
|
-
|
|
1723
|
-
inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
1724
|
-
}
|
|
1680
|
+
senderTransferTokenTransferable = value;
|
|
1725
1681
|
}
|
|
1726
1682
|
const {
|
|
1727
|
-
value:
|
|
1728
|
-
} = await this.
|
|
1683
|
+
value: receiverTransferTokenTransferable
|
|
1684
|
+
} = await this.getAddressTransferableBalance({
|
|
1729
1685
|
address: to,
|
|
1730
1686
|
networkKey,
|
|
1731
|
-
token: tokenSlug
|
|
1732
|
-
|
|
1687
|
+
token: tokenSlug,
|
|
1688
|
+
extrinsicType
|
|
1689
|
+
}); // todo: shouldn't be just transferable, locked also counts
|
|
1733
1690
|
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
const atLeastStr = (0, _number.formatNumber)(atLeast, tokenInfo.decimals || 0, _number.balanceFormatter, {
|
|
1738
|
-
maxNumberFormat: tokenInfo.decimals || 6
|
|
1739
|
-
});
|
|
1740
|
-
inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
|
|
1741
|
-
replace: {
|
|
1742
|
-
amount: atLeastStr,
|
|
1743
|
-
symbol: tokenInfo.symbol
|
|
1744
|
-
}
|
|
1745
|
-
})));
|
|
1746
|
-
}
|
|
1691
|
+
const [warning, error] = (0, _transfer.additionalValidateTransfer)(transferTokenInfo, extrinsicType, receiverTransferTokenTransferable, transferAmount.value, senderTransferTokenTransferable);
|
|
1692
|
+
warning && inputTransaction.warnings.push(warning);
|
|
1693
|
+
error && inputTransaction.errors.push(error);
|
|
1747
1694
|
};
|
|
1748
1695
|
return this.#koniState.transactionService.handleTransaction({
|
|
1749
1696
|
errors,
|
|
@@ -1754,24 +1701,13 @@ class KoniExtension {
|
|
|
1754
1701
|
transferNativeAmount,
|
|
1755
1702
|
transaction,
|
|
1756
1703
|
data: inputData,
|
|
1757
|
-
extrinsicType
|
|
1704
|
+
extrinsicType,
|
|
1758
1705
|
ignoreWarnings: transferAll,
|
|
1759
1706
|
isTransferAll: isTransferNativeToken ? transferAll : false,
|
|
1760
1707
|
edAsWarning: isTransferNativeToken,
|
|
1761
1708
|
additionalValidator: additionalValidator
|
|
1762
1709
|
});
|
|
1763
1710
|
}
|
|
1764
|
-
validateCrossChainTransfer(destinationNetworkKey, sendingTokenSlug, sender, sendingValue) {
|
|
1765
|
-
const errors = [];
|
|
1766
|
-
const keypair = _uiKeyring.keyring.getPair(sender);
|
|
1767
|
-
const transferValue = new _util.BN(sendingValue);
|
|
1768
|
-
const originTokenInfo = this.#koniState.getAssetBySlug(sendingTokenSlug);
|
|
1769
|
-
const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destinationNetworkKey, sendingTokenSlug);
|
|
1770
|
-
if (!destinationTokenInfo) {
|
|
1771
|
-
errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.INVALID_TOKEN, (0, _i18next.t)('Not found token from registry')));
|
|
1772
|
-
}
|
|
1773
|
-
return [errors, keypair, transferValue, originTokenInfo, destinationTokenInfo];
|
|
1774
|
-
}
|
|
1775
1711
|
async makeCrossChainTransfer(inputData) {
|
|
1776
1712
|
const {
|
|
1777
1713
|
destinationNetworkKey,
|
|
@@ -1781,7 +1717,9 @@ class KoniExtension {
|
|
|
1781
1717
|
tokenSlug,
|
|
1782
1718
|
value
|
|
1783
1719
|
} = inputData;
|
|
1784
|
-
const
|
|
1720
|
+
const originTokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
|
|
1721
|
+
const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destinationNetworkKey, tokenSlug);
|
|
1722
|
+
const [errors, fromKeyPair] = (0, _transfer.validateXcmTransferRequest)(destinationTokenInfo, from, value);
|
|
1785
1723
|
let extrinsic = null;
|
|
1786
1724
|
if (errors.length > 0) {
|
|
1787
1725
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(errors);
|
|
@@ -1800,37 +1738,16 @@ class KoniExtension {
|
|
|
1800
1738
|
substrateApi
|
|
1801
1739
|
});
|
|
1802
1740
|
additionalValidator = async inputTransaction => {
|
|
1803
|
-
const
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
amount: atLeastStr,
|
|
1814
|
-
symbol: originTokenInfo.symbol
|
|
1815
|
-
}
|
|
1816
|
-
})));
|
|
1817
|
-
}
|
|
1818
|
-
const srcMinAmount = originTokenInfo.minAmount || '0';
|
|
1819
|
-
const isTransferNativeToken = originTokenInfo.assetType === _types._AssetType.NATIVE;
|
|
1820
|
-
|
|
1821
|
-
// Check ed for sender
|
|
1822
|
-
if (!isTransferNativeToken) {
|
|
1823
|
-
const {
|
|
1824
|
-
value: balance
|
|
1825
|
-
} = await this.getAddressFreeBalance({
|
|
1826
|
-
address: from,
|
|
1827
|
-
networkKey: originNetworkKey,
|
|
1828
|
-
token: originTokenInfo.slug
|
|
1829
|
-
});
|
|
1830
|
-
if (new _bignumber.default(balance).minus(value).lt(srcMinAmount)) {
|
|
1831
|
-
inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1741
|
+
const {
|
|
1742
|
+
value: senderTransferable
|
|
1743
|
+
} = await this.getAddressTransferableBalance({
|
|
1744
|
+
address: from,
|
|
1745
|
+
networkKey: originNetworkKey,
|
|
1746
|
+
token: originTokenInfo.slug
|
|
1747
|
+
});
|
|
1748
|
+
const [warning, error] = (0, _transfer.additionalValidateXcmTransfer)(originTokenInfo, destinationTokenInfo, value, senderTransferable);
|
|
1749
|
+
error && inputTransaction.errors.push(error);
|
|
1750
|
+
warning && inputTransaction.warnings.push(warning);
|
|
1834
1751
|
};
|
|
1835
1752
|
eventsHandler = eventEmitter => {
|
|
1836
1753
|
eventEmitter.on('send', () => {
|
|
@@ -1849,9 +1766,6 @@ class KoniExtension {
|
|
|
1849
1766
|
});
|
|
1850
1767
|
};
|
|
1851
1768
|
}
|
|
1852
|
-
|
|
1853
|
-
// this.addContact(to);
|
|
1854
|
-
|
|
1855
1769
|
return await this.#koniState.transactionService.handleTransaction({
|
|
1856
1770
|
url: _constants3.EXTENSION_REQUEST_URL,
|
|
1857
1771
|
address: from,
|
|
@@ -1877,7 +1791,7 @@ class KoniExtension {
|
|
|
1877
1791
|
} = inputData;
|
|
1878
1792
|
const contractAddress = params.contractAddress;
|
|
1879
1793
|
const tokenId = params.tokenId;
|
|
1880
|
-
const transaction = await (0,
|
|
1794
|
+
const transaction = await (0, _transfer4.getERC721Transaction)(this.#koniState.getEvmApi(networkKey), networkKey, contractAddress, senderAddress, recipientAddress, tokenId);
|
|
1881
1795
|
|
|
1882
1796
|
// this.addContact(recipientAddress);
|
|
1883
1797
|
|
|
@@ -1957,9 +1871,10 @@ class KoniExtension {
|
|
|
1957
1871
|
async validateCustomAsset(data) {
|
|
1958
1872
|
return await this.#koniState.validateCustomAsset(data);
|
|
1959
1873
|
}
|
|
1960
|
-
async
|
|
1874
|
+
async getAddressTransferableBalance(_ref49) {
|
|
1961
1875
|
let {
|
|
1962
1876
|
address,
|
|
1877
|
+
extrinsicType,
|
|
1963
1878
|
networkKey,
|
|
1964
1879
|
token
|
|
1965
1880
|
} = _ref49;
|
|
@@ -1969,9 +1884,9 @@ class KoniExtension {
|
|
|
1969
1884
|
return await this.#koniState.getMantaPayZkBalance(address, tokenInfo);
|
|
1970
1885
|
}
|
|
1971
1886
|
}
|
|
1972
|
-
return await this.#koniState.balanceService.
|
|
1887
|
+
return await this.#koniState.balanceService.getTransferableBalance(address, networkKey, token, extrinsicType);
|
|
1973
1888
|
}
|
|
1974
|
-
async
|
|
1889
|
+
async getMaxTransferable(_ref50) {
|
|
1975
1890
|
let {
|
|
1976
1891
|
address,
|
|
1977
1892
|
destChain,
|
|
@@ -1979,92 +1894,67 @@ class KoniExtension {
|
|
|
1979
1894
|
networkKey,
|
|
1980
1895
|
token
|
|
1981
1896
|
} = _ref50;
|
|
1982
|
-
const freeBalance = await this.getAddressFreeBalance({
|
|
1983
|
-
address,
|
|
1984
|
-
networkKey,
|
|
1985
|
-
token
|
|
1986
|
-
});
|
|
1987
1897
|
const tokenInfo = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(networkKey);
|
|
1988
1898
|
if (!(0, _utils2._isNativeToken)(tokenInfo)) {
|
|
1989
|
-
return
|
|
1899
|
+
return await this.getAddressTransferableBalance({
|
|
1900
|
+
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_TOKEN,
|
|
1901
|
+
address,
|
|
1902
|
+
networkKey,
|
|
1903
|
+
token
|
|
1904
|
+
});
|
|
1990
1905
|
} else {
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destChain, tokenInfo.slug);
|
|
1998
|
-
if (!destinationTokenInfo) {
|
|
1999
|
-
estimatedFee = '0';
|
|
2000
|
-
} else {
|
|
2001
|
-
maxTransferable = maxTransferable.minus(new _bignumber.default(tokenInfo.minAmount || '0').multipliedBy(_constants.XCM_MIN_AMOUNT_RATIO));
|
|
2002
|
-
const desChainInfo = chainInfoMap[destChain];
|
|
2003
|
-
const orgChainInfo = chainInfoMap[networkKey];
|
|
2004
|
-
const recipient = !(0, _utilCrypto.isEthereumAddress)(address) && (0, _utils2._isChainEvmCompatible)(desChainInfo) && !(0, _utils2._isChainEvmCompatible)(orgChainInfo) ? (0, _util.u8aToHex)((0, _utilCrypto.addressToEvm)(address)) : address;
|
|
2005
|
-
const mockTx = await (0, _xcm.createXcmExtrinsic)({
|
|
2006
|
-
chainInfoMap,
|
|
2007
|
-
destinationTokenInfo,
|
|
2008
|
-
originTokenInfo: tokenInfo,
|
|
2009
|
-
recipient: recipient,
|
|
2010
|
-
sendingValue: '1000000000000000000',
|
|
2011
|
-
substrateApi
|
|
2012
|
-
});
|
|
2013
|
-
try {
|
|
2014
|
-
var _paymentInfo$partialF;
|
|
2015
|
-
const paymentInfo = await mockTx.paymentInfo(address);
|
|
2016
|
-
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0';
|
|
2017
|
-
} catch (e) {
|
|
2018
|
-
estimatedFee = tokenInfo.minAmount || '0';
|
|
2019
|
-
}
|
|
2020
|
-
}
|
|
2021
|
-
} else {
|
|
2022
|
-
const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
|
|
2023
|
-
if ((0, _utils2._isChainEvmCompatible)(chainInfo) && (0, _utils2._isTokenTransferredByEvm)(tokenInfo)) {
|
|
2024
|
-
const web3 = this.#koniState.chainService.getEvmApi(networkKey);
|
|
2025
|
-
const transaction = {
|
|
2026
|
-
value: 0,
|
|
2027
|
-
to: '0x0000000000000000000000000000000000000000',
|
|
2028
|
-
// null address
|
|
2029
|
-
from: address
|
|
2030
|
-
};
|
|
2031
|
-
const gasLimit = await web3.api.eth.estimateGas(transaction);
|
|
2032
|
-
const priority = await (0, _utils3.calculateGasFeeParams)(web3, networkKey);
|
|
2033
|
-
if (priority.baseGasFee) {
|
|
2034
|
-
const maxFee = priority.maxFeePerGas;
|
|
2035
|
-
estimatedFee = maxFee.multipliedBy(gasLimit).toFixed(0);
|
|
2036
|
-
} else {
|
|
2037
|
-
estimatedFee = new _bignumber.default(priority.gasPrice).multipliedBy(gasLimit).toFixed(0);
|
|
2038
|
-
}
|
|
2039
|
-
} else {
|
|
2040
|
-
var _paymentInfo$partialF2;
|
|
2041
|
-
const [mockTx] = await (0, _transfer.createTransferExtrinsic)({
|
|
2042
|
-
from: address,
|
|
2043
|
-
networkKey,
|
|
2044
|
-
substrateApi,
|
|
2045
|
-
to: address,
|
|
2046
|
-
tokenInfo,
|
|
2047
|
-
transferAll: true,
|
|
2048
|
-
value: '1000000000000000000'
|
|
2049
|
-
});
|
|
2050
|
-
const paymentInfo = await (mockTx === null || mockTx === void 0 ? void 0 : mockTx.paymentInfo(address));
|
|
2051
|
-
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
|
|
2052
|
-
}
|
|
2053
|
-
}
|
|
2054
|
-
} catch (e) {
|
|
2055
|
-
estimatedFee = '0';
|
|
2056
|
-
console.warn('Unable to estimate fee', e);
|
|
1906
|
+
let maxTransferable;
|
|
1907
|
+
if (isXcmTransfer) {
|
|
1908
|
+
maxTransferable = await this.getXcmMaxTransferable(tokenInfo, destChain, address);
|
|
1909
|
+
} else {
|
|
1910
|
+
// regular transfer with native token
|
|
1911
|
+
maxTransferable = await this.getNativeTokenMaxTransferable(tokenInfo, networkKey, address);
|
|
2057
1912
|
}
|
|
2058
|
-
maxTransferable = maxTransferable.minus(new _bignumber.default(estimatedFee).multipliedBy(isXcmTransfer ? _constants.XCM_FEE_RATIO : 1));
|
|
2059
1913
|
return {
|
|
2060
|
-
|
|
2061
|
-
|
|
1914
|
+
value: maxTransferable.gt(_utils3.BN_ZERO) ? maxTransferable.toFixed(0) || '0' : '0',
|
|
1915
|
+
decimals: tokenInfo.decimals,
|
|
1916
|
+
symbol: tokenInfo.symbol
|
|
2062
1917
|
};
|
|
2063
1918
|
}
|
|
2064
1919
|
}
|
|
2065
|
-
async
|
|
1920
|
+
async getXcmMaxTransferable(originTokenInfo, destChain, address) {
|
|
1921
|
+
const substrateApi = this.#koniState.chainService.getSubstrateApi(originTokenInfo.originChain);
|
|
1922
|
+
const chainInfoMap = this.#koniState.chainService.getChainInfoMap();
|
|
1923
|
+
const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destChain, originTokenInfo.slug);
|
|
1924
|
+
if (destinationTokenInfo) {
|
|
1925
|
+
const [bnMockFee, {
|
|
1926
|
+
value
|
|
1927
|
+
}] = await Promise.all([(0, _xcm.getXcmMockTxFee)(substrateApi, chainInfoMap, address, originTokenInfo, destinationTokenInfo), this.getAddressTransferableBalance({
|
|
1928
|
+
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_XCM,
|
|
1929
|
+
address,
|
|
1930
|
+
networkKey: originTokenInfo.originChain,
|
|
1931
|
+
token: originTokenInfo.slug
|
|
1932
|
+
})]);
|
|
1933
|
+
const bnMaxTransferable = new _bignumber.default(value);
|
|
1934
|
+
const estimatedFee = bnMockFee.multipliedBy(_constants.XCM_FEE_RATIO); // multiply by weight to account for destination chain fee
|
|
1935
|
+
|
|
1936
|
+
return bnMaxTransferable.minus(estimatedFee);
|
|
1937
|
+
}
|
|
1938
|
+
return new _bignumber.default(0);
|
|
1939
|
+
}
|
|
1940
|
+
async getNativeTokenMaxTransferable(tokenInfo, networkKey, address) {
|
|
1941
|
+
const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
|
|
1942
|
+
const api = (0, _utils2._isChainEvmCompatible)(chainInfo) && (0, _utils2._isTokenTransferredByEvm)(tokenInfo) ? this.#koniState.chainService.getEvmApi(networkKey) : this.#koniState.chainService.getSubstrateApi(networkKey);
|
|
1943
|
+
const [mockTxFee, {
|
|
1944
|
+
value
|
|
1945
|
+
}] = await Promise.all([(0, _transfer2.getTransferMockTxFee)(address, chainInfo, tokenInfo, api), this.getAddressTransferableBalance({
|
|
1946
|
+
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_BALANCE,
|
|
1947
|
+
address,
|
|
1948
|
+
networkKey,
|
|
1949
|
+
token: tokenInfo.slug
|
|
1950
|
+
})]);
|
|
1951
|
+
const bnMaxTransferable = new _bignumber.default(value);
|
|
1952
|
+
return bnMaxTransferable.minus(mockTxFee);
|
|
1953
|
+
}
|
|
1954
|
+
async subscribeAddressTransferableBalance(_ref51, id, port) {
|
|
2066
1955
|
let {
|
|
2067
1956
|
address,
|
|
1957
|
+
extrinsicType,
|
|
2068
1958
|
networkKey,
|
|
2069
1959
|
token
|
|
2070
1960
|
} = _ref51;
|
|
@@ -2079,7 +1969,7 @@ class KoniExtension {
|
|
|
2079
1969
|
// eslint-disable-next-line node/no-callback-literal
|
|
2080
1970
|
cb(convertData(data));
|
|
2081
1971
|
};
|
|
2082
|
-
const [unsub, currentFreeBalance] = await this.#koniState.balanceService.
|
|
1972
|
+
const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTransferableBalance(address, networkKey, token, extrinsicType, _cb);
|
|
2083
1973
|
this.createUnsubscriptionHandle(id, unsub);
|
|
2084
1974
|
port.onDisconnect.addListener(() => {
|
|
2085
1975
|
this.cancelSubscription(id);
|
|
@@ -2092,7 +1982,7 @@ class KoniExtension {
|
|
|
2092
1982
|
networkKey
|
|
2093
1983
|
} = _ref52;
|
|
2094
1984
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return
|
|
2095
|
-
return await (0,
|
|
1985
|
+
return await (0, _transfer2.checkReferenceCount)(networkKey, address, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
|
|
2096
1986
|
}
|
|
2097
1987
|
async transferCheckSupporting(_ref53) {
|
|
2098
1988
|
let {
|
|
@@ -2100,7 +1990,7 @@ class KoniExtension {
|
|
|
2100
1990
|
tokenSlug
|
|
2101
1991
|
} = _ref53;
|
|
2102
1992
|
const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
|
|
2103
|
-
return await (0,
|
|
1993
|
+
return await (0, _transfer2.checkSupportTransfer)(networkKey, tokenInfo, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
|
|
2104
1994
|
}
|
|
2105
1995
|
transferGetExistentialDeposit(_ref54) {
|
|
2106
1996
|
let {
|
|
@@ -2115,13 +2005,13 @@ class KoniExtension {
|
|
|
2115
2005
|
recipientAddress,
|
|
2116
2006
|
senderAddress
|
|
2117
2007
|
} = inputData;
|
|
2118
|
-
const isSendingSelf = (0,
|
|
2008
|
+
const isSendingSelf = (0, _transfer3.isRecipientSelf)(senderAddress, recipientAddress);
|
|
2119
2009
|
|
|
2120
2010
|
// TODO: do better to detect tokenType
|
|
2121
2011
|
const isPSP34 = params === null || params === void 0 ? void 0 : params.isPsp34;
|
|
2122
2012
|
const networkKey = params === null || params === void 0 ? void 0 : params.networkKey;
|
|
2123
2013
|
const apiProps = this.#koniState.getSubstrateApi(networkKey);
|
|
2124
|
-
const extrinsic = !isPSP34 ? await (0,
|
|
2014
|
+
const extrinsic = !isPSP34 ? await (0, _transfer3.getNftTransferExtrinsic)(networkKey, apiProps, senderAddress, recipientAddress, params || {}) : await (0, _wasm.getPSP34TransferExtrinsic)(networkKey, apiProps, senderAddress, recipientAddress, params || {});
|
|
2125
2015
|
|
|
2126
2016
|
// this.addContact(recipientAddress);
|
|
2127
2017
|
|
|
@@ -2575,7 +2465,7 @@ class KoniExtension {
|
|
|
2575
2465
|
signed = await pair.evmSigner.signMessage(data, 'personal_sign');
|
|
2576
2466
|
} else {
|
|
2577
2467
|
var _signedTranaction$r, _signedTranaction$s, _signedTranaction$v;
|
|
2578
|
-
const tx = (0,
|
|
2468
|
+
const tx = (0, _utils3.createTransactionFromRLP)(message);
|
|
2579
2469
|
if (!tx) {
|
|
2580
2470
|
throw new Error((0, _i18next.t)('Failed to decode data. Please use a valid QR code'));
|
|
2581
2471
|
}
|
|
@@ -2600,7 +2490,7 @@ class KoniExtension {
|
|
|
2600
2490
|
common
|
|
2601
2491
|
});
|
|
2602
2492
|
const signedTranaction = _tx.LegacyTransaction.fromSerializedTx((0, _util.hexToU8a)(pair.evmSigner.signTransaction(transaction)));
|
|
2603
|
-
signed = (0,
|
|
2493
|
+
signed = (0, _utils3.signatureToHex)({
|
|
2604
2494
|
r: ((_signedTranaction$r = signedTranaction.r) === null || _signedTranaction$r === void 0 ? void 0 : _signedTranaction$r.toString(16)) || '',
|
|
2605
2495
|
s: ((_signedTranaction$s = signedTranaction.s) === null || _signedTranaction$s === void 0 ? void 0 : _signedTranaction$s.toString(16)) || '',
|
|
2606
2496
|
v: ((_signedTranaction$v = signedTranaction.v) === null || _signedTranaction$v === void 0 ? void 0 : _signedTranaction$v.toString(16)) || ''
|
|
@@ -2728,7 +2618,7 @@ class KoniExtension {
|
|
|
2728
2618
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
2729
2619
|
}
|
|
2730
2620
|
const chain = poolHandler.chain;
|
|
2731
|
-
const stakingType = poolHandler.type ===
|
|
2621
|
+
const stakingType = poolHandler.type === _types2.YieldPoolType.NOMINATION_POOL ? _KoniTypes.StakingType.POOLED : _KoniTypes.StakingType.NOMINATED;
|
|
2732
2622
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2733
2623
|
const extrinsic = await (0, _bonding.getClaimRewardExtrinsic)(substrateApi, chain, address, stakingType, bondReward);
|
|
2734
2624
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -3076,7 +2966,7 @@ class KoniExtension {
|
|
|
3076
2966
|
const {
|
|
3077
2967
|
payload
|
|
3078
2968
|
} = request;
|
|
3079
|
-
let registry = new
|
|
2969
|
+
let registry = new _types3.TypeRegistry();
|
|
3080
2970
|
let isEvm = false;
|
|
3081
2971
|
if (isJsonPayload(payload)) {
|
|
3082
2972
|
/**
|
|
@@ -3521,12 +3411,12 @@ class KoniExtension {
|
|
|
3521
3411
|
if (namespace.chains) {
|
|
3522
3412
|
const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
|
|
3523
3413
|
if (unSupportChains.length) {
|
|
3524
|
-
throw new Error((0,
|
|
3414
|
+
throw new Error((0, _utils4.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + unSupportChains.toString());
|
|
3525
3415
|
}
|
|
3526
3416
|
availableNamespaces[key] = namespace;
|
|
3527
3417
|
}
|
|
3528
3418
|
} else {
|
|
3529
|
-
throw new Error((0,
|
|
3419
|
+
throw new Error((0, _utils4.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
|
|
3530
3420
|
}
|
|
3531
3421
|
});
|
|
3532
3422
|
Object.entries(optionalNamespaces).forEach(_ref86 => {
|
|
@@ -3558,7 +3448,7 @@ class KoniExtension {
|
|
|
3558
3448
|
let [key, namespace] = _ref87;
|
|
3559
3449
|
if (namespace.chains) {
|
|
3560
3450
|
const accounts = [];
|
|
3561
|
-
const chains = (0,
|
|
3451
|
+
const chains = (0, _utils3.uniqueStringArray)(namespace.chains);
|
|
3562
3452
|
chains.forEach(chain => {
|
|
3563
3453
|
accounts.push(...selectedAccounts.filter(address => (0, _utilCrypto.isEthereumAddress)(address) === (key === _constants5.WALLET_CONNECT_EIP155_NAMESPACE)).map(address => `${chain}:${address}`));
|
|
3564
3454
|
});
|
|
@@ -3659,7 +3549,7 @@ class KoniExtension {
|
|
|
3659
3549
|
const {
|
|
3660
3550
|
connectionStatus
|
|
3661
3551
|
} = this.#koniState.chainService.getChainStatusByKey(_constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
3662
|
-
if (connectionStatus !==
|
|
3552
|
+
if (connectionStatus !== _types._ChainConnectionStatus.CONNECTED) {
|
|
3663
3553
|
// TODO: do better
|
|
3664
3554
|
await timeout();
|
|
3665
3555
|
}
|
|
@@ -3700,7 +3590,7 @@ class KoniExtension {
|
|
|
3700
3590
|
}
|
|
3701
3591
|
async initSyncMantaPay(address) {
|
|
3702
3592
|
var _this$koniState$chain3, _this$koniState$chain4, _this$koniState$chain5, _this$koniState$chain6;
|
|
3703
|
-
if ((_this$koniState$chain3 = this.#koniState.chainService) !== null && _this$koniState$chain3 !== void 0 && (_this$koniState$chain4 = _this$koniState$chain3.mantaPay) !== null && _this$koniState$chain4 !== void 0 && _this$koniState$chain4.getSyncState().isSyncing || !
|
|
3593
|
+
if ((_this$koniState$chain3 = this.#koniState.chainService) !== null && _this$koniState$chain3 !== void 0 && (_this$koniState$chain4 = _this$koniState$chain3.mantaPay) !== null && _this$koniState$chain4 !== void 0 && _this$koniState$chain4.getSyncState().isSyncing || !_utils3.MODULE_SUPPORT.MANTA_ZK) {
|
|
3704
3594
|
return;
|
|
3705
3595
|
}
|
|
3706
3596
|
this.#skipAutoLock = true;
|
|
@@ -4523,13 +4413,13 @@ class KoniExtension {
|
|
|
4523
4413
|
case 'pri(transfer.getExistentialDeposit)':
|
|
4524
4414
|
return this.transferGetExistentialDeposit(request);
|
|
4525
4415
|
case 'pri(transfer.getMaxTransferable)':
|
|
4526
|
-
return this.
|
|
4416
|
+
return this.getMaxTransferable(request);
|
|
4527
4417
|
case 'pri(transfer.subscribeMaxTransferable)':
|
|
4528
|
-
return this.
|
|
4418
|
+
return this.getMaxTransferable(request);
|
|
4529
4419
|
case 'pri(freeBalance.get)':
|
|
4530
|
-
return this.
|
|
4420
|
+
return this.getAddressTransferableBalance(request);
|
|
4531
4421
|
case 'pri(freeBalance.subscribe)':
|
|
4532
|
-
return this.
|
|
4422
|
+
return this.subscribeAddressTransferableBalance(request, id, port);
|
|
4533
4423
|
case 'pri(subscription.cancel)':
|
|
4534
4424
|
return this.cancelSubscription(request);
|
|
4535
4425
|
case 'pri(chainService.recoverSubstrateApi)':
|