@subwallet/extension-base 1.1.9-0 → 1.1.11-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 (102) 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/defaults.js +3 -1
  24. package/cjs/koni/api/dotsama/parseTransaction.js +2 -1
  25. package/cjs/koni/api/nft/config.js +10 -12
  26. package/cjs/koni/api/staking/bonding/paraChain.js +10 -6
  27. package/cjs/koni/api/staking/bonding/relayChain.js +16 -7
  28. package/cjs/koni/api/staking/bonding/utils.js +80 -7
  29. package/cjs/koni/background/handlers/Extension.js +256 -183
  30. package/cjs/koni/background/handlers/State.js +19 -14
  31. package/cjs/koni/background/handlers/Tabs.js +15 -14
  32. package/cjs/packageInfo.js +1 -1
  33. package/cjs/services/balance-service/index.js +12 -3
  34. package/cjs/services/chain-service/constants.js +3 -2
  35. package/cjs/services/keyring-service/index.js +4 -0
  36. package/cjs/services/request-service/handler/AuthRequestHandler.js +4 -4
  37. package/cjs/services/request-service/handler/EvmRequestHandler.js +24 -11
  38. package/cjs/services/request-service/handler/SubstrateRequestHandler.js +10 -2
  39. package/cjs/services/request-service/index.js +1 -1
  40. package/cjs/services/setting-service/SettingService.js +29 -7
  41. package/cjs/services/setting-service/constants.js +5 -1
  42. package/cjs/services/setting-service/i18n/Backend.js +42 -0
  43. package/cjs/services/setting-service/i18n/cache.js +12 -0
  44. package/cjs/services/setting-service/i18n/extend.js +16 -0
  45. package/cjs/services/setting-service/i18n/i18n.js +29 -0
  46. package/cjs/services/transaction-service/index.js +25 -16
  47. package/cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js +0 -1
  48. package/cjs/utils/eth/parseTransaction/base.js +1 -1
  49. package/cjs/utils/eth/parseTransaction/index.js +2 -1
  50. package/cjs/utils/getId.js +1 -1
  51. package/cjs/utils/index.js +2 -1
  52. package/constants/i18n.js +4 -1
  53. package/constants/index.d.ts +1 -0
  54. package/constants/index.js +2 -1
  55. package/constants/storage.d.ts +1 -0
  56. package/constants/storage.js +4 -0
  57. package/defaults.d.ts +2 -1
  58. package/defaults.js +2 -1
  59. package/koni/api/dotsama/parseTransaction.js +2 -1
  60. package/koni/api/nft/config.d.ts +1 -1
  61. package/koni/api/nft/config.js +8 -10
  62. package/koni/api/staking/bonding/paraChain.js +11 -7
  63. package/koni/api/staking/bonding/relayChain.js +17 -8
  64. package/koni/api/staking/bonding/utils.d.ts +4 -0
  65. package/koni/api/staking/bonding/utils.js +70 -2
  66. package/koni/background/handlers/Extension.d.ts +1 -0
  67. package/koni/background/handlers/Extension.js +135 -63
  68. package/koni/background/handlers/State.js +19 -14
  69. package/koni/background/handlers/Tabs.js +15 -14
  70. package/package.json +31 -11
  71. package/packageInfo.js +1 -1
  72. package/services/balance-service/index.js +12 -3
  73. package/services/chain-service/constants.js +3 -2
  74. package/services/keyring-service/index.d.ts +1 -0
  75. package/services/keyring-service/index.js +4 -0
  76. package/services/request-service/handler/AuthRequestHandler.js +4 -4
  77. package/services/request-service/handler/EvmRequestHandler.js +24 -11
  78. package/services/request-service/handler/SubstrateRequestHandler.js +10 -2
  79. package/services/request-service/index.d.ts +1 -1
  80. package/services/request-service/index.js +1 -1
  81. package/services/setting-service/SettingService.d.ts +2 -0
  82. package/services/setting-service/SettingService.js +26 -5
  83. package/services/setting-service/constants.d.ts +2 -1
  84. package/services/setting-service/constants.js +4 -1
  85. package/services/setting-service/i18n/Backend.d.ts +9 -0
  86. package/services/setting-service/i18n/Backend.js +34 -0
  87. package/services/setting-service/i18n/cache.d.ts +2 -0
  88. package/services/setting-service/i18n/cache.js +5 -0
  89. package/services/setting-service/i18n/extend.d.ts +2 -0
  90. package/services/setting-service/i18n/extend.js +8 -0
  91. package/services/setting-service/i18n/i18n.d.ts +2 -0
  92. package/services/setting-service/i18n/i18n.js +21 -0
  93. package/services/transaction-service/index.d.ts +3 -3
  94. package/services/transaction-service/index.js +25 -16
  95. package/services/wallet-connect-service/handler/PolkadotRequestHandler.js +0 -1
  96. package/utils/eth/parseTransaction/base.js +1 -1
  97. package/utils/eth/parseTransaction/index.js +2 -1
  98. package/utils/getId.js +2 -2
  99. package/utils/index.js +2 -1
  100. package/cjs/utils/keyring.js +0 -57
  101. package/utils/keyring.d.ts +0 -4
  102. package/utils/keyring.js +0 -49
@@ -42,6 +42,7 @@ var _uiKeyring = require("@subwallet/ui-keyring");
42
42
  var _utils3 = require("@walletconnect/utils");
43
43
  var _bignumber = _interopRequireDefault(require("bignumber.js"));
44
44
  var _ethereumjsTx = require("ethereumjs-tx");
45
+ var _i18next = require("i18next");
45
46
  var _types3 = require("@polkadot/types");
46
47
  var _util = require("@polkadot/util");
47
48
  var _utilCrypto = require("@polkadot/util-crypto");
@@ -77,16 +78,31 @@ class KoniExtension {
77
78
  #koniState;
78
79
  #timeAutoLock = _constants4.DEFAULT_AUTO_LOCK_TIME;
79
80
  #skipAutoLock = false;
81
+ #alwaysLock = false;
82
+ #firstTime = true;
80
83
  constructor(state) {
81
84
  this.#koniState = state;
82
85
  const updateTimeAutoLock = rs => {
83
- this.#timeAutoLock = rs.timeAutoLock;
84
- clearTimeout(this.#lockTimeOut);
85
- this.#lockTimeOut = setTimeout(() => {
86
- if (!this.#skipAutoLock) {
87
- this.keyringLock();
86
+ // Check time auto lock change
87
+ if (this.#timeAutoLock !== rs.timeAutoLock) {
88
+ this.#timeAutoLock = rs.timeAutoLock;
89
+ this.#alwaysLock = !rs.timeAutoLock;
90
+ clearTimeout(this.#lockTimeOut);
91
+ if (this.#timeAutoLock > 0) {
92
+ this.#lockTimeOut = setTimeout(() => {
93
+ if (!this.#skipAutoLock) {
94
+ this.keyringLock();
95
+ }
96
+ }, this.#timeAutoLock * 60 * 1000);
97
+ } else if (this.#alwaysLock) {
98
+ if (!this.#firstTime) {
99
+ this.keyringLock();
100
+ }
88
101
  }
89
- }, this.#timeAutoLock * 60 * 1000);
102
+ }
103
+ if (this.#firstTime) {
104
+ this.#firstTime = false;
105
+ }
90
106
  };
91
107
  this.#koniState.settingService.getSettings(updateTimeAutoLock);
92
108
  this.#koniState.settingService.getSubject().subscribe({
@@ -144,14 +160,14 @@ class KoniExtension {
144
160
  oldPass
145
161
  } = _ref5;
146
162
  const pair = _uiKeyring.keyring.getPair(address);
147
- (0, _util.assert)(pair, 'Unable to find pair');
163
+ (0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
148
164
  try {
149
165
  if (!pair.isLocked) {
150
166
  pair.lock();
151
167
  }
152
168
  pair.decodePkcs8(oldPass);
153
169
  } catch (error) {
154
- throw new Error('oldPass is invalid');
170
+ throw new Error((0, _i18next.t)('Wrong password'));
155
171
  }
156
172
  _uiKeyring.keyring.encryptAccount(pair, newPass);
157
173
  return true;
@@ -162,7 +178,7 @@ class KoniExtension {
162
178
  name
163
179
  } = _ref6;
164
180
  const pair = _uiKeyring.keyring.getPair(address);
165
- (0, _util.assert)(pair, 'Unable to find pair');
181
+ (0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
166
182
  _uiKeyring.keyring.saveAccountMeta(pair, {
167
183
  ...pair.meta,
168
184
  name
@@ -184,7 +200,7 @@ class KoniExtension {
184
200
  isShowing
185
201
  } = _ref8;
186
202
  const pair = _uiKeyring.keyring.getPair(address);
187
- (0, _util.assert)(pair, 'Unable to find pair');
203
+ (0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
188
204
  _uiKeyring.keyring.saveAccountMeta(pair, {
189
205
  ...pair.meta,
190
206
  isHidden: !isShowing
@@ -220,7 +236,7 @@ class KoniExtension {
220
236
  id
221
237
  } = _ref10;
222
238
  const queued = this.#koniState.getMetaRequest(id);
223
- (0, _util.assert)(queued, 'Unable to find request');
239
+ (0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
224
240
  const {
225
241
  request,
226
242
  resolve
@@ -240,7 +256,7 @@ class KoniExtension {
240
256
  id
241
257
  } = _ref11;
242
258
  const queued = this.#koniState.getMetaRequest(id);
243
- (0, _util.assert)(queued, 'Unable to find request');
259
+ (0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
244
260
  const {
245
261
  reject
246
262
  } = queued;
@@ -320,11 +336,15 @@ class KoniExtension {
320
336
  phrase
321
337
  } = (0, _utilCrypto.keyExtractSuri)(suri);
322
338
  if ((0, _util.isHex)(phrase)) {
323
- (0, _util.assert)((0, _util.isHex)(phrase, 256), 'Hex seed needs to be 256-bits');
339
+ (0, _util.assert)((0, _util.isHex)(phrase, 256), (0, _i18next.t)('Invalid seed phrase. Please try again.'));
324
340
  } else {
325
341
  // sadly isHex detects as string, so we need a cast here
326
- (0, _util.assert)(_Extension.SEED_LENGTHS.includes(phrase.split(' ').length), `Mnemonic needs to contain ${_Extension.SEED_LENGTHS.join(', ')} words`);
327
- (0, _util.assert)((0, _utilCrypto.mnemonicValidate)(phrase), 'Not a valid mnemonic seed');
342
+ (0, _util.assert)(_Extension.SEED_LENGTHS.includes(phrase.split(' ').length), (0, _i18next.t)('Seed phrase needs to contain {{x}} words', {
343
+ replace: {
344
+ x: _Extension.SEED_LENGTHS.join(', ')
345
+ }
346
+ }));
347
+ (0, _util.assert)((0, _utilCrypto.mnemonicValidate)(phrase), (0, _i18next.t)('Invalid seed phrase. Please try again.'));
328
348
  }
329
349
  return {
330
350
  address: _uiKeyring.keyring.createFromUri(getSuri(suri, type), {}, type).address,
@@ -339,7 +359,7 @@ class KoniExtension {
339
359
  signature
340
360
  } = _ref16;
341
361
  const queued = this.#koniState.getSignRequest(id);
342
- (0, _util.assert)(queued, 'Unable to find request');
362
+ (0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
343
363
  const {
344
364
  resolve
345
365
  } = queued;
@@ -356,7 +376,7 @@ class KoniExtension {
356
376
  id
357
377
  } = _ref17;
358
378
  const queued = this.#koniState.getSignRequest(id);
359
- (0, _util.assert)(queued, 'Unable to find request');
379
+ (0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
360
380
  const {
361
381
  reject
362
382
  } = queued;
@@ -406,12 +426,16 @@ class KoniExtension {
406
426
  try {
407
427
  parentPair.decodePkcs8(password);
408
428
  } catch (e) {
409
- throw new Error('invalid password');
429
+ throw new Error((0, _i18next.t)('Wrong password'));
410
430
  }
411
431
  try {
412
432
  return parentPair.derive(suri, metadata);
413
433
  } catch (err) {
414
- throw new Error(`"${suri}" is not a valid derivation path`);
434
+ throw new Error((0, _i18next.t)('"{{suri}}" is not a valid derivation path', {
435
+ replace: {
436
+ suri
437
+ }
438
+ }));
415
439
  }
416
440
  }
417
441
  derivationValidate(_ref19) {
@@ -549,7 +573,7 @@ class KoniExtension {
549
573
  publicKey: (0, _utilCrypto.decodeAddress)(address)
550
574
  };
551
575
  } else {
552
- throw Error('Invalid address');
576
+ throw Error((0, _i18next.t)('This is not an address'));
553
577
  }
554
578
  }
555
579
  editContactAccount(_ref23) {
@@ -562,7 +586,7 @@ class KoniExtension {
562
586
  _uiKeyring.keyring.saveAddress(_address, meta);
563
587
  return true;
564
588
  } else {
565
- throw Error('Invalid address');
589
+ throw Error((0, _i18next.t)('This is not an address'));
566
590
  }
567
591
  }
568
592
  deleteContactAccount(_ref24) {
@@ -574,7 +598,7 @@ class KoniExtension {
574
598
  _uiKeyring.keyring.forgetAddress(_address);
575
599
  return true;
576
600
  } else {
577
- throw Error('Invalid address');
601
+ throw Error((0, _i18next.t)('This is not an address'));
578
602
  }
579
603
  }
580
604
  _getAuthListV2() {
@@ -623,7 +647,7 @@ class KoniExtension {
623
647
  id
624
648
  } = _ref25;
625
649
  const queued = this.#koniState.getAuthRequestV2(id);
626
- (0, _util.assert)(queued, 'Unable to find request');
650
+ (0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
627
651
  const {
628
652
  resolve
629
653
  } = queued;
@@ -638,7 +662,7 @@ class KoniExtension {
638
662
  id
639
663
  } = _ref26;
640
664
  const queued = this.#koniState.getAuthRequestV2(id);
641
- (0, _util.assert)(queued, 'Unable to find request');
665
+ (0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
642
666
  const {
643
667
  reject
644
668
  } = queued;
@@ -650,7 +674,7 @@ class KoniExtension {
650
674
  id
651
675
  } = _ref27;
652
676
  const queued = this.#koniState.getAuthRequestV2(id);
653
- (0, _util.assert)(queued, 'Unable to find request');
677
+ (0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
654
678
  const {
655
679
  reject
656
680
  } = queued;
@@ -887,6 +911,13 @@ class KoniExtension {
887
911
  this.#koniState.updateSetting('timeAutoLock', autoLockTime);
888
912
  return true;
889
913
  }
914
+ setUnlockType(_ref30) {
915
+ let {
916
+ unlockType
917
+ } = _ref30;
918
+ this.#koniState.updateSetting('unlockType', unlockType);
919
+ return true;
920
+ }
890
921
  async subscribeSettings(id, port) {
891
922
  const cb = (0, _subscriptions.createSubscription)(id, port);
892
923
  const balancesVisibilitySubscription = this.#koniState.subscribeSettingsSubject().subscribe({
@@ -900,31 +931,31 @@ class KoniExtension {
900
931
  });
901
932
  return await this.getSettings();
902
933
  }
903
- setEnableChainPatrol(_ref30) {
934
+ setEnableChainPatrol(_ref31) {
904
935
  let {
905
936
  enable
906
- } = _ref30;
937
+ } = _ref31;
907
938
  this.#koniState.updateSetting('enableChainPatrol', enable);
908
939
  return true;
909
940
  }
910
- setShowZeroBalance(_ref31) {
941
+ setShowZeroBalance(_ref32) {
911
942
  let {
912
943
  show
913
- } = _ref31;
944
+ } = _ref32;
914
945
  this.#koniState.updateSetting('isShowZeroBalance', show);
915
946
  return true;
916
947
  }
917
- setLanguage(_ref32) {
948
+ setLanguage(_ref33) {
918
949
  let {
919
950
  language
920
- } = _ref32;
951
+ } = _ref33;
921
952
  this.#koniState.updateSetting('language', language);
922
953
  return true;
923
954
  }
924
- setShowBalance(_ref33) {
955
+ setShowBalance(_ref34) {
925
956
  let {
926
957
  enable
927
- } = _ref33;
958
+ } = _ref34;
928
959
  this.#koniState.updateSetting('isShowBalance', enable);
929
960
  return true;
930
961
  }
@@ -1100,7 +1131,7 @@ class KoniExtension {
1100
1131
  }
1101
1132
  });
1102
1133
  }
1103
- async accountsCreateSuriV2(_ref34) {
1134
+ async accountsCreateSuriV2(_ref35) {
1104
1135
  let {
1105
1136
  genesisHash,
1106
1137
  isAllowed,
@@ -1108,13 +1139,13 @@ class KoniExtension {
1108
1139
  password,
1109
1140
  suri: _suri,
1110
1141
  types
1111
- } = _ref34;
1142
+ } = _ref35;
1112
1143
  const addressDict = {};
1113
1144
  let changedAccount = false;
1114
1145
  const hasMasterPassword = _uiKeyring.keyring.keyring.hasMasterPassword;
1115
1146
  if (!hasMasterPassword) {
1116
1147
  if (!password) {
1117
- throw Error('Require password to set up master password');
1148
+ throw Error((0, _i18next.t)('The password of each account is needed to set up master password'));
1118
1149
  } else {
1119
1150
  _uiKeyring.keyring.changeMasterPassword(password);
1120
1151
  this.#koniState.updateKeyringState();
@@ -1154,12 +1185,15 @@ class KoniExtension {
1154
1185
  resolve();
1155
1186
  });
1156
1187
  });
1188
+ if (this.#alwaysLock) {
1189
+ this.keyringLock();
1190
+ }
1157
1191
  return addressDict;
1158
1192
  }
1159
- async accountsForgetOverride(_ref35) {
1193
+ async accountsForgetOverride(_ref36) {
1160
1194
  let {
1161
1195
  address
1162
- } = _ref35;
1196
+ } = _ref36;
1163
1197
  _uiKeyring.keyring.forgetAccount(address);
1164
1198
  await new Promise(resolve => {
1165
1199
  this.#koniState.removeAccountRef(address, () => {
@@ -1192,12 +1226,12 @@ class KoniExtension {
1192
1226
  await this.#koniState.disableMantaPay(address);
1193
1227
  return true;
1194
1228
  }
1195
- seedCreateV2(_ref36) {
1229
+ seedCreateV2(_ref37) {
1196
1230
  let {
1197
1231
  length = _Extension.SEED_DEFAULT_LENGTH,
1198
1232
  seed: _seed,
1199
1233
  types
1200
- } = _ref36;
1234
+ } = _ref37;
1201
1235
  const seed = _seed || (0, _utilCrypto.mnemonicGenerate)(length);
1202
1236
  const rs = {
1203
1237
  seed: seed,
@@ -1208,20 +1242,24 @@ class KoniExtension {
1208
1242
  });
1209
1243
  return rs;
1210
1244
  }
1211
- seedValidateV2(_ref37) {
1245
+ seedValidateV2(_ref38) {
1212
1246
  let {
1213
1247
  suri,
1214
1248
  types
1215
- } = _ref37;
1249
+ } = _ref38;
1216
1250
  const {
1217
1251
  phrase
1218
1252
  } = (0, _utilCrypto.keyExtractSuri)(suri);
1219
1253
  if ((0, _util.isHex)(phrase)) {
1220
- (0, _util.assert)((0, _util.isHex)(phrase, 256), 'Hex seed needs to be 256-bits');
1254
+ (0, _util.assert)((0, _util.isHex)(phrase, 256), (0, _i18next.t)('Invalid seed phrase. Please try again.'));
1221
1255
  } else {
1222
1256
  // sadly isHex detects as string, so we need a cast here
1223
- (0, _util.assert)(_Extension.SEED_LENGTHS.includes(phrase.split(' ').length), `Mnemonic needs to contain ${_Extension.SEED_LENGTHS.join(', ')} words`);
1224
- (0, _util.assert)((0, _utilCrypto.mnemonicValidate)(phrase), 'Not a valid mnemonic seed');
1257
+ (0, _util.assert)(_Extension.SEED_LENGTHS.includes(phrase.split(' ').length), (0, _i18next.t)('Seed phrase needs to contain {{x}} words', {
1258
+ replace: {
1259
+ x: _Extension.SEED_LENGTHS.join(', ')
1260
+ }
1261
+ }));
1262
+ (0, _util.assert)((0, _utilCrypto.mnemonicValidate)(phrase), (0, _i18next.t)('Invalid seed phrase. Please try again.'));
1225
1263
  }
1226
1264
  const rs = {
1227
1265
  seed: suri,
@@ -1232,11 +1270,11 @@ class KoniExtension {
1232
1270
  });
1233
1271
  return rs;
1234
1272
  }
1235
- _checkValidatePrivateKey(_ref38) {
1273
+ _checkValidatePrivateKey(_ref39) {
1236
1274
  let {
1237
1275
  suri,
1238
1276
  types
1239
- } = _ref38;
1277
+ } = _ref39;
1240
1278
  let autoAddPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1241
1279
  const {
1242
1280
  phrase
@@ -1255,15 +1293,15 @@ class KoniExtension {
1255
1293
  });
1256
1294
  } else {
1257
1295
  rs.autoAddPrefix = false;
1258
- (0, _util.assert)(false, 'Not valid private key');
1296
+ (0, _util.assert)(false, (0, _i18next.t)('Invalid private key. Please try again.'));
1259
1297
  }
1260
1298
  return rs;
1261
1299
  }
1262
- metamaskPrivateKeyValidateV2(_ref39) {
1300
+ metamaskPrivateKeyValidateV2(_ref40) {
1263
1301
  let {
1264
1302
  suri,
1265
1303
  types
1266
- } = _ref39;
1304
+ } = _ref40;
1267
1305
  const isValidSuri = suri.startsWith('0x');
1268
1306
  if (isValidSuri) {
1269
1307
  return this._checkValidatePrivateKey({
@@ -1285,17 +1323,21 @@ class KoniExtension {
1285
1323
  try {
1286
1324
  return parentPair.derive(suri, metadata);
1287
1325
  } catch (err) {
1288
- throw new Error(`"${suri}" is not a valid derivation path`);
1326
+ throw new Error((0, _i18next.t)('"{{suri}}" is not a valid derivation path', {
1327
+ replace: {
1328
+ suri
1329
+ }
1330
+ }));
1289
1331
  }
1290
1332
  }
1291
- derivationCreateV2(_ref40) {
1333
+ derivationCreateV2(_ref41) {
1292
1334
  let {
1293
1335
  genesisHash,
1294
1336
  isAllowed,
1295
1337
  name,
1296
1338
  parentAddress,
1297
1339
  suri
1298
- } = _ref40;
1340
+ } = _ref41;
1299
1341
  const childPair = this.deriveV2(parentAddress, suri, {
1300
1342
  genesisHash,
1301
1343
  name,
@@ -1309,14 +1351,14 @@ class KoniExtension {
1309
1351
  });
1310
1352
  return true;
1311
1353
  }
1312
- jsonRestoreV2(_ref41) {
1354
+ jsonRestoreV2(_ref42) {
1313
1355
  let {
1314
1356
  address,
1315
1357
  file,
1316
1358
  isAllowed,
1317
1359
  password,
1318
1360
  withMasterPassword
1319
- } = _ref41;
1361
+ } = _ref42;
1320
1362
  const isPasswordValidated = this.validatePassword(file, password);
1321
1363
  if (isPasswordValidated) {
1322
1364
  try {
@@ -1324,20 +1366,23 @@ class KoniExtension {
1324
1366
  _uiKeyring.keyring.restoreAccount(file, password, withMasterPassword);
1325
1367
  this._addAddressToAuthList(address, isAllowed);
1326
1368
  });
1369
+ if (this.#alwaysLock) {
1370
+ this.keyringLock();
1371
+ }
1327
1372
  } catch (error) {
1328
1373
  throw new Error(error.message);
1329
1374
  }
1330
1375
  } else {
1331
- throw new Error('Unable to decode using the supplied passphrase');
1376
+ throw new Error((0, _i18next.t)('Wrong password'));
1332
1377
  }
1333
1378
  }
1334
- batchRestoreV2(_ref42) {
1379
+ batchRestoreV2(_ref43) {
1335
1380
  let {
1336
1381
  accountsInfo,
1337
1382
  file,
1338
1383
  isAllowed,
1339
1384
  password
1340
- } = _ref42;
1385
+ } = _ref43;
1341
1386
  const addressList = accountsInfo.map(acc => acc.address);
1342
1387
  const isPasswordValidated = this.validatedAccountsPassword(file, password);
1343
1388
  if (isPasswordValidated) {
@@ -1346,11 +1391,14 @@ class KoniExtension {
1346
1391
  _uiKeyring.keyring.restoreAccounts(file, password);
1347
1392
  this._addAddressesToAuthList(addressList, isAllowed);
1348
1393
  });
1394
+ if (this.#alwaysLock) {
1395
+ this.keyringLock();
1396
+ }
1349
1397
  } catch (error) {
1350
1398
  throw new Error(error.message);
1351
1399
  }
1352
1400
  } else {
1353
- throw new Error('Unable to decode using the supplied passphrase');
1401
+ throw new Error((0, _i18next.t)('Wrong password'));
1354
1402
  }
1355
1403
  }
1356
1404
  getNftCollection() {
@@ -1457,7 +1505,7 @@ class KoniExtension {
1457
1505
  let transferValue;
1458
1506
  if (!transferAll) {
1459
1507
  if (value === undefined) {
1460
- errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, 'Require transfer value'));
1508
+ errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Transfer amount is required')));
1461
1509
  }
1462
1510
  if (value) {
1463
1511
  transferValue = new _util.BN(value);
@@ -1465,10 +1513,10 @@ class KoniExtension {
1465
1513
  }
1466
1514
  const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1467
1515
  if (!tokenInfo) {
1468
- errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, 'Not found token from registry'));
1516
+ errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found token from registry')));
1469
1517
  }
1470
1518
  if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils._isTokenEvmSmartContract)(tokenInfo) && (0, _utils._getContractAddressOfToken)(tokenInfo).length === 0) {
1471
- errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, 'Not found ERC20 address for this token'));
1519
+ errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found ERC20 address for this token')));
1472
1520
  }
1473
1521
  return [errors, keypair, transferValue, tokenInfo];
1474
1522
  }
@@ -1536,7 +1584,7 @@ class KoniExtension {
1536
1584
  } catch (e) {
1537
1585
  const error = e;
1538
1586
  if (error.message.includes('transfer amount exceeds balance')) {
1539
- error.message = 'Not enough balance';
1587
+ error.message = (0, _i18next.t)('Insufficient balance');
1540
1588
  }
1541
1589
  throw error;
1542
1590
  }
@@ -1557,7 +1605,7 @@ class KoniExtension {
1557
1605
  token: tokenSlug
1558
1606
  });
1559
1607
  if (new _bignumber.default(balance).minus(transferAmount.value).lt(minAmount)) {
1560
- inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
1608
+ inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
1561
1609
  }
1562
1610
  }
1563
1611
  const {
@@ -1572,7 +1620,12 @@ class KoniExtension {
1572
1620
  if (new _bignumber.default(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
1573
1621
  const atLeast = new _bignumber.default(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
1574
1622
  const atLeastStr = (0, _number.formatNumber)(atLeast, tokenInfo.decimals || 0, _number.balanceFormatter);
1575
- inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, `You must transfer at least ${atLeastStr} ${tokenInfo.symbol} to keep the destination account alive`));
1623
+ inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
1624
+ replace: {
1625
+ amount: atLeastStr,
1626
+ symbol: tokenInfo.symbol
1627
+ }
1628
+ })));
1576
1629
  }
1577
1630
  };
1578
1631
  return this.#koniState.transactionService.handleTransaction({
@@ -1598,7 +1651,7 @@ class KoniExtension {
1598
1651
  const originTokenInfo = this.#koniState.getAssetBySlug(sendingTokenSlug);
1599
1652
  const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destinationNetworkKey, sendingTokenSlug);
1600
1653
  if (!destinationTokenInfo) {
1601
- errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.INVALID_TOKEN, 'Not found token from registry'));
1654
+ errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.INVALID_TOKEN, (0, _i18next.t)('Not found token from registry')));
1602
1655
  }
1603
1656
  return [errors, keypair, transferValue, originTokenInfo, destinationTokenInfo];
1604
1657
  }
@@ -1636,7 +1689,12 @@ class KoniExtension {
1636
1689
  // Check ed for receiver
1637
1690
  if (new _bignumber.default(value).lt(atLeast)) {
1638
1691
  const atLeastStr = (0, _number.formatNumber)(atLeast, destinationTokenInfo.decimals || 0, _number.balanceFormatter);
1639
- inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, `You must transfer at least ${atLeastStr} ${originTokenInfo.symbol} to keep the destination account alive`));
1692
+ inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
1693
+ replace: {
1694
+ amount: atLeastStr,
1695
+ symbol: originTokenInfo.symbol
1696
+ }
1697
+ })));
1640
1698
  }
1641
1699
  const srcMinAmount = originTokenInfo.minAmount || '0';
1642
1700
  const isTransferNativeToken = originTokenInfo.assetType === _types._AssetType.NATIVE;
@@ -1651,7 +1709,7 @@ class KoniExtension {
1651
1709
  token: originTokenInfo.slug
1652
1710
  });
1653
1711
  if (new _bignumber.default(balance).minus(value).lt(srcMinAmount)) {
1654
- inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
1712
+ inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
1655
1713
  }
1656
1714
  }
1657
1715
  };
@@ -1728,21 +1786,21 @@ class KoniExtension {
1728
1786
  disableChain(networkKey) {
1729
1787
  return this.#koniState.disableChain(networkKey);
1730
1788
  }
1731
- async enableChain(_ref43) {
1789
+ async enableChain(_ref44) {
1732
1790
  let {
1733
1791
  chainSlug,
1734
1792
  enableTokens
1735
- } = _ref43;
1793
+ } = _ref44;
1736
1794
  return await this.#koniState.enableChain(chainSlug, enableTokens);
1737
1795
  }
1738
1796
  async reconnectChain(chainSlug) {
1739
1797
  return this.#koniState.chainService.reconnectChain(chainSlug);
1740
1798
  }
1741
- async validateNetwork(_ref44) {
1799
+ async validateNetwork(_ref45) {
1742
1800
  let {
1743
1801
  existedChainSlug,
1744
1802
  provider
1745
- } = _ref44;
1803
+ } = _ref45;
1746
1804
  return await this.#koniState.validateCustomChain(provider, existedChainSlug);
1747
1805
  }
1748
1806
  resetDefaultNetwork() {
@@ -1780,12 +1838,12 @@ class KoniExtension {
1780
1838
  async validateCustomAsset(data) {
1781
1839
  return await this.#koniState.validateCustomAsset(data);
1782
1840
  }
1783
- async getAddressFreeBalance(_ref45) {
1841
+ async getAddressFreeBalance(_ref46) {
1784
1842
  let {
1785
1843
  address,
1786
1844
  networkKey,
1787
1845
  token
1788
- } = _ref45;
1846
+ } = _ref46;
1789
1847
  if (token && _constants2._MANTA_ZK_CHAIN_GROUP.includes(networkKey)) {
1790
1848
  const tokenInfo = this.#koniState.chainService.getAssetBySlug(token);
1791
1849
  if (tokenInfo.symbol.startsWith(_constants2._ZK_ASSET_PREFIX)) {
@@ -1794,14 +1852,14 @@ class KoniExtension {
1794
1852
  }
1795
1853
  return await this.#koniState.balanceService.getTokenFreeBalance(address, networkKey, token);
1796
1854
  }
1797
- async transferGetMaxTransferable(_ref46) {
1855
+ async transferGetMaxTransferable(_ref47) {
1798
1856
  let {
1799
1857
  address,
1800
1858
  destChain,
1801
1859
  isXcmTransfer,
1802
1860
  networkKey,
1803
1861
  token
1804
- } = _ref46;
1862
+ } = _ref47;
1805
1863
  const freeBalance = await this.getAddressFreeBalance({
1806
1864
  address,
1807
1865
  networkKey,
@@ -1867,7 +1925,7 @@ class KoniExtension {
1867
1925
  }
1868
1926
  } catch (e) {
1869
1927
  estimatedFee = '0';
1870
- console.warn('Error estimating fee', e);
1928
+ console.warn('Unable to estimate fee', e);
1871
1929
  }
1872
1930
  maxTransferable = maxTransferable.sub(new _util.BN(estimatedFee));
1873
1931
  return {
@@ -1876,12 +1934,12 @@ class KoniExtension {
1876
1934
  };
1877
1935
  }
1878
1936
  }
1879
- async subscribeAddressFreeBalance(_ref47, id, port) {
1937
+ async subscribeAddressFreeBalance(_ref48, id, port) {
1880
1938
  let {
1881
1939
  address,
1882
1940
  networkKey,
1883
1941
  token
1884
- } = _ref47;
1942
+ } = _ref48;
1885
1943
  const cb = (0, _subscriptions.createSubscription)(id, port);
1886
1944
  const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTokenFreeBalance(address, networkKey, token, cb);
1887
1945
  this.createUnsubscriptionHandle(id, unsub);
@@ -1890,26 +1948,26 @@ class KoniExtension {
1890
1948
  });
1891
1949
  return currentFreeBalance;
1892
1950
  }
1893
- async transferCheckReferenceCount(_ref48) {
1951
+ async transferCheckReferenceCount(_ref49) {
1894
1952
  let {
1895
1953
  address,
1896
1954
  networkKey
1897
- } = _ref48;
1955
+ } = _ref49;
1898
1956
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return
1899
1957
  return await (0, _transfer.checkReferenceCount)(networkKey, address, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
1900
1958
  }
1901
- async transferCheckSupporting(_ref49) {
1959
+ async transferCheckSupporting(_ref50) {
1902
1960
  let {
1903
1961
  networkKey,
1904
1962
  tokenSlug
1905
- } = _ref49;
1963
+ } = _ref50;
1906
1964
  const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1907
1965
  return await (0, _transfer.checkSupportTransfer)(networkKey, tokenInfo, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
1908
1966
  }
1909
- transferGetExistentialDeposit(_ref50) {
1967
+ transferGetExistentialDeposit(_ref51) {
1910
1968
  let {
1911
1969
  tokenSlug
1912
- } = _ref50;
1970
+ } = _ref51;
1913
1971
  const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1914
1972
  return (0, _utils._getTokenMinAmount)(tokenInfo);
1915
1973
  }
@@ -1945,11 +2003,11 @@ class KoniExtension {
1945
2003
  isSendingSelf
1946
2004
  };
1947
2005
  }
1948
- async enableChains(_ref51) {
2006
+ async enableChains(_ref52) {
1949
2007
  let {
1950
2008
  chainSlugs,
1951
2009
  enableTokens
1952
- } = _ref51;
2010
+ } = _ref52;
1953
2011
  try {
1954
2012
  await Promise.all(chainSlugs.map(chainSlug => this.enableChain({
1955
2013
  chainSlug,
@@ -1960,24 +2018,24 @@ class KoniExtension {
1960
2018
  }
1961
2019
  return true;
1962
2020
  }
1963
- getAccountMeta(_ref52) {
2021
+ getAccountMeta(_ref53) {
1964
2022
  let {
1965
2023
  address
1966
- } = _ref52;
2024
+ } = _ref53;
1967
2025
  const pair = _uiKeyring.keyring.getPair(address);
1968
- (0, _util.assert)(pair, 'Unable to find pair');
2026
+ (0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
1969
2027
  return {
1970
2028
  meta: pair.meta
1971
2029
  };
1972
2030
  }
1973
- accountsTie2(_ref53) {
2031
+ accountsTie2(_ref54) {
1974
2032
  let {
1975
2033
  address,
1976
2034
  genesisHash
1977
- } = _ref53;
2035
+ } = _ref54;
1978
2036
  return this.#koniState.setAccountTie(address, genesisHash);
1979
2037
  }
1980
- async accountsCreateExternalV2(_ref54) {
2038
+ async accountsCreateExternalV2(_ref55) {
1981
2039
  let {
1982
2040
  address,
1983
2041
  genesisHash,
@@ -1985,7 +2043,7 @@ class KoniExtension {
1985
2043
  isEthereum,
1986
2044
  isReadOnly,
1987
2045
  name
1988
- } = _ref54;
2046
+ } = _ref55;
1989
2047
  try {
1990
2048
  let result;
1991
2049
  try {
@@ -1994,7 +2052,7 @@ class KoniExtension {
1994
2052
  if (exists.type === (isEthereum ? 'ethereum' : 'sr25519')) {
1995
2053
  return [{
1996
2054
  code: _KoniTypes.AccountExternalErrorCode.INVALID_ADDRESS,
1997
- message: 'Account exists'
2055
+ message: (0, _i18next.t)('Account exists')
1998
2056
  }];
1999
2057
  }
2000
2058
  }
@@ -2044,7 +2102,7 @@ class KoniExtension {
2044
2102
  }];
2045
2103
  }
2046
2104
  }
2047
- async accountsCreateHardwareV2(_ref55) {
2105
+ async accountsCreateHardwareV2(_ref56) {
2048
2106
  let {
2049
2107
  accountIndex,
2050
2108
  address,
@@ -2053,7 +2111,7 @@ class KoniExtension {
2053
2111
  hardwareType,
2054
2112
  isAllowed,
2055
2113
  name
2056
- } = _ref55;
2114
+ } = _ref56;
2057
2115
  const key = _uiKeyring.keyring.addHardware(address, hardwareType, {
2058
2116
  accountIndex,
2059
2117
  addressOffset,
@@ -2076,13 +2134,13 @@ class KoniExtension {
2076
2134
  });
2077
2135
  return true;
2078
2136
  }
2079
- async accountsCreateHardwareMultiple(_ref56) {
2137
+ async accountsCreateHardwareMultiple(_ref57) {
2080
2138
  let {
2081
2139
  accounts
2082
- } = _ref56;
2140
+ } = _ref57;
2083
2141
  const addresses = [];
2084
2142
  if (!accounts.length) {
2085
- throw new Error('No accounts to import');
2143
+ throw new Error((0, _i18next.t)("Can't find an account. Please try again"));
2086
2144
  }
2087
2145
  const slugMap = {};
2088
2146
  for (const account of accounts) {
@@ -2157,14 +2215,14 @@ class KoniExtension {
2157
2215
  }
2158
2216
  return true;
2159
2217
  }
2160
- async accountsCreateWithSecret(_ref57) {
2218
+ async accountsCreateWithSecret(_ref58) {
2161
2219
  let {
2162
2220
  isAllow,
2163
2221
  isEthereum,
2164
2222
  name,
2165
2223
  publicKey,
2166
2224
  secretKey
2167
- } = _ref57;
2225
+ } = _ref58;
2168
2226
  try {
2169
2227
  let keyringPair = null;
2170
2228
  if (isEthereum) {
@@ -2195,7 +2253,7 @@ class KoniExtension {
2195
2253
  success: false,
2196
2254
  errors: [{
2197
2255
  code: _KoniTypes.AccountExternalErrorCode.KEYRING_ERROR,
2198
- message: 'Invalid keyring'
2256
+ message: (0, _i18next.t)('Cannot create account')
2199
2257
  }]
2200
2258
  };
2201
2259
  }
@@ -2211,6 +2269,9 @@ class KoniExtension {
2211
2269
  resolve();
2212
2270
  });
2213
2271
  });
2272
+ if (this.#alwaysLock) {
2273
+ this.keyringLock();
2274
+ }
2214
2275
  return {
2215
2276
  errors: [],
2216
2277
  success: true
@@ -2307,32 +2368,32 @@ class KoniExtension {
2307
2368
 
2308
2369
  // Parse transaction
2309
2370
 
2310
- parseSubstrateTransaction(_ref58) {
2371
+ parseSubstrateTransaction(_ref59) {
2311
2372
  let {
2312
2373
  data,
2313
2374
  networkKey
2314
- } = _ref58;
2375
+ } = _ref59;
2315
2376
  const apiProps = this.#koniState.getSubstrateApi(networkKey);
2316
2377
  const apiPromise = apiProps.api;
2317
2378
  return (0, _parseTransaction.parseSubstrateTransaction)(data, apiPromise);
2318
2379
  }
2319
- async parseEVMRLP(_ref59) {
2380
+ async parseEVMRLP(_ref60) {
2320
2381
  let {
2321
2382
  data
2322
- } = _ref59;
2383
+ } = _ref60;
2323
2384
  return await (0, _parseTransaction2.parseEvmRlp)(data, this.#koniState.getChainInfoMap(), this.#koniState.getEvmApiMap());
2324
2385
  }
2325
2386
 
2326
2387
  // Sign
2327
2388
 
2328
- qrSignSubstrate(_ref60) {
2389
+ qrSignSubstrate(_ref61) {
2329
2390
  let {
2330
2391
  address,
2331
2392
  data,
2332
2393
  networkKey
2333
- } = _ref60;
2394
+ } = _ref61;
2334
2395
  const pair = _uiKeyring.keyring.getPair(address);
2335
- (0, _util.assert)(pair, 'Unable to find pair');
2396
+ (0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
2336
2397
  if (pair.isLocked) {
2337
2398
  _uiKeyring.keyring.unlockPair(pair.address);
2338
2399
  }
@@ -2347,21 +2408,21 @@ class KoniExtension {
2347
2408
  signature: signed
2348
2409
  };
2349
2410
  }
2350
- async qrSignEVM(_ref61) {
2411
+ async qrSignEVM(_ref62) {
2351
2412
  let {
2352
2413
  address,
2353
2414
  chainId,
2354
2415
  message,
2355
2416
  type
2356
- } = _ref61;
2417
+ } = _ref62;
2357
2418
  let signed;
2358
2419
  const network = this.getNetworkJsonByChainId(chainId);
2359
2420
  if (!network) {
2360
- throw new Error('Cannot find network');
2421
+ throw new Error((0, _i18next.t)('Cannot find network'));
2361
2422
  }
2362
2423
  const pair = _uiKeyring.keyring.getPair(address);
2363
2424
  if (!pair) {
2364
- throw Error('Unable to find pair');
2425
+ throw Error((0, _i18next.t)('Unable to find account'));
2365
2426
  }
2366
2427
  if (pair.isLocked) {
2367
2428
  _uiKeyring.keyring.unlockPair(pair.address);
@@ -2377,7 +2438,7 @@ class KoniExtension {
2377
2438
  } else {
2378
2439
  const tx = (0, _eth.createTransactionFromRLP)(message);
2379
2440
  if (!tx) {
2380
- throw new Error(`Cannot create tx from ${message}`);
2441
+ throw new Error((0, _i18next.t)('Failed to decode data. Please use a valid QR code'));
2381
2442
  }
2382
2443
  const txObject = {
2383
2444
  gasPrice: new _bignumber.default(tx.gasPrice).toNumber(),
@@ -2434,11 +2495,11 @@ class KoniExtension {
2434
2495
  });
2435
2496
  return this.#koniState.getNominatorMetadata();
2436
2497
  }
2437
- async getBondingOptions(_ref62) {
2498
+ async getBondingOptions(_ref63) {
2438
2499
  let {
2439
2500
  chain,
2440
2501
  type
2441
- } = _ref62;
2502
+ } = _ref63;
2442
2503
  const apiProps = this.#koniState.getSubstrateApi(chain);
2443
2504
  const chainInfo = this.#koniState.getChainInfo(chain);
2444
2505
  const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, type);
@@ -2627,12 +2688,12 @@ class KoniExtension {
2627
2688
  }
2628
2689
 
2629
2690
  // EVM Transaction
2630
- async parseContractInput(_ref63) {
2691
+ async parseContractInput(_ref64) {
2631
2692
  let {
2632
2693
  chainId,
2633
2694
  contract,
2634
2695
  data
2635
- } = _ref63;
2696
+ } = _ref64;
2636
2697
  const network = this.getNetworkJsonByChainId(chainId);
2637
2698
  return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
2638
2699
  }
@@ -2703,12 +2764,12 @@ class KoniExtension {
2703
2764
 
2704
2765
  // Change master password
2705
2766
 
2706
- keyringChangeMasterPassword(_ref64) {
2767
+ keyringChangeMasterPassword(_ref65) {
2707
2768
  let {
2708
2769
  createNew,
2709
2770
  newPassword,
2710
2771
  oldPassword
2711
- } = _ref64;
2772
+ } = _ref65;
2712
2773
  try {
2713
2774
  // Remove isMasterPassword meta if createNew
2714
2775
  if (createNew) {
@@ -2729,11 +2790,14 @@ class KoniExtension {
2729
2790
  } catch (e) {
2730
2791
  console.error(e);
2731
2792
  return {
2732
- errors: [e.message],
2793
+ errors: [(0, _i18next.t)(e.message)],
2733
2794
  status: false
2734
2795
  };
2735
2796
  }
2736
2797
  this.#koniState.updateKeyringState();
2798
+ if (this.#alwaysLock) {
2799
+ this.keyringLock();
2800
+ }
2737
2801
  return {
2738
2802
  status: true,
2739
2803
  errors: []
@@ -2742,11 +2806,11 @@ class KoniExtension {
2742
2806
 
2743
2807
  // Migrate password
2744
2808
 
2745
- keyringMigrateMasterPassword(_ref65) {
2809
+ keyringMigrateMasterPassword(_ref66) {
2746
2810
  let {
2747
2811
  address,
2748
2812
  password
2749
- } = _ref65;
2813
+ } = _ref66;
2750
2814
  try {
2751
2815
  _uiKeyring.keyring.migrateWithMasterPassword(address, password);
2752
2816
  } catch (e) {
@@ -2764,10 +2828,10 @@ class KoniExtension {
2764
2828
 
2765
2829
  // Unlock wallet
2766
2830
 
2767
- keyringUnlock(_ref66) {
2831
+ keyringUnlock(_ref67) {
2768
2832
  let {
2769
2833
  password
2770
- } = _ref66;
2834
+ } = _ref67;
2771
2835
  try {
2772
2836
  _uiKeyring.keyring.unlockKeyring(password);
2773
2837
  this.#koniState.initMantaPay(password).catch(console.error);
@@ -2787,18 +2851,17 @@ class KoniExtension {
2787
2851
  // Lock wallet
2788
2852
 
2789
2853
  keyringLock() {
2790
- _uiKeyring.keyring.lockAll();
2791
- this.#koniState.updateKeyringState();
2854
+ this.#koniState.keyringService.lock();
2792
2855
  clearTimeout(this.#lockTimeOut);
2793
2856
  }
2794
2857
 
2795
2858
  // Export mnemonic
2796
2859
 
2797
- keyringExportMnemonic(_ref67) {
2860
+ keyringExportMnemonic(_ref68) {
2798
2861
  let {
2799
2862
  address,
2800
2863
  password
2801
- } = _ref67;
2864
+ } = _ref68;
2802
2865
  const pair = _uiKeyring.keyring.getPair(address);
2803
2866
  const result = pair.exportMnemonic(password);
2804
2867
  return {
@@ -2808,10 +2871,10 @@ class KoniExtension {
2808
2871
 
2809
2872
  // Reset wallet
2810
2873
 
2811
- async resetWallet(_ref68) {
2874
+ async resetWallet(_ref69) {
2812
2875
  let {
2813
2876
  resetAll
2814
- } = _ref68;
2877
+ } = _ref69;
2815
2878
  try {
2816
2879
  await this.#koniState.resetWallet(resetAll);
2817
2880
  return {
@@ -2827,12 +2890,12 @@ class KoniExtension {
2827
2890
  }
2828
2891
 
2829
2892
  /// Signing external request
2830
- signingApprovePasswordV2(_ref69) {
2893
+ signingApprovePasswordV2(_ref70) {
2831
2894
  let {
2832
2895
  id
2833
- } = _ref69;
2896
+ } = _ref70;
2834
2897
  const queued = this.#koniState.getSignRequest(id);
2835
- (0, _util.assert)(queued, 'Unable to find request');
2898
+ (0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
2836
2899
  const {
2837
2900
  reject,
2838
2901
  request,
@@ -2847,7 +2910,7 @@ class KoniExtension {
2847
2910
  address
2848
2911
  } = pair;
2849
2912
  if (!pair) {
2850
- reject(new Error('Unable to find pair'));
2913
+ reject(new Error((0, _i18next.t)('Unable to find account')));
2851
2914
  return false;
2852
2915
  }
2853
2916
  if (pair.isLocked) {
@@ -2887,27 +2950,30 @@ class KoniExtension {
2887
2950
  // In case evm chain, must be cut 2 character after 0x
2888
2951
  signature: isEvm ? `0x${result.signature.slice(4)}` : result.signature
2889
2952
  });
2953
+ if (this.#alwaysLock) {
2954
+ this.keyringLock();
2955
+ }
2890
2956
  return true;
2891
2957
  }
2892
2958
 
2893
2959
  /// Derive account
2894
2960
 
2895
- derivationCreateMultiple(_ref70) {
2961
+ derivationCreateMultiple(_ref71) {
2896
2962
  let {
2897
2963
  isAllowed,
2898
2964
  items,
2899
2965
  parentAddress
2900
- } = _ref70;
2966
+ } = _ref71;
2901
2967
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2902
2968
  const isEvm = parentPair.type === 'ethereum';
2903
2969
  if (parentPair.isLocked) {
2904
2970
  _uiKeyring.keyring.unlockPair(parentPair.address);
2905
2971
  }
2906
- const createChild = _ref71 => {
2972
+ const createChild = _ref72 => {
2907
2973
  let {
2908
2974
  name,
2909
2975
  suri
2910
- } = _ref71;
2976
+ } = _ref72;
2911
2977
  const meta = {
2912
2978
  name: name,
2913
2979
  parentAddress
@@ -2922,7 +2988,7 @@ class KoniExtension {
2922
2988
  }
2923
2989
  } catch (e) {}
2924
2990
  if (!index) {
2925
- throw Error('Invalid derive path');
2991
+ throw Error((0, _i18next.t)('Invalid derive path'));
2926
2992
  }
2927
2993
  meta.suri = `//${index}`;
2928
2994
  return parentPair.deriveEvm(index, meta);
@@ -2953,10 +3019,10 @@ class KoniExtension {
2953
3019
  }
2954
3020
  return true;
2955
3021
  }
2956
- derivationCreateV3(_ref72) {
3022
+ derivationCreateV3(_ref73) {
2957
3023
  let {
2958
3024
  address: parentAddress
2959
- } = _ref72;
3025
+ } = _ref73;
2960
3026
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2961
3027
  const isEvm = parentPair.type === 'ethereum';
2962
3028
  if (parentPair.isLocked) {
@@ -2986,13 +3052,16 @@ class KoniExtension {
2986
3052
  _uiKeyring.keyring.addPair(childPair, true);
2987
3053
  this._addAddressToAuthList(address, true);
2988
3054
  });
3055
+ if (this.#alwaysLock) {
3056
+ this.keyringLock();
3057
+ }
2989
3058
  return true;
2990
3059
  }
2991
- validateDerivePath(_ref73) {
3060
+ validateDerivePath(_ref74) {
2992
3061
  let {
2993
3062
  parentAddress,
2994
3063
  suri
2995
- } = _ref73;
3064
+ } = _ref74;
2996
3065
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2997
3066
  const isEvm = parentPair.type === 'ethereum';
2998
3067
  if (parentPair.isLocked) {
@@ -3012,7 +3081,7 @@ class KoniExtension {
3012
3081
  }
3013
3082
  } catch (e) {}
3014
3083
  if (!index) {
3015
- throw Error('Invalid derive path');
3084
+ throw Error((0, _i18next.t)('Invalid derive path'));
3016
3085
  }
3017
3086
  meta.suri = `//${index}`;
3018
3087
  childPair = parentPair.deriveEvm(index, meta);
@@ -3025,12 +3094,12 @@ class KoniExtension {
3025
3094
  suri: meta.suri
3026
3095
  };
3027
3096
  }
3028
- getListDeriveAccounts(_ref74) {
3097
+ getListDeriveAccounts(_ref75) {
3029
3098
  let {
3030
3099
  limit,
3031
3100
  page,
3032
3101
  parentAddress
3033
- } = _ref74;
3102
+ } = _ref75;
3034
3103
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
3035
3104
  const isEvm = parentPair.type === 'ethereum';
3036
3105
  if (parentPair.isLocked) {
@@ -3121,10 +3190,10 @@ class KoniExtension {
3121
3190
  getSupportedSmartContractTypes() {
3122
3191
  return this.#koniState.getSupportedSmartContractTypes();
3123
3192
  }
3124
- getTransaction(_ref75) {
3193
+ getTransaction(_ref76) {
3125
3194
  let {
3126
3195
  id
3127
- } = _ref75;
3196
+ } = _ref76;
3128
3197
  const {
3129
3198
  transaction,
3130
3199
  ...transactionResult
@@ -3134,8 +3203,8 @@ class KoniExtension {
3134
3203
  subscribeTransactions(id, port) {
3135
3204
  const cb = (0, _subscriptions.createSubscription)(id, port);
3136
3205
  function convertRs(rs) {
3137
- return Object.fromEntries(Object.entries(rs).map(_ref76 => {
3138
- let [key, value] = _ref76;
3206
+ return Object.fromEntries(Object.entries(rs).map(_ref77 => {
3207
+ let [key, value] = _ref77;
3139
3208
  const {
3140
3209
  additionalValidator,
3141
3210
  eventsHandler,
@@ -3167,10 +3236,10 @@ class KoniExtension {
3167
3236
  });
3168
3237
  return notificationSubject.value;
3169
3238
  }
3170
- async reloadCron(_ref77) {
3239
+ async reloadCron(_ref78) {
3171
3240
  let {
3172
3241
  data
3173
- } = _ref77;
3242
+ } = _ref78;
3174
3243
  if (data === 'nft') {
3175
3244
  return await this.#koniState.reloadNft();
3176
3245
  } else if (data === 'staking') {
@@ -3188,20 +3257,20 @@ class KoniExtension {
3188
3257
 
3189
3258
  // Phishing detect
3190
3259
 
3191
- async passPhishingPage(_ref78) {
3260
+ async passPhishingPage(_ref79) {
3192
3261
  let {
3193
3262
  url
3194
- } = _ref78;
3263
+ } = _ref79;
3195
3264
  return await this.#koniState.approvePassPhishingPage(url);
3196
3265
  }
3197
3266
 
3198
3267
  /// Wallet connect
3199
3268
 
3200
3269
  // Connect
3201
- async connectWalletConnect(_ref79) {
3270
+ async connectWalletConnect(_ref80) {
3202
3271
  let {
3203
3272
  uri
3204
- } = _ref79;
3273
+ } = _ref80;
3205
3274
  await this.#koniState.walletConnectService.connect(uri);
3206
3275
  return true;
3207
3276
  }
@@ -3214,11 +3283,11 @@ class KoniExtension {
3214
3283
  });
3215
3284
  return this.#koniState.requestService.allConnectWCRequests;
3216
3285
  }
3217
- async approveWalletConnectSession(_ref80) {
3286
+ async approveWalletConnectSession(_ref81) {
3218
3287
  let {
3219
3288
  accounts: selectedAccounts,
3220
3289
  id
3221
- } = _ref80;
3290
+ } = _ref81;
3222
3291
  const request = this.#koniState.requestService.getConnectWCRequest(id);
3223
3292
  if ((0, _helpers2.isProposalExpired)(request.request.params)) {
3224
3293
  throw new Error('The proposal has been expired');
@@ -3230,8 +3299,8 @@ class KoniExtension {
3230
3299
  const availableNamespaces = {};
3231
3300
  const namespaces = {};
3232
3301
  const chainInfoMap = this.#koniState.getChainInfoMap();
3233
- Object.entries(requiredNamespaces).forEach(_ref81 => {
3234
- let [key, namespace] = _ref81;
3302
+ Object.entries(requiredNamespaces).forEach(_ref82 => {
3303
+ let [key, namespace] = _ref82;
3235
3304
  if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
3236
3305
  if (namespace.chains) {
3237
3306
  const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
@@ -3244,8 +3313,8 @@ class KoniExtension {
3244
3313
  throw new Error((0, _utils3.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
3245
3314
  }
3246
3315
  });
3247
- Object.entries(optionalNamespaces).forEach(_ref82 => {
3248
- let [key, namespace] = _ref82;
3316
+ Object.entries(optionalNamespaces).forEach(_ref83 => {
3317
+ let [key, namespace] = _ref83;
3249
3318
  if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
3250
3319
  if (namespace.chains) {
3251
3320
  const supportChains = namespace.chains.filter(chain => (0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap)) || [];
@@ -3269,8 +3338,8 @@ class KoniExtension {
3269
3338
  }
3270
3339
  }
3271
3340
  });
3272
- Object.entries(availableNamespaces).forEach(_ref83 => {
3273
- let [key, namespace] = _ref83;
3341
+ Object.entries(availableNamespaces).forEach(_ref84 => {
3342
+ let [key, namespace] = _ref84;
3274
3343
  if (namespace.chains) {
3275
3344
  const accounts = [];
3276
3345
  const chains = (0, _utils2.uniqueStringArray)(namespace.chains);
@@ -3294,10 +3363,10 @@ class KoniExtension {
3294
3363
  request.resolve();
3295
3364
  return true;
3296
3365
  }
3297
- async rejectWalletConnectSession(_ref84) {
3366
+ async rejectWalletConnectSession(_ref85) {
3298
3367
  let {
3299
3368
  id
3300
- } = _ref84;
3369
+ } = _ref85;
3301
3370
  const request = this.#koniState.requestService.getConnectWCRequest(id);
3302
3371
  const wcId = request.request.id;
3303
3372
  if ((0, _helpers2.isProposalExpired)(request.request.params)) {
@@ -3319,10 +3388,10 @@ class KoniExtension {
3319
3388
  });
3320
3389
  return this.#koniState.walletConnectService.sessions;
3321
3390
  }
3322
- async disconnectWalletConnectSession(_ref85) {
3391
+ async disconnectWalletConnectSession(_ref86) {
3323
3392
  let {
3324
3393
  topic
3325
- } = _ref85;
3394
+ } = _ref86;
3326
3395
  await this.#koniState.walletConnectService.disconnect(topic);
3327
3396
  return true;
3328
3397
  }
@@ -3335,18 +3404,18 @@ class KoniExtension {
3335
3404
  });
3336
3405
  return this.#koniState.requestService.allNotSupportWCRequests;
3337
3406
  }
3338
- approveWalletConnectNotSupport(_ref86) {
3407
+ approveWalletConnectNotSupport(_ref87) {
3339
3408
  let {
3340
3409
  id
3341
- } = _ref86;
3410
+ } = _ref87;
3342
3411
  const request = this.#koniState.requestService.getNotSupportWCRequest(id);
3343
3412
  request.resolve();
3344
3413
  return true;
3345
3414
  }
3346
- rejectWalletConnectNotSupport(_ref87) {
3415
+ rejectWalletConnectNotSupport(_ref88) {
3347
3416
  let {
3348
3417
  id
3349
- } = _ref87;
3418
+ } = _ref88;
3350
3419
  const request = this.#koniState.requestService.getNotSupportWCRequest(id);
3351
3420
  request.reject(new Error('USER_REJECTED'));
3352
3421
  return true;
@@ -3354,11 +3423,11 @@ class KoniExtension {
3354
3423
 
3355
3424
  /// Manta
3356
3425
 
3357
- async enableMantaPay(_ref88) {
3426
+ async enableMantaPay(_ref89) {
3358
3427
  let {
3359
3428
  address,
3360
3429
  password
3361
- } = _ref88;
3430
+ } = _ref89;
3362
3431
  // always takes the current account
3363
3432
  function timeout() {
3364
3433
  return new Promise(resolve => setTimeout(resolve, 1500));
@@ -3482,10 +3551,10 @@ class KoniExtension {
3482
3551
 
3483
3552
  /// Metadata
3484
3553
 
3485
- async findRawMetadata(_ref89) {
3554
+ async findRawMetadata(_ref90) {
3486
3555
  let {
3487
3556
  genesisHash
3488
- } = _ref89;
3557
+ } = _ref90;
3489
3558
  const {
3490
3559
  metadata,
3491
3560
  specVersion
@@ -3508,11 +3577,13 @@ class KoniExtension {
3508
3577
  // eslint-disable-next-line @typescript-eslint/require-await
3509
3578
  async handle(id, type, request, port) {
3510
3579
  clearTimeout(this.#lockTimeOut);
3511
- this.#lockTimeOut = setTimeout(() => {
3512
- if (!this.#skipAutoLock) {
3513
- this.keyringLock();
3514
- }
3515
- }, this.#timeAutoLock * 60 * 1000);
3580
+ if (this.#timeAutoLock > 0) {
3581
+ this.#lockTimeOut = setTimeout(() => {
3582
+ if (!this.#skipAutoLock) {
3583
+ this.keyringLock();
3584
+ }
3585
+ }, this.#timeAutoLock * 60 * 1000);
3586
+ }
3516
3587
  switch (type) {
3517
3588
  /// Clone from PolkadotJs
3518
3589
  case 'pri(accounts.create.external)':
@@ -3607,6 +3678,8 @@ class KoniExtension {
3607
3678
  return this.saveBrowserConfirmationType(request);
3608
3679
  case 'pri(settings.saveAutoLockTime)':
3609
3680
  return this.setAutoLockTime(request);
3681
+ case 'pri(settings.saveUnlockType)':
3682
+ return this.setUnlockType(request);
3610
3683
  case 'pri(settings.saveEnableChainPatrol)':
3611
3684
  return this.setEnableChainPatrol(request);
3612
3685
  case 'pri(settings.saveShowZeroBalance)':