@subwallet/extension-base 1.1.9-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/parseTransaction.js +2 -1
- 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/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/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/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/parseTransaction.js +2 -1
- 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/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 +31 -11
- package/packageInfo.js +1 -1
- package/services/balance-service/index.js +12 -3
- 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/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
|
@@ -13,7 +13,9 @@ exports.calculateTernoaValidatorReturn = calculateTernoaValidatorReturn;
|
|
|
13
13
|
exports.calculateValidatorStakedReturn = calculateValidatorStakedReturn;
|
|
14
14
|
exports.getBondedValidators = getBondedValidators;
|
|
15
15
|
exports.getCommission = getCommission;
|
|
16
|
+
exports.getExistUnstakeErrorMessage = void 0;
|
|
16
17
|
exports.getInflationParams = getInflationParams;
|
|
18
|
+
exports.getMinStakeErrorMessage = exports.getMaxValidatorErrorMessage = void 0;
|
|
17
19
|
exports.getParaCurrentInflation = getParaCurrentInflation;
|
|
18
20
|
exports.getStakingAvailableActionsByChain = getStakingAvailableActionsByChain;
|
|
19
21
|
exports.getStakingAvailableActionsByNominator = getStakingAvailableActionsByNominator;
|
|
@@ -29,7 +31,9 @@ exports.transformPoolName = transformPoolName;
|
|
|
29
31
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
30
32
|
var _astar = require("@subwallet/extension-base/koni/api/staking/bonding/astar");
|
|
31
33
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
32
|
-
var _utils = require("@subwallet/extension-base/utils");
|
|
34
|
+
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
35
|
+
var _utils2 = require("@subwallet/extension-base/utils");
|
|
36
|
+
var _i18next = require("i18next");
|
|
33
37
|
var _util = require("@polkadot/util");
|
|
34
38
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
35
39
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -133,8 +137,8 @@ function getCommission(commissionString) {
|
|
|
133
137
|
|
|
134
138
|
function getParaCurrentInflation(totalStaked, inflationConfig) {
|
|
135
139
|
// read more at https://hackmd.io/@sbAqOuXkRvyiZPOB3Ryn6Q/Sypr3ZJh5
|
|
136
|
-
const expectMin = (0,
|
|
137
|
-
const expectMax = (0,
|
|
140
|
+
const expectMin = (0, _utils2.parseRawNumber)(inflationConfig.expect.min);
|
|
141
|
+
const expectMax = (0, _utils2.parseRawNumber)(inflationConfig.expect.max);
|
|
138
142
|
if (totalStaked < expectMin) {
|
|
139
143
|
const inflationString = inflationConfig.annual.min.split('%')[0];
|
|
140
144
|
return parseFloat(inflationString);
|
|
@@ -161,7 +165,7 @@ function getBondedValidators(nominations) {
|
|
|
161
165
|
let nominationCount = 0;
|
|
162
166
|
for (const nomination of nominations) {
|
|
163
167
|
nominationCount += 1;
|
|
164
|
-
bondedValidators.push((0,
|
|
168
|
+
bondedValidators.push((0, _utils2.reformatAddress)(nomination.validatorAddress, 0));
|
|
165
169
|
}
|
|
166
170
|
return {
|
|
167
171
|
nominationCount,
|
|
@@ -171,8 +175,8 @@ function getBondedValidators(nominations) {
|
|
|
171
175
|
function isUnstakeAll(selectedValidator, nominations, unstakeAmount) {
|
|
172
176
|
let isUnstakeAll = false;
|
|
173
177
|
for (const nomination of nominations) {
|
|
174
|
-
const parsedValidatorAddress = (0,
|
|
175
|
-
const parsedSelectedValidator = (0,
|
|
178
|
+
const parsedValidatorAddress = (0, _utils2.reformatAddress)(nomination.validatorAddress, 0);
|
|
179
|
+
const parsedSelectedValidator = (0, _utils2.reformatAddress)(selectedValidator, 0);
|
|
176
180
|
if (parsedValidatorAddress === parsedSelectedValidator) {
|
|
177
181
|
if (unstakeAmount === nomination.activeStake) {
|
|
178
182
|
isUnstakeAll = true;
|
|
@@ -278,4 +282,73 @@ function getValidatorLabel(chain) {
|
|
|
278
282
|
return 'Validator';
|
|
279
283
|
}
|
|
280
284
|
return 'Collator';
|
|
281
|
-
}
|
|
285
|
+
}
|
|
286
|
+
const getMinStakeErrorMessage = (chainInfo, bnMinStake) => {
|
|
287
|
+
const tokenInfo = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
288
|
+
const number = bnMinStake.div(new _util.BN(10).pow(new _util.BN(tokenInfo.decimals))).toString();
|
|
289
|
+
return (0, _i18next.t)('Insufficient stake. Please stake at least {{number}} {{tokenSymbol}} to get rewards', {
|
|
290
|
+
replace: {
|
|
291
|
+
tokenSymbol: tokenInfo.symbol,
|
|
292
|
+
number
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
exports.getMinStakeErrorMessage = getMinStakeErrorMessage;
|
|
297
|
+
const getMaxValidatorErrorMessage = (chainInfo, max) => {
|
|
298
|
+
let message = (0, _utils2.detectTranslate)('You cannot select more than {{number}} validators for this network');
|
|
299
|
+
const label = getValidatorLabel(chainInfo.slug);
|
|
300
|
+
if (max > 1) {
|
|
301
|
+
switch (label) {
|
|
302
|
+
case 'dApp':
|
|
303
|
+
message = (0, _utils2.detectTranslate)('You cannot select more than {{number}} dApps for this network');
|
|
304
|
+
break;
|
|
305
|
+
case 'Collator':
|
|
306
|
+
message = (0, _utils2.detectTranslate)('You cannot select more than {{number}} collators for this network');
|
|
307
|
+
break;
|
|
308
|
+
case 'Validator':
|
|
309
|
+
message = (0, _utils2.detectTranslate)('You cannot select more than {{number}} validators for this network');
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
} else {
|
|
313
|
+
switch (label) {
|
|
314
|
+
case 'dApp':
|
|
315
|
+
message = (0, _utils2.detectTranslate)('You cannot select more than {{number}} dApp for this network');
|
|
316
|
+
break;
|
|
317
|
+
case 'Collator':
|
|
318
|
+
message = (0, _utils2.detectTranslate)('You cannot select more than {{number}} collator for this network');
|
|
319
|
+
break;
|
|
320
|
+
case 'Validator':
|
|
321
|
+
message = (0, _utils2.detectTranslate)('You cannot select more than {{number}} validator for this network');
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return (0, _i18next.t)(message, {
|
|
326
|
+
replace: {
|
|
327
|
+
number: max
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
exports.getMaxValidatorErrorMessage = getMaxValidatorErrorMessage;
|
|
332
|
+
const getExistUnstakeErrorMessage = (chain, isStakeMore) => {
|
|
333
|
+
const label = getValidatorLabel(chain);
|
|
334
|
+
if (!isStakeMore) {
|
|
335
|
+
switch (label) {
|
|
336
|
+
case 'dApp':
|
|
337
|
+
return (0, _i18next.t)('You can unstake from a dApp once');
|
|
338
|
+
case 'Collator':
|
|
339
|
+
return (0, _i18next.t)('You can unstake from a collator once');
|
|
340
|
+
case 'Validator':
|
|
341
|
+
return (0, _i18next.t)('You can unstake from a validator once');
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
switch (label) {
|
|
345
|
+
case 'dApp':
|
|
346
|
+
return (0, _i18next.t)('You cannot stake more for a dApp you are unstaking from');
|
|
347
|
+
case 'Collator':
|
|
348
|
+
return (0, _i18next.t)('You cannot stake more for a collator you are unstaking from');
|
|
349
|
+
case 'Validator':
|
|
350
|
+
return (0, _i18next.t)('You cannot stake more for a validator you are unstaking from');
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
exports.getExistUnstakeErrorMessage = getExistUnstakeErrorMessage;
|