@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.
Files changed (106) hide show
  1. package/background/KoniTypes.d.ts +13 -1
  2. package/background/KoniTypes.js +5 -0
  3. package/background/errors/BalanceError.js +7 -5
  4. package/background/errors/EvmProviderError.js +10 -8
  5. package/background/errors/ProviderError.js +5 -4
  6. package/background/errors/TransactionError.js +22 -17
  7. package/background/handlers/Extension.js +18 -18
  8. package/background/handlers/State.js +5 -5
  9. package/background/handlers/Tabs.js +1 -1
  10. package/background/warnings/TransactionWarning.js +4 -2
  11. package/cjs/background/KoniTypes.js +7 -1
  12. package/cjs/background/errors/BalanceError.js +7 -5
  13. package/cjs/background/errors/EvmProviderError.js +10 -8
  14. package/cjs/background/errors/ProviderError.js +5 -4
  15. package/cjs/background/errors/TransactionError.js +22 -17
  16. package/cjs/background/handlers/Extension.js +18 -18
  17. package/cjs/background/handlers/State.js +5 -5
  18. package/cjs/background/handlers/Tabs.js +1 -1
  19. package/cjs/background/warnings/TransactionWarning.js +4 -2
  20. package/cjs/constants/i18n.js +4 -1
  21. package/cjs/constants/index.js +12 -0
  22. package/cjs/constants/storage.js +11 -0
  23. package/cjs/koni/api/dotsama/domain.js +3 -1
  24. package/cjs/koni/api/dotsama/parseTransaction.js +2 -1
  25. package/cjs/koni/api/nft/acala_nft/index.js +1 -1
  26. package/cjs/koni/api/nft/karura_nft/index.js +1 -1
  27. package/cjs/koni/api/nft/nft.js +3 -0
  28. package/cjs/koni/api/nft/wasm_nft/index.js +25 -7
  29. package/cjs/koni/api/staking/bonding/paraChain.js +10 -6
  30. package/cjs/koni/api/staking/bonding/relayChain.js +16 -7
  31. package/cjs/koni/api/staking/bonding/utils.js +80 -7
  32. package/cjs/koni/api/tokens/wasm/index.js +14 -0
  33. package/cjs/koni/background/cron.js +1 -1
  34. package/cjs/koni/background/handlers/Extension.js +206 -170
  35. package/cjs/koni/background/handlers/State.js +19 -14
  36. package/cjs/koni/background/handlers/Tabs.js +15 -14
  37. package/cjs/packageInfo.js +1 -1
  38. package/cjs/services/balance-service/index.js +12 -3
  39. package/cjs/services/chain-service/helper/index.js +8 -2
  40. package/cjs/services/request-service/handler/AuthRequestHandler.js +4 -4
  41. package/cjs/services/request-service/handler/EvmRequestHandler.js +11 -10
  42. package/cjs/services/setting-service/SettingService.js +20 -7
  43. package/cjs/services/setting-service/constants.js +5 -1
  44. package/cjs/services/setting-service/i18n/Backend.js +42 -0
  45. package/cjs/services/setting-service/i18n/cache.js +12 -0
  46. package/cjs/services/setting-service/i18n/extend.js +16 -0
  47. package/cjs/services/setting-service/i18n/i18n.js +29 -0
  48. package/cjs/services/transaction-service/index.js +25 -16
  49. package/cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js +0 -1
  50. package/cjs/services/wallet-connect-service/index.js +18 -10
  51. package/cjs/utils/eth/parseTransaction/base.js +1 -1
  52. package/cjs/utils/eth/parseTransaction/index.js +2 -1
  53. package/cjs/utils/index.js +2 -1
  54. package/constants/i18n.js +4 -1
  55. package/constants/index.d.ts +1 -0
  56. package/constants/index.js +2 -1
  57. package/constants/storage.d.ts +1 -0
  58. package/constants/storage.js +4 -0
  59. package/koni/api/dotsama/domain.d.ts +1 -0
  60. package/koni/api/dotsama/domain.js +1 -0
  61. package/koni/api/dotsama/parseTransaction.js +2 -1
  62. package/koni/api/nft/acala_nft/index.js +1 -1
  63. package/koni/api/nft/karura_nft/index.js +1 -1
  64. package/koni/api/nft/nft.js +3 -0
  65. package/koni/api/nft/wasm_nft/index.js +26 -8
  66. package/koni/api/staking/bonding/paraChain.js +11 -7
  67. package/koni/api/staking/bonding/relayChain.js +17 -8
  68. package/koni/api/staking/bonding/utils.d.ts +4 -0
  69. package/koni/api/staking/bonding/utils.js +70 -2
  70. package/koni/api/tokens/wasm/index.d.ts +2 -0
  71. package/koni/api/tokens/wasm/index.js +13 -1
  72. package/koni/background/cron.js +1 -1
  73. package/koni/background/handlers/Extension.d.ts +1 -0
  74. package/koni/background/handlers/Extension.js +85 -50
  75. package/koni/background/handlers/State.js +19 -14
  76. package/koni/background/handlers/Tabs.js +15 -14
  77. package/package.json +34 -12
  78. package/packageInfo.js +1 -1
  79. package/services/balance-service/index.js +12 -3
  80. package/services/chain-service/helper/azero_domain_registry_abi.json +5428 -0
  81. package/services/chain-service/helper/index.d.ts +2 -0
  82. package/services/chain-service/helper/index.js +5 -1
  83. package/services/chain-service/helper/pink_psp34_abi.json +2758 -0
  84. package/services/request-service/handler/AuthRequestHandler.js +4 -4
  85. package/services/request-service/handler/EvmRequestHandler.js +11 -10
  86. package/services/setting-service/SettingService.d.ts +1 -0
  87. package/services/setting-service/SettingService.js +17 -5
  88. package/services/setting-service/constants.d.ts +2 -1
  89. package/services/setting-service/constants.js +4 -1
  90. package/services/setting-service/i18n/Backend.d.ts +9 -0
  91. package/services/setting-service/i18n/Backend.js +34 -0
  92. package/services/setting-service/i18n/cache.d.ts +2 -0
  93. package/services/setting-service/i18n/cache.js +5 -0
  94. package/services/setting-service/i18n/extend.d.ts +2 -0
  95. package/services/setting-service/i18n/extend.js +8 -0
  96. package/services/setting-service/i18n/i18n.d.ts +2 -0
  97. package/services/setting-service/i18n/i18n.js +21 -0
  98. package/services/transaction-service/index.js +25 -16
  99. package/services/wallet-connect-service/handler/PolkadotRequestHandler.js +0 -1
  100. package/services/wallet-connect-service/index.js +18 -10
  101. package/utils/eth/parseTransaction/base.js +1 -1
  102. package/utils/eth/parseTransaction/index.js +2 -1
  103. package/utils/index.js +2 -1
  104. package/cjs/utils/keyring.js +0 -57
  105. package/utils/keyring.d.ts +0 -4
  106. package/utils/keyring.js +0 -49
@@ -4,7 +4,9 @@
4
4
  import { StakingStatus, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
5
5
  import { getAstarWithdrawable } from '@subwallet/extension-base/koni/api/staking/bonding/astar';
6
6
  import { _KNOWN_CHAIN_INFLATION_PARAMS, _STAKING_CHAIN_GROUP, _SUBSTRATE_DEFAULT_INFLATION_PARAMS } from '@subwallet/extension-base/services/chain-service/constants';
7
- import { parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
7
+ import { _getChainNativeTokenBasicInfo } from '@subwallet/extension-base/services/chain-service/utils';
8
+ import { detectTranslate, parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
9
+ import { t } from 'i18next';
8
10
  import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_THOUSAND, BN_ZERO, bnToU8a, stringToU8a, u8aConcat } from '@polkadot/util';
9
11
  export let PalletParachainStakingRequestType;
10
12
  (function (PalletParachainStakingRequestType) {
@@ -249,4 +251,70 @@ export function getValidatorLabel(chain) {
249
251
  return 'Validator';
250
252
  }
251
253
  return 'Collator';
252
- }
254
+ }
255
+ export const getMinStakeErrorMessage = (chainInfo, bnMinStake) => {
256
+ const tokenInfo = _getChainNativeTokenBasicInfo(chainInfo);
257
+ const number = bnMinStake.div(new BN(10).pow(new BN(tokenInfo.decimals))).toString();
258
+ return t('Insufficient stake. Please stake at least {{number}} {{tokenSymbol}} to get rewards', {
259
+ replace: {
260
+ tokenSymbol: tokenInfo.symbol,
261
+ number
262
+ }
263
+ });
264
+ };
265
+ export const getMaxValidatorErrorMessage = (chainInfo, max) => {
266
+ let message = detectTranslate('You cannot select more than {{number}} validators for this network');
267
+ const label = getValidatorLabel(chainInfo.slug);
268
+ if (max > 1) {
269
+ switch (label) {
270
+ case 'dApp':
271
+ message = detectTranslate('You cannot select more than {{number}} dApps for this network');
272
+ break;
273
+ case 'Collator':
274
+ message = detectTranslate('You cannot select more than {{number}} collators for this network');
275
+ break;
276
+ case 'Validator':
277
+ message = detectTranslate('You cannot select more than {{number}} validators for this network');
278
+ break;
279
+ }
280
+ } else {
281
+ switch (label) {
282
+ case 'dApp':
283
+ message = detectTranslate('You cannot select more than {{number}} dApp for this network');
284
+ break;
285
+ case 'Collator':
286
+ message = detectTranslate('You cannot select more than {{number}} collator for this network');
287
+ break;
288
+ case 'Validator':
289
+ message = detectTranslate('You cannot select more than {{number}} validator for this network');
290
+ break;
291
+ }
292
+ }
293
+ return t(message, {
294
+ replace: {
295
+ number: max
296
+ }
297
+ });
298
+ };
299
+ export const getExistUnstakeErrorMessage = (chain, isStakeMore) => {
300
+ const label = getValidatorLabel(chain);
301
+ if (!isStakeMore) {
302
+ switch (label) {
303
+ case 'dApp':
304
+ return t('You can unstake from a dApp once');
305
+ case 'Collator':
306
+ return t('You can unstake from a collator once');
307
+ case 'Validator':
308
+ return t('You can unstake from a validator once');
309
+ }
310
+ } else {
311
+ switch (label) {
312
+ case 'dApp':
313
+ return t('You cannot stake more for a dApp you are unstaking from');
314
+ case 'Collator':
315
+ return t('You cannot stake more for a collator you are unstaking from');
316
+ case 'Validator':
317
+ return t('You cannot stake more for a validator you are unstaking from');
318
+ }
319
+ }
320
+ };
@@ -2,5 +2,7 @@ import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/
2
2
  import { ApiPromise } from '@polkadot/api';
3
3
  import { ContractPromise } from '@polkadot/api-contract';
4
4
  export declare function getPSP22ContractPromise(apiPromise: ApiPromise, contractAddress: string): ContractPromise;
5
+ export declare function isPinkRoboNft(contractAddress: string): boolean;
6
+ export declare function isAzeroDomainNft(contractAddress: string): boolean;
5
7
  export declare function getPSP34ContractPromise(apiPromise: ApiPromise, contractAddress: string): ContractPromise;
6
8
  export declare function getPSP34TransferExtrinsic(networkKey: string, substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null>;
@@ -2,12 +2,24 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { getWasmContractGasLimit } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
5
- import { _PSP22_ABI, _PSP34_ABI } from '@subwallet/extension-base/services/chain-service/helper';
5
+ import { _AZERO_DOMAIN_REGISTRY_ABI, _PINK_PSP34_ABI, _PSP22_ABI, _PSP34_ABI } from '@subwallet/extension-base/services/chain-service/helper';
6
6
  import { ContractPromise } from '@polkadot/api-contract';
7
7
  export function getPSP22ContractPromise(apiPromise, contractAddress) {
8
8
  return new ContractPromise(apiPromise, _PSP22_ABI, contractAddress);
9
9
  }
10
+ export function isPinkRoboNft(contractAddress) {
11
+ return ['XoywUxTTtNKPRrRN7V5KXCqz2QLMFeK7DxhpSniqZHps5Xq'].includes(contractAddress);
12
+ }
13
+ export function isAzeroDomainNft(contractAddress) {
14
+ return ['5FsB91tXSEuMj6akzdPczAtmBaVKToqHmtAwSUzXh49AYzaD', '5CTQBfBC9SfdrCDBJdfLiyW2pg9z5W6C6Es8sK313BLnFgDf'].includes(contractAddress);
15
+ }
10
16
  export function getPSP34ContractPromise(apiPromise, contractAddress) {
17
+ if (isPinkRoboNft(contractAddress)) {
18
+ return new ContractPromise(apiPromise, _PINK_PSP34_ABI, contractAddress);
19
+ }
20
+ if (isAzeroDomainNft(contractAddress)) {
21
+ return new ContractPromise(apiPromise, _AZERO_DOMAIN_REGISTRY_ABI, contractAddress);
22
+ }
11
23
  return new ContractPromise(apiPromise, _PSP34_ABI, contractAddress);
12
24
  }
13
25
  const mustFormatNumberReg = /^-?[0-9][0-9,.]+$/;
@@ -105,7 +105,7 @@ export class KoniCron {
105
105
  this.resetNft(currentAccountInfo.address);
106
106
  this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
107
107
  this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
108
- this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
108
+ this.addCron('refreshPoolingSta kingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
109
109
  this.addCron('syncMantaPay', this.syncMantaPay, CRON_SYNC_MANTA_PAY);
110
110
  } else {
111
111
  this.setStakingRewardReady();
@@ -74,6 +74,7 @@ export default class KoniExtension {
74
74
  private setCamera;
75
75
  private saveBrowserConfirmationType;
76
76
  private setAutoLockTime;
77
+ private setUnlockType;
77
78
  private subscribeSettings;
78
79
  private setEnableChainPatrol;
79
80
  private setShowZeroBalance;
@@ -38,6 +38,7 @@ import { keyring } from '@subwallet/ui-keyring';
38
38
  import { getSdkError } from '@walletconnect/utils';
39
39
  import BigN from 'bignumber.js';
40
40
  import { Transaction } from 'ethereumjs-tx';
41
+ import { t } from 'i18next';
41
42
  import { TypeRegistry } from '@polkadot/types';
42
43
  import { assert, BN, BN_ZERO, hexStripPrefix, hexToU8a, isAscii, isHex, u8aToHex, u8aToString } from '@polkadot/util';
43
44
  import { addressToEvm, base64Decode, decodeAddress, isAddress, isEthereumAddress, jsonDecrypt, keyExtractSuri, mnemonicGenerate, mnemonicValidate } from '@polkadot/util-crypto';
@@ -130,14 +131,14 @@ export default class KoniExtension {
130
131
  oldPass
131
132
  }) {
132
133
  const pair = keyring.getPair(address);
133
- assert(pair, 'Unable to find pair');
134
+ assert(pair, t('Unable to find account'));
134
135
  try {
135
136
  if (!pair.isLocked) {
136
137
  pair.lock();
137
138
  }
138
139
  pair.decodePkcs8(oldPass);
139
140
  } catch (error) {
140
- throw new Error('oldPass is invalid');
141
+ throw new Error(t('Wrong password'));
141
142
  }
142
143
  keyring.encryptAccount(pair, newPass);
143
144
  return true;
@@ -147,7 +148,7 @@ export default class KoniExtension {
147
148
  name
148
149
  }) {
149
150
  const pair = keyring.getPair(address);
150
- assert(pair, 'Unable to find pair');
151
+ assert(pair, t('Unable to find account'));
151
152
  keyring.saveAccountMeta(pair, {
152
153
  ...pair.meta,
153
154
  name
@@ -167,7 +168,7 @@ export default class KoniExtension {
167
168
  isShowing
168
169
  }) {
169
170
  const pair = keyring.getPair(address);
170
- assert(pair, 'Unable to find pair');
171
+ assert(pair, t('Unable to find account'));
171
172
  keyring.saveAccountMeta(pair, {
172
173
  ...pair.meta,
173
174
  isHidden: !isShowing
@@ -201,7 +202,7 @@ export default class KoniExtension {
201
202
  id
202
203
  }) {
203
204
  const queued = this.#koniState.getMetaRequest(id);
204
- assert(queued, 'Unable to find request');
205
+ assert(queued, t('Unable to proceed. Please try again'));
205
206
  const {
206
207
  request,
207
208
  resolve
@@ -220,7 +221,7 @@ export default class KoniExtension {
220
221
  id
221
222
  }) {
222
223
  const queued = this.#koniState.getMetaRequest(id);
223
- assert(queued, 'Unable to find request');
224
+ assert(queued, t('Unable to proceed. Please try again'));
224
225
  const {
225
226
  reject
226
227
  } = queued;
@@ -296,11 +297,15 @@ export default class KoniExtension {
296
297
  phrase
297
298
  } = keyExtractSuri(suri);
298
299
  if (isHex(phrase)) {
299
- assert(isHex(phrase, 256), 'Hex seed needs to be 256-bits');
300
+ assert(isHex(phrase, 256), t('Invalid seed phrase. Please try again.'));
300
301
  } else {
301
302
  // sadly isHex detects as string, so we need a cast here
302
- assert(SEED_LENGTHS.includes(phrase.split(' ').length), `Mnemonic needs to contain ${SEED_LENGTHS.join(', ')} words`);
303
- assert(mnemonicValidate(phrase), 'Not a valid mnemonic seed');
303
+ assert(SEED_LENGTHS.includes(phrase.split(' ').length), t('Seed phrase needs to contain {{x}} words', {
304
+ replace: {
305
+ x: SEED_LENGTHS.join(', ')
306
+ }
307
+ }));
308
+ assert(mnemonicValidate(phrase), t('Invalid seed phrase. Please try again.'));
304
309
  }
305
310
  return {
306
311
  address: keyring.createFromUri(getSuri(suri, type), {}, type).address,
@@ -314,7 +319,7 @@ export default class KoniExtension {
314
319
  signature
315
320
  }) {
316
321
  const queued = this.#koniState.getSignRequest(id);
317
- assert(queued, 'Unable to find request');
322
+ assert(queued, t('Unable to proceed. Please try again'));
318
323
  const {
319
324
  resolve
320
325
  } = queued;
@@ -330,7 +335,7 @@ export default class KoniExtension {
330
335
  id
331
336
  }) {
332
337
  const queued = this.#koniState.getSignRequest(id);
333
- assert(queued, 'Unable to find request');
338
+ assert(queued, t('Unable to proceed. Please try again'));
334
339
  const {
335
340
  reject
336
341
  } = queued;
@@ -379,12 +384,16 @@ export default class KoniExtension {
379
384
  try {
380
385
  parentPair.decodePkcs8(password);
381
386
  } catch (e) {
382
- throw new Error('invalid password');
387
+ throw new Error(t('Wrong password'));
383
388
  }
384
389
  try {
385
390
  return parentPair.derive(suri, metadata);
386
391
  } catch (err) {
387
- throw new Error(`"${suri}" is not a valid derivation path`);
392
+ throw new Error(t('"{{suri}}" is not a valid derivation path', {
393
+ replace: {
394
+ suri
395
+ }
396
+ }));
388
397
  }
389
398
  }
390
399
  derivationValidate({
@@ -518,7 +527,7 @@ export default class KoniExtension {
518
527
  publicKey: decodeAddress(address)
519
528
  };
520
529
  } else {
521
- throw Error('Invalid address');
530
+ throw Error(t('This is not an address'));
522
531
  }
523
532
  }
524
533
  editContactAccount({
@@ -530,7 +539,7 @@ export default class KoniExtension {
530
539
  keyring.saveAddress(_address, meta);
531
540
  return true;
532
541
  } else {
533
- throw Error('Invalid address');
542
+ throw Error(t('This is not an address'));
534
543
  }
535
544
  }
536
545
  deleteContactAccount({
@@ -541,7 +550,7 @@ export default class KoniExtension {
541
550
  keyring.forgetAddress(_address);
542
551
  return true;
543
552
  } else {
544
- throw Error('Invalid address');
553
+ throw Error(t('This is not an address'));
545
554
  }
546
555
  }
547
556
  _getAuthListV2() {
@@ -589,7 +598,7 @@ export default class KoniExtension {
589
598
  id
590
599
  }) {
591
600
  const queued = this.#koniState.getAuthRequestV2(id);
592
- assert(queued, 'Unable to find request');
601
+ assert(queued, t('Unable to proceed. Please try again'));
593
602
  const {
594
603
  resolve
595
604
  } = queued;
@@ -603,7 +612,7 @@ export default class KoniExtension {
603
612
  id
604
613
  }) {
605
614
  const queued = this.#koniState.getAuthRequestV2(id);
606
- assert(queued, 'Unable to find request');
615
+ assert(queued, t('Unable to proceed. Please try again'));
607
616
  const {
608
617
  reject
609
618
  } = queued;
@@ -614,7 +623,7 @@ export default class KoniExtension {
614
623
  id
615
624
  }) {
616
625
  const queued = this.#koniState.getAuthRequestV2(id);
617
- assert(queued, 'Unable to find request');
626
+ assert(queued, t('Unable to proceed. Please try again'));
618
627
  const {
619
628
  reject
620
629
  } = queued;
@@ -849,6 +858,12 @@ export default class KoniExtension {
849
858
  this.#koniState.updateSetting('timeAutoLock', autoLockTime);
850
859
  return true;
851
860
  }
861
+ setUnlockType({
862
+ unlockType
863
+ }) {
864
+ this.#koniState.updateSetting('unlockType', unlockType);
865
+ return true;
866
+ }
852
867
  async subscribeSettings(id, port) {
853
868
  const cb = createSubscription(id, port);
854
869
  const balancesVisibilitySubscription = this.#koniState.subscribeSettingsSubject().subscribe({
@@ -1071,7 +1086,7 @@ export default class KoniExtension {
1071
1086
  const hasMasterPassword = keyring.keyring.hasMasterPassword;
1072
1087
  if (!hasMasterPassword) {
1073
1088
  if (!password) {
1074
- throw Error('Require password to set up master password');
1089
+ throw Error(t('The password of each account is needed to set up master password'));
1075
1090
  } else {
1076
1091
  keyring.changeMasterPassword(password);
1077
1092
  this.#koniState.updateKeyringState();
@@ -1171,11 +1186,15 @@ export default class KoniExtension {
1171
1186
  phrase
1172
1187
  } = keyExtractSuri(suri);
1173
1188
  if (isHex(phrase)) {
1174
- assert(isHex(phrase, 256), 'Hex seed needs to be 256-bits');
1189
+ assert(isHex(phrase, 256), t('Invalid seed phrase. Please try again.'));
1175
1190
  } else {
1176
1191
  // sadly isHex detects as string, so we need a cast here
1177
- assert(SEED_LENGTHS.includes(phrase.split(' ').length), `Mnemonic needs to contain ${SEED_LENGTHS.join(', ')} words`);
1178
- assert(mnemonicValidate(phrase), 'Not a valid mnemonic seed');
1192
+ assert(SEED_LENGTHS.includes(phrase.split(' ').length), t('Seed phrase needs to contain {{x}} words', {
1193
+ replace: {
1194
+ x: SEED_LENGTHS.join(', ')
1195
+ }
1196
+ }));
1197
+ assert(mnemonicValidate(phrase), t('Invalid seed phrase. Please try again.'));
1179
1198
  }
1180
1199
  const rs = {
1181
1200
  seed: suri,
@@ -1207,7 +1226,7 @@ export default class KoniExtension {
1207
1226
  });
1208
1227
  } else {
1209
1228
  rs.autoAddPrefix = false;
1210
- assert(false, 'Not valid private key');
1229
+ assert(false, t('Invalid private key. Please try again.'));
1211
1230
  }
1212
1231
  return rs;
1213
1232
  }
@@ -1236,7 +1255,11 @@ export default class KoniExtension {
1236
1255
  try {
1237
1256
  return parentPair.derive(suri, metadata);
1238
1257
  } catch (err) {
1239
- throw new Error(`"${suri}" is not a valid derivation path`);
1258
+ throw new Error(t('"{{suri}}" is not a valid derivation path', {
1259
+ replace: {
1260
+ suri
1261
+ }
1262
+ }));
1240
1263
  }
1241
1264
  }
1242
1265
  derivationCreateV2({
@@ -1277,7 +1300,7 @@ export default class KoniExtension {
1277
1300
  throw new Error(error.message);
1278
1301
  }
1279
1302
  } else {
1280
- throw new Error('Unable to decode using the supplied passphrase');
1303
+ throw new Error(t('Wrong password'));
1281
1304
  }
1282
1305
  }
1283
1306
  batchRestoreV2({
@@ -1298,7 +1321,7 @@ export default class KoniExtension {
1298
1321
  throw new Error(error.message);
1299
1322
  }
1300
1323
  } else {
1301
- throw new Error('Unable to decode using the supplied passphrase');
1324
+ throw new Error(t('Wrong password'));
1302
1325
  }
1303
1326
  }
1304
1327
  getNftCollection() {
@@ -1405,7 +1428,7 @@ export default class KoniExtension {
1405
1428
  let transferValue;
1406
1429
  if (!transferAll) {
1407
1430
  if (value === undefined) {
1408
- errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, 'Require transfer value'));
1431
+ errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, t('Transfer amount is required')));
1409
1432
  }
1410
1433
  if (value) {
1411
1434
  transferValue = new BN(value);
@@ -1413,10 +1436,10 @@ export default class KoniExtension {
1413
1436
  }
1414
1437
  const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1415
1438
  if (!tokenInfo) {
1416
- errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, 'Not found token from registry'));
1439
+ errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, t('Not found token from registry')));
1417
1440
  }
1418
1441
  if (isEthereumAddress(from) && isEthereumAddress(to) && _isTokenEvmSmartContract(tokenInfo) && _getContractAddressOfToken(tokenInfo).length === 0) {
1419
- errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, 'Not found ERC20 address for this token'));
1442
+ errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, t('Not found ERC20 address for this token')));
1420
1443
  }
1421
1444
  return [errors, keypair, transferValue, tokenInfo];
1422
1445
  }
@@ -1484,7 +1507,7 @@ export default class KoniExtension {
1484
1507
  } catch (e) {
1485
1508
  const error = e;
1486
1509
  if (error.message.includes('transfer amount exceeds balance')) {
1487
- error.message = 'Not enough balance';
1510
+ error.message = t('Insufficient balance');
1488
1511
  }
1489
1512
  throw error;
1490
1513
  }
@@ -1505,7 +1528,7 @@ export default class KoniExtension {
1505
1528
  token: tokenSlug
1506
1529
  });
1507
1530
  if (new BigN(balance).minus(transferAmount.value).lt(minAmount)) {
1508
- inputTransaction.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
1531
+ inputTransaction.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
1509
1532
  }
1510
1533
  }
1511
1534
  const {
@@ -1520,7 +1543,12 @@ export default class KoniExtension {
1520
1543
  if (new BigN(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
1521
1544
  const atLeast = new BigN(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
1522
1545
  const atLeastStr = formatNumber(atLeast, tokenInfo.decimals || 0, balanceFormatter);
1523
- inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, `You must transfer at least ${atLeastStr} ${tokenInfo.symbol} to keep the destination account alive`));
1546
+ inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
1547
+ replace: {
1548
+ amount: atLeastStr,
1549
+ symbol: tokenInfo.symbol
1550
+ }
1551
+ })));
1524
1552
  }
1525
1553
  };
1526
1554
  return this.#koniState.transactionService.handleTransaction({
@@ -1546,7 +1574,7 @@ export default class KoniExtension {
1546
1574
  const originTokenInfo = this.#koniState.getAssetBySlug(sendingTokenSlug);
1547
1575
  const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destinationNetworkKey, sendingTokenSlug);
1548
1576
  if (!destinationTokenInfo) {
1549
- errors.push(new TransactionError(TransferTxErrorType.INVALID_TOKEN, 'Not found token from registry'));
1577
+ errors.push(new TransactionError(TransferTxErrorType.INVALID_TOKEN, t('Not found token from registry')));
1550
1578
  }
1551
1579
  return [errors, keypair, transferValue, originTokenInfo, destinationTokenInfo];
1552
1580
  }
@@ -1584,7 +1612,12 @@ export default class KoniExtension {
1584
1612
  // Check ed for receiver
1585
1613
  if (new BigN(value).lt(atLeast)) {
1586
1614
  const atLeastStr = formatNumber(atLeast, destinationTokenInfo.decimals || 0, balanceFormatter);
1587
- inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, `You must transfer at least ${atLeastStr} ${originTokenInfo.symbol} to keep the destination account alive`));
1615
+ inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
1616
+ replace: {
1617
+ amount: atLeastStr,
1618
+ symbol: originTokenInfo.symbol
1619
+ }
1620
+ })));
1588
1621
  }
1589
1622
  const srcMinAmount = originTokenInfo.minAmount || '0';
1590
1623
  const isTransferNativeToken = originTokenInfo.assetType === _AssetType.NATIVE;
@@ -1599,7 +1632,7 @@ export default class KoniExtension {
1599
1632
  token: originTokenInfo.slug
1600
1633
  });
1601
1634
  if (new BigN(balance).minus(value).lt(srcMinAmount)) {
1602
- inputTransaction.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
1635
+ inputTransaction.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
1603
1636
  }
1604
1637
  }
1605
1638
  };
@@ -1811,7 +1844,7 @@ export default class KoniExtension {
1811
1844
  }
1812
1845
  } catch (e) {
1813
1846
  estimatedFee = '0';
1814
- console.warn('Error estimating fee', e);
1847
+ console.warn('Unable to estimate fee', e);
1815
1848
  }
1816
1849
  maxTransferable = maxTransferable.sub(new BN(estimatedFee));
1817
1850
  return {
@@ -1903,7 +1936,7 @@ export default class KoniExtension {
1903
1936
  address
1904
1937
  }) {
1905
1938
  const pair = keyring.getPair(address);
1906
- assert(pair, 'Unable to find pair');
1939
+ assert(pair, t('Unable to find account'));
1907
1940
  return {
1908
1941
  meta: pair.meta
1909
1942
  };
@@ -1930,7 +1963,7 @@ export default class KoniExtension {
1930
1963
  if (exists.type === (isEthereum ? 'ethereum' : 'sr25519')) {
1931
1964
  return [{
1932
1965
  code: AccountExternalErrorCode.INVALID_ADDRESS,
1933
- message: 'Account exists'
1966
+ message: t('Account exists')
1934
1967
  }];
1935
1968
  }
1936
1969
  }
@@ -2016,7 +2049,7 @@ export default class KoniExtension {
2016
2049
  }) {
2017
2050
  const addresses = [];
2018
2051
  if (!accounts.length) {
2019
- throw new Error('No accounts to import');
2052
+ throw new Error(t("Can't find an account. Please try again"));
2020
2053
  }
2021
2054
  const slugMap = {};
2022
2055
  for (const account of accounts) {
@@ -2128,7 +2161,7 @@ export default class KoniExtension {
2128
2161
  success: false,
2129
2162
  errors: [{
2130
2163
  code: AccountExternalErrorCode.KEYRING_ERROR,
2131
- message: 'Invalid keyring'
2164
+ message: t('Cannot create account')
2132
2165
  }]
2133
2166
  };
2134
2167
  }
@@ -2262,7 +2295,7 @@ export default class KoniExtension {
2262
2295
  networkKey
2263
2296
  }) {
2264
2297
  const pair = keyring.getPair(address);
2265
- assert(pair, 'Unable to find pair');
2298
+ assert(pair, t('Unable to find account'));
2266
2299
  if (pair.isLocked) {
2267
2300
  keyring.unlockPair(pair.address);
2268
2301
  }
@@ -2286,11 +2319,11 @@ export default class KoniExtension {
2286
2319
  let signed;
2287
2320
  const network = this.getNetworkJsonByChainId(chainId);
2288
2321
  if (!network) {
2289
- throw new Error('Cannot find network');
2322
+ throw new Error(t('Cannot find network'));
2290
2323
  }
2291
2324
  const pair = keyring.getPair(address);
2292
2325
  if (!pair) {
2293
- throw Error('Unable to find pair');
2326
+ throw Error(t('Unable to find account'));
2294
2327
  }
2295
2328
  if (pair.isLocked) {
2296
2329
  keyring.unlockPair(pair.address);
@@ -2306,7 +2339,7 @@ export default class KoniExtension {
2306
2339
  } else {
2307
2340
  const tx = createTransactionFromRLP(message);
2308
2341
  if (!tx) {
2309
- throw new Error(`Cannot create tx from ${message}`);
2342
+ throw new Error(t('Failed to decode data. Please use a valid QR code'));
2310
2343
  }
2311
2344
  const txObject = {
2312
2345
  gasPrice: new BigN(tx.gasPrice).toNumber(),
@@ -2655,7 +2688,7 @@ export default class KoniExtension {
2655
2688
  } catch (e) {
2656
2689
  console.error(e);
2657
2690
  return {
2658
- errors: [e.message],
2691
+ errors: [t(e.message)],
2659
2692
  status: false
2660
2693
  };
2661
2694
  }
@@ -2753,7 +2786,7 @@ export default class KoniExtension {
2753
2786
  id
2754
2787
  }) {
2755
2788
  const queued = this.#koniState.getSignRequest(id);
2756
- assert(queued, 'Unable to find request');
2789
+ assert(queued, t('Unable to proceed. Please try again'));
2757
2790
  const {
2758
2791
  reject,
2759
2792
  request,
@@ -2768,7 +2801,7 @@ export default class KoniExtension {
2768
2801
  address
2769
2802
  } = pair;
2770
2803
  if (!pair) {
2771
- reject(new Error('Unable to find pair'));
2804
+ reject(new Error(t('Unable to find account')));
2772
2805
  return false;
2773
2806
  }
2774
2807
  if (pair.isLocked) {
@@ -2841,7 +2874,7 @@ export default class KoniExtension {
2841
2874
  }
2842
2875
  } catch (e) {}
2843
2876
  if (!index) {
2844
- throw Error('Invalid derive path');
2877
+ throw Error(t('Invalid derive path'));
2845
2878
  }
2846
2879
  meta.suri = `//${index}`;
2847
2880
  return parentPair.deriveEvm(index, meta);
@@ -2929,7 +2962,7 @@ export default class KoniExtension {
2929
2962
  }
2930
2963
  } catch (e) {}
2931
2964
  if (!index) {
2932
- throw Error('Invalid derive path');
2965
+ throw Error(t('Invalid derive path'));
2933
2966
  }
2934
2967
  meta.suri = `//${index}`;
2935
2968
  childPair = parentPair.deriveEvm(index, meta);
@@ -3508,6 +3541,8 @@ export default class KoniExtension {
3508
3541
  return this.saveBrowserConfirmationType(request);
3509
3542
  case 'pri(settings.saveAutoLockTime)':
3510
3543
  return this.setAutoLockTime(request);
3544
+ case 'pri(settings.saveUnlockType)':
3545
+ return this.setUnlockType(request);
3511
3546
  case 'pri(settings.saveEnableChainPatrol)':
3512
3547
  return this.setEnableChainPatrol(request);
3513
3548
  case 'pri(settings.saveShowZeroBalance)':