@subwallet/extension-base 1.0.1 → 1.0.2-1

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 (169) hide show
  1. package/background/KoniTypes.d.ts +10 -3
  2. package/background/KoniTypes.js +6 -0
  3. package/cjs/background/KoniTypes.js +8 -1
  4. package/cjs/constants/index.js +6 -3
  5. package/cjs/koni/api/dotsama/balance.js +11 -0
  6. package/cjs/koni/api/staking/bonding/amplitude.js +6 -2
  7. package/cjs/koni/api/staking/bonding/astar.js +40 -243
  8. package/cjs/koni/api/staking/bonding/index.js +4 -4
  9. package/cjs/koni/api/staking/bonding/paraChain.js +16 -10
  10. package/cjs/koni/api/staking/bonding/relayChain.js +62 -7
  11. package/cjs/koni/api/staking/bonding/utils.js +29 -3
  12. package/cjs/koni/api/xcm/index.js +0 -111
  13. package/cjs/koni/api/xcm/polkadotXcm.js +1 -1
  14. package/cjs/koni/api/xcm/xTokens.js +2 -4
  15. package/cjs/koni/background/cron.js +61 -62
  16. package/cjs/koni/background/handlers/Extension.js +143 -149
  17. package/cjs/koni/background/handlers/State.js +129 -91
  18. package/cjs/koni/background/handlers/Tabs.js +40 -38
  19. package/cjs/koni/background/subscription.js +48 -43
  20. package/cjs/packageInfo.js +1 -1
  21. package/cjs/page/index.js +5 -0
  22. package/cjs/services/chain-service/constants.js +1 -11
  23. package/cjs/services/chain-service/index.js +39 -5
  24. package/cjs/services/chain-service/utils.js +4 -0
  25. package/cjs/services/event-service/index.js +71 -0
  26. package/cjs/services/event-service/types.js +1 -0
  27. package/cjs/services/history-service/index.js +36 -17
  28. package/cjs/services/history-service/subsquid-multi-chain-history.js +7 -2
  29. package/cjs/services/keyring-service/index.js +101 -0
  30. package/cjs/services/migration-service/index.js +13 -10
  31. package/cjs/{koni/migration/scripts/RemoveWrongCrowdloan.js → services/migration-service/scripts/AutoEnableChainsTokens.js} +11 -6
  32. package/cjs/services/migration-service/scripts/MigrateNetworkSettings.js +39 -19
  33. package/cjs/services/migration-service/scripts/MigrateSettings.js +31 -0
  34. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +72 -0
  35. package/cjs/services/migration-service/scripts/index.js +13 -4
  36. package/cjs/services/price-service/coingecko.js +16 -3
  37. package/cjs/services/price-service/index.js +15 -17
  38. package/cjs/services/request-service/constants.js +8 -2
  39. package/cjs/services/request-service/handler/AuthRequestHandler.js +39 -12
  40. package/cjs/services/request-service/index.js +3 -0
  41. package/cjs/services/storage-service/DatabaseService.js +1 -1
  42. package/cjs/services/storage-service/databases/index.js +1 -1
  43. package/cjs/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
  44. package/cjs/services/storage-service/db-stores/Nft.js +4 -1
  45. package/cjs/services/storage-service/db-stores/Transaction.js +10 -7
  46. package/cjs/services/subscan-service/index.js +107 -0
  47. package/cjs/services/subscan-service/subscan-chain-map.js +74 -0
  48. package/cjs/services/subscan-service/types.js +1 -0
  49. package/cjs/services/transaction-service/index.js +45 -10
  50. package/cjs/services/transaction-service/utils.js +4 -6
  51. package/cjs/utils/address.js +9 -1
  52. package/cjs/utils/index.js +24 -13
  53. package/constants/index.d.ts +1 -0
  54. package/constants/index.js +1 -0
  55. package/koni/api/dotsama/balance.js +11 -0
  56. package/koni/api/staking/bonding/amplitude.d.ts +1 -1
  57. package/koni/api/staking/bonding/amplitude.js +8 -4
  58. package/koni/api/staking/bonding/astar.d.ts +2 -11
  59. package/koni/api/staking/bonding/astar.js +35 -229
  60. package/koni/api/staking/bonding/index.d.ts +1 -1
  61. package/koni/api/staking/bonding/index.js +4 -4
  62. package/koni/api/staking/bonding/paraChain.d.ts +1 -1
  63. package/koni/api/staking/bonding/paraChain.js +17 -11
  64. package/koni/api/staking/bonding/relayChain.d.ts +1 -1
  65. package/koni/api/staking/bonding/relayChain.js +63 -8
  66. package/koni/api/staking/bonding/utils.d.ts +13 -1
  67. package/koni/api/staking/bonding/utils.js +27 -3
  68. package/koni/api/xcm/index.js +1 -112
  69. package/koni/api/xcm/polkadotXcm.js +1 -1
  70. package/koni/api/xcm/xTokens.js +3 -5
  71. package/koni/background/cron.js +60 -60
  72. package/koni/background/handlers/Extension.js +71 -76
  73. package/koni/background/handlers/State.d.ts +16 -14
  74. package/koni/background/handlers/State.js +126 -91
  75. package/koni/background/handlers/Tabs.js +22 -19
  76. package/koni/background/subscription.d.ts +1 -1
  77. package/koni/background/subscription.js +49 -44
  78. package/package.json +56 -16
  79. package/packageInfo.js +1 -1
  80. package/page/index.d.ts +2 -0
  81. package/page/index.js +4 -0
  82. package/services/chain-service/constants.d.ts +0 -1
  83. package/services/chain-service/constants.js +0 -9
  84. package/services/chain-service/index.d.ts +6 -4
  85. package/services/chain-service/index.js +39 -7
  86. package/services/chain-service/utils.d.ts +1 -0
  87. package/services/chain-service/utils.js +3 -0
  88. package/services/event-service/index.d.ts +22 -0
  89. package/services/event-service/index.js +59 -0
  90. package/services/event-service/types.d.ts +32 -0
  91. package/services/event-service/types.js +1 -0
  92. package/services/history-service/index.d.ts +5 -3
  93. package/services/history-service/index.js +36 -17
  94. package/services/history-service/subsquid-multi-chain-history.js +7 -2
  95. package/services/keyring-service/index.d.ts +19 -0
  96. package/services/keyring-service/index.js +93 -0
  97. package/services/migration-service/index.js +11 -9
  98. package/services/migration-service/scripts/AutoEnableChainsTokens.d.ts +4 -0
  99. package/services/migration-service/scripts/AutoEnableChainsTokens.js +13 -0
  100. package/services/migration-service/scripts/MigrateNetworkSettings.js +37 -18
  101. package/services/migration-service/scripts/MigrateSettings.d.ts +4 -0
  102. package/services/migration-service/scripts/MigrateSettings.js +23 -0
  103. package/services/migration-service/scripts/MigrateTransactionHistory.d.ts +4 -0
  104. package/services/migration-service/scripts/MigrateTransactionHistory.js +64 -0
  105. package/services/migration-service/scripts/index.d.ts +1 -0
  106. package/services/migration-service/scripts/index.js +10 -3
  107. package/services/price-service/coingecko.js +16 -3
  108. package/services/price-service/index.d.ts +5 -3
  109. package/services/price-service/index.js +15 -17
  110. package/services/request-service/constants.d.ts +1 -0
  111. package/services/request-service/constants.js +6 -1
  112. package/services/request-service/handler/AuthRequestHandler.d.ts +8 -1
  113. package/services/request-service/handler/AuthRequestHandler.js +40 -13
  114. package/services/request-service/index.d.ts +7 -1
  115. package/services/request-service/index.js +3 -0
  116. package/services/storage-service/DatabaseService.js +1 -1
  117. package/services/storage-service/databases/index.js +1 -1
  118. package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.d.ts +1 -1
  119. package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
  120. package/services/storage-service/db-stores/Nft.d.ts +2 -1
  121. package/services/storage-service/db-stores/Nft.js +4 -1
  122. package/services/storage-service/db-stores/Transaction.js +10 -7
  123. package/services/subscan-service/index.d.ts +20 -0
  124. package/services/subscan-service/index.js +99 -0
  125. package/services/subscan-service/subscan-chain-map.d.ts +5 -0
  126. package/services/subscan-service/subscan-chain-map.js +63 -0
  127. package/services/subscan-service/types.d.ts +27 -0
  128. package/services/subscan-service/types.js +1 -0
  129. package/services/transaction-service/event-parser/index.d.ts +2 -2
  130. package/services/transaction-service/index.d.ts +4 -2
  131. package/services/transaction-service/index.js +45 -10
  132. package/services/transaction-service/utils.js +5 -6
  133. package/utils/address.d.ts +1 -0
  134. package/utils/address.js +9 -2
  135. package/utils/index.d.ts +1 -0
  136. package/utils/index.js +21 -12
  137. package/cjs/background/errors/EvmRpcError.js +0 -21
  138. package/cjs/background/errors/SubWalletProviderError.js +0 -17
  139. package/cjs/constants/ethereum.js +0 -19
  140. package/cjs/errors/SubWalletProviderError.js +0 -17
  141. package/cjs/koni/api/xcm/astar.js +0 -160
  142. package/cjs/koni/api/xcm/moonbeamXcm.js +0 -80
  143. package/cjs/koni/api/xcm/statemintXcm.js +0 -197
  144. package/cjs/koni/api/xcm/substrateXcm.js +0 -213
  145. package/cjs/koni/migration/Base.js +0 -20
  146. package/cjs/koni/migration/index.js +0 -45
  147. package/cjs/koni/migration/scripts/ChangeRouteToHome.js +0 -22
  148. package/cjs/koni/migration/scripts/ClearOldStorage.js +0 -24
  149. package/cjs/koni/migration/scripts/RemoveWrongTransactionHistoriesFromStore.js +0 -36
  150. package/cjs/koni/migration/scripts/ResetTransactionHistoryEventIdx.js +0 -21
  151. package/cjs/koni/migration/scripts/index.js +0 -22
  152. package/cjs/koni/page/index.js +0 -16
  153. package/cjs/services/asset-service/index.js +0 -91
  154. package/cjs/services/storage-service/db-stores/ExtraDelegationInfo.js +0 -17
  155. package/cjs/stores/Balance.js +0 -18
  156. package/cjs/stores/Crowdloan.js +0 -18
  157. package/cjs/stores/CustomEvmToken.js +0 -18
  158. package/cjs/stores/NetworkMap.js +0 -18
  159. package/cjs/stores/Nft.js +0 -18
  160. package/cjs/stores/NftCollection.js +0 -18
  161. package/cjs/stores/Price.js +0 -18
  162. package/cjs/stores/Staking.js +0 -18
  163. package/cjs/stores/StakingReward.js +0 -18
  164. package/cjs/utils/eth/parseTransactionData.js +0 -284
  165. package/koni/page/index.d.ts +0 -2
  166. package/koni/page/index.js +0 -9
  167. /package/cjs/{koni/page → page}/SubWalleEvmProvider.js +0 -0
  168. /package/{koni/page → page}/SubWalleEvmProvider.d.ts +0 -0
  169. /package/{koni/page → page}/SubWalleEvmProvider.js +0 -0
@@ -62,6 +62,7 @@ const ACCOUNT_ALL_JSON = {
62
62
  name: 'All'
63
63
  };
64
64
  class KoniExtension {
65
+ #lockTimeOut = undefined;
65
66
  #koniState;
66
67
  constructor(state) {
67
68
  this.#koniState = state;
@@ -439,19 +440,18 @@ class KoniExtension {
439
440
  accounts
440
441
  };
441
442
  setTimeout(() => {
442
- this.#koniState.getCurrentAccount(accountInfo => {
443
- if (accountInfo) {
444
- accountsWithCurrentAddress.currentAddress = accountInfo.address;
445
- if (accountInfo.address === _constants.ALL_ACCOUNT_KEY) {
446
- accountsWithCurrentAddress.currentGenesisHash = accountInfo.currentGenesisHash;
447
- } else {
448
- const acc = accounts.find(a => a.address === accountInfo.address);
449
- accountsWithCurrentAddress.currentGenesisHash = (acc === null || acc === void 0 ? void 0 : acc.genesisHash) || _constants.ALL_GENESIS_HASH;
450
- }
443
+ const accountInfo = this.#koniState.keyringService.currentAccount;
444
+ if (accountInfo) {
445
+ accountsWithCurrentAddress.currentAddress = accountInfo.address;
446
+ if (accountInfo.address === _constants.ALL_ACCOUNT_KEY) {
447
+ accountsWithCurrentAddress.currentGenesisHash = accountInfo.currentGenesisHash;
448
+ } else {
449
+ const acc = accounts.find(a => a.address === accountInfo.address);
450
+ accountsWithCurrentAddress.currentGenesisHash = (acc === null || acc === void 0 ? void 0 : acc.genesisHash) || _constants.ALL_GENESIS_HASH;
451
451
  }
452
- resolve(accountsWithCurrentAddress);
453
- cb(accountsWithCurrentAddress);
454
- });
452
+ }
453
+ resolve(accountsWithCurrentAddress);
454
+ cb(accountsWithCurrentAddress);
455
455
  }, 300);
456
456
  });
457
457
  this.createUnsubscriptionHandle(id, subscription.unsubscribe);
@@ -830,25 +830,24 @@ class KoniExtension {
830
830
  return await this.#koniState.getAuthList();
831
831
  }
832
832
  _saveCurrentAccountAddress(address, callback) {
833
- this.#koniState.getCurrentAccount(accountInfo => {
834
- if (!accountInfo) {
835
- accountInfo = {
836
- address,
837
- currentGenesisHash: _constants.ALL_GENESIS_HASH,
838
- allGenesisHash: _constants.ALL_GENESIS_HASH || undefined
839
- };
833
+ let accountInfo = this.#koniState.keyringService.currentAccount;
834
+ if (!accountInfo) {
835
+ accountInfo = {
836
+ address,
837
+ currentGenesisHash: _constants.ALL_GENESIS_HASH,
838
+ allGenesisHash: _constants.ALL_GENESIS_HASH || undefined
839
+ };
840
+ } else {
841
+ accountInfo.address = address;
842
+ if (address !== _constants.ALL_ACCOUNT_KEY) {
843
+ const currentKeyPair = _uiKeyring.keyring.getAccount(address);
844
+ accountInfo.currentGenesisHash = (currentKeyPair === null || currentKeyPair === void 0 ? void 0 : currentKeyPair.meta.genesisHash) || _constants.ALL_GENESIS_HASH;
840
845
  } else {
841
- accountInfo.address = address;
842
- if (address !== _constants.ALL_ACCOUNT_KEY) {
843
- const currentKeyPair = _uiKeyring.keyring.getAccount(address);
844
- accountInfo.currentGenesisHash = (currentKeyPair === null || currentKeyPair === void 0 ? void 0 : currentKeyPair.meta.genesisHash) || _constants.ALL_GENESIS_HASH;
845
- } else {
846
- accountInfo.currentGenesisHash = accountInfo.allGenesisHash || _constants.ALL_GENESIS_HASH;
847
- }
846
+ accountInfo.currentGenesisHash = accountInfo.allGenesisHash || _constants.ALL_GENESIS_HASH;
848
847
  }
849
- this.#koniState.setCurrentAccount(accountInfo, () => {
850
- callback && callback(accountInfo);
851
- });
848
+ }
849
+ this.#koniState.setCurrentAccount(accountInfo, () => {
850
+ callback && callback(accountInfo);
852
851
  });
853
852
  }
854
853
  updateCurrentAccountAddress(address) {
@@ -1004,16 +1003,10 @@ class KoniExtension {
1004
1003
  throw Error('Require password to set up master password');
1005
1004
  } else {
1006
1005
  _uiKeyring.keyring.changeMasterPassword(password);
1007
- this.#koniState.setKeyringState({
1008
- hasMasterPassword: true,
1009
- isLocked: false,
1010
- isReady: true
1011
- });
1006
+ this.#koniState.updateKeyringState();
1012
1007
  }
1013
1008
  }
1014
- const currentAccount = await new Promise(resolve => {
1015
- this.#koniState.getCurrentAccount(resolve);
1016
- });
1009
+ const currentAccount = this.#koniState.keyringService.currentAccount;
1017
1010
  const allGenesisHash = (currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.allGenesisHash) || undefined;
1018
1011
  types === null || types === void 0 ? void 0 : types.forEach(type => {
1019
1012
  const suri = getSuri(_suri, type);
@@ -1074,29 +1067,22 @@ class KoniExtension {
1074
1067
  });
1075
1068
  });
1076
1069
 
1077
- // Remove history
1078
- await this.#koniState.historyService.removeHistoryByAddress(address);
1079
-
1080
1070
  // Set current account to all account
1081
1071
  await new Promise(resolve => {
1082
- this.#koniState.getCurrentAccount(_ref28 => {
1083
- let {
1084
- allGenesisHash
1085
- } = _ref28;
1086
- this.#koniState.setCurrentAccount({
1087
- currentGenesisHash: allGenesisHash || null,
1088
- address: _constants.ALL_ACCOUNT_KEY
1089
- }, resolve);
1090
- });
1072
+ const currentAccountInfo = this.#koniState.keyringService.currentAccount;
1073
+ this.#koniState.setCurrentAccount({
1074
+ currentGenesisHash: (currentAccountInfo === null || currentAccountInfo === void 0 ? void 0 : currentAccountInfo.allGenesisHash) || null,
1075
+ address: _constants.ALL_ACCOUNT_KEY
1076
+ }, resolve);
1091
1077
  });
1092
1078
  return true;
1093
1079
  }
1094
- seedCreateV2(_ref29) {
1080
+ seedCreateV2(_ref28) {
1095
1081
  let {
1096
1082
  length = _Extension.SEED_DEFAULT_LENGTH,
1097
1083
  seed: _seed,
1098
1084
  types
1099
- } = _ref29;
1085
+ } = _ref28;
1100
1086
  const seed = _seed || (0, _utilCrypto.mnemonicGenerate)(length);
1101
1087
  const rs = {
1102
1088
  seed: seed,
@@ -1107,11 +1093,11 @@ class KoniExtension {
1107
1093
  });
1108
1094
  return rs;
1109
1095
  }
1110
- seedValidateV2(_ref30) {
1096
+ seedValidateV2(_ref29) {
1111
1097
  let {
1112
1098
  suri,
1113
1099
  types
1114
- } = _ref30;
1100
+ } = _ref29;
1115
1101
  const {
1116
1102
  phrase
1117
1103
  } = (0, _utilCrypto.keyExtractSuri)(suri);
@@ -1131,11 +1117,11 @@ class KoniExtension {
1131
1117
  });
1132
1118
  return rs;
1133
1119
  }
1134
- _checkValidatePrivateKey(_ref31) {
1120
+ _checkValidatePrivateKey(_ref30) {
1135
1121
  let {
1136
1122
  suri,
1137
1123
  types
1138
- } = _ref31;
1124
+ } = _ref30;
1139
1125
  let autoAddPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1140
1126
  const {
1141
1127
  phrase
@@ -1158,11 +1144,11 @@ class KoniExtension {
1158
1144
  }
1159
1145
  return rs;
1160
1146
  }
1161
- metamaskPrivateKeyValidateV2(_ref32) {
1147
+ metamaskPrivateKeyValidateV2(_ref31) {
1162
1148
  let {
1163
1149
  suri,
1164
1150
  types
1165
- } = _ref32;
1151
+ } = _ref31;
1166
1152
  const isValidSuri = suri.startsWith('0x');
1167
1153
  if (isValidSuri) {
1168
1154
  return this._checkValidatePrivateKey({
@@ -1187,14 +1173,14 @@ class KoniExtension {
1187
1173
  throw new Error(`"${suri}" is not a valid derivation path`);
1188
1174
  }
1189
1175
  }
1190
- derivationCreateV2(_ref33) {
1176
+ derivationCreateV2(_ref32) {
1191
1177
  let {
1192
1178
  genesisHash,
1193
1179
  isAllowed,
1194
1180
  name,
1195
1181
  parentAddress,
1196
1182
  suri
1197
- } = _ref33;
1183
+ } = _ref32;
1198
1184
  const childPair = this.deriveV2(parentAddress, suri, {
1199
1185
  genesisHash,
1200
1186
  name,
@@ -1208,14 +1194,14 @@ class KoniExtension {
1208
1194
  });
1209
1195
  return true;
1210
1196
  }
1211
- jsonRestoreV2(_ref34) {
1197
+ jsonRestoreV2(_ref33) {
1212
1198
  let {
1213
1199
  address,
1214
1200
  file,
1215
1201
  isAllowed,
1216
1202
  password,
1217
1203
  withMasterPassword
1218
- } = _ref34;
1204
+ } = _ref33;
1219
1205
  const isPasswordValidated = this.validatePassword(file, password);
1220
1206
  if (isPasswordValidated) {
1221
1207
  try {
@@ -1230,13 +1216,13 @@ class KoniExtension {
1230
1216
  throw new Error('Unable to decode using the supplied passphrase');
1231
1217
  }
1232
1218
  }
1233
- batchRestoreV2(_ref35) {
1219
+ batchRestoreV2(_ref34) {
1234
1220
  let {
1235
1221
  accountsInfo,
1236
1222
  file,
1237
1223
  isAllowed,
1238
1224
  password
1239
- } = _ref35;
1225
+ } = _ref34;
1240
1226
  const addressList = accountsInfo.map(acc => acc.address);
1241
1227
  const isPasswordValidated = this.validatedAccountsPassword(file, password);
1242
1228
  if (isPasswordValidated) {
@@ -1346,7 +1332,7 @@ class KoniExtension {
1346
1332
  if (!tokenInfo) {
1347
1333
  errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, 'Not found token from registry'));
1348
1334
  }
1349
- if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && !(0, _utils._isNativeToken)(tokenInfo) && !(0, _utils._isTokenEvmSmartContract)(tokenInfo)) {
1335
+ if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils._isTokenEvmSmartContract)(tokenInfo) && (0, _utils._getContractAddressOfToken)(tokenInfo).length === 0) {
1350
1336
  errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, 'Not found ERC20 address for this token'));
1351
1337
  }
1352
1338
  return [errors, keypair, transferValue, tokenInfo];
@@ -1386,7 +1372,7 @@ class KoniExtension {
1386
1372
  const txVal = transferAll ? freeBalance.value : value || '0';
1387
1373
 
1388
1374
  // Estimate with EVM API
1389
- if ((0, _utils._isTokenEvmSmartContract)(tokenInfo)) {
1375
+ if ((0, _utils._isTokenEvmSmartContract)(tokenInfo) || (0, _utils._isLocalToken)(tokenInfo)) {
1390
1376
  [transaction, transferAmount.value] = await (0, _transfer3.getERC20TransactionObject)((0, _utils._getContractAddressOfToken)(tokenInfo), chainInfo, from, to, txVal, !!transferAll, evmApiMap);
1391
1377
  } else {
1392
1378
  [transaction, transferAmount.value] = await (0, _transfer3.getEVMTransactionObject)(chainInfo, to, txVal, !!transferAll, evmApiMap);
@@ -1507,11 +1493,11 @@ class KoniExtension {
1507
1493
  async enableChain(networkKey) {
1508
1494
  return await this.#koniState.enableChain(networkKey);
1509
1495
  }
1510
- async validateNetwork(_ref36) {
1496
+ async validateNetwork(_ref35) {
1511
1497
  let {
1512
1498
  existedChainSlug,
1513
1499
  provider
1514
- } = _ref36;
1500
+ } = _ref35;
1515
1501
  return await this.#koniState.validateCustomChain(provider, existedChainSlug);
1516
1502
  }
1517
1503
  resetDefaultNetwork() {
@@ -1549,20 +1535,20 @@ class KoniExtension {
1549
1535
  async validateCustomAsset(data) {
1550
1536
  return await this.#koniState.validateCustomAsset(data);
1551
1537
  }
1552
- async getAddressFreeBalance(_ref37) {
1538
+ async getAddressFreeBalance(_ref36) {
1553
1539
  let {
1554
1540
  address,
1555
1541
  networkKey,
1556
1542
  token
1557
- } = _ref37;
1543
+ } = _ref36;
1558
1544
  return await this.#koniState.balanceService.getTokenFreeBalance(address, networkKey, token);
1559
1545
  }
1560
- async subscribeAddressFreeBalance(_ref38, id, port) {
1546
+ async subscribeAddressFreeBalance(_ref37, id, port) {
1561
1547
  let {
1562
1548
  address,
1563
1549
  networkKey,
1564
1550
  token
1565
- } = _ref38;
1551
+ } = _ref37;
1566
1552
  const cb = (0, _subscriptions.createSubscription)(id, port);
1567
1553
  const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTokenFreeBalance(address, networkKey, token, cb);
1568
1554
  this.createUnsubscriptionHandle(id, unsub);
@@ -1571,26 +1557,26 @@ class KoniExtension {
1571
1557
  });
1572
1558
  return currentFreeBalance;
1573
1559
  }
1574
- async transferCheckReferenceCount(_ref39) {
1560
+ async transferCheckReferenceCount(_ref38) {
1575
1561
  let {
1576
1562
  address,
1577
1563
  networkKey
1578
- } = _ref39;
1564
+ } = _ref38;
1579
1565
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return
1580
1566
  return await (0, _transfer.checkReferenceCount)(networkKey, address, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
1581
1567
  }
1582
- async transferCheckSupporting(_ref40) {
1568
+ async transferCheckSupporting(_ref39) {
1583
1569
  let {
1584
1570
  networkKey,
1585
1571
  tokenSlug
1586
- } = _ref40;
1572
+ } = _ref39;
1587
1573
  const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1588
1574
  return await (0, _transfer.checkSupportTransfer)(networkKey, tokenInfo, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
1589
1575
  }
1590
- transferGetExistentialDeposit(_ref41) {
1576
+ transferGetExistentialDeposit(_ref40) {
1591
1577
  let {
1592
1578
  tokenSlug
1593
- } = _ref41;
1579
+ } = _ref40;
1594
1580
  const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1595
1581
  return (0, _utils._getTokenMinAmount)(tokenInfo);
1596
1582
  }
@@ -1631,10 +1617,10 @@ class KoniExtension {
1631
1617
  }
1632
1618
  return true;
1633
1619
  }
1634
- getAccountMeta(_ref42) {
1620
+ getAccountMeta(_ref41) {
1635
1621
  let {
1636
1622
  address
1637
- } = _ref42;
1623
+ } = _ref41;
1638
1624
  const pair = _uiKeyring.keyring.getPair(address);
1639
1625
  (0, _util.assert)(pair, 'Unable to find pair');
1640
1626
  return {
@@ -1658,14 +1644,14 @@ class KoniExtension {
1658
1644
  // });
1659
1645
  // }
1660
1646
 
1661
- accountsTie2(_ref43) {
1647
+ accountsTie2(_ref42) {
1662
1648
  let {
1663
1649
  address,
1664
1650
  genesisHash
1665
- } = _ref43;
1651
+ } = _ref42;
1666
1652
  return this.#koniState.setAccountTie(address, genesisHash);
1667
1653
  }
1668
- async accountsCreateExternalV2(_ref44) {
1654
+ async accountsCreateExternalV2(_ref43) {
1669
1655
  let {
1670
1656
  address,
1671
1657
  genesisHash,
@@ -1673,7 +1659,7 @@ class KoniExtension {
1673
1659
  isEthereum,
1674
1660
  isReadOnly,
1675
1661
  name
1676
- } = _ref44;
1662
+ } = _ref43;
1677
1663
  try {
1678
1664
  let result;
1679
1665
  try {
@@ -1732,7 +1718,7 @@ class KoniExtension {
1732
1718
  }];
1733
1719
  }
1734
1720
  }
1735
- async accountsCreateHardwareV2(_ref45) {
1721
+ async accountsCreateHardwareV2(_ref44) {
1736
1722
  let {
1737
1723
  accountIndex,
1738
1724
  address,
@@ -1741,7 +1727,7 @@ class KoniExtension {
1741
1727
  hardwareType,
1742
1728
  isAllowed,
1743
1729
  name
1744
- } = _ref45;
1730
+ } = _ref44;
1745
1731
  const key = _uiKeyring.keyring.addHardware(address, hardwareType, {
1746
1732
  accountIndex,
1747
1733
  addressOffset,
@@ -1764,10 +1750,10 @@ class KoniExtension {
1764
1750
  });
1765
1751
  return true;
1766
1752
  }
1767
- async accountsCreateHardwareMultiple(_ref46) {
1753
+ async accountsCreateHardwareMultiple(_ref45) {
1768
1754
  let {
1769
1755
  accounts
1770
- } = _ref46;
1756
+ } = _ref45;
1771
1757
  const addresses = [];
1772
1758
  if (!accounts.length) {
1773
1759
  throw new Error('No accounts to import');
@@ -1796,9 +1782,7 @@ class KoniExtension {
1796
1782
  resolve();
1797
1783
  });
1798
1784
  }
1799
- const currentAccount = await new Promise(resolve => {
1800
- this.#koniState.getCurrentAccount(resolve);
1801
- });
1785
+ const currentAccount = this.#koniState.keyringService.currentAccount;
1802
1786
  const allGenesisHash = (currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.allGenesisHash) || undefined;
1803
1787
  if (addresses.length <= 1) {
1804
1788
  this.#koniState.setCurrentAccount({
@@ -1820,14 +1804,14 @@ class KoniExtension {
1820
1804
  });
1821
1805
  return true;
1822
1806
  }
1823
- async accountsCreateWithSecret(_ref47) {
1807
+ async accountsCreateWithSecret(_ref46) {
1824
1808
  let {
1825
1809
  isAllow,
1826
1810
  isEthereum,
1827
1811
  name,
1828
1812
  publicKey,
1829
1813
  secretKey
1830
- } = _ref47;
1814
+ } = _ref46;
1831
1815
  try {
1832
1816
  let keyringPair = null;
1833
1817
  if (isEthereum) {
@@ -1970,30 +1954,30 @@ class KoniExtension {
1970
1954
 
1971
1955
  // Parse transaction
1972
1956
 
1973
- parseSubstrateTransaction(_ref48) {
1957
+ parseSubstrateTransaction(_ref47) {
1974
1958
  let {
1975
1959
  data,
1976
1960
  networkKey
1977
- } = _ref48;
1961
+ } = _ref47;
1978
1962
  const apiProps = this.#koniState.getSubstrateApi(networkKey);
1979
1963
  const apiPromise = apiProps.api;
1980
1964
  return (0, _parseTransaction.parseSubstrateTransaction)(data, apiPromise);
1981
1965
  }
1982
- async parseEVMRLP(_ref49) {
1966
+ async parseEVMRLP(_ref48) {
1983
1967
  let {
1984
1968
  data
1985
- } = _ref49;
1969
+ } = _ref48;
1986
1970
  return await (0, _parseTransaction2.parseEvmRlp)(data, this.#koniState.getChainInfoMap(), this.#koniState.getEvmApiMap());
1987
1971
  }
1988
1972
 
1989
1973
  // Sign
1990
1974
 
1991
- qrSignSubstrate(_ref50) {
1975
+ qrSignSubstrate(_ref49) {
1992
1976
  let {
1993
1977
  address,
1994
1978
  data,
1995
1979
  networkKey
1996
- } = _ref50;
1980
+ } = _ref49;
1997
1981
  const pair = _uiKeyring.keyring.getPair(address);
1998
1982
  (0, _util.assert)(pair, 'Unable to find pair');
1999
1983
  if (pair.isLocked) {
@@ -2010,13 +1994,13 @@ class KoniExtension {
2010
1994
  signature: signed
2011
1995
  };
2012
1996
  }
2013
- async qrSignEVM(_ref51) {
1997
+ async qrSignEVM(_ref50) {
2014
1998
  let {
2015
1999
  address,
2016
2000
  chainId,
2017
2001
  message,
2018
2002
  type
2019
- } = _ref51;
2003
+ } = _ref50;
2020
2004
  let signed;
2021
2005
  const network = this.getNetworkJsonByChainId(chainId);
2022
2006
  if (!network) {
@@ -2097,11 +2081,11 @@ class KoniExtension {
2097
2081
  });
2098
2082
  return this.#koniState.getNominatorMetadata();
2099
2083
  }
2100
- async getBondingOptions(_ref52) {
2084
+ async getBondingOptions(_ref51) {
2101
2085
  let {
2102
2086
  chain,
2103
2087
  type
2104
- } = _ref52;
2088
+ } = _ref51;
2105
2089
  const apiProps = this.#koniState.getSubstrateApi(chain);
2106
2090
  const chainInfo = this.#koniState.getChainInfo(chain);
2107
2091
  const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, type);
@@ -2119,21 +2103,23 @@ class KoniExtension {
2119
2103
  }
2120
2104
  async submitBonding(inputData) {
2121
2105
  const {
2106
+ address,
2122
2107
  amount,
2123
2108
  chain,
2124
2109
  nominatorMetadata,
2125
2110
  selectedValidators
2126
2111
  } = inputData;
2127
- if (!amount || !nominatorMetadata || !selectedValidators) {
2112
+ if (!amount || !selectedValidators) {
2128
2113
  // Todo: Check and return error here
2129
2114
 
2130
2115
  return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
2131
2116
  }
2132
2117
  const chainInfo = this.#koniState.getChainInfo(chain);
2133
2118
  const substrateApi = this.#koniState.getSubstrateApi(chain);
2134
- const extrinsic = await (0, _bonding.getBondingExtrinsic)(chainInfo, amount, nominatorMetadata, selectedValidators, substrateApi);
2119
+ const extrinsic = await (0, _bonding.getBondingExtrinsic)(chainInfo, amount, selectedValidators, substrateApi, address, nominatorMetadata);
2120
+ console.log('Bonding extrinsic: ', chain, extrinsic.toHex());
2135
2121
  return await this.#koniState.transactionService.handleTransaction({
2136
- address: nominatorMetadata.address,
2122
+ address,
2137
2123
  chain: chain,
2138
2124
  chainType: _KoniTypes.ChainType.SUBSTRATE,
2139
2125
  data: inputData,
@@ -2154,6 +2140,7 @@ class KoniExtension {
2154
2140
  }
2155
2141
  const substrateApi = this.#koniState.getSubstrateApi(chain);
2156
2142
  const extrinsic = await (0, _bonding.getUnbondingExtrinsic)(nominatorMetadata, amount, chain, substrateApi, validatorAddress);
2143
+ console.log('unbonding extrinsic: ', extrinsic.toHex());
2157
2144
  return await this.#koniState.transactionService.handleTransaction({
2158
2145
  address: nominatorMetadata.address,
2159
2146
  chain: chain,
@@ -2174,6 +2161,7 @@ class KoniExtension {
2174
2161
  }
2175
2162
  const dotSamaApi = this.#koniState.getSubstrateApi(chain);
2176
2163
  const extrinsic = await (0, _bonding.getWithdrawalExtrinsic)(dotSamaApi, chain, nominatorMetadata, validatorAddress);
2164
+ console.log('Stake withdrawal extrinsic: ', extrinsic.toHex());
2177
2165
  return await this.#koniState.transactionService.handleTransaction({
2178
2166
  address: nominatorMetadata.address,
2179
2167
  chain: chain,
@@ -2195,6 +2183,7 @@ class KoniExtension {
2195
2183
  }
2196
2184
  const substrateApi = this.#koniState.getSubstrateApi(chain);
2197
2185
  const extrinsic = await (0, _bonding.getClaimRewardExtrinsic)(substrateApi, chain, address, stakingType, bondReward);
2186
+ console.log('Staking claim reward extrinsic: ', extrinsic.toHex());
2198
2187
  return await this.#koniState.transactionService.handleTransaction({
2199
2188
  address,
2200
2189
  chain: chain,
@@ -2215,6 +2204,7 @@ class KoniExtension {
2215
2204
  }
2216
2205
  const substrateApi = this.#koniState.getSubstrateApi(chain);
2217
2206
  const extrinsic = await (0, _bonding.getCancelWithdrawalExtrinsic)(substrateApi, chain, selectedUnstaking);
2207
+ console.log('Cancel stake withdrawal extrinsic', extrinsic.toHex());
2218
2208
  return await this.#koniState.transactionService.handleTransaction({
2219
2209
  address,
2220
2210
  chain,
@@ -2232,8 +2222,11 @@ class KoniExtension {
2232
2222
  nominatorMetadata,
2233
2223
  selectedPool
2234
2224
  } = inputData;
2225
+
2226
+ // TODO: can't stake when unstake all
2235
2227
  const substrateApi = this.#koniState.getSubstrateApi(chain);
2236
2228
  const extrinsic = await (0, _relayChain.getPoolingBondingExtrinsic)(substrateApi, amount, selectedPool.id, nominatorMetadata);
2229
+ console.log('Join nomination pool extrinsic', extrinsic.toHex());
2237
2230
  return await this.#koniState.transactionService.handleTransaction({
2238
2231
  address,
2239
2232
  chain,
@@ -2251,6 +2244,7 @@ class KoniExtension {
2251
2244
  } = inputData;
2252
2245
  const substrateApi = this.#koniState.getSubstrateApi(chain);
2253
2246
  const extrinsic = await (0, _relayChain.getPoolingUnbondingExtrinsic)(substrateApi, amount, nominatorMetadata);
2247
+ console.log('Nomination pool unbond extrinsic', extrinsic.toHex());
2254
2248
  return await this.#koniState.transactionService.handleTransaction({
2255
2249
  address: nominatorMetadata.address,
2256
2250
  chain,
@@ -2262,12 +2256,12 @@ class KoniExtension {
2262
2256
  }
2263
2257
 
2264
2258
  // EVM Transaction
2265
- async parseContractInput(_ref53) {
2259
+ async parseContractInput(_ref52) {
2266
2260
  let {
2267
2261
  chainId,
2268
2262
  contract,
2269
2263
  data
2270
- } = _ref53;
2264
+ } = _ref52;
2271
2265
  const network = this.getNetworkJsonByChainId(chainId);
2272
2266
  return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
2273
2267
  }
@@ -2322,19 +2316,20 @@ class KoniExtension {
2322
2316
  }
2323
2317
  keyringStateSubscribe(id, port) {
2324
2318
  const cb = (0, _subscriptions.createSubscription)(id, port);
2325
- const subscription = this.#koniState.subscribeKeyringState().subscribe(value => cb(value));
2319
+ const keyringStateSubject = this.#koniState.keyringService.keyringStateSubject;
2320
+ const subscription = keyringStateSubject.subscribe(value => cb(value));
2326
2321
  this.createUnsubscriptionHandle(id, subscription.unsubscribe);
2327
2322
  port.onDisconnect.addListener(() => {
2328
2323
  this.cancelSubscription(id);
2329
2324
  });
2330
- return this.#koniState.getKeyringState();
2325
+ return this.#koniState.keyringService.keyringState;
2331
2326
  }
2332
- keyringChangeMasterPassword(_ref54) {
2327
+ keyringChangeMasterPassword(_ref53) {
2333
2328
  let {
2334
2329
  createNew,
2335
2330
  newPassword,
2336
2331
  oldPassword
2337
- } = _ref54;
2332
+ } = _ref53;
2338
2333
  try {
2339
2334
  // Remove isMasterPassword meta if createNew
2340
2335
  if (createNew) {
@@ -2359,21 +2354,17 @@ class KoniExtension {
2359
2354
  status: false
2360
2355
  };
2361
2356
  }
2362
- this.#koniState.setKeyringState({
2363
- hasMasterPassword: true,
2364
- isLocked: false,
2365
- isReady: true
2366
- });
2357
+ this.#koniState.updateKeyringState();
2367
2358
  return {
2368
2359
  status: true,
2369
2360
  errors: []
2370
2361
  };
2371
2362
  }
2372
- keyringMigrateMasterPassword(_ref55) {
2363
+ keyringMigrateMasterPassword(_ref54) {
2373
2364
  let {
2374
2365
  address,
2375
2366
  password
2376
- } = _ref55;
2367
+ } = _ref54;
2377
2368
  try {
2378
2369
  _uiKeyring.keyring.migrateWithMasterPassword(address, password);
2379
2370
  } catch (e) {
@@ -2388,10 +2379,10 @@ class KoniExtension {
2388
2379
  errors: []
2389
2380
  };
2390
2381
  }
2391
- keyringUnlock(_ref56) {
2382
+ keyringUnlock(_ref55) {
2392
2383
  let {
2393
2384
  password
2394
- } = _ref56;
2385
+ } = _ref55;
2395
2386
  try {
2396
2387
  _uiKeyring.keyring.unlockKeyring(password);
2397
2388
  } catch (e) {
@@ -2400,11 +2391,7 @@ class KoniExtension {
2400
2391
  status: false
2401
2392
  };
2402
2393
  }
2403
- this.#koniState.setKeyringState({
2404
- isReady: true,
2405
- hasMasterPassword: true,
2406
- isLocked: false
2407
- });
2394
+ this.#koniState.updateKeyringState();
2408
2395
  return {
2409
2396
  status: true,
2410
2397
  errors: []
@@ -2412,17 +2399,14 @@ class KoniExtension {
2412
2399
  }
2413
2400
  keyringLock() {
2414
2401
  _uiKeyring.keyring.lockAll();
2415
- this.#koniState.setKeyringState({
2416
- isReady: true,
2417
- hasMasterPassword: true,
2418
- isLocked: true
2419
- });
2402
+ this.#koniState.updateKeyringState();
2403
+ clearTimeout(this.#lockTimeOut);
2420
2404
  }
2421
- keyringExportMnemonic(_ref57) {
2405
+ keyringExportMnemonic(_ref56) {
2422
2406
  let {
2423
2407
  address,
2424
2408
  password
2425
- } = _ref57;
2409
+ } = _ref56;
2426
2410
  const pair = _uiKeyring.keyring.getPair(address);
2427
2411
  const result = pair.exportMnemonic(password);
2428
2412
  return {
@@ -2431,10 +2415,10 @@ class KoniExtension {
2431
2415
  }
2432
2416
 
2433
2417
  /// Signing external request
2434
- signingApprovePasswordV2(_ref58) {
2418
+ signingApprovePasswordV2(_ref57) {
2435
2419
  let {
2436
2420
  id
2437
- } = _ref58;
2421
+ } = _ref57;
2438
2422
  const queued = this.#koniState.getSignRequest(id);
2439
2423
  (0, _util.assert)(queued, 'Unable to find request');
2440
2424
  const {
@@ -2461,6 +2445,7 @@ class KoniExtension {
2461
2445
  payload
2462
2446
  } = request;
2463
2447
  const registry = new _types.TypeRegistry();
2448
+ let isEvm = false;
2464
2449
  if ((0, _Extension.isJsonPayload)(payload)) {
2465
2450
  // Get the metadata for the genesisHash
2466
2451
  const currentMetadata = this.#koniState.knownMetadata.find(meta => meta.genesisHash === payload.genesisHash);
@@ -2470,33 +2455,38 @@ class KoniExtension {
2470
2455
  if (currentMetadata) {
2471
2456
  registry.register(currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.types);
2472
2457
  }
2458
+ const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
2459
+ if (chainInfo) {
2460
+ isEvm = (0, _utils._isChainEvmCompatible)(chainInfo);
2461
+ }
2473
2462
  }
2474
2463
  const result = request.sign(registry, pair);
2475
2464
  resolve({
2476
2465
  id,
2477
- ...result
2466
+ // In case evm chain, must be cut 2 character after 0x
2467
+ signature: isEvm ? `0x${result.signature.slice(4)}` : result.signature
2478
2468
  });
2479
2469
  return true;
2480
2470
  }
2481
2471
 
2482
2472
  /// Derive account
2483
2473
 
2484
- derivationCreateMultiple(_ref59) {
2474
+ derivationCreateMultiple(_ref58) {
2485
2475
  let {
2486
2476
  isAllowed,
2487
2477
  items,
2488
2478
  parentAddress
2489
- } = _ref59;
2479
+ } = _ref58;
2490
2480
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2491
2481
  const isEvm = parentPair.type === 'ethereum';
2492
2482
  if (parentPair.isLocked) {
2493
2483
  _uiKeyring.keyring.unlockPair(parentPair.address);
2494
2484
  }
2495
- const createChild = _ref60 => {
2485
+ const createChild = _ref59 => {
2496
2486
  let {
2497
2487
  name,
2498
2488
  suri
2499
- } = _ref60;
2489
+ } = _ref59;
2500
2490
  const meta = {
2501
2491
  name: name,
2502
2492
  parentAddress
@@ -2542,10 +2532,10 @@ class KoniExtension {
2542
2532
  }
2543
2533
  return true;
2544
2534
  }
2545
- derivationCreateV3(_ref61) {
2535
+ derivationCreateV3(_ref60) {
2546
2536
  let {
2547
2537
  address: parentAddress
2548
- } = _ref61;
2538
+ } = _ref60;
2549
2539
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2550
2540
  const isEvm = parentPair.type === 'ethereum';
2551
2541
  if (parentPair.isLocked) {
@@ -2577,11 +2567,11 @@ class KoniExtension {
2577
2567
  });
2578
2568
  return true;
2579
2569
  }
2580
- validateDerivePath(_ref62) {
2570
+ validateDerivePath(_ref61) {
2581
2571
  let {
2582
2572
  parentAddress,
2583
2573
  suri
2584
- } = _ref62;
2574
+ } = _ref61;
2585
2575
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2586
2576
  const isEvm = parentPair.type === 'ethereum';
2587
2577
  if (parentPair.isLocked) {
@@ -2614,12 +2604,12 @@ class KoniExtension {
2614
2604
  suri: meta.suri
2615
2605
  };
2616
2606
  }
2617
- getListDeriveAccounts(_ref63) {
2607
+ getListDeriveAccounts(_ref62) {
2618
2608
  let {
2619
2609
  limit,
2620
2610
  page,
2621
2611
  parentAddress
2622
- } = _ref63;
2612
+ } = _ref62;
2623
2613
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2624
2614
  const isEvm = parentPair.type === 'ethereum';
2625
2615
  if (parentPair.isLocked) {
@@ -2710,10 +2700,10 @@ class KoniExtension {
2710
2700
  getSupportedSmartContractTypes() {
2711
2701
  return this.#koniState.getSupportedSmartContractTypes();
2712
2702
  }
2713
- getTransaction(_ref64) {
2703
+ getTransaction(_ref63) {
2714
2704
  let {
2715
2705
  id
2716
- } = _ref64;
2706
+ } = _ref63;
2717
2707
  const {
2718
2708
  transaction,
2719
2709
  ...transactionResult
@@ -2723,8 +2713,8 @@ class KoniExtension {
2723
2713
  subscribeTransactions(id, port) {
2724
2714
  const cb = (0, _subscriptions.createSubscription)(id, port);
2725
2715
  function convertRs(rs) {
2726
- return Object.fromEntries(Object.entries(rs).map(_ref65 => {
2727
- let [key, value] = _ref65;
2716
+ return Object.fromEntries(Object.entries(rs).map(_ref64 => {
2717
+ let [key, value] = _ref64;
2728
2718
  const {
2729
2719
  transaction,
2730
2720
  ...transactionResult
@@ -2758,6 +2748,10 @@ class KoniExtension {
2758
2748
  // --------------------------------------------------------------
2759
2749
  // eslint-disable-next-line @typescript-eslint/require-await
2760
2750
  async handle(id, type, request, port) {
2751
+ clearTimeout(this.#lockTimeOut);
2752
+ this.#lockTimeOut = setTimeout(() => {
2753
+ this.keyringLock();
2754
+ }, _constants.DEFAULT_TIME_AUTO_LOCK);
2761
2755
  switch (type) {
2762
2756
  /// Clone from PolkadotJs
2763
2757
  case 'pri(accounts.create.external)':