@subwallet/extension-base 1.1.8-0 → 1.1.10-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +13 -1
- package/background/KoniTypes.js +5 -0
- package/background/errors/BalanceError.js +7 -5
- package/background/errors/EvmProviderError.js +10 -8
- package/background/errors/ProviderError.js +5 -4
- package/background/errors/TransactionError.js +22 -17
- package/background/handlers/Extension.js +18 -18
- package/background/handlers/State.js +5 -5
- package/background/handlers/Tabs.js +1 -1
- package/background/warnings/TransactionWarning.js +4 -2
- package/cjs/background/KoniTypes.js +7 -1
- package/cjs/background/errors/BalanceError.js +7 -5
- package/cjs/background/errors/EvmProviderError.js +10 -8
- package/cjs/background/errors/ProviderError.js +5 -4
- package/cjs/background/errors/TransactionError.js +22 -17
- package/cjs/background/handlers/Extension.js +18 -18
- package/cjs/background/handlers/State.js +5 -5
- package/cjs/background/handlers/Tabs.js +1 -1
- package/cjs/background/warnings/TransactionWarning.js +4 -2
- package/cjs/constants/i18n.js +4 -1
- package/cjs/constants/index.js +12 -0
- package/cjs/constants/storage.js +11 -0
- package/cjs/koni/api/dotsama/domain.js +3 -1
- package/cjs/koni/api/dotsama/parseTransaction.js +2 -1
- package/cjs/koni/api/nft/acala_nft/index.js +1 -1
- package/cjs/koni/api/nft/karura_nft/index.js +1 -1
- package/cjs/koni/api/nft/nft.js +3 -0
- package/cjs/koni/api/nft/wasm_nft/index.js +25 -7
- package/cjs/koni/api/staking/bonding/paraChain.js +10 -6
- package/cjs/koni/api/staking/bonding/relayChain.js +16 -7
- package/cjs/koni/api/staking/bonding/utils.js +80 -7
- package/cjs/koni/api/tokens/wasm/index.js +14 -0
- package/cjs/koni/background/cron.js +1 -1
- package/cjs/koni/background/handlers/Extension.js +206 -170
- package/cjs/koni/background/handlers/State.js +19 -14
- package/cjs/koni/background/handlers/Tabs.js +15 -14
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/index.js +12 -3
- package/cjs/services/chain-service/helper/index.js +8 -2
- package/cjs/services/request-service/handler/AuthRequestHandler.js +4 -4
- package/cjs/services/request-service/handler/EvmRequestHandler.js +11 -10
- package/cjs/services/setting-service/SettingService.js +20 -7
- package/cjs/services/setting-service/constants.js +5 -1
- package/cjs/services/setting-service/i18n/Backend.js +42 -0
- package/cjs/services/setting-service/i18n/cache.js +12 -0
- package/cjs/services/setting-service/i18n/extend.js +16 -0
- package/cjs/services/setting-service/i18n/i18n.js +29 -0
- package/cjs/services/transaction-service/index.js +25 -16
- package/cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js +0 -1
- package/cjs/services/wallet-connect-service/index.js +18 -10
- package/cjs/utils/eth/parseTransaction/base.js +1 -1
- package/cjs/utils/eth/parseTransaction/index.js +2 -1
- package/cjs/utils/index.js +2 -1
- package/constants/i18n.js +4 -1
- package/constants/index.d.ts +1 -0
- package/constants/index.js +2 -1
- package/constants/storage.d.ts +1 -0
- package/constants/storage.js +4 -0
- package/koni/api/dotsama/domain.d.ts +1 -0
- package/koni/api/dotsama/domain.js +1 -0
- package/koni/api/dotsama/parseTransaction.js +2 -1
- package/koni/api/nft/acala_nft/index.js +1 -1
- package/koni/api/nft/karura_nft/index.js +1 -1
- package/koni/api/nft/nft.js +3 -0
- package/koni/api/nft/wasm_nft/index.js +26 -8
- package/koni/api/staking/bonding/paraChain.js +11 -7
- package/koni/api/staking/bonding/relayChain.js +17 -8
- package/koni/api/staking/bonding/utils.d.ts +4 -0
- package/koni/api/staking/bonding/utils.js +70 -2
- package/koni/api/tokens/wasm/index.d.ts +2 -0
- package/koni/api/tokens/wasm/index.js +13 -1
- package/koni/background/cron.js +1 -1
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +85 -50
- package/koni/background/handlers/State.js +19 -14
- package/koni/background/handlers/Tabs.js +15 -14
- package/package.json +34 -12
- package/packageInfo.js +1 -1
- package/services/balance-service/index.js +12 -3
- package/services/chain-service/helper/azero_domain_registry_abi.json +5428 -0
- package/services/chain-service/helper/index.d.ts +2 -0
- package/services/chain-service/helper/index.js +5 -1
- package/services/chain-service/helper/pink_psp34_abi.json +2758 -0
- package/services/request-service/handler/AuthRequestHandler.js +4 -4
- package/services/request-service/handler/EvmRequestHandler.js +11 -10
- package/services/setting-service/SettingService.d.ts +1 -0
- package/services/setting-service/SettingService.js +17 -5
- package/services/setting-service/constants.d.ts +2 -1
- package/services/setting-service/constants.js +4 -1
- package/services/setting-service/i18n/Backend.d.ts +9 -0
- package/services/setting-service/i18n/Backend.js +34 -0
- package/services/setting-service/i18n/cache.d.ts +2 -0
- package/services/setting-service/i18n/cache.js +5 -0
- package/services/setting-service/i18n/extend.d.ts +2 -0
- package/services/setting-service/i18n/extend.js +8 -0
- package/services/setting-service/i18n/i18n.d.ts +2 -0
- package/services/setting-service/i18n/i18n.js +21 -0
- package/services/transaction-service/index.js +25 -16
- package/services/wallet-connect-service/handler/PolkadotRequestHandler.js +0 -1
- package/services/wallet-connect-service/index.js +18 -10
- package/utils/eth/parseTransaction/base.js +1 -1
- package/utils/eth/parseTransaction/index.js +2 -1
- package/utils/index.js +2 -1
- package/cjs/utils/keyring.js +0 -57
- package/utils/keyring.d.ts +0 -4
- package/utils/keyring.js +0 -49
|
@@ -26,6 +26,7 @@ var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
|
26
26
|
var _ethereumjsUtil = require("ethereumjs-util");
|
|
27
27
|
var _ethers = require("ethers");
|
|
28
28
|
var _eventemitter = _interopRequireDefault(require("eventemitter3"));
|
|
29
|
+
var _i18next = require("i18next");
|
|
29
30
|
var _rxjs = require("rxjs");
|
|
30
31
|
var _util = require("@polkadot/util");
|
|
31
32
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
@@ -97,7 +98,7 @@ class TransactionService {
|
|
|
97
98
|
};
|
|
98
99
|
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
99
100
|
if (!chainInfo) {
|
|
100
|
-
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR,
|
|
101
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR, (0, _i18next.t)('Cannot find network')));
|
|
101
102
|
} else {
|
|
102
103
|
const {
|
|
103
104
|
decimals,
|
|
@@ -112,7 +113,7 @@ class TransactionService {
|
|
|
112
113
|
} else {
|
|
113
114
|
const web3 = this.chainService.getEvmApi(chain);
|
|
114
115
|
if (!web3) {
|
|
115
|
-
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.CHAIN_DISCONNECTED));
|
|
116
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
|
|
116
117
|
} else {
|
|
117
118
|
const gasPrice = await web3.api.eth.getGasPrice();
|
|
118
119
|
const gasLimit = await web3.api.eth.estimateGas(transaction);
|
|
@@ -133,11 +134,11 @@ class TransactionService {
|
|
|
133
134
|
// Read-only account
|
|
134
135
|
const pair = _uiKeyring.default.getPair(address);
|
|
135
136
|
if (!pair) {
|
|
136
|
-
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR, '
|
|
137
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR, (0, _i18next.t)('Unable to find account')));
|
|
137
138
|
} else {
|
|
138
139
|
var _pair$meta;
|
|
139
140
|
if ((_pair$meta = pair.meta) !== null && _pair$meta !== void 0 && _pair$meta.isReadOnly) {
|
|
140
|
-
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR, 'This is watch-only
|
|
141
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR, (0, _i18next.t)('This account is watch-only')));
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
|
|
@@ -166,9 +167,9 @@ class TransactionService {
|
|
|
166
167
|
if (!isTransferAll) {
|
|
167
168
|
if (balanceNum - (transferNativeNum + feeNum) < edNum) {
|
|
168
169
|
if (edAsWarning) {
|
|
169
|
-
validationResponse.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT
|
|
170
|
+
validationResponse.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
170
171
|
} else {
|
|
171
|
-
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT
|
|
172
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
}
|
|
@@ -593,8 +594,12 @@ class TransactionService {
|
|
|
593
594
|
const info = (0, _util.isHex)(extrinsicHash) ? extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.chainService.getChainInfoMap());
|
|
594
595
|
this.notificationService.notify({
|
|
595
596
|
type: _KoniTypes.NotificationType.SUCCESS,
|
|
596
|
-
title: 'Transaction completed',
|
|
597
|
-
message:
|
|
597
|
+
title: (0, _i18next.t)('Transaction completed'),
|
|
598
|
+
message: (0, _i18next.t)('Transaction {{info}} completed', {
|
|
599
|
+
replace: {
|
|
600
|
+
info
|
|
601
|
+
}
|
|
602
|
+
}),
|
|
598
603
|
action: {
|
|
599
604
|
url: this.getTransactionLink(id)
|
|
600
605
|
},
|
|
@@ -629,8 +634,12 @@ class TransactionService {
|
|
|
629
634
|
const info = (0, _util.isHex)(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.chainService.getChainInfoMap());
|
|
630
635
|
this.notificationService.notify({
|
|
631
636
|
type: _KoniTypes.NotificationType.ERROR,
|
|
632
|
-
title: 'Transaction failed',
|
|
633
|
-
message:
|
|
637
|
+
title: (0, _i18next.t)('Transaction failed'),
|
|
638
|
+
message: (0, _i18next.t)('Transaction {{info}} failed', {
|
|
639
|
+
replace: {
|
|
640
|
+
info
|
|
641
|
+
}
|
|
642
|
+
}),
|
|
634
643
|
action: {
|
|
635
644
|
url: this.getTransactionLink(id)
|
|
636
645
|
},
|
|
@@ -735,7 +744,7 @@ class TransactionService {
|
|
|
735
744
|
if (isApproved) {
|
|
736
745
|
let signedTransaction;
|
|
737
746
|
if (!payload) {
|
|
738
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.UNAUTHORIZED, '
|
|
747
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.UNAUTHORIZED, (0, _i18next.t)('Failed to sign'));
|
|
739
748
|
}
|
|
740
749
|
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
741
750
|
if (!isExternal) {
|
|
@@ -744,7 +753,7 @@ class TransactionService {
|
|
|
744
753
|
const signed = (0, _mergeTransactionAndSignature.mergeTransactionAndSignature)(txObject, payload);
|
|
745
754
|
const recover = web3Api.eth.accounts.recoverTransaction(signed);
|
|
746
755
|
if (recover.toLowerCase() !== account.address.toLowerCase()) {
|
|
747
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.UNAUTHORIZED, '
|
|
756
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.UNAUTHORIZED, (0, _i18next.t)('Wrong signature. Please sign with the account you use in dApp'));
|
|
748
757
|
}
|
|
749
758
|
signedTransaction = signed;
|
|
750
759
|
}
|
|
@@ -768,10 +777,10 @@ class TransactionService {
|
|
|
768
777
|
eventData.blockNumber = rs.blockNumber;
|
|
769
778
|
emitter.emit('success', eventData);
|
|
770
779
|
}).once('error', e => {
|
|
771
|
-
eventData.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.SEND_TRANSACTION_FAILED, e.message));
|
|
780
|
+
eventData.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.SEND_TRANSACTION_FAILED, (0, _i18next.t)(e.message)));
|
|
772
781
|
emitter.emit('error', eventData);
|
|
773
782
|
}).catch(e => {
|
|
774
|
-
eventData.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNABLE_TO_SEND, e.message));
|
|
783
|
+
eventData.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNABLE_TO_SEND, (0, _i18next.t)(e.message)));
|
|
775
784
|
emitter.emit('error', eventData);
|
|
776
785
|
});
|
|
777
786
|
} else {
|
|
@@ -781,7 +790,7 @@ class TransactionService {
|
|
|
781
790
|
}
|
|
782
791
|
}).catch(e => {
|
|
783
792
|
this.removeTransaction(id);
|
|
784
|
-
eventData.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNABLE_TO_SIGN, e.message));
|
|
793
|
+
eventData.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNABLE_TO_SIGN, (0, _i18next.t)(e.message)));
|
|
785
794
|
emitter.emit('error', eventData);
|
|
786
795
|
});
|
|
787
796
|
return emitter;
|
|
@@ -876,7 +885,7 @@ class TransactionService {
|
|
|
876
885
|
const timeout = setTimeout(() => {
|
|
877
886
|
const transaction = this.getTransaction(eventData.id);
|
|
878
887
|
if (transaction.status !== _KoniTypes.ExtrinsicStatus.SUCCESS && transaction.status !== _KoniTypes.ExtrinsicStatus.FAIL) {
|
|
879
|
-
eventData.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.TIMEOUT, 'Transaction timeout'));
|
|
888
|
+
eventData.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.TIMEOUT, (0, _i18next.t)('Transaction timeout')));
|
|
880
889
|
emitter.emit('error', eventData);
|
|
881
890
|
clearTimeout(timeout);
|
|
882
891
|
}
|
|
@@ -111,7 +111,6 @@ function _checkAccount2(address, accounts) {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
function _handleError2(topic, id, e) {
|
|
114
|
-
console.log(e);
|
|
115
114
|
let message = e.message;
|
|
116
115
|
if (message.includes('User Rejected Request')) {
|
|
117
116
|
message = (0, _utils3.getSdkError)('USER_REJECTED').message;
|
|
@@ -145,21 +145,29 @@ class WalletConnectService {
|
|
|
145
145
|
// Disconnect session
|
|
146
146
|
const sessions = ((_classPrivateFieldLoo7 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo7 === void 0 ? void 0 : _classPrivateFieldLoo7.session.values) || [];
|
|
147
147
|
for (const session of sessions) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
try {
|
|
149
|
+
var _classPrivateFieldLoo8;
|
|
150
|
+
await ((_classPrivateFieldLoo8 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo8 === void 0 ? void 0 : _classPrivateFieldLoo8.disconnect({
|
|
151
|
+
topic: session.topic,
|
|
152
|
+
reason: (0, _utils2.getSdkError)('USER_DISCONNECTED')
|
|
153
|
+
}));
|
|
154
|
+
} catch (e) {
|
|
155
|
+
console.error(e);
|
|
156
|
+
}
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
// Disconnect pair
|
|
156
160
|
const pairs = ((_classPrivateFieldLoo9 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo9 === void 0 ? void 0 : _classPrivateFieldLoo9.pairing.values) || [];
|
|
157
161
|
for (const pair of pairs) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
try {
|
|
163
|
+
var _classPrivateFieldLoo10;
|
|
164
|
+
await ((_classPrivateFieldLoo10 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo10 === void 0 ? void 0 : _classPrivateFieldLoo10.disconnect({
|
|
165
|
+
topic: pair.topic,
|
|
166
|
+
reason: (0, _utils2.getSdkError)('USER_DISCONNECTED')
|
|
167
|
+
}));
|
|
168
|
+
} catch (e) {
|
|
169
|
+
console.error(e);
|
|
170
|
+
}
|
|
163
171
|
}
|
|
164
172
|
const keys = (await ((_classPrivateFieldLoo11 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo11 === void 0 ? void 0 : _classPrivateFieldLoo11.core.storage.getKeys())) || [];
|
|
165
173
|
const deleteKeys = resetAll ? keys : keys.filter(key => key.startsWith('wc@'));
|
|
@@ -11,6 +11,7 @@ var _eth = require("@subwallet/extension-base/utils/eth");
|
|
|
11
11
|
var _base = require("@subwallet/extension-base/utils/eth/parseTransaction/base");
|
|
12
12
|
var _axios = _interopRequireDefault(require("axios"));
|
|
13
13
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
14
|
+
var _i18next = require("i18next");
|
|
14
15
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
15
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
16
17
|
|
|
@@ -189,7 +190,7 @@ const getChainInfoByChainId = (networkMap, chainId) => {
|
|
|
189
190
|
const parseEvmRlp = async (data, networkMap, evmApiMap) => {
|
|
190
191
|
const tx = (0, _eth.createTransactionFromRLP)(data);
|
|
191
192
|
if (!tx) {
|
|
192
|
-
throw new Error(
|
|
193
|
+
throw new Error((0, _i18next.t)('Failed to decode data. Please use a valid QR code'));
|
|
193
194
|
}
|
|
194
195
|
const result = {
|
|
195
196
|
input: tx.data,
|
package/cjs/utils/index.js
CHANGED
|
@@ -72,6 +72,7 @@ exports.waitTimeout = waitTimeout;
|
|
|
72
72
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
73
73
|
var _constants = require("@subwallet/extension-base/constants");
|
|
74
74
|
var _environment = require("@subwallet/extension-base/utils/environment");
|
|
75
|
+
var _i18next = require("i18next");
|
|
75
76
|
var _util = require("@polkadot/util");
|
|
76
77
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
77
78
|
var _canDerive = require("./canDerive");
|
|
@@ -430,7 +431,7 @@ async function waitTimeout(ms) {
|
|
|
430
431
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
431
432
|
}
|
|
432
433
|
const stripUrl = url => {
|
|
433
|
-
(0, _util.assert)(url && (url.startsWith('http:') || url.startsWith('https:') || url.startsWith('ipfs:') || url.startsWith('ipns:')),
|
|
434
|
+
(0, _util.assert)(url && (url.startsWith('http:') || url.startsWith('https:') || url.startsWith('ipfs:') || url.startsWith('ipns:')), (0, _i18next.t)('Invalid URL for provider'));
|
|
434
435
|
const parts = url.split('/');
|
|
435
436
|
return parts[2];
|
|
436
437
|
};
|
package/constants/i18n.js
CHANGED
|
@@ -13,6 +13,9 @@ export const languageOptions = [{
|
|
|
13
13
|
}, {
|
|
14
14
|
text: '日本語',
|
|
15
15
|
value: 'ja'
|
|
16
|
+
}, {
|
|
17
|
+
text: 'Русский',
|
|
18
|
+
value: 'ru'
|
|
16
19
|
}, {
|
|
17
20
|
text: 'Français',
|
|
18
21
|
value: 'fr'
|
|
@@ -29,4 +32,4 @@ export const languageOptions = [{
|
|
|
29
32
|
text: 'اردو',
|
|
30
33
|
value: 'ur'
|
|
31
34
|
}];
|
|
32
|
-
export const ENABLE_LANGUAGES = ['en', 'vi', 'zh'];
|
|
35
|
+
export const ENABLE_LANGUAGES = ['en', 'vi', 'zh', 'ja'];
|
package/constants/index.d.ts
CHANGED
package/constants/index.js
CHANGED
|
@@ -23,4 +23,5 @@ export const ALL_GENESIS_HASH = null;
|
|
|
23
23
|
export const IGNORE_GET_SUBSTRATE_FEATURES_LIST = ['astarEvm', 'ethereum', 'ethereum_goerli', 'binance', 'binance_test', 'boba_rinkeby', 'boba', 'bobabase', 'bobabeam'];
|
|
24
24
|
export const IGNORE_QR_SIGNER = [];
|
|
25
25
|
export const XCM_MIN_AMOUNT_RATIO = 1.2;
|
|
26
|
-
export * from "./staking.js";
|
|
26
|
+
export * from "./staking.js";
|
|
27
|
+
export * from "./storage.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LANGUAGE = "current-language";
|
|
@@ -4,6 +4,7 @@ export declare const TZERO_ID_SUFFIX = ".tzero";
|
|
|
4
4
|
export declare const AZERO_ID_SUFFIX = ".azero";
|
|
5
5
|
export declare const SUPPORTED_DOMAIN_SUFFIX: string[];
|
|
6
6
|
export declare const CHAINS_SUPPORTED_DOMAIN: string[];
|
|
7
|
+
export declare const AZERO_DOMAIN_CONTRACTS: string[];
|
|
7
8
|
export declare function resolveAzeroDomainToAddress(domain: string, chain: string, api: ApiPromise): Promise<string | undefined>;
|
|
8
9
|
export declare function resolveAzeroAddressToDomain(address: string, chain: string, api: ApiPromise): Promise<string | undefined>;
|
|
9
10
|
export declare function isAzeroDomain(input: string): boolean;
|
|
@@ -7,6 +7,7 @@ export const TZERO_ID_SUFFIX = '.tzero';
|
|
|
7
7
|
export const AZERO_ID_SUFFIX = '.azero';
|
|
8
8
|
export const SUPPORTED_DOMAIN_SUFFIX = [ENS_SUFFIX, TZERO_ID_SUFFIX, AZERO_ID_SUFFIX];
|
|
9
9
|
export const CHAINS_SUPPORTED_DOMAIN = ['aleph', 'alephTest'];
|
|
10
|
+
export const AZERO_DOMAIN_CONTRACTS = ['5FsB91tXSEuMj6akzdPczAtmBaVKToqHmtAwSUzXh49AYzaD', '5CTQBfBC9SfdrCDBJdfLiyW2pg9z5W6C6Es8sK313BLnFgDf'];
|
|
10
11
|
export async function resolveAzeroDomainToAddress(domain, chain, api) {
|
|
11
12
|
let chainId = SupportedChainId.AlephZero;
|
|
12
13
|
if (chain === 'alephTest') {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @polkadot/extension-koni-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { t } from 'i18next';
|
|
4
5
|
import { hexToU8a } from '@polkadot/util';
|
|
5
6
|
const formatArgs = callInstance => {
|
|
6
7
|
const paramArgKvArray = [];
|
|
@@ -80,7 +81,7 @@ export const parseSubstrateTransaction = (data, apiPromise) => {
|
|
|
80
81
|
} catch (e) {
|
|
81
82
|
return {
|
|
82
83
|
...baseInfo,
|
|
83
|
-
message: 'Unable to decode
|
|
84
|
+
message: t('Unable to decode the information'),
|
|
84
85
|
method: _method
|
|
85
86
|
};
|
|
86
87
|
}
|
|
@@ -135,7 +135,7 @@ const getMetadata = metadataUrl => {
|
|
|
135
135
|
if (!metadataUrl) {
|
|
136
136
|
return null;
|
|
137
137
|
}
|
|
138
|
-
url = getRandomIpfsGateway() + metadataUrl + '/
|
|
138
|
+
url = getRandomIpfsGateway() + metadataUrl + '/azero_domain_registry_abi.json';
|
|
139
139
|
return fetch(url, {
|
|
140
140
|
method: 'GET',
|
|
141
141
|
headers
|
|
@@ -137,7 +137,7 @@ const getKaruraMetadata = metadataUrl => {
|
|
|
137
137
|
if (!metadataUrl) {
|
|
138
138
|
return null;
|
|
139
139
|
}
|
|
140
|
-
url = getRandomIpfsGateway() + metadataUrl + '/
|
|
140
|
+
url = getRandomIpfsGateway() + metadataUrl + '/azero_domain_registry_abi.json';
|
|
141
141
|
return fetch(url, {
|
|
142
142
|
method: 'GET',
|
|
143
143
|
headers: {
|
package/koni/api/nft/nft.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { _AssetType } from '@subwallet/chain-list/types';
|
|
5
|
+
import { AZERO_DOMAIN_CONTRACTS } from '@subwallet/extension-base/koni/api/dotsama/domain';
|
|
5
6
|
import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
6
7
|
import { collectionApiFromArtZero, collectionDetailApiFromArtZero, externalUrlOnArtZero, ipfsApiFromArtZero, itemImageApiFromArtZero } from '@subwallet/extension-base/koni/api/nft/wasm_nft/utils';
|
|
7
|
-
import { getPSP34ContractPromise } from '@subwallet/extension-base/koni/api/tokens/wasm';
|
|
8
|
+
import { getPSP34ContractPromise, isAzeroDomainNft, isPinkRoboNft } from '@subwallet/extension-base/koni/api/tokens/wasm';
|
|
8
9
|
import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
|
|
9
10
|
import { _getContractAddressOfToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
11
|
+
import { isUrl } from '@subwallet/extension-base/utils';
|
|
10
12
|
import axios from 'axios';
|
|
11
13
|
import fetch from 'cross-fetch';
|
|
12
14
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -70,6 +72,9 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
70
72
|
if (!tokenUri || tokenUri.length === 0) {
|
|
71
73
|
return undefined;
|
|
72
74
|
}
|
|
75
|
+
if (isUrl(tokenUri)) {
|
|
76
|
+
return tokenUri;
|
|
77
|
+
}
|
|
73
78
|
if (tokenUri.startsWith('/ipfs/')) {
|
|
74
79
|
return tokenUri;
|
|
75
80
|
}
|
|
@@ -256,16 +261,19 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
256
261
|
owner: '',
|
|
257
262
|
name: tokenId
|
|
258
263
|
};
|
|
259
|
-
const
|
|
264
|
+
const _isFeatured = isFeatured && !AZERO_DOMAIN_CONTRACTS.includes(contractPromise.address.toString());
|
|
265
|
+
const _tokenUri = await contractPromise.query[isPinkRoboNft(contractPromise.address.toString()) ? 'pinkMint::tokenUri' : 'psp34Traits::tokenUri'](address, {
|
|
260
266
|
gasLimit: getDefaultWeightV2((_this$substrateApi2 = this.substrateApi) === null || _this$substrateApi2 === void 0 ? void 0 : _this$substrateApi2.api)
|
|
261
|
-
},
|
|
267
|
+
}, isAzeroDomainNft(contractPromise.address.toString()) ? {
|
|
268
|
+
bytes: tokenId
|
|
269
|
+
} : tokenId);
|
|
262
270
|
if (_tokenUri.output) {
|
|
263
271
|
let itemDetail = false;
|
|
264
272
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
265
273
|
const _tokenUriObj = _tokenUri.output.toJSON();
|
|
266
274
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
267
|
-
const tokenUri = _tokenUriObj.Ok || _tokenUriObj.ok;
|
|
268
|
-
if (
|
|
275
|
+
const tokenUri = isPinkRoboNft(contractPromise.address.toString()) ? _tokenUriObj.ok.ok : _tokenUriObj.Ok || _tokenUriObj.ok;
|
|
276
|
+
if (_isFeatured) {
|
|
269
277
|
const parsedTokenUri = this.parseFeaturedTokenUri(tokenUri);
|
|
270
278
|
if (parsedTokenUri) {
|
|
271
279
|
const resp = await fetch(`${ipfsApiFromArtZero(this.chain)}?input=${parsedTokenUri}`);
|
|
@@ -277,6 +285,11 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
277
285
|
if (detailUrl) {
|
|
278
286
|
const resp = await fetch(detailUrl);
|
|
279
287
|
itemDetail = resp && resp.ok && (await resp.json());
|
|
288
|
+
if (AZERO_DOMAIN_CONTRACTS.includes(contractPromise.address.toString())) {
|
|
289
|
+
var _itemDetail;
|
|
290
|
+
// @ts-ignore
|
|
291
|
+
itemDetail = (_itemDetail = itemDetail) === null || _itemDetail === void 0 ? void 0 : _itemDetail.metadata;
|
|
292
|
+
}
|
|
280
293
|
}
|
|
281
294
|
}
|
|
282
295
|
if (!itemDetail) {
|
|
@@ -286,14 +299,14 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
286
299
|
nftItem.description = itemDetail.description;
|
|
287
300
|
nftItem.externalUrl = itemDetail.external_url;
|
|
288
301
|
const rawImageSrc = itemDetail.image ? itemDetail.image : itemDetail.image_url;
|
|
289
|
-
if (
|
|
302
|
+
if (_isFeatured) {
|
|
290
303
|
nftItem.image = await this.parseFeaturedNftImage(rawImageSrc);
|
|
291
304
|
nftItem.externalUrl = externalUrlOnArtZero(this.chain);
|
|
292
305
|
} else {
|
|
293
306
|
nftItem.image = this.parseUrl(rawImageSrc);
|
|
294
307
|
}
|
|
295
308
|
const propertiesMap = {};
|
|
296
|
-
const traitList = itemDetail.attributes
|
|
309
|
+
const traitList = itemDetail.attributes || itemDetail.traits;
|
|
297
310
|
if (traitList) {
|
|
298
311
|
traitList.forEach(traitMap => {
|
|
299
312
|
propertiesMap[traitMap.trait_type] = {
|
|
@@ -339,8 +352,13 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
339
352
|
if (_tokenByIndexResp.output) {
|
|
340
353
|
const rawTokenId = _tokenByIndexResp.output.toHuman();
|
|
341
354
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
342
|
-
|
|
355
|
+
let tokenIdObj = rawTokenId.Ok.Ok || rawTokenId.ok.ok; // capital O, not normal o
|
|
343
356
|
const tokenId = Object.values(tokenIdObj)[0].replaceAll(',', '');
|
|
357
|
+
if (isAzeroDomainNft(contractPromise.address.toString())) {
|
|
358
|
+
tokenIdObj = {
|
|
359
|
+
bytes: tokenId
|
|
360
|
+
};
|
|
361
|
+
}
|
|
344
362
|
nftIds.push(tokenId);
|
|
345
363
|
let tokenUri;
|
|
346
364
|
try {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
5
5
|
import { BasicTxErrorType, StakingStatus, StakingTxErrorType, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
|
-
import { getBondedValidators, getParaCurrentInflation, getStakingStatusByNominations, isUnstakeAll, parseIdentity } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
6
|
+
import { getBondedValidators, getExistUnstakeErrorMessage, getMaxValidatorErrorMessage, getMinStakeErrorMessage, getParaCurrentInflation, getStakingStatusByNominations, isUnstakeAll, parseIdentity } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
7
7
|
import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
8
|
import { _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
9
|
import { isSameAddress, parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
@@ -27,8 +27,9 @@ export function validateParaChainUnbondingCondition(amount, nominatorMetadata, c
|
|
|
27
27
|
const bnChainMinStake = new BN(chainStakingMetadata.minStake || '0');
|
|
28
28
|
const bnCollatorMinStake = new BN(targetNomination.validatorMinStake || '0');
|
|
29
29
|
const bnMinStake = BN.max(bnCollatorMinStake, bnChainMinStake);
|
|
30
|
+
const existUnstakeErrorMessage = getExistUnstakeErrorMessage(chainStakingMetadata.chain);
|
|
30
31
|
if (targetNomination.hasUnstaking) {
|
|
31
|
-
errors.push(new TransactionError(StakingTxErrorType.EXIST_UNSTAKING_REQUEST));
|
|
32
|
+
errors.push(new TransactionError(StakingTxErrorType.EXIST_UNSTAKING_REQUEST, existUnstakeErrorMessage));
|
|
32
33
|
}
|
|
33
34
|
if (!(bnRemainingStake.isZero() || bnRemainingStake.gte(bnMinStake))) {
|
|
34
35
|
errors.push(new TransactionError(StakingTxErrorType.INVALID_ACTIVE_STAKE));
|
|
@@ -42,9 +43,12 @@ export function validateParaChainBondingCondition(chainInfo, amount, selectedCol
|
|
|
42
43
|
const bnChainMinStake = new BN(chainStakingMetadata.minStake || '0');
|
|
43
44
|
const bnCollatorMinStake = new BN(selectedCollator.minBond || '0');
|
|
44
45
|
const bnMinStake = bnCollatorMinStake > bnChainMinStake ? bnCollatorMinStake : bnChainMinStake;
|
|
46
|
+
const minStakeErrorMessage = getMinStakeErrorMessage(chainInfo, bnMinStake);
|
|
47
|
+
const maxValidatorErrorMessage = getMaxValidatorErrorMessage(chainInfo, chainStakingMetadata.maxValidatorPerNominator);
|
|
48
|
+
const existUnstakeErrorMessage = getExistUnstakeErrorMessage(chainInfo.slug, true);
|
|
45
49
|
if (!nominatorMetadata || nominatorMetadata.status === StakingStatus.NOT_STAKING) {
|
|
46
50
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
47
|
-
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE));
|
|
51
|
+
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
48
52
|
}
|
|
49
53
|
return errors;
|
|
50
54
|
}
|
|
@@ -55,11 +59,11 @@ export function validateParaChainBondingCondition(chainInfo, amount, selectedCol
|
|
|
55
59
|
if (!bondedValidators.includes(parsedSelectedCollatorAddress)) {
|
|
56
60
|
// new delegation
|
|
57
61
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
58
|
-
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE));
|
|
62
|
+
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
59
63
|
}
|
|
60
64
|
const delegationCount = nominatorMetadata.nominations.length + 1;
|
|
61
65
|
if (delegationCount > chainStakingMetadata.maxValidatorPerNominator) {
|
|
62
|
-
errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_NOMINATIONS));
|
|
66
|
+
errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_NOMINATIONS, maxValidatorErrorMessage));
|
|
63
67
|
}
|
|
64
68
|
} else {
|
|
65
69
|
let currentDelegationAmount = '0';
|
|
@@ -73,10 +77,10 @@ export function validateParaChainBondingCondition(chainInfo, amount, selectedCol
|
|
|
73
77
|
}
|
|
74
78
|
bnTotalStake = bnTotalStake.add(new BN(currentDelegationAmount));
|
|
75
79
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
76
|
-
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE));
|
|
80
|
+
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
77
81
|
}
|
|
78
82
|
if (hasUnstaking) {
|
|
79
|
-
errors.push(new TransactionError(StakingTxErrorType.EXIST_UNSTAKING_REQUEST));
|
|
83
|
+
errors.push(new TransactionError(StakingTxErrorType.EXIST_UNSTAKING_REQUEST, existUnstakeErrorMessage));
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
return errors;
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
5
5
|
import { StakingStatus, StakingTxErrorType, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
|
-
import { calculateAlephZeroValidatorReturn, calculateChainStakedReturn, calculateInflation, calculateTernoaValidatorReturn, calculateValidatorStakedReturn, getCommission, parseIdentity, parsePoolStashAddress, transformPoolName } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
6
|
+
import { calculateAlephZeroValidatorReturn, calculateChainStakedReturn, calculateInflation, calculateTernoaValidatorReturn, calculateValidatorStakedReturn, getCommission, getExistUnstakeErrorMessage, getMaxValidatorErrorMessage, getMinStakeErrorMessage, parseIdentity, parsePoolStashAddress, transformPoolName } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
7
7
|
import { _STAKING_CHAIN_GROUP, _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
8
|
import { _getChainSubstrateAddressPrefix } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
9
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
10
|
+
import { t } from 'i18next';
|
|
10
11
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
11
12
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
12
13
|
export function validateRelayUnbondingCondition(amount, chainStakingMetadata, nominatorMetadata) {
|
|
@@ -18,7 +19,11 @@ export function validateRelayUnbondingCondition(amount, chainStakingMetadata, no
|
|
|
18
19
|
errors.push(new TransactionError(StakingTxErrorType.INVALID_ACTIVE_STAKE));
|
|
19
20
|
}
|
|
20
21
|
if (nominatorMetadata.unstakings.length > chainStakingMetadata.maxWithdrawalRequestPerValidator) {
|
|
21
|
-
errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_UNSTAKING
|
|
22
|
+
errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_UNSTAKING, t('You cannot unstake more than {{number}} times', {
|
|
23
|
+
replace: {
|
|
24
|
+
number: chainStakingMetadata.maxWithdrawalRequestPerValidator
|
|
25
|
+
}
|
|
26
|
+
})));
|
|
22
27
|
}
|
|
23
28
|
return errors;
|
|
24
29
|
}
|
|
@@ -28,6 +33,8 @@ export function validatePoolBondingCondition(chainInfo, amount, selectedPool, ad
|
|
|
28
33
|
const errors = [];
|
|
29
34
|
let bnTotalStake = new BN(amount);
|
|
30
35
|
const bnMinStake = new BN(chainStakingMetadata.minJoinNominationPool || '0');
|
|
36
|
+
const minStakeErrorMessage = getMinStakeErrorMessage(chainInfo, bnMinStake);
|
|
37
|
+
const existUnstakeErrorMessage = getExistUnstakeErrorMessage(chainInfo.slug, true);
|
|
31
38
|
if (selectedPool.state !== 'Open') {
|
|
32
39
|
errors.push(new TransactionError(StakingTxErrorType.INACTIVE_NOMINATION_POOL));
|
|
33
40
|
}
|
|
@@ -35,11 +42,11 @@ export function validatePoolBondingCondition(chainInfo, amount, selectedPool, ad
|
|
|
35
42
|
const bnCurrentActiveStake = new BN(nominatorMetadata.activeStake);
|
|
36
43
|
bnTotalStake = bnTotalStake.add(bnCurrentActiveStake);
|
|
37
44
|
if (nominatorMetadata.unstakings.length > 0 && bnCurrentActiveStake.isZero()) {
|
|
38
|
-
errors.push(new TransactionError(StakingTxErrorType.EXIST_UNSTAKING_REQUEST));
|
|
45
|
+
errors.push(new TransactionError(StakingTxErrorType.EXIST_UNSTAKING_REQUEST, existUnstakeErrorMessage));
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
42
|
-
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE));
|
|
49
|
+
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
43
50
|
}
|
|
44
51
|
return errors;
|
|
45
52
|
}
|
|
@@ -47,22 +54,24 @@ export function validateRelayBondingCondition(chainInfo, amount, selectedValidat
|
|
|
47
54
|
const errors = [];
|
|
48
55
|
let bnTotalStake = new BN(amount);
|
|
49
56
|
const bnMinStake = new BN(chainStakingMetadata.minStake);
|
|
57
|
+
const minStakeErrorMessage = getMinStakeErrorMessage(chainInfo, bnMinStake);
|
|
58
|
+
const maxValidatorErrorMessage = getMaxValidatorErrorMessage(chainInfo, chainStakingMetadata.maxValidatorPerNominator);
|
|
50
59
|
if (!nominatorMetadata || nominatorMetadata.status === StakingStatus.NOT_STAKING) {
|
|
51
60
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
52
|
-
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE));
|
|
61
|
+
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
53
62
|
}
|
|
54
63
|
if (selectedValidators.length > chainStakingMetadata.maxValidatorPerNominator) {
|
|
55
|
-
errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_NOMINATIONS));
|
|
64
|
+
errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_NOMINATIONS, maxValidatorErrorMessage));
|
|
56
65
|
}
|
|
57
66
|
return errors;
|
|
58
67
|
}
|
|
59
68
|
const bnCurrentActiveStake = new BN(nominatorMetadata.activeStake);
|
|
60
69
|
bnTotalStake = bnTotalStake.add(bnCurrentActiveStake);
|
|
61
70
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
62
|
-
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE));
|
|
71
|
+
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
63
72
|
}
|
|
64
73
|
if (selectedValidators.length > chainStakingMetadata.maxValidatorPerNominator) {
|
|
65
|
-
errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_NOMINATIONS));
|
|
74
|
+
errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_NOMINATIONS, maxValidatorErrorMessage));
|
|
66
75
|
}
|
|
67
76
|
return errors;
|
|
68
77
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
|
+
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
3
|
import { NominationInfo, NominatorMetadata, StakingStatus, StakingType, UnstakingInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
4
|
import { _SubstrateInflationParams } from '@subwallet/extension-base/services/chain-service/constants';
|
|
4
5
|
import { ApiPromise } from '@polkadot/api';
|
|
@@ -159,3 +160,6 @@ export declare function isActionFromValidator(stakingType: StakingType, chain: s
|
|
|
159
160
|
export declare function getWithdrawalInfo(nominatorMetadata: NominatorMetadata): UnstakingInfo | undefined;
|
|
160
161
|
export declare function getStakingStatusByNominations(bnTotalActiveStake: BN, nominationList: NominationInfo[]): StakingStatus;
|
|
161
162
|
export declare function getValidatorLabel(chain: string): "dApp" | "Validator" | "Collator";
|
|
163
|
+
export declare const getMinStakeErrorMessage: (chainInfo: _ChainInfo, bnMinStake: BN) => string;
|
|
164
|
+
export declare const getMaxValidatorErrorMessage: (chainInfo: _ChainInfo, max: number) => string;
|
|
165
|
+
export declare const getExistUnstakeErrorMessage: (chain: string, isStakeMore?: boolean) => string;
|