@subwallet/extension-base 1.3.22-0 → 1.3.24-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 (210) hide show
  1. package/background/KoniTypes.d.ts +77 -4
  2. package/background/KoniTypes.js +2 -0
  3. package/cjs/background/KoniTypes.js +2 -0
  4. package/cjs/constants/environment.js +4 -2
  5. package/cjs/constants/index.js +21 -4
  6. package/cjs/constants/signing.js +6 -2
  7. package/cjs/core/logic-validation/recipientAddress.js +9 -1
  8. package/cjs/core/logic-validation/transfer.js +57 -36
  9. package/cjs/core/types.js +1 -0
  10. package/cjs/core/utils.js +12 -1
  11. package/cjs/defaults.js +1 -1
  12. package/cjs/koni/api/dotsama/crowdloan.js +1 -1
  13. package/cjs/koni/api/nft/index.js +9 -16
  14. package/cjs/koni/api/staking/index.js +3 -4
  15. package/cjs/koni/background/handlers/Extension.js +343 -185
  16. package/cjs/koni/background/handlers/State.js +17 -2
  17. package/cjs/koni/background/handlers/Tabs.js +1 -1
  18. package/cjs/packageInfo.js +1 -1
  19. package/cjs/services/balance-service/helpers/subscribe/cardano/consts.js +11 -0
  20. package/cjs/services/balance-service/helpers/subscribe/cardano/index.js +63 -0
  21. package/cjs/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
  22. package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +74 -0
  23. package/cjs/services/balance-service/helpers/subscribe/index.js +21 -7
  24. package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +2 -2
  25. package/cjs/services/balance-service/index.js +4 -2
  26. package/cjs/services/balance-service/transfer/cardano-transfer.js +122 -0
  27. package/cjs/services/balance-service/transfer/smart-contract.js +24 -3
  28. package/cjs/services/balance-service/transfer/token.js +4 -4
  29. package/cjs/services/chain-service/handler/CardanoApi.js +176 -0
  30. package/cjs/services/chain-service/handler/CardanoChainHandler.js +83 -0
  31. package/cjs/services/chain-service/handler/TonApi.js +2 -5
  32. package/cjs/services/chain-service/index.js +40 -7
  33. package/cjs/services/chain-service/utils/index.js +40 -11
  34. package/cjs/services/chain-service/utils/patch.js +1 -1
  35. package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
  36. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
  37. package/cjs/services/earning-service/service.js +6 -12
  38. package/cjs/services/fee-service/service.js +19 -8
  39. package/cjs/services/fee-service/utils/tokenPayFee.js +151 -0
  40. package/cjs/services/history-service/index.js +4 -6
  41. package/cjs/services/inapp-notification-service/index.js +12 -4
  42. package/cjs/services/keyring-service/context/account-context.js +17 -2
  43. package/cjs/services/keyring-service/context/handlers/Derive.js +10 -7
  44. package/cjs/services/keyring-service/context/handlers/Migration.js +268 -0
  45. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +2 -2
  46. package/cjs/services/keyring-service/context/handlers/Secret.js +1 -1
  47. package/cjs/services/keyring-service/utils.js +18 -0
  48. package/cjs/services/request-service/handler/CardanoRequestHandler.js +172 -0
  49. package/cjs/services/request-service/handler/EvmRequestHandler.js +1 -1
  50. package/cjs/services/request-service/handler/MetadataRequestHandler.js +5 -13
  51. package/cjs/services/request-service/index.js +22 -4
  52. package/cjs/services/setting-service/constants.js +10 -1
  53. package/cjs/services/storage-service/DatabaseService.js +3 -0
  54. package/cjs/services/storage-service/db-stores/InappNotification.js +6 -0
  55. package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -59
  56. package/cjs/services/swap-service/handler/chainflip-handler.js +33 -281
  57. package/cjs/services/swap-service/handler/hydradx-handler.js +23 -190
  58. package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -222
  59. package/cjs/services/swap-service/handler/uniswap-handler.js +331 -0
  60. package/cjs/services/swap-service/index.js +31 -22
  61. package/cjs/services/swap-service/utils.js +21 -38
  62. package/cjs/services/transaction-service/helpers/index.js +6 -1
  63. package/cjs/services/transaction-service/index.js +286 -26
  64. package/cjs/services/transaction-service/utils.js +5 -1
  65. package/cjs/types/account/info/keyring.js +12 -1
  66. package/cjs/types/fee/cardano.js +1 -0
  67. package/cjs/types/swap/index.js +7 -2
  68. package/cjs/utils/account/analyze.js +2 -1
  69. package/cjs/utils/account/common.js +29 -20
  70. package/cjs/utils/account/derive/info/solo.js +9 -4
  71. package/cjs/utils/account/derive/validate.js +36 -2
  72. package/cjs/utils/account/transform.js +38 -13
  73. package/cjs/utils/fee/transfer.js +87 -21
  74. package/cjs/utils/index.js +2 -2
  75. package/cjs/utils/staticData/index.js +7 -2
  76. package/constants/environment.d.ts +1 -0
  77. package/constants/environment.js +2 -1
  78. package/constants/index.d.ts +6 -1
  79. package/constants/index.js +14 -1
  80. package/constants/signing.js +6 -2
  81. package/core/logic-validation/recipientAddress.js +11 -3
  82. package/core/logic-validation/transfer.d.ts +1 -1
  83. package/core/logic-validation/transfer.js +33 -12
  84. package/core/substrate/xcm-parser.d.ts +1 -1
  85. package/core/types.d.ts +1 -0
  86. package/core/types.js +1 -0
  87. package/core/utils.d.ts +1 -0
  88. package/core/utils.js +13 -3
  89. package/defaults.d.ts +1 -1
  90. package/defaults.js +1 -1
  91. package/koni/api/dotsama/crowdloan.js +3 -3
  92. package/koni/api/nft/index.js +10 -16
  93. package/koni/api/nft/story_odyssey_nft/index.d.ts +1 -1
  94. package/koni/api/staking/index.js +4 -5
  95. package/koni/background/handlers/Extension.d.ts +9 -0
  96. package/koni/background/handlers/Extension.js +225 -69
  97. package/koni/background/handlers/State.d.ts +6 -2
  98. package/koni/background/handlers/State.js +18 -3
  99. package/koni/background/handlers/Tabs.js +1 -1
  100. package/package.json +76 -9
  101. package/packageInfo.js +1 -1
  102. package/services/balance-service/helpers/subscribe/cardano/consts.d.ts +1 -0
  103. package/services/balance-service/helpers/subscribe/cardano/consts.js +4 -0
  104. package/services/balance-service/helpers/subscribe/cardano/index.d.ts +2 -0
  105. package/services/balance-service/helpers/subscribe/cardano/index.js +57 -0
  106. package/services/balance-service/helpers/subscribe/cardano/types.d.ts +34 -0
  107. package/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
  108. package/services/balance-service/helpers/subscribe/cardano/utils.d.ts +15 -0
  109. package/services/balance-service/helpers/subscribe/cardano/utils.js +62 -0
  110. package/services/balance-service/helpers/subscribe/index.d.ts +2 -2
  111. package/services/balance-service/helpers/subscribe/index.js +23 -9
  112. package/services/balance-service/helpers/subscribe/ton/utils.d.ts +1 -1
  113. package/services/balance-service/helpers/subscribe/ton/utils.js +1 -1
  114. package/services/balance-service/index.js +4 -2
  115. package/services/balance-service/transfer/cardano-transfer.d.ts +24 -0
  116. package/services/balance-service/transfer/cardano-transfer.js +114 -0
  117. package/services/balance-service/transfer/smart-contract.d.ts +4 -2
  118. package/services/balance-service/transfer/smart-contract.js +24 -3
  119. package/services/balance-service/transfer/token.d.ts +1 -1
  120. package/services/balance-service/transfer/token.js +2 -2
  121. package/services/chain-service/handler/CardanoApi.d.ts +38 -0
  122. package/services/chain-service/handler/CardanoApi.js +167 -0
  123. package/services/chain-service/handler/CardanoChainHandler.d.ts +17 -0
  124. package/services/chain-service/handler/CardanoChainHandler.js +75 -0
  125. package/services/chain-service/handler/TonApi.js +3 -6
  126. package/services/chain-service/handler/types.d.ts +1 -0
  127. package/services/chain-service/index.d.ts +4 -1
  128. package/services/chain-service/index.js +41 -8
  129. package/services/chain-service/types.d.ts +9 -1
  130. package/services/chain-service/utils/index.d.ts +4 -0
  131. package/services/chain-service/utils/index.js +32 -11
  132. package/services/chain-service/utils/patch.js +1 -1
  133. package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
  134. package/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
  135. package/services/earning-service/service.js +8 -14
  136. package/services/fee-service/interfaces.d.ts +25 -0
  137. package/services/fee-service/service.js +19 -8
  138. package/services/fee-service/utils/tokenPayFee.d.ts +8 -0
  139. package/services/fee-service/utils/tokenPayFee.js +141 -0
  140. package/services/history-service/index.js +6 -8
  141. package/services/inapp-notification-service/index.d.ts +3 -4
  142. package/services/inapp-notification-service/index.js +14 -6
  143. package/services/keyring-service/context/account-context.d.ts +6 -2
  144. package/services/keyring-service/context/account-context.js +17 -2
  145. package/services/keyring-service/context/handlers/Derive.d.ts +1 -1
  146. package/services/keyring-service/context/handlers/Derive.js +10 -8
  147. package/services/keyring-service/context/handlers/Migration.d.ts +17 -0
  148. package/services/keyring-service/context/handlers/Migration.js +258 -0
  149. package/services/keyring-service/context/handlers/Mnemonic.js +2 -2
  150. package/services/keyring-service/context/handlers/Secret.js +2 -2
  151. package/services/keyring-service/utils.d.ts +2 -0
  152. package/services/keyring-service/utils.js +11 -0
  153. package/services/request-service/handler/CardanoRequestHandler.d.ts +16 -0
  154. package/services/request-service/handler/CardanoRequestHandler.js +163 -0
  155. package/services/request-service/handler/EvmRequestHandler.js +1 -1
  156. package/services/request-service/handler/MetadataRequestHandler.d.ts +1 -1
  157. package/services/request-service/handler/MetadataRequestHandler.js +5 -13
  158. package/services/request-service/index.d.ts +7 -4
  159. package/services/request-service/index.js +21 -7
  160. package/services/setting-service/constants.d.ts +3 -0
  161. package/services/setting-service/constants.js +6 -0
  162. package/services/storage-service/DatabaseService.d.ts +1 -0
  163. package/services/storage-service/DatabaseService.js +3 -0
  164. package/services/storage-service/db-stores/InappNotification.d.ts +1 -0
  165. package/services/storage-service/db-stores/InappNotification.js +6 -0
  166. package/services/swap-service/handler/asset-hub/handler.d.ts +1 -4
  167. package/services/swap-service/handler/asset-hub/handler.js +2 -61
  168. package/services/swap-service/handler/base-handler.d.ts +1 -4
  169. package/services/swap-service/handler/chainflip-handler.d.ts +2 -9
  170. package/services/swap-service/handler/chainflip-handler.js +31 -280
  171. package/services/swap-service/handler/hydradx-handler.d.ts +1 -6
  172. package/services/swap-service/handler/hydradx-handler.js +13 -180
  173. package/services/swap-service/handler/simpleswap-handler.d.ts +1 -4
  174. package/services/swap-service/handler/simpleswap-handler.js +5 -226
  175. package/services/swap-service/handler/uniswap-handler.d.ts +41 -0
  176. package/services/swap-service/handler/uniswap-handler.js +323 -0
  177. package/services/swap-service/index.js +30 -22
  178. package/services/swap-service/utils.d.ts +1 -5
  179. package/services/swap-service/utils.js +7 -21
  180. package/services/transaction-service/helpers/index.d.ts +2 -0
  181. package/services/transaction-service/helpers/index.js +4 -0
  182. package/services/transaction-service/index.d.ts +8 -2
  183. package/services/transaction-service/index.js +273 -17
  184. package/services/transaction-service/types.d.ts +7 -0
  185. package/services/transaction-service/utils.js +7 -2
  186. package/types/account/info/keyring.d.ts +4 -1
  187. package/types/account/info/keyring.js +9 -0
  188. package/types/account/info/proxy.d.ts +2 -0
  189. package/types/balance/index.d.ts +4 -1
  190. package/types/fee/base.d.ts +1 -1
  191. package/types/fee/cardano.d.ts +18 -0
  192. package/types/fee/cardano.js +1 -0
  193. package/types/fee/option.d.ts +1 -1
  194. package/types/fee/subscription.d.ts +4 -3
  195. package/types/swap/index.d.ts +11 -3
  196. package/types/swap/index.js +7 -2
  197. package/utils/account/analyze.js +2 -1
  198. package/utils/account/common.d.ts +11 -6
  199. package/utils/account/common.js +28 -19
  200. package/utils/account/derive/info/solo.js +10 -5
  201. package/utils/account/derive/validate.d.ts +1 -0
  202. package/utils/account/derive/validate.js +34 -1
  203. package/utils/account/transform.d.ts +2 -1
  204. package/utils/account/transform.js +37 -13
  205. package/utils/fee/transfer.d.ts +3 -2
  206. package/utils/fee/transfer.js +90 -24
  207. package/utils/index.js +4 -4
  208. package/utils/staticData/index.d.ts +4 -1
  209. package/utils/staticData/index.js +5 -1
  210. package/utils/staticData/oldChainPrefix.json +1 -0
@@ -1,14 +1,14 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-base
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { ExtrinsicStatus, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
4
+ import { ChainType, ExtrinsicStatus, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
5
5
  import { CRON_RECOVER_HISTORY_INTERVAL } from '@subwallet/extension-base/constants';
6
6
  import { ServiceStatus } from '@subwallet/extension-base/services/base/types';
7
7
  import { _isChainEvmCompatible, _isChainSubstrateCompatible } from '@subwallet/extension-base/services/chain-service/utils';
8
8
  import { historyRecover, HistoryRecoverStatus } from '@subwallet/extension-base/services/history-service/helpers/recoverHistoryStatus';
9
9
  import { getExtrinsicParserKey } from '@subwallet/extension-base/services/history-service/helpers/subscan-extrinsic-parser-helper';
10
10
  import { parseSubscanExtrinsicData, parseSubscanTransferData } from '@subwallet/extension-base/services/history-service/subscan-history';
11
- import { categoryAddresses } from '@subwallet/extension-base/utils';
11
+ import { getAddressesByChainType } from '@subwallet/extension-base/utils';
12
12
  import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
13
13
  import { keyring } from '@subwallet/ui-keyring';
14
14
  import { BehaviorSubject } from 'rxjs';
@@ -144,19 +144,17 @@ export class HistoryService {
144
144
  }
145
145
  subscribeHistories(chain, proxyId, cb) {
146
146
  const addresses = this.keyringService.context.getDecodedAddresses(proxyId, false);
147
- const {
148
- evm,
149
- substrate
150
- } = categoryAddresses(addresses);
147
+ const evmAddresses = getAddressesByChainType(addresses, [ChainType.EVM]);
148
+ const substrateAddresses = getAddressesByChainType(addresses, [ChainType.SUBSTRATE]);
151
149
  const subscription = this.historySubject.subscribe(items => {
152
150
  cb(items.filter(filterHistoryItemByAddressAndChain(chain, addresses)));
153
151
  });
154
152
  const chainInfo = this.chainService.getChainInfoByKey(chain);
155
153
  if (_isChainSubstrateCompatible(chainInfo)) {
156
154
  if (_isChainEvmCompatible(chainInfo)) {
157
- this.fetchSubscanTransactionHistory(chain, evm);
155
+ this.fetchSubscanTransactionHistory(chain, evmAddresses);
158
156
  } else {
159
- this.fetchSubscanTransactionHistory(chain, substrate);
157
+ this.fetchSubscanTransactionHistory(chain, substrateAddresses);
160
158
  }
161
159
  }
162
160
  return {
@@ -28,10 +28,8 @@ export declare class InappNotificationService implements CronServiceInterface {
28
28
  validateAndWriteNotificationsToDB(notifications: _BaseNotificationInfo[], address: string): Promise<void>;
29
29
  cronCreateBridgeClaimNotification(): void;
30
30
  getCategorizedAddresses(): {
31
- substrate: string[];
32
- evm: string[];
33
- ton: string[];
34
- bitcoin: string[];
31
+ evmAddresses: string[];
32
+ substrateAddresses: string[];
35
33
  };
36
34
  createAvailBridgeClaimNotification(): void;
37
35
  processWriteAvailBridgeClaim(address: string, transactions: AvailBridgeTransaction[], token: _ChainAsset): Promise<void>;
@@ -44,4 +42,5 @@ export declare class InappNotificationService implements CronServiceInterface {
44
42
  stopCron(): Promise<void>;
45
43
  onAccountProxyRemove(): void;
46
44
  removeAccountNotifications(proxyId: string): void;
45
+ migrateNotificationProxyId(proxyIds: string[], newProxyId: string, newName: string): void;
47
46
  }
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { COMMON_ASSETS, COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
5
- import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
5
+ import { ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
6
6
  import { CRON_LISTEN_AVAIL_BRIDGE_CLAIM } from '@subwallet/extension-base/constants';
7
7
  import { fetchLastestRemindNotificationTime } from '@subwallet/extension-base/constants/remind-notification-time';
8
8
  import { ServiceStatus } from '@subwallet/extension-base/services/base/types';
@@ -11,7 +11,7 @@ import { NotificationDescriptionMap, NotificationTitleMap, ONE_DAY_MILLISECOND }
11
11
  import { NotificationActionType, NotificationTab } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
12
12
  import { AvailBridgeSourceChain, fetchAllAvailBridgeClaimable, fetchPolygonBridgeTransactions, hrsToMillisecond } from '@subwallet/extension-base/services/inapp-notification-service/utils';
13
13
  import { ProcessType, YieldPoolType } from '@subwallet/extension-base/types';
14
- import { categoryAddresses, formatNumber, reformatAddress } from '@subwallet/extension-base/utils';
14
+ import { formatNumber, getAddressesByChainType, reformatAddress } from '@subwallet/extension-base/utils';
15
15
  import { isSubstrateAddress } from '@subwallet/keyring';
16
16
  export class InappNotificationService {
17
17
  constructor(dbService, keyringService, eventService, chainService) {
@@ -170,12 +170,17 @@ export class InappNotificationService {
170
170
  }
171
171
  getCategorizedAddresses() {
172
172
  const addresses = this.keyringService.context.getAllAddresses();
173
- return categoryAddresses(addresses);
173
+ const evmAddresses = getAddressesByChainType(addresses, [ChainType.EVM]);
174
+ const substrateAddresses = getAddressesByChainType(addresses, [ChainType.SUBSTRATE]);
175
+ return {
176
+ evmAddresses: evmAddresses,
177
+ substrateAddresses: substrateAddresses
178
+ };
174
179
  }
175
180
  createAvailBridgeClaimNotification() {
176
181
  const {
177
- evm: evmAddresses,
178
- substrate: substrateAddresses
182
+ evmAddresses,
183
+ substrateAddresses
179
184
  } = this.getCategorizedAddresses();
180
185
  const chainAssets = this.chainService.getAssetRegistry();
181
186
  let ASSET_TYPE;
@@ -262,7 +267,7 @@ export class InappNotificationService {
262
267
  // Polygon Claimable Handle
263
268
  async createPolygonClaimableTransactions() {
264
269
  const {
265
- evm: evmAddresses
270
+ evmAddresses
266
271
  } = this.getCategorizedAddresses();
267
272
  const etherChains = [COMMON_ASSETS.ETH, COMMON_ASSETS.ETH_SEPOLIA];
268
273
  const polygonAssets = Object.values(this.chainService.getAssetRegistry()).filter(asset => etherChains.includes(asset.slug));
@@ -433,4 +438,7 @@ export class InappNotificationService {
433
438
  removeAccountNotifications(proxyId) {
434
439
  this.dbService.removeAccountNotifications(proxyId).catch(console.error);
435
440
  }
441
+ migrateNotificationProxyId(proxyIds, newProxyId, newName) {
442
+ this.dbService.updateNotificationProxyId(proxyIds, newProxyId, newName);
443
+ }
436
444
  }
@@ -1,4 +1,4 @@
1
- import { AccountExternalError, RequestAccountCreateExternalV2, RequestAccountCreateHardwareMultiple, RequestAccountCreateHardwareV2, RequestAccountCreateWithSecretKey, RequestAccountExportPrivateKey, RequestChangeMasterPassword, RequestMigratePassword, ResponseAccountCreateWithSecretKey, ResponseAccountExportPrivateKey, ResponseChangeMasterPassword, ResponseMigratePassword } from '@subwallet/extension-base/background/KoniTypes';
1
+ import { AccountExternalError, RequestAccountCreateExternalV2, RequestAccountCreateHardwareMultiple, RequestAccountCreateHardwareV2, RequestAccountCreateWithSecretKey, RequestAccountExportPrivateKey, RequestChangeMasterPassword, RequestMigratePassword, RequestMigrateSoloAccount, RequestMigrateUnifiedAndFetchEligibleSoloAccounts, RequestPingSession, ResponseAccountCreateWithSecretKey, ResponseAccountExportPrivateKey, ResponseChangeMasterPassword, ResponseMigratePassword } from '@subwallet/extension-base/background/KoniTypes';
2
2
  import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
3
3
  import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
4
4
  import { AccountProxyMap, CurrentAccountInfo, RequestAccountBatchExportV2, RequestAccountCreateSuriV2, RequestAccountNameValidate, RequestAccountProxyEdit, RequestAccountProxyForget, RequestBatchJsonGetAccountInfo, RequestBatchRestoreV2, RequestChangeTonWalletContractVersion, RequestCheckPublicAndSecretKey, RequestDeriveCreateMultiple, RequestDeriveCreateV3, RequestDeriveValidateV2, RequestExportAccountProxyMnemonic, RequestGetAllTonWalletContractVersion, RequestGetDeriveAccounts, RequestGetDeriveSuggestion, RequestJsonGetAccountInfo, RequestJsonRestoreV2, RequestMnemonicCreateV2, RequestMnemonicValidateV2, RequestPrivateKeyValidateV2, ResponseAccountBatchExportV2, ResponseAccountCreateSuriV2, ResponseAccountNameValidate, ResponseBatchJsonGetAccountInfo, ResponseCheckPublicAndSecretKey, ResponseDeriveValidateV2, ResponseExportAccountProxyMnemonic, ResponseGetAllTonWalletContractVersion, ResponseGetDeriveAccounts, ResponseGetDeriveSuggestion, ResponseJsonGetAccountInfo, ResponseMnemonicCreateV2, ResponseMnemonicValidateV2, ResponsePrivateKeyValidateV2 } from '@subwallet/extension-base/types';
@@ -15,6 +15,7 @@ export declare class AccountContext {
15
15
  private readonly ledgerHandler;
16
16
  private readonly modifyHandler;
17
17
  private readonly secretHandler;
18
+ private readonly migrationHandler;
18
19
  constructor(koniState: KoniState, parentService: KeyringService);
19
20
  get pairs(): SubjectInfo;
20
21
  get observable(): {
@@ -81,9 +82,12 @@ export declare class AccountContext {
81
82
  getListDeriveAccounts(request: RequestGetDeriveAccounts): ResponseGetDeriveAccounts;
82
83
  validateDerivePath(request: RequestDeriveValidateV2): ResponseDeriveValidateV2;
83
84
  getDeriveSuggestion(request: RequestGetDeriveSuggestion): ResponseGetDeriveSuggestion;
84
- derivationAccountProxyCreate(request: RequestDeriveCreateV3): boolean;
85
+ derivationAccountProxyCreate(request: RequestDeriveCreateV3, isMigration?: boolean): boolean;
85
86
  addInjectAccounts(accounts: InjectedAccountWithMeta[]): void;
86
87
  removeInjectAccounts(_addresses: string[]): void;
88
+ migrateUnifiedAndFetchEligibleSoloAccounts(request: RequestMigrateUnifiedAndFetchEligibleSoloAccounts, setMigratingModeFn: () => void): Promise<import("@subwallet/extension-base/background/KoniTypes").ResponseMigrateUnifiedAndFetchEligibleSoloAccounts>;
89
+ migrateSoloAccount(request: RequestMigrateSoloAccount): import("@subwallet/extension-base/background/KoniTypes").ResponseMigrateSoloAccount;
90
+ pingSession(request: RequestPingSession): boolean;
87
91
  removeNoneHardwareGenesisHash(): void;
88
92
  updateMetadataForPair(): void;
89
93
  resetWallet(): void;
@@ -1,6 +1,7 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-base
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { AccountMigrationHandler } from '@subwallet/extension-base/services/keyring-service/context/handlers/Migration';
4
5
  import { AccountDeriveHandler, AccountInjectHandler, AccountJsonHandler, AccountLedgerHandler, AccountMnemonicHandler, AccountModifyHandler, AccountSecretHandler } from "./handlers/index.js";
5
6
  import { AccountState } from "./state.js";
6
7
  export class AccountContext {
@@ -15,6 +16,7 @@ export class AccountContext {
15
16
  this.ledgerHandler = new AccountLedgerHandler(this.parentService, this.state);
16
17
  this.modifyHandler = new AccountModifyHandler(this.parentService, this.state);
17
18
  this.secretHandler = new AccountSecretHandler(this.parentService, this.state);
19
+ this.migrationHandler = new AccountMigrationHandler(this.parentService, this.state);
18
20
  }
19
21
 
20
22
  // TODO: Merge to value
@@ -222,8 +224,8 @@ export class AccountContext {
222
224
  }
223
225
 
224
226
  /* Derive account proxy */
225
- derivationAccountProxyCreate(request) {
226
- return this.deriveHandler.derivationAccountProxyCreate(request);
227
+ derivationAccountProxyCreate(request, isMigration) {
228
+ return this.deriveHandler.derivationAccountProxyCreate(request, isMigration);
227
229
  }
228
230
 
229
231
  /* Derive */
@@ -239,6 +241,19 @@ export class AccountContext {
239
241
 
240
242
  /* Inject */
241
243
 
244
+ /* Migration */
245
+ async migrateUnifiedAndFetchEligibleSoloAccounts(request, setMigratingModeFn) {
246
+ return await this.migrationHandler.migrateUnifiedAndFetchEligibleSoloAccounts(request, setMigratingModeFn);
247
+ }
248
+ migrateSoloAccount(request) {
249
+ return this.migrationHandler.migrateSoloToUnifiedAccount(request);
250
+ }
251
+ pingSession(request) {
252
+ return this.migrationHandler.pingSession(request);
253
+ }
254
+
255
+ /* Migration */
256
+
242
257
  /* Others */
243
258
 
244
259
  removeNoneHardwareGenesisHash() {
@@ -25,5 +25,5 @@ export declare class AccountDeriveHandler extends AccountBaseHandler {
25
25
  /**
26
26
  * Derive account proxy
27
27
  * */
28
- derivationAccountProxyCreate(request: RequestDeriveCreateV3): boolean;
28
+ derivationAccountProxyCreate(request: RequestDeriveCreateV3, isMigration?: boolean): boolean;
29
29
  }
@@ -9,7 +9,7 @@ import { keyring } from '@subwallet/ui-keyring';
9
9
  import { t } from 'i18next';
10
10
  import { assert } from '@polkadot/util';
11
11
  import { AccountBaseHandler } from "./Base.js";
12
- const validDeriveKeypairTypes = [...SubstrateKeypairTypes, ...EthereumKeypairTypes, 'ton'];
12
+ const validDeriveKeypairTypes = [...SubstrateKeypairTypes, ...EthereumKeypairTypes, 'ton', 'cardano'];
13
13
 
14
14
  /**
15
15
  * @class AccountDeriveHandler
@@ -208,7 +208,7 @@ export class AccountDeriveHandler extends AccountBaseHandler {
208
208
  /**
209
209
  * Derive account proxy
210
210
  * */
211
- derivationAccountProxyCreate(request) {
211
+ derivationAccountProxyCreate(request, isMigration = false) {
212
212
  const {
213
213
  name,
214
214
  proxyId: deriveId,
@@ -219,7 +219,7 @@ export class AccountDeriveHandler extends AccountBaseHandler {
219
219
  const rootId = this.state.value.accounts[parentProxyId].parentId || parentProxyId;
220
220
  const rootProxyId = this.state.belongUnifiedAccount(rootId) || rootId;
221
221
  const nameExists = this.state.checkNameExists(name);
222
- if (nameExists) {
222
+ if (nameExists && !isMigration) {
223
223
  throw new SWCommonAccountError(CommonAccountErrorType.ACCOUNT_NAME_EXISTED);
224
224
  }
225
225
  const validateRs = this.validateDerivePath({
@@ -343,11 +343,13 @@ export class AccountDeriveHandler extends AccountBaseHandler {
343
343
  }
344
344
  const addresses = pairs.map(pair => pair.address);
345
345
  const exists = this.state.checkAddressExists(addresses);
346
- assert(!exists, t('Account already exists under the name "{{name}}"', {
347
- replace: {
348
- name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || ''
349
- }
350
- }));
346
+ if (!isMigration) {
347
+ assert(!exists, t('Account already exists under the name "{{name}}"', {
348
+ replace: {
349
+ name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || ''
350
+ }
351
+ }));
352
+ }
351
353
  childAccountProxy && this.state.upsertAccountProxyByKey(childAccountProxy);
352
354
  this.state.upsertModifyPairs(modifyPairs);
353
355
  for (const childPair of pairs) {
@@ -0,0 +1,17 @@
1
+ import { RequestMigrateSoloAccount, RequestMigrateUnifiedAndFetchEligibleSoloAccounts, RequestPingSession, ResponseMigrateSoloAccount, ResponseMigrateUnifiedAndFetchEligibleSoloAccounts, SoloAccountToBeMigrated } from '@subwallet/extension-base/background/KoniTypes';
2
+ import { AccountBaseHandler } from '@subwallet/extension-base/services/keyring-service/context/handlers/Base';
3
+ import { AccountProxy } from '@subwallet/extension-base/types';
4
+ export declare const SESSION_TIMEOUT = 10000;
5
+ export declare class AccountMigrationHandler extends AccountBaseHandler {
6
+ private sessionIdToPassword;
7
+ pingSession({ sessionId }: RequestPingSession): boolean;
8
+ migrateUnifiedAndFetchEligibleSoloAccounts(request: RequestMigrateUnifiedAndFetchEligibleSoloAccounts, setMigratingModeFn: () => void): Promise<ResponseMigrateUnifiedAndFetchEligibleSoloAccounts>;
9
+ migrateUnifiedToUnifiedAccount(password: string, accountProxies: AccountProxy[], setMigratingModeFn: () => void): Promise<string[]>;
10
+ getUACanBeMigrated(accountProxies: AccountProxy[]): AccountProxy[];
11
+ getSoloAccountsNeedToBeMigrated(accountProxies: AccountProxy[]): AccountProxy[];
12
+ groupSoloAccountByMnemonic(password: string, accountProxies: AccountProxy[]): Record<string, AccountProxy[]>;
13
+ accountProxiesToEligibleSoloAccountMap(accountProxyMap: Record<string, AccountProxy[]>): Record<string, SoloAccountToBeMigrated[]>;
14
+ sortUAByParent(accountProxies: AccountProxy[]): AccountProxy[];
15
+ migrateSoloToUnifiedAccount(request: RequestMigrateSoloAccount): ResponseMigrateSoloAccount;
16
+ migrateDerivedSoloAccountRelationship(soloAccounts: SoloAccountToBeMigrated[]): void;
17
+ }
@@ -0,0 +1,258 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { AccountBaseHandler } from '@subwallet/extension-base/services/keyring-service/context/handlers/Base';
5
+ import { AccountChainType, SUPPORTED_ACCOUNT_CHAIN_TYPES } from '@subwallet/extension-base/types';
6
+ import { createAccountProxyId, getDefaultKeypairTypeFromAccountChainType, getSuri } from '@subwallet/extension-base/utils';
7
+ import { generateRandomString } from '@subwallet/extension-base/utils/getId';
8
+ import { keyring } from '@subwallet/ui-keyring';
9
+ import { keyExtractSuri } from '@polkadot/util-crypto';
10
+ export const SESSION_TIMEOUT = 10000;
11
+ export class AccountMigrationHandler extends AccountBaseHandler {
12
+ sessionIdToPassword = {};
13
+ pingSession({
14
+ sessionId
15
+ }) {
16
+ if (!this.sessionIdToPassword[sessionId]) {
17
+ // todo: if no persistent sessionId, should we jump to enter password again?
18
+ throw Error(`Session ID ${sessionId} not found.`);
19
+ }
20
+ clearTimeout(this.sessionIdToPassword[sessionId].timeoutId);
21
+ this.sessionIdToPassword[sessionId].timeoutId = setTimeout(() => {
22
+ delete this.sessionIdToPassword[sessionId];
23
+ }, SESSION_TIMEOUT);
24
+ return true;
25
+ }
26
+ async migrateUnifiedAndFetchEligibleSoloAccounts(request, setMigratingModeFn) {
27
+ // Migrate unified -> unified
28
+ const password = request.password;
29
+ const allAccountProxies = Object.values(this.state.accounts);
30
+ const UACanBeMigrated = this.getUACanBeMigrated(allAccountProxies);
31
+ const UACanBeMigratedSortedByParent = this.sortUAByParent(UACanBeMigrated); // master account must be migrated before derived account
32
+ const migratedUnifiedAccountIds = await this.migrateUnifiedToUnifiedAccount(password, UACanBeMigratedSortedByParent, setMigratingModeFn);
33
+
34
+ // Get solo accounts can be migrated
35
+ const soloAccountsNeedToBeMigrated = this.getSoloAccountsNeedToBeMigrated(allAccountProxies);
36
+ const soloAccountsNeedToBeMigratedGroup = this.groupSoloAccountByMnemonic(password, soloAccountsNeedToBeMigrated);
37
+ const eligibleSoloAccountMap = this.accountProxiesToEligibleSoloAccountMap(soloAccountsNeedToBeMigratedGroup);
38
+
39
+ // Create persistent mapping sessionId <-> password
40
+ const uniqueId = Date.now().toString();
41
+ const timeoutId = setTimeout(() => delete this.sessionIdToPassword[uniqueId], SESSION_TIMEOUT * 2);
42
+ this.sessionIdToPassword[uniqueId] = {
43
+ password,
44
+ timeoutId
45
+ };
46
+ return {
47
+ migratedUnifiedAccountIds,
48
+ soloAccounts: eligibleSoloAccountMap,
49
+ sessionId: uniqueId
50
+ };
51
+ }
52
+ async migrateUnifiedToUnifiedAccount(password, accountProxies, setMigratingModeFn) {
53
+ keyring.unlockKeyring(password);
54
+ this.parentService.updateKeyringState();
55
+ setMigratingModeFn();
56
+ const unifiedAccountIds = [];
57
+ const modifiedPairs = structuredClone(this.state.modifyPairs);
58
+ const {
59
+ derivedUnifiedAccounts,
60
+ masterUnifiedAccounts
61
+ } = accountProxies.reduce((accountInfo, account) => {
62
+ const isDerivedAccount = !!account.parentId;
63
+ isDerivedAccount ? accountInfo.derivedUnifiedAccounts.push(account) : accountInfo.masterUnifiedAccounts.push(account);
64
+ return accountInfo;
65
+ }, {
66
+ derivedUnifiedAccounts: [],
67
+ masterUnifiedAccounts: []
68
+ });
69
+ try {
70
+ for (const unifiedAccount of masterUnifiedAccounts) {
71
+ const proxyId = unifiedAccount.id;
72
+ const mnemonic = this.parentService.context.exportAccountProxyMnemonic({
73
+ password,
74
+ proxyId
75
+ }).result;
76
+ const newChainTypes = Object.values(AccountChainType).filter(type => !unifiedAccount.chainTypes.includes(type) && SUPPORTED_ACCOUNT_CHAIN_TYPES.includes(type));
77
+ const keypairTypes = newChainTypes.map(chainType => getDefaultKeypairTypeFromAccountChainType(chainType));
78
+ keypairTypes.forEach(type => {
79
+ const suri = getSuri(mnemonic, type);
80
+ const pair = keyring.createFromUri(suri, {}, type);
81
+ const address = pair.address;
82
+ modifiedPairs[address] = {
83
+ accountProxyId: proxyId,
84
+ migrated: true,
85
+ key: address
86
+ };
87
+ });
88
+ keypairTypes.forEach(type => {
89
+ const suri = getSuri(mnemonic, type);
90
+ const {
91
+ derivePath
92
+ } = keyExtractSuri(suri);
93
+ const metadata = {
94
+ name: unifiedAccount.name,
95
+ derivationPath: derivePath ? derivePath.substring(1) : undefined
96
+ };
97
+ const rs = keyring.addUri(suri, metadata, type);
98
+ const address = rs.pair.address;
99
+ this.state._addAddressToAuthList(address, true);
100
+ });
101
+ this.state.upsertModifyPairs(modifiedPairs);
102
+ unifiedAccountIds.push(proxyId);
103
+ }
104
+ await new Promise(resolve => setTimeout(resolve, 1800)); // Wait last master unified account migrated. // todo: can be optimized later by await a promise resolve if master account is migrating
105
+
106
+ for (const unifiedAccount of derivedUnifiedAccounts) {
107
+ this.parentService.context.derivationAccountProxyCreate({
108
+ name: unifiedAccount.name,
109
+ suri: unifiedAccount.suri || '',
110
+ proxyId: unifiedAccount.parentId || ''
111
+ }, true);
112
+ unifiedAccountIds.push(unifiedAccount.id);
113
+ }
114
+ } catch (error) {
115
+ console.error('Migration unified account failed with error:', error);
116
+ } finally {
117
+ keyring.lockAll(false);
118
+ this.parentService.updateKeyringState();
119
+ }
120
+ return unifiedAccountIds;
121
+ }
122
+ getUACanBeMigrated(accountProxies) {
123
+ return accountProxies.filter(account => this.state.isUnifiedAccount(account.id) && account.isNeedMigrateUnifiedAccount);
124
+ }
125
+ getSoloAccountsNeedToBeMigrated(accountProxies) {
126
+ return accountProxies.filter(account => !this.state.isUnifiedAccount(account.id) && account.isNeedMigrateUnifiedAccount);
127
+ }
128
+ groupSoloAccountByMnemonic(password, accountProxies) {
129
+ const parentService = this.parentService;
130
+ return accountProxies.reduce(function (rs, item) {
131
+ const oldProxyId = item.id;
132
+ const mnemonic = parentService.context.exportAccountProxyMnemonic({
133
+ password,
134
+ proxyId: oldProxyId
135
+ }).result;
136
+ const upcomingProxyId = createAccountProxyId(mnemonic);
137
+ if (!rs[upcomingProxyId]) {
138
+ rs[upcomingProxyId] = [];
139
+ }
140
+ rs[upcomingProxyId].push(item);
141
+ return rs;
142
+ }, {});
143
+ }
144
+ accountProxiesToEligibleSoloAccountMap(accountProxyMap) {
145
+ const eligibleSoloAccountMap = {};
146
+ Object.entries(accountProxyMap).forEach(([upcomingProxyId, accounts]) => {
147
+ eligibleSoloAccountMap[upcomingProxyId] = accounts.map(account => {
148
+ return {
149
+ upcomingProxyId,
150
+ proxyId: account.accounts[0].proxyId,
151
+ address: account.accounts[0].address,
152
+ name: account.name,
153
+ chainType: account.chainTypes[0]
154
+ };
155
+ });
156
+ });
157
+ return eligibleSoloAccountMap;
158
+ }
159
+ sortUAByParent(accountProxies) {
160
+ const undefinedToStr = str => str !== null && str !== void 0 ? str : '';
161
+ return accountProxies.sort((a, b) => undefinedToStr(a.parentId) < undefinedToStr(b.parentId) ? -1 : undefinedToStr(a.parentId) > undefinedToStr(b.parentId) ? 1 : 0);
162
+ }
163
+ migrateSoloToUnifiedAccount(request) {
164
+ const {
165
+ accountName,
166
+ sessionId,
167
+ soloAccounts
168
+ } = request;
169
+ const password = this.sessionIdToPassword[sessionId].password;
170
+ keyring.unlockKeyring(password);
171
+ this.parentService.updateKeyringState();
172
+ const modifiedPairs = structuredClone(this.state.modifyPairs);
173
+ const firstAccountInfo = soloAccounts[0];
174
+ const upcomingProxyId = firstAccountInfo.upcomingProxyId;
175
+ const firstAccountOldProxyId = firstAccountInfo.proxyId;
176
+ try {
177
+ const mnemonic = this.parentService.context.exportAccountProxyMnemonic({
178
+ password,
179
+ proxyId: firstAccountOldProxyId
180
+ }).result;
181
+ const keypairTypes = SUPPORTED_ACCOUNT_CHAIN_TYPES.map(chainType => getDefaultKeypairTypeFromAccountChainType(chainType));
182
+ keypairTypes.forEach(type => {
183
+ const suri = getSuri(mnemonic, type);
184
+ const pair = keyring.createFromUri(suri, {}, type);
185
+ const address = pair.address;
186
+ modifiedPairs[address] = {
187
+ accountProxyId: upcomingProxyId,
188
+ migrated: true,
189
+ key: address
190
+ };
191
+ });
192
+ this.state.upsertAccountProxyByKey({
193
+ id: upcomingProxyId,
194
+ name: accountName,
195
+ isMigrationDone: false
196
+ });
197
+ const soloAccountProxyIds = [];
198
+ keypairTypes.forEach(type => {
199
+ const suri = getSuri(mnemonic, type);
200
+ const {
201
+ derivePath
202
+ } = keyExtractSuri(suri);
203
+ const metadata = {
204
+ name: accountName.concat(' - ').concat(generateRandomString()),
205
+ derivationPath: derivePath ? derivePath.substring(1) : undefined
206
+ };
207
+ const rs = keyring.addUri(suri, metadata, type);
208
+ soloAccountProxyIds.push(rs.json.address);
209
+ const address = rs.pair.address;
210
+ this.state._addAddressToAuthList(address, true);
211
+ });
212
+ this.state.upsertModifyPairs(modifiedPairs);
213
+ this.migrateDerivedSoloAccountRelationship(soloAccounts);
214
+ this.state.upsertAccountProxyByKey({
215
+ id: upcomingProxyId,
216
+ name: accountName,
217
+ isMigrationDone: true
218
+ });
219
+
220
+ // Re-update account name
221
+ soloAccountProxyIds.forEach(oldProxyId => {
222
+ const pair = keyring.getPair(oldProxyId);
223
+ keyring.saveAccountMeta(pair, {
224
+ ...pair.meta,
225
+ name: accountName
226
+ });
227
+ });
228
+
229
+ // Update current account after migrating
230
+ const currentAccountProxyId = this.state.currentAccount.proxyId;
231
+ if (soloAccountProxyIds.includes(currentAccountProxyId)) {
232
+ this.state.saveCurrentAccountProxyId(upcomingProxyId);
233
+ }
234
+ } catch (error) {
235
+ console.error('Migration solo account failed with error', error);
236
+ } finally {
237
+ keyring.lockAll(false);
238
+ this.parentService.updateKeyringState();
239
+ }
240
+ return {
241
+ migratedUnifiedAccountId: upcomingProxyId
242
+ };
243
+ }
244
+ migrateDerivedSoloAccountRelationship(soloAccounts) {
245
+ const accountProxies = this.state.accountProxies;
246
+
247
+ // Use Set.has & Map.get to optimize search performance
248
+ const proxyIdsSet = new Set(soloAccounts.map(account => account.proxyId));
249
+ const proxyIdToUpcomingProxyIdMap = new Map(soloAccounts.map(account => [account.proxyId, account.upcomingProxyId]));
250
+ for (const account of Object.values(accountProxies)) {
251
+ const currentParent = account.parentId;
252
+ if (currentParent && proxyIdsSet.has(currentParent)) {
253
+ accountProxies[account.id].parentId = proxyIdToUpcomingProxyIdMap.get(currentParent);
254
+ }
255
+ }
256
+ this.state.upsertAccountProxy(accountProxies);
257
+ }
258
+ }
@@ -27,7 +27,7 @@ export class AccountMnemonicHandler extends AccountBaseHandler {
27
27
  mnemonic: _seed,
28
28
  type = 'general'
29
29
  }) {
30
- const types = type === 'general' ? ['sr25519', 'ethereum', 'ton'] : ['ton-native'];
30
+ const types = type === 'general' ? ['sr25519', 'ethereum', 'ton', 'cardano'] : ['ton-native'];
31
31
  const seed = _seed || type === 'general' ? mnemonicGenerate(length) : await tonMnemonicGenerate(length);
32
32
  const rs = {
33
33
  mnemonic: seed,
@@ -97,7 +97,7 @@ export class AccountMnemonicHandler extends AccountBaseHandler {
97
97
  const addressDict = {};
98
98
  let changedAccount = false;
99
99
  const hasMasterPassword = keyring.keyring.hasMasterPassword;
100
- const types = type ? [type] : ['sr25519', 'ethereum', 'ton'];
100
+ const types = type ? [type] : ['sr25519', 'ethereum', 'ton', 'cardano'];
101
101
  if (!hasMasterPassword) {
102
102
  if (!password) {
103
103
  throw Error(t('The password of each account is needed to set up master password'));
@@ -5,7 +5,7 @@ import { AccountExternalErrorCode } from '@subwallet/extension-base/background/K
5
5
  import { AccountChainType, CommonAccountErrorType, SWCommonAccountError } from '@subwallet/extension-base/types';
6
6
  import { getKeypairTypeByAddress } from '@subwallet/keyring';
7
7
  import { decodePair } from '@subwallet/keyring/pair/decode';
8
- import { BitcoinKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
8
+ import { BitcoinKeypairTypes, CardanoKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
9
9
  import keyring from '@subwallet/ui-keyring';
10
10
  import { t } from 'i18next';
11
11
  import { assert, hexStripPrefix, hexToU8a, isHex, u8aToHex } from '@polkadot/util';
@@ -49,7 +49,7 @@ export class AccountSecretHandler extends AccountBaseHandler {
49
49
  isReadOnly,
50
50
  genesisHash: ''
51
51
  };
52
- if ([...BitcoinKeypairTypes, ...TonKeypairTypes].includes(type) && isReadOnly) {
52
+ if ([...BitcoinKeypairTypes, ...TonKeypairTypes, ...CardanoKeypairTypes].includes(type) && isReadOnly) {
53
53
  meta.noPublicKey = true;
54
54
  }
55
55
  const result = keyring.keyring.addFromAddress(address, meta, null, type);
@@ -0,0 +1,2 @@
1
+ import { AccountProxy } from '@subwallet/extension-base/types';
2
+ export declare const hasAnyAccountForMigration: (allAccountProxies: AccountProxy[]) => boolean;
@@ -0,0 +1,11 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export const hasAnyAccountForMigration = allAccountProxies => {
5
+ for (const account of allAccountProxies) {
6
+ if (account.isNeedMigrateUnifiedAccount) {
7
+ return true;
8
+ }
9
+ }
10
+ return false;
11
+ };
@@ -0,0 +1,16 @@
1
+ import { ConfirmationDefinitionsCardano, ConfirmationsQueueCardano, ConfirmationsQueueItemOptions, ConfirmationTypeCardano, RequestConfirmationCompleteCardano } from '@subwallet/extension-base/background/KoniTypes';
2
+ import RequestService from '@subwallet/extension-base/services/request-service';
3
+ import { BehaviorSubject } from 'rxjs';
4
+ export default class CardanoRequestHandler {
5
+ #private;
6
+ private readonly confirmationsQueueSubjectCardano;
7
+ private readonly confirmationsPromiseMap;
8
+ constructor(requestService: RequestService);
9
+ get numCardanoRequests(): number;
10
+ getConfirmationsQueueSubjectCardano(): BehaviorSubject<ConfirmationsQueueCardano>;
11
+ addConfirmationCardano<CT extends ConfirmationTypeCardano>(id: string, url: string, type: CT, payload: ConfirmationDefinitionsCardano[CT][0]['payload'], options?: ConfirmationsQueueItemOptions, validator?: (input: ConfirmationDefinitionsCardano[CT][1]) => Error | undefined): Promise<ConfirmationDefinitionsCardano[CT][1]>;
12
+ completeConfirmationCardano(request: RequestConfirmationCompleteCardano): Promise<boolean>;
13
+ private decorateResult;
14
+ private signTransactionCardano;
15
+ resetWallet(): void;
16
+ }