@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
|
@@ -36,6 +36,7 @@ var _promise = require("@subwallet/extension-base/utils/promise");
|
|
|
36
36
|
var _decode = require("@subwallet/keyring/pair/decode");
|
|
37
37
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
38
38
|
var _ethSimpleKeyring = _interopRequireDefault(require("eth-simple-keyring"));
|
|
39
|
+
var _i18next = require("i18next");
|
|
39
40
|
var _rxjs = require("rxjs");
|
|
40
41
|
var _util = require("@polkadot/util");
|
|
41
42
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
@@ -146,7 +147,7 @@ class KoniState {
|
|
|
146
147
|
|
|
147
148
|
// Start a provider, return its meta
|
|
148
149
|
rpcStartProvider(key, port) {
|
|
149
|
-
(0, _util.assert)(Object.keys(this.providers).includes(key),
|
|
150
|
+
(0, _util.assert)(Object.keys(this.providers).includes(key), 'Provider cannot be found.');
|
|
150
151
|
if (this.injectedProviders.get(port)) {
|
|
151
152
|
return Promise.resolve(this.providers[key].meta);
|
|
152
153
|
}
|
|
@@ -500,7 +501,7 @@ class KoniState {
|
|
|
500
501
|
setAccountTie(address, genesisHash) {
|
|
501
502
|
if (address !== _constants.ALL_ACCOUNT_KEY) {
|
|
502
503
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
503
|
-
(0, _util.assert)(pair, 'Unable to find
|
|
504
|
+
(0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
|
|
504
505
|
_uiKeyring.keyring.saveAccountMeta(pair, {
|
|
505
506
|
...pair.meta,
|
|
506
507
|
genesisHash
|
|
@@ -524,7 +525,11 @@ class KoniState {
|
|
|
524
525
|
authUrls[shortenUrl].currentEvmNetworkKey = networkKey;
|
|
525
526
|
this.setAuthorize(authUrls);
|
|
526
527
|
} else {
|
|
527
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR,
|
|
528
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR, (0, _i18next.t)('Not found {{shortenUrl}} in auth list', {
|
|
529
|
+
replace: {
|
|
530
|
+
shortenUrl
|
|
531
|
+
}
|
|
532
|
+
}));
|
|
528
533
|
}
|
|
529
534
|
}
|
|
530
535
|
async switchNetworkAccount(id, url, networkKey, changeAddress) {
|
|
@@ -550,7 +555,7 @@ class KoniState {
|
|
|
550
555
|
}
|
|
551
556
|
if (useAddress !== _constants.ALL_ACCOUNT_KEY) {
|
|
552
557
|
const pair = _uiKeyring.keyring.getPair(useAddress);
|
|
553
|
-
(0, _util.assert)(pair, 'Unable to find
|
|
558
|
+
(0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
|
|
554
559
|
_uiKeyring.keyring.saveAccountMeta(pair, {
|
|
555
560
|
...pair.meta,
|
|
556
561
|
genesisHash: (0, _utils._getSubstrateGenesisHash)(chainInfo)
|
|
@@ -1137,10 +1142,10 @@ class KoniState {
|
|
|
1137
1142
|
payload = p1;
|
|
1138
1143
|
}
|
|
1139
1144
|
if (address === '' || !payload) {
|
|
1140
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Not found address or payload to sign');
|
|
1145
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found address or payload to sign'));
|
|
1141
1146
|
}
|
|
1142
1147
|
if (['eth_sign', 'personal_sign', 'eth_signTypedData', 'eth_signTypedData_v1', 'eth_signTypedData_v3', 'eth_signTypedData_v4'].indexOf(method) < 0) {
|
|
1143
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
1148
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Unsupported action'));
|
|
1144
1149
|
}
|
|
1145
1150
|
if (['eth_signTypedData_v3', 'eth_signTypedData_v4'].indexOf(method) > -1) {
|
|
1146
1151
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment
|
|
@@ -1149,11 +1154,11 @@ class KoniState {
|
|
|
1149
1154
|
|
|
1150
1155
|
// Check sign abiblity
|
|
1151
1156
|
if (!allowedAccounts.find(acc => acc.toLowerCase() === address.toLowerCase())) {
|
|
1152
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS,
|
|
1157
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('You have rescinded allowance for this account in wallet'));
|
|
1153
1158
|
}
|
|
1154
1159
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
1155
1160
|
if (!pair) {
|
|
1156
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
1161
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Unable to find account'));
|
|
1157
1162
|
}
|
|
1158
1163
|
const account = {
|
|
1159
1164
|
address: pair.address,
|
|
@@ -1176,7 +1181,7 @@ class KoniState {
|
|
|
1176
1181
|
}
|
|
1177
1182
|
break;
|
|
1178
1183
|
default:
|
|
1179
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
1184
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Unsupported action'));
|
|
1180
1185
|
}
|
|
1181
1186
|
const signPayload = {
|
|
1182
1187
|
account: account,
|
|
@@ -1198,7 +1203,7 @@ class KoniState {
|
|
|
1198
1203
|
if (payload) {
|
|
1199
1204
|
return payload;
|
|
1200
1205
|
} else {
|
|
1201
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Not found signature');
|
|
1206
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found signature'));
|
|
1202
1207
|
}
|
|
1203
1208
|
} else {
|
|
1204
1209
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.USER_REJECTED_REQUEST);
|
|
@@ -1218,7 +1223,7 @@ class KoniState {
|
|
|
1218
1223
|
return val;
|
|
1219
1224
|
};
|
|
1220
1225
|
if (transactionParams.from === transactionParams.to) {
|
|
1221
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
1226
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Receiving address must be different from sending address'));
|
|
1222
1227
|
}
|
|
1223
1228
|
const transaction = {
|
|
1224
1229
|
from: transactionParams.from,
|
|
@@ -1247,11 +1252,11 @@ class KoniState {
|
|
|
1247
1252
|
// Address is validated in before step
|
|
1248
1253
|
const fromAddress = allowedAccounts.find(account => account.toLowerCase() === transaction.from.toLowerCase());
|
|
1249
1254
|
if (!fromAddress) {
|
|
1250
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
1255
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('You have rescinded allowance for this account in wallet'));
|
|
1251
1256
|
}
|
|
1252
1257
|
const pair = _uiKeyring.keyring.getPair(fromAddress);
|
|
1253
1258
|
if (!pair) {
|
|
1254
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
1259
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Unable to find account'));
|
|
1255
1260
|
}
|
|
1256
1261
|
const account = {
|
|
1257
1262
|
address: pair.address,
|
|
@@ -1261,7 +1266,7 @@ class KoniState {
|
|
|
1261
1266
|
// Validate balance
|
|
1262
1267
|
const balance = new _util.BN((await web3.eth.getBalance(fromAddress)) || 0);
|
|
1263
1268
|
if (balance.lt(new _util.BN(gasPrice.toString()).mul(new _util.BN(transaction.gas)).add(new _util.BN(autoFormatNumber(transactionParams.value) || '0')))) {
|
|
1264
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
1269
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Insufficient balance'));
|
|
1265
1270
|
}
|
|
1266
1271
|
transaction.nonce = await web3.eth.getTransactionCount(fromAddress);
|
|
1267
1272
|
const hashPayload = this.transactionService.generateHashPayload(networkKey, transaction);
|
|
@@ -19,6 +19,7 @@ var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
|
19
19
|
var _constants2 = require("@subwallet/extension-base/services/setting-service/constants");
|
|
20
20
|
var _utils2 = require("@subwallet/extension-base/utils");
|
|
21
21
|
var _uiKeyring = _interopRequireDefault(require("@subwallet/ui-keyring"));
|
|
22
|
+
var _i18next = require("i18next");
|
|
22
23
|
var _web = _interopRequireDefault(require("web3"));
|
|
23
24
|
var _phishing = require("@polkadot/phishing");
|
|
24
25
|
var _util = require("@polkadot/util");
|
|
@@ -135,7 +136,7 @@ class KoniTabs {
|
|
|
135
136
|
/// Clone from Polkadot.js
|
|
136
137
|
getSigningPair(address) {
|
|
137
138
|
const pair = _uiKeyring.default.getPair(address);
|
|
138
|
-
(0, _util.assert)(pair, 'Unable to find
|
|
139
|
+
(0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
|
|
139
140
|
return pair;
|
|
140
141
|
}
|
|
141
142
|
async bytesSign(url, request) {
|
|
@@ -369,13 +370,13 @@ class KoniTabs {
|
|
|
369
370
|
const web3 = evmApi === null || evmApi === void 0 ? void 0 : evmApi.api;
|
|
370
371
|
if ((web3 === null || web3 === void 0 ? void 0 : web3.currentProvider) instanceof _web.default.providers.WebsocketProvider) {
|
|
371
372
|
if (!web3.currentProvider.connected) {
|
|
372
|
-
console.log(
|
|
373
|
+
console.log(`${slug} is disconnected, trying to connect...`);
|
|
373
374
|
this.#koniState.refreshWeb3Api(slug);
|
|
374
375
|
let checkingNum = 0;
|
|
375
376
|
const poll = resolve => {
|
|
376
377
|
checkingNum += 1;
|
|
377
378
|
if (web3.currentProvider.connected) {
|
|
378
|
-
console.log(
|
|
379
|
+
console.log(`${slug} is connected.`);
|
|
379
380
|
resolve(true);
|
|
380
381
|
} else {
|
|
381
382
|
console.log(`Connecting to network [${slug}]`);
|
|
@@ -426,7 +427,7 @@ class KoniTabs {
|
|
|
426
427
|
if (networkKey) {
|
|
427
428
|
await this.#koniState.switchEvmNetworkByUrl((0, _utils2.stripUrl)(url), networkKey);
|
|
428
429
|
} else {
|
|
429
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS,
|
|
430
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'This network is currently not supported');
|
|
430
431
|
}
|
|
431
432
|
return null;
|
|
432
433
|
}
|
|
@@ -438,15 +439,15 @@ class KoniTabs {
|
|
|
438
439
|
const input = params;
|
|
439
440
|
const _tokenType = (input === null || input === void 0 ? void 0 : (_input$type = input.type) === null || _input$type === void 0 ? void 0 : _input$type.toLowerCase()) || '';
|
|
440
441
|
if (_tokenType !== 'erc20' && _tokenType !== 'erc721') {
|
|
441
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS,
|
|
442
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Assets type {{tokenType}} is not supported'.replace('{{tokenType}}', _tokenType));
|
|
442
443
|
}
|
|
443
444
|
if (!(input !== null && input !== void 0 && (_input$options = input.options) !== null && _input$options !== void 0 && _input$options.address) || !(input !== null && input !== void 0 && (_input$options2 = input.options) !== null && _input$options2 !== void 0 && _input$options2.symbol)) {
|
|
444
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
445
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Unable to get contract address and token symbol');
|
|
445
446
|
}
|
|
446
447
|
const evmState = await this.getEvmState(url);
|
|
447
448
|
const chain = evmState.networkKey;
|
|
448
449
|
if (!chain) {
|
|
449
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR, '
|
|
450
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR, 'The network on dApp is not supported in wallet. Please manually add the network to wallet');
|
|
450
451
|
}
|
|
451
452
|
const tokenType = _tokenType === 'erc20' ? _types._AssetType.ERC20 : _types._AssetType.ERC721;
|
|
452
453
|
const tokenInfo = {
|
|
@@ -548,7 +549,7 @@ class KoniTabs {
|
|
|
548
549
|
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
549
550
|
});
|
|
550
551
|
if (!filteredUrls.length) {
|
|
551
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR, 'Currently HTTP provider for EVM network');
|
|
552
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR, 'Currently support WSS provider for Substrate networks and HTTP provider for EVM network');
|
|
552
553
|
}
|
|
553
554
|
const provider = filteredUrls[0];
|
|
554
555
|
const chainInfo = {
|
|
@@ -796,7 +797,7 @@ class KoniTabs {
|
|
|
796
797
|
if (signResult) {
|
|
797
798
|
return signResult;
|
|
798
799
|
} else {
|
|
799
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
800
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Failed to sign message');
|
|
800
801
|
}
|
|
801
802
|
}
|
|
802
803
|
async evmSendTransaction(id, url, _ref21) {
|
|
@@ -808,10 +809,10 @@ class KoniTabs {
|
|
|
808
809
|
const evmState = await this.getEvmState(url);
|
|
809
810
|
const networkKey = evmState.networkKey;
|
|
810
811
|
if (!canUseAccount) {
|
|
811
|
-
throw new Error(
|
|
812
|
+
throw new Error((0, _i18next.t)('You have rescinded allowance for this account in wallet'));
|
|
812
813
|
}
|
|
813
814
|
if (!networkKey) {
|
|
814
|
-
throw new Error('
|
|
815
|
+
throw new Error('Network unavailable. Please switch network or manually add network to wallet');
|
|
815
816
|
}
|
|
816
817
|
const allowedAccounts = await this.getEvmCurrentAccount(url, true);
|
|
817
818
|
const transactionHash = await this.#koniState.evmSendTransaction(id, url, networkKey, allowedAccounts, transactionParams);
|
|
@@ -903,14 +904,14 @@ class KoniTabs {
|
|
|
903
904
|
} = _ref22;
|
|
904
905
|
const _tokenType = input.type;
|
|
905
906
|
if (_tokenType !== 'psp22' && _tokenType !== 'psp34') {
|
|
906
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS,
|
|
907
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Assets type {{tokenType}} is not supported'.replace('{{tokenType}}', _tokenType));
|
|
907
908
|
}
|
|
908
909
|
if (!input.address || !input.symbol) {
|
|
909
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
910
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Unable to get contract address and token symbol');
|
|
910
911
|
}
|
|
911
912
|
const [chain] = this.#koniState.findNetworkKeyByGenesisHash(genesisHash);
|
|
912
913
|
if (!chain) {
|
|
913
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR, '
|
|
914
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR, 'The network on dApp is not supported in wallet. Please manually add the network to wallet');
|
|
914
915
|
}
|
|
915
916
|
const state = this.#koniState.getChainStateByKey(chain);
|
|
916
917
|
if (!state.active) {
|
package/cjs/packageInfo.js
CHANGED
|
@@ -11,6 +11,7 @@ var _handlers = require("@subwallet/extension-base/koni/background/handlers");
|
|
|
11
11
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
12
12
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
13
13
|
var _utils2 = require("@subwallet/extension-base/utils");
|
|
14
|
+
var _i18next = require("i18next");
|
|
14
15
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
15
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
16
17
|
|
|
@@ -32,12 +33,20 @@ class BalanceService {
|
|
|
32
33
|
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
33
34
|
const chainState = this.chainService.getChainStateByKey(chain);
|
|
34
35
|
if (!chainInfo || !chainState || !chainState.active) {
|
|
35
|
-
return Promise.reject(new _BalanceError.BalanceError(_KoniTypes.BalanceErrorType.NETWORK_ERROR,
|
|
36
|
+
return Promise.reject(new _BalanceError.BalanceError(_KoniTypes.BalanceErrorType.NETWORK_ERROR, (0, _i18next.t)('{{chain}} is inactive. Please enable network', {
|
|
37
|
+
replace: {
|
|
38
|
+
chain
|
|
39
|
+
}
|
|
40
|
+
})));
|
|
36
41
|
}
|
|
37
42
|
const tSlug = tokenSlug || (0, _utils._getChainNativeTokenSlug)(chainInfo);
|
|
38
43
|
const tokenInfo = this.chainService.getAssetBySlug(tSlug);
|
|
39
44
|
if (!tokenInfo) {
|
|
40
|
-
return Promise.reject(new _BalanceError.BalanceError(_KoniTypes.BalanceErrorType.TOKEN_ERROR,
|
|
45
|
+
return Promise.reject(new _BalanceError.BalanceError(_KoniTypes.BalanceErrorType.TOKEN_ERROR, (0, _i18next.t)('Transfer is currently not available for this token: {{tSlug}}', {
|
|
46
|
+
replace: {
|
|
47
|
+
slug: tSlug
|
|
48
|
+
}
|
|
49
|
+
})));
|
|
41
50
|
}
|
|
42
51
|
return new Promise((resolve, reject) => {
|
|
43
52
|
let hasError = true;
|
|
@@ -61,7 +70,7 @@ class BalanceService {
|
|
|
61
70
|
setTimeout(() => {
|
|
62
71
|
if (hasError) {
|
|
63
72
|
unsub();
|
|
64
|
-
reject(new Error('
|
|
73
|
+
reject(new Error((0, _i18next.t)('Failed to get balance. Please check your internet connection or change your network endpoint')));
|
|
65
74
|
}
|
|
66
75
|
}, 9999);
|
|
67
76
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports._TEST_ERC721_ABI = exports._PSP34_ABI = exports._PSP22_ABI = exports._ERC721_ABI = exports._ERC20_ABI = void 0;
|
|
6
|
+
exports._TEST_ERC721_ABI = exports._PSP34_ABI = exports._PSP22_ABI = exports._PINK_PSP34_ABI = exports._ERC721_ABI = exports._ERC20_ABI = exports._AZERO_DOMAIN_REGISTRY_ABI = void 0;
|
|
7
7
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
|
|
@@ -21,4 +21,10 @@ const _PSP22_ABI = require('./psp22_abi.json');
|
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
22
22
|
exports._PSP22_ABI = _PSP22_ABI;
|
|
23
23
|
const _PSP34_ABI = require('./psp34_abi.json');
|
|
24
|
-
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
25
|
+
exports._PSP34_ABI = _PSP34_ABI;
|
|
26
|
+
const _PINK_PSP34_ABI = require('./pink_psp34_abi.json');
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
28
|
+
exports._PINK_PSP34_ABI = _PINK_PSP34_ABI;
|
|
29
|
+
const _AZERO_DOMAIN_REGISTRY_ABI = require('./azero_domain_registry_abi.json');
|
|
30
|
+
exports._AZERO_DOMAIN_REGISTRY_ABI = _AZERO_DOMAIN_REGISTRY_ABI;
|
|
@@ -222,7 +222,7 @@ class AuthRequestHandler {
|
|
|
222
222
|
const idStr = (0, _utils2.stripUrl)(url);
|
|
223
223
|
// Do not enqueue duplicate authorization requests.
|
|
224
224
|
const isDuplicate = Object.values(this.#authRequestsV2).some(request => request.idStr === idStr);
|
|
225
|
-
(0, _util.assert)(!isDuplicate,
|
|
225
|
+
(0, _util.assert)(!isDuplicate, 'The source {{url}} has a pending authorization request'.replace('{{url}}', url));
|
|
226
226
|
const existedAuth = authList[idStr];
|
|
227
227
|
const existedAccountAuthType = existedAuth === null || existedAuth === void 0 ? void 0 : existedAuth.accountAuthType;
|
|
228
228
|
const confirmAnotherType = existedAccountAuthType !== 'both' && existedAccountAuthType !== request.accountAuthType;
|
|
@@ -234,7 +234,7 @@ class AuthRequestHandler {
|
|
|
234
234
|
if (existedAuth) {
|
|
235
235
|
const inBlackList = existedAuth && !existedAuth.isAllowed;
|
|
236
236
|
if (inBlackList) {
|
|
237
|
-
throw new Error(
|
|
237
|
+
throw new Error('The source {{url}} is not allowed to interact with this extension'.replace('{{url}}', url));
|
|
238
238
|
}
|
|
239
239
|
request.allowedAccounts = Object.entries(existedAuth.isAllowedMap).map(_ref3 => {
|
|
240
240
|
let [address, allowed] = _ref3;
|
|
@@ -285,11 +285,11 @@ class AuthRequestHandler {
|
|
|
285
285
|
}
|
|
286
286
|
const entry = Object.keys(value).includes(idStr);
|
|
287
287
|
if (!entry) {
|
|
288
|
-
reject(new Error(
|
|
288
|
+
reject(new Error('The source {{url}} has not been authorized yet'.replace('{{url}}', url)));
|
|
289
289
|
}
|
|
290
290
|
const isConnected = value[idStr] && Object.keys(value[idStr].isAllowedMap).some(address => value[idStr].isAllowedMap[address]);
|
|
291
291
|
if (!isConnected) {
|
|
292
|
-
reject(new Error(
|
|
292
|
+
reject(new Error('The source {{url}} is not allowed to interact with this extension'.replace('{{url}}', url)));
|
|
293
293
|
}
|
|
294
294
|
resolve(true);
|
|
295
295
|
});
|
|
@@ -14,6 +14,7 @@ var _uiKeyring = _interopRequireDefault(require("@subwallet/ui-keyring"));
|
|
|
14
14
|
var _bn = _interopRequireDefault(require("bn.js"));
|
|
15
15
|
var _ethereumjsTx = require("ethereumjs-tx");
|
|
16
16
|
var _ethereumjsUtil = require("ethereumjs-util");
|
|
17
|
+
var _i18next = require("i18next");
|
|
17
18
|
var _rxjs = require("rxjs");
|
|
18
19
|
var _util = require("@polkadot/util");
|
|
19
20
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
@@ -55,7 +56,7 @@ class EvmRequestHandler {
|
|
|
55
56
|
// Check duplicate request
|
|
56
57
|
const duplicated = Object.values(confirmationType).find(c => c.url === url && c.payloadJson === payloadJson);
|
|
57
58
|
if (duplicated) {
|
|
58
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Duplicate request
|
|
59
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Duplicate request'));
|
|
59
60
|
}
|
|
60
61
|
confirmationType[id] = {
|
|
61
62
|
id,
|
|
@@ -90,7 +91,7 @@ class EvmRequestHandler {
|
|
|
90
91
|
// Check duplicate request
|
|
91
92
|
const exists = confirmationType[id];
|
|
92
93
|
if (!exists) {
|
|
93
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Request does not exist');
|
|
94
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Request does not exist'));
|
|
94
95
|
}
|
|
95
96
|
const payloadJson = JSON.stringify(payload);
|
|
96
97
|
confirmationType[id] = {
|
|
@@ -124,7 +125,7 @@ class EvmRequestHandler {
|
|
|
124
125
|
case 'eth_signTypedData_v4':
|
|
125
126
|
return await pair.evmSigner.signMessage(payload, type);
|
|
126
127
|
default:
|
|
127
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, '
|
|
128
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Unsupported action'));
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
configToTransaction(config) {
|
|
@@ -197,8 +198,8 @@ class EvmRequestHandler {
|
|
|
197
198
|
async completeConfirmation(request) {
|
|
198
199
|
const confirmations = this.confirmationsQueueSubject.getValue();
|
|
199
200
|
for (const ct in request) {
|
|
200
|
-
const
|
|
201
|
-
const result = request[
|
|
201
|
+
const type = ct;
|
|
202
|
+
const result = request[type];
|
|
202
203
|
const {
|
|
203
204
|
id
|
|
204
205
|
} = result;
|
|
@@ -206,14 +207,14 @@ class EvmRequestHandler {
|
|
|
206
207
|
resolver,
|
|
207
208
|
validator
|
|
208
209
|
} = this.confirmationsPromiseMap[id];
|
|
209
|
-
const confirmation = confirmations[
|
|
210
|
+
const confirmation = confirmations[type][id];
|
|
210
211
|
if (!resolver || !confirmation) {
|
|
211
|
-
this.#logger.error('
|
|
212
|
-
throw new Error('
|
|
212
|
+
this.#logger.error((0, _i18next.t)('Unable to proceed. Please try again'), type, id);
|
|
213
|
+
throw new Error((0, _i18next.t)('Unable to proceed. Please try again'));
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
// Fill signature for some special type
|
|
216
|
-
await this.decorateResult(
|
|
217
|
+
await this.decorateResult(type, confirmation, result);
|
|
217
218
|
|
|
218
219
|
// Validate response from confirmation popup some info like password, response format....
|
|
219
220
|
const error = validator && validator(result);
|
|
@@ -223,7 +224,7 @@ class EvmRequestHandler {
|
|
|
223
224
|
|
|
224
225
|
// Delete confirmations from queue
|
|
225
226
|
delete this.confirmationsPromiseMap[id];
|
|
226
|
-
delete confirmations[
|
|
227
|
+
delete confirmations[type][id];
|
|
227
228
|
this.confirmationsQueueSubject.next(confirmations);
|
|
228
229
|
|
|
229
230
|
// Update icon, and close queue
|
|
@@ -5,25 +5,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _constants = require("@subwallet/extension-base/constants");
|
|
8
9
|
var _PassPhishingStore = _interopRequireDefault(require("@subwallet/extension-base/stores/PassPhishingStore"));
|
|
9
10
|
var _Settings = _interopRequireDefault(require("@subwallet/extension-base/stores/Settings"));
|
|
10
|
-
var
|
|
11
|
+
var _i18n = _interopRequireDefault(require("./i18n/i18n"));
|
|
12
|
+
var _constants2 = require("./constants");
|
|
11
13
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
12
14
|
// SPDX-License-Identifier: Apache-2.0
|
|
13
15
|
|
|
14
16
|
class SettingService {
|
|
15
17
|
settingsStore = new _Settings.default();
|
|
16
18
|
passPhishingStore = new _PassPhishingStore.default();
|
|
19
|
+
constructor() {
|
|
20
|
+
let old = localStorage.getItem(_constants.LANGUAGE) || 'en';
|
|
21
|
+
this.settingsStore.getSubject().subscribe(_ref => {
|
|
22
|
+
let {
|
|
23
|
+
language
|
|
24
|
+
} = _ref;
|
|
25
|
+
if (language !== old) {
|
|
26
|
+
old = language;
|
|
27
|
+
_i18n.default.changeLanguage(language).catch(console.error);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
17
31
|
getSubject() {
|
|
18
32
|
return this.settingsStore.getSubject();
|
|
19
33
|
}
|
|
20
34
|
getSettings(update) {
|
|
21
35
|
this.settingsStore.get('Settings', value => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
36
|
+
update({
|
|
37
|
+
..._constants2.DEFAULT_SETTING,
|
|
38
|
+
...(value || {})
|
|
39
|
+
});
|
|
27
40
|
});
|
|
28
41
|
}
|
|
29
42
|
setSettings(data, callback) {
|
|
@@ -41,7 +54,7 @@ class SettingService {
|
|
|
41
54
|
this.passPhishingStore.set('PassPhishing', data, callback);
|
|
42
55
|
}
|
|
43
56
|
resetWallet() {
|
|
44
|
-
this.settingsStore.set('Settings',
|
|
57
|
+
this.settingsStore.set('Settings', _constants2.DEFAULT_SETTING);
|
|
45
58
|
this.passPhishingStore.set('PassPhishing', {});
|
|
46
59
|
}
|
|
47
60
|
}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DEFAULT_THEME = exports.DEFAULT_SHOW_ZERO_BALANCE = exports.DEFAULT_SHOW_BALANCE = exports.DEFAULT_SETTING = exports.DEFAULT_NOTIFICATION_TYPE = exports.DEFAULT_LANGUAGE = exports.DEFAULT_CHAIN_PATROL_ENABLE = exports.DEFAULT_CAMERA_ENABLE = exports.DEFAULT_AUTO_LOCK_TIME = exports.DEFAULT_ALL_LOGO = void 0;
|
|
6
|
+
exports.DEFAULT_UNLOCK_TYPE = exports.DEFAULT_THEME = exports.DEFAULT_SHOW_ZERO_BALANCE = exports.DEFAULT_SHOW_BALANCE = exports.DEFAULT_SETTING = exports.DEFAULT_NOTIFICATION_TYPE = exports.DEFAULT_LANGUAGE = exports.DEFAULT_CHAIN_PATROL_ENABLE = exports.DEFAULT_CAMERA_ENABLE = exports.DEFAULT_AUTO_LOCK_TIME = exports.DEFAULT_ALL_LOGO = void 0;
|
|
7
7
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
8
9
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
9
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
10
11
|
|
|
@@ -14,6 +15,8 @@ const DEFAULT_NOTIFICATION_TYPE = 'popup';
|
|
|
14
15
|
exports.DEFAULT_NOTIFICATION_TYPE = DEFAULT_NOTIFICATION_TYPE;
|
|
15
16
|
const DEFAULT_AUTO_LOCK_TIME = 15;
|
|
16
17
|
exports.DEFAULT_AUTO_LOCK_TIME = DEFAULT_AUTO_LOCK_TIME;
|
|
18
|
+
const DEFAULT_UNLOCK_TYPE = _utils.TARGET_ENV === 'extension' ? _KoniTypes.WalletUnlockType.ALWAYS_REQUIRED : _KoniTypes.WalletUnlockType.WHEN_NEEDED;
|
|
19
|
+
exports.DEFAULT_UNLOCK_TYPE = DEFAULT_UNLOCK_TYPE;
|
|
17
20
|
const DEFAULT_CHAIN_PATROL_ENABLE = false;
|
|
18
21
|
exports.DEFAULT_CHAIN_PATROL_ENABLE = DEFAULT_CHAIN_PATROL_ENABLE;
|
|
19
22
|
const DEFAULT_LANGUAGE = 'en';
|
|
@@ -33,6 +36,7 @@ const DEFAULT_SETTING = {
|
|
|
33
36
|
isShowBalance: DEFAULT_SHOW_BALANCE,
|
|
34
37
|
accountAllLogo: DEFAULT_ALL_LOGO,
|
|
35
38
|
theme: DEFAULT_THEME,
|
|
39
|
+
unlockType: DEFAULT_UNLOCK_TYPE,
|
|
36
40
|
camera: DEFAULT_CAMERA_ENABLE,
|
|
37
41
|
timeAutoLock: DEFAULT_AUTO_LOCK_TIME,
|
|
38
42
|
enableChainPatrol: DEFAULT_CHAIN_PATROL_ENABLE,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _cache = _interopRequireDefault(require("./cache"));
|
|
9
|
+
// Copyright 2017-2022 @polkadot/react-components authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
const loaders = {};
|
|
13
|
+
class Backend {
|
|
14
|
+
type = 'backend';
|
|
15
|
+
static type = 'backend';
|
|
16
|
+
async read(lng, _namespace, responder) {
|
|
17
|
+
if (_cache.default[lng]) {
|
|
18
|
+
return responder(null, _cache.default[lng]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
22
|
+
if (!loaders[lng]) {
|
|
23
|
+
loaders[lng] = this.createLoader(lng);
|
|
24
|
+
}
|
|
25
|
+
const [error, data] = await loaders[lng];
|
|
26
|
+
return responder(error, data);
|
|
27
|
+
}
|
|
28
|
+
async createLoader(lng) {
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetch(`locales/${lng}/translation.json`, {});
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
return [`i18n: failed loading ${lng}`, response.status >= 500 && response.status < 600];
|
|
33
|
+
} else {
|
|
34
|
+
_cache.default[lng] = await response.json();
|
|
35
|
+
return [null, _cache.default[lng]];
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
return [error.message, false];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = Backend;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
// Copyright 2017-2022 @polkadot/react-components authors & contributors
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
10
|
+
const languageCache = {};
|
|
11
|
+
var _default = languageCache;
|
|
12
|
+
exports.default = _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InternalTranslation = exports.ExternalTranslation = void 0;
|
|
7
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
8
|
+
// Copyright 2017-2022 @subwallet/extension-base authors & contributors
|
|
9
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
|
|
11
|
+
const ExternalTranslation = [
|
|
12
|
+
// Case change password
|
|
13
|
+
(0, _utils.detectTranslate)('Invalid master password')];
|
|
14
|
+
exports.ExternalTranslation = ExternalTranslation;
|
|
15
|
+
const InternalTranslation = [];
|
|
16
|
+
exports.InternalTranslation = InternalTranslation;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _constants = require("@subwallet/extension-base/constants");
|
|
9
|
+
var _i18next = _interopRequireDefault(require("i18next"));
|
|
10
|
+
var _Backend = _interopRequireDefault(require("./Backend"));
|
|
11
|
+
// Copyright 2019-2022 @polkadot/extension-ui authors & contributors
|
|
12
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
13
|
+
|
|
14
|
+
_i18next.default.use(_Backend.default).init({
|
|
15
|
+
backend: {},
|
|
16
|
+
debug: false,
|
|
17
|
+
fallbackLng: 'en',
|
|
18
|
+
interpolation: {
|
|
19
|
+
escapeValue: false
|
|
20
|
+
},
|
|
21
|
+
keySeparator: false,
|
|
22
|
+
lng: localStorage.getItem(_constants.LANGUAGE) || 'en',
|
|
23
|
+
load: 'languageOnly',
|
|
24
|
+
nsSeparator: false,
|
|
25
|
+
returnEmptyString: false,
|
|
26
|
+
returnNull: false
|
|
27
|
+
}).catch(error => console.log('i18n: failure', error));
|
|
28
|
+
var _default = _i18next.default;
|
|
29
|
+
exports.default = _default;
|