@subwallet/extension-base 1.3.21-0 → 1.3.23-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 (223) hide show
  1. package/background/KoniTypes.d.ts +75 -2
  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/signing.js +6 -2
  6. package/cjs/core/logic-validation/recipientAddress.js +9 -1
  7. package/cjs/core/logic-validation/transfer.js +35 -29
  8. package/cjs/core/types.js +1 -0
  9. package/cjs/core/utils.js +12 -1
  10. package/cjs/defaults.js +1 -1
  11. package/cjs/koni/api/dotsama/crowdloan.js +1 -1
  12. package/cjs/koni/api/nft/index.js +9 -16
  13. package/cjs/koni/api/staking/index.js +3 -4
  14. package/cjs/koni/background/handlers/Extension.js +234 -96
  15. package/cjs/koni/background/handlers/State.js +15 -0
  16. package/cjs/packageInfo.js +1 -1
  17. package/cjs/services/balance-service/helpers/subscribe/cardano/consts.js +11 -0
  18. package/cjs/services/balance-service/helpers/subscribe/cardano/index.js +63 -0
  19. package/cjs/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
  20. package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +74 -0
  21. package/cjs/services/balance-service/helpers/subscribe/index.js +21 -7
  22. package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +2 -2
  23. package/cjs/services/balance-service/index.js +4 -2
  24. package/cjs/services/balance-service/transfer/cardano-transfer.js +122 -0
  25. package/cjs/services/balance-service/transfer/token.js +4 -4
  26. package/cjs/services/chain-service/constants.js +8 -3
  27. package/cjs/services/chain-service/handler/CardanoApi.js +176 -0
  28. package/cjs/services/chain-service/handler/CardanoChainHandler.js +83 -0
  29. package/cjs/services/chain-service/handler/SubstrateChainHandler.js +3 -2
  30. package/cjs/services/chain-service/handler/TonApi.js +2 -5
  31. package/cjs/services/chain-service/index.js +38 -7
  32. package/cjs/services/chain-service/utils/index.js +40 -11
  33. package/cjs/services/chain-service/utils/patch.js +1 -1
  34. package/cjs/services/earning-service/constants/chains.js +2 -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/handlers/native-staking/mythos.js +337 -0
  38. package/cjs/services/earning-service/service.js +10 -12
  39. package/cjs/services/earning-service/utils/index.js +2 -0
  40. package/cjs/services/fee-service/service.js +19 -8
  41. package/cjs/services/history-service/index.js +4 -6
  42. package/cjs/services/inapp-notification-service/index.js +12 -4
  43. package/cjs/services/keyring-service/context/account-context.js +17 -2
  44. package/cjs/services/keyring-service/context/handlers/Derive.js +10 -7
  45. package/cjs/services/keyring-service/context/handlers/Migration.js +268 -0
  46. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +2 -2
  47. package/cjs/services/keyring-service/context/handlers/Secret.js +1 -1
  48. package/cjs/services/keyring-service/utils.js +18 -0
  49. package/cjs/services/migration-service/scripts/databases/ClearMetadataDatabase.js +3 -23
  50. package/cjs/services/migration-service/scripts/databases/ClearMetadataForChains.js +40 -0
  51. package/cjs/services/migration-service/scripts/databases/ClearMetadataForMythos.js +15 -0
  52. package/cjs/services/migration-service/scripts/index.js +6 -2
  53. package/cjs/services/request-service/handler/CardanoRequestHandler.js +172 -0
  54. package/cjs/services/request-service/handler/EvmRequestHandler.js +1 -1
  55. package/cjs/services/request-service/index.js +20 -2
  56. package/cjs/services/setting-service/constants.js +10 -1
  57. package/cjs/services/storage-service/DatabaseService.js +6 -0
  58. package/cjs/services/storage-service/db-stores/InappNotification.js +6 -0
  59. package/cjs/services/storage-service/db-stores/Metadata.js +3 -0
  60. package/cjs/services/storage-service/db-stores/Migration.js +6 -1
  61. package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -59
  62. package/cjs/services/swap-service/handler/chainflip-handler.js +33 -281
  63. package/cjs/services/swap-service/handler/hydradx-handler.js +23 -190
  64. package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -222
  65. package/cjs/services/swap-service/handler/uniswap-handler.js +331 -0
  66. package/cjs/services/swap-service/index.js +31 -22
  67. package/cjs/services/swap-service/utils.js +21 -38
  68. package/cjs/services/transaction-service/helpers/index.js +6 -1
  69. package/cjs/services/transaction-service/index.js +278 -21
  70. package/cjs/services/transaction-service/utils.js +5 -1
  71. package/cjs/types/account/info/keyring.js +12 -1
  72. package/cjs/types/fee/cardano.js +1 -0
  73. package/cjs/types/swap/index.js +7 -2
  74. package/cjs/utils/account/analyze.js +2 -1
  75. package/cjs/utils/account/common.js +29 -20
  76. package/cjs/utils/account/derive/info/solo.js +9 -4
  77. package/cjs/utils/account/derive/validate.js +36 -2
  78. package/cjs/utils/account/transform.js +38 -13
  79. package/cjs/utils/fee/transfer.js +40 -7
  80. package/cjs/utils/index.js +2 -2
  81. package/cjs/utils/staticData/index.js +7 -2
  82. package/constants/environment.d.ts +1 -0
  83. package/constants/environment.js +2 -1
  84. package/constants/signing.js +6 -2
  85. package/core/logic-validation/recipientAddress.js +11 -3
  86. package/core/logic-validation/transfer.js +9 -3
  87. package/core/substrate/xcm-parser.d.ts +1 -1
  88. package/core/types.d.ts +1 -0
  89. package/core/types.js +1 -0
  90. package/core/utils.d.ts +1 -0
  91. package/core/utils.js +13 -3
  92. package/defaults.d.ts +1 -1
  93. package/defaults.js +1 -1
  94. package/koni/api/dotsama/crowdloan.js +3 -3
  95. package/koni/api/nft/index.js +10 -16
  96. package/koni/api/nft/story_odyssey_nft/index.d.ts +1 -1
  97. package/koni/api/staking/index.js +4 -5
  98. package/koni/background/handlers/Extension.d.ts +9 -0
  99. package/koni/background/handlers/Extension.js +144 -8
  100. package/koni/background/handlers/State.d.ts +5 -1
  101. package/koni/background/handlers/State.js +16 -1
  102. package/package.json +102 -25
  103. package/packageInfo.js +1 -1
  104. package/services/balance-service/helpers/subscribe/cardano/consts.d.ts +1 -0
  105. package/services/balance-service/helpers/subscribe/cardano/consts.js +4 -0
  106. package/services/balance-service/helpers/subscribe/cardano/index.d.ts +2 -0
  107. package/services/balance-service/helpers/subscribe/cardano/index.js +57 -0
  108. package/services/balance-service/helpers/subscribe/cardano/types.d.ts +34 -0
  109. package/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
  110. package/services/balance-service/helpers/subscribe/cardano/utils.d.ts +15 -0
  111. package/services/balance-service/helpers/subscribe/cardano/utils.js +62 -0
  112. package/services/balance-service/helpers/subscribe/index.d.ts +2 -2
  113. package/services/balance-service/helpers/subscribe/index.js +23 -9
  114. package/services/balance-service/helpers/subscribe/ton/utils.d.ts +1 -1
  115. package/services/balance-service/helpers/subscribe/ton/utils.js +1 -1
  116. package/services/balance-service/index.js +4 -2
  117. package/services/balance-service/transfer/cardano-transfer.d.ts +24 -0
  118. package/services/balance-service/transfer/cardano-transfer.js +114 -0
  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/constants.js +8 -3
  122. package/services/chain-service/handler/CardanoApi.d.ts +38 -0
  123. package/services/chain-service/handler/CardanoApi.js +167 -0
  124. package/services/chain-service/handler/CardanoChainHandler.d.ts +17 -0
  125. package/services/chain-service/handler/CardanoChainHandler.js +75 -0
  126. package/services/chain-service/handler/SubstrateChainHandler.js +3 -2
  127. package/services/chain-service/handler/TonApi.js +3 -6
  128. package/services/chain-service/handler/types.d.ts +1 -0
  129. package/services/chain-service/index.d.ts +4 -1
  130. package/services/chain-service/index.js +38 -7
  131. package/services/chain-service/types.d.ts +9 -1
  132. package/services/chain-service/utils/index.d.ts +4 -0
  133. package/services/chain-service/utils/index.js +32 -11
  134. package/services/chain-service/utils/patch.js +1 -1
  135. package/services/earning-service/constants/chains.d.ts +1 -0
  136. package/services/earning-service/constants/chains.js +2 -1
  137. package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
  138. package/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
  139. package/services/earning-service/handlers/native-staking/mythos.d.ts +35 -0
  140. package/services/earning-service/handlers/native-staking/mythos.js +329 -0
  141. package/services/earning-service/service.js +12 -14
  142. package/services/earning-service/utils/index.js +2 -0
  143. package/services/fee-service/service.js +19 -8
  144. package/services/history-service/index.js +6 -8
  145. package/services/inapp-notification-service/index.d.ts +3 -4
  146. package/services/inapp-notification-service/index.js +14 -6
  147. package/services/keyring-service/context/account-context.d.ts +6 -2
  148. package/services/keyring-service/context/account-context.js +17 -2
  149. package/services/keyring-service/context/handlers/Derive.d.ts +1 -1
  150. package/services/keyring-service/context/handlers/Derive.js +10 -8
  151. package/services/keyring-service/context/handlers/Migration.d.ts +17 -0
  152. package/services/keyring-service/context/handlers/Migration.js +258 -0
  153. package/services/keyring-service/context/handlers/Mnemonic.js +2 -2
  154. package/services/keyring-service/context/handlers/Secret.js +2 -2
  155. package/services/keyring-service/utils.d.ts +2 -0
  156. package/services/keyring-service/utils.js +11 -0
  157. package/services/migration-service/scripts/databases/ClearMetadataDatabase.d.ts +3 -3
  158. package/services/migration-service/scripts/databases/ClearMetadataDatabase.js +3 -23
  159. package/services/migration-service/scripts/databases/ClearMetadataForChains.d.ts +5 -0
  160. package/services/migration-service/scripts/databases/ClearMetadataForChains.js +32 -0
  161. package/services/migration-service/scripts/databases/ClearMetadataForMythos.d.ts +4 -0
  162. package/services/migration-service/scripts/databases/ClearMetadataForMythos.js +7 -0
  163. package/services/migration-service/scripts/index.d.ts +1 -0
  164. package/services/migration-service/scripts/index.js +4 -1
  165. package/services/request-service/handler/CardanoRequestHandler.d.ts +16 -0
  166. package/services/request-service/handler/CardanoRequestHandler.js +163 -0
  167. package/services/request-service/handler/EvmRequestHandler.js +1 -1
  168. package/services/request-service/index.d.ts +6 -3
  169. package/services/request-service/index.js +19 -5
  170. package/services/setting-service/constants.d.ts +3 -0
  171. package/services/setting-service/constants.js +6 -0
  172. package/services/storage-service/DatabaseService.d.ts +2 -0
  173. package/services/storage-service/DatabaseService.js +6 -0
  174. package/services/storage-service/db-stores/InappNotification.d.ts +1 -0
  175. package/services/storage-service/db-stores/InappNotification.js +6 -0
  176. package/services/storage-service/db-stores/Metadata.d.ts +1 -0
  177. package/services/storage-service/db-stores/Metadata.js +3 -0
  178. package/services/storage-service/db-stores/Migration.d.ts +1 -0
  179. package/services/storage-service/db-stores/Migration.js +6 -1
  180. package/services/swap-service/handler/asset-hub/handler.d.ts +1 -4
  181. package/services/swap-service/handler/asset-hub/handler.js +2 -61
  182. package/services/swap-service/handler/base-handler.d.ts +1 -4
  183. package/services/swap-service/handler/chainflip-handler.d.ts +2 -9
  184. package/services/swap-service/handler/chainflip-handler.js +31 -280
  185. package/services/swap-service/handler/hydradx-handler.d.ts +1 -6
  186. package/services/swap-service/handler/hydradx-handler.js +13 -180
  187. package/services/swap-service/handler/simpleswap-handler.d.ts +1 -4
  188. package/services/swap-service/handler/simpleswap-handler.js +5 -226
  189. package/services/swap-service/handler/uniswap-handler.d.ts +41 -0
  190. package/services/swap-service/handler/uniswap-handler.js +323 -0
  191. package/services/swap-service/index.js +30 -22
  192. package/services/swap-service/utils.d.ts +1 -5
  193. package/services/swap-service/utils.js +7 -21
  194. package/services/transaction-service/helpers/index.d.ts +2 -0
  195. package/services/transaction-service/helpers/index.js +4 -0
  196. package/services/transaction-service/index.d.ts +8 -2
  197. package/services/transaction-service/index.js +263 -10
  198. package/services/transaction-service/types.d.ts +7 -0
  199. package/services/transaction-service/utils.js +7 -2
  200. package/types/account/info/keyring.d.ts +4 -1
  201. package/types/account/info/keyring.js +9 -0
  202. package/types/account/info/proxy.d.ts +2 -0
  203. package/types/balance/index.d.ts +4 -1
  204. package/types/fee/base.d.ts +1 -1
  205. package/types/fee/cardano.d.ts +18 -0
  206. package/types/fee/cardano.js +1 -0
  207. package/types/fee/subscription.d.ts +4 -3
  208. package/types/swap/index.d.ts +11 -3
  209. package/types/swap/index.js +7 -2
  210. package/utils/account/analyze.js +2 -1
  211. package/utils/account/common.d.ts +11 -6
  212. package/utils/account/common.js +28 -19
  213. package/utils/account/derive/info/solo.js +10 -5
  214. package/utils/account/derive/validate.d.ts +1 -0
  215. package/utils/account/derive/validate.js +34 -1
  216. package/utils/account/transform.d.ts +2 -1
  217. package/utils/account/transform.js +37 -13
  218. package/utils/fee/transfer.d.ts +2 -1
  219. package/utils/fee/transfer.js +44 -11
  220. package/utils/index.js +4 -4
  221. package/utils/staticData/index.d.ts +4 -1
  222. package/utils/staticData/index.js +5 -1
  223. package/utils/staticData/oldChainPrefix.json +1 -0
@@ -65,7 +65,16 @@ export let AccountChainType;
65
65
  AccountChainType["ETHEREUM"] = "ethereum";
66
66
  AccountChainType["BITCOIN"] = "bitcoin";
67
67
  AccountChainType["TON"] = "ton";
68
+ AccountChainType["CARDANO"] = "cardano";
68
69
  })(AccountChainType || (AccountChainType = {}));
70
+ export const ACCOUNT_CHAIN_TYPE_ORDINAL_MAP = {
71
+ [AccountChainType.SUBSTRATE]: 1,
72
+ [AccountChainType.ETHEREUM]: 2,
73
+ [AccountChainType.TON]: 3,
74
+ [AccountChainType.CARDANO]: 4,
75
+ [AccountChainType.BITCOIN]: 5
76
+ };
77
+ export const SUPPORTED_ACCOUNT_CHAIN_TYPES = ['substrate', 'ethereum', 'ton', 'cardano'];
69
78
  export let AccountActions;
70
79
 
71
80
  /**
@@ -15,6 +15,7 @@ export interface AccountProxyData {
15
15
  name: string;
16
16
  parentId?: string;
17
17
  suri?: string;
18
+ isMigrationDone?: boolean;
18
19
  }
19
20
  /**
20
21
  * Represents a mapping of unique identifiers to account proxy data.
@@ -55,6 +56,7 @@ export interface AccountProxy extends AccountProxyData {
55
56
  children?: string[];
56
57
  tokenTypes: _AssetType[];
57
58
  accountActions: AccountActions[];
59
+ isNeedMigrateUnifiedAccount?: boolean;
58
60
  }
59
61
  export declare type AccountProxyMap = Record<string, AccountProxy>;
60
62
  export interface AccountProxyExtra extends AccountProxy {
@@ -1,7 +1,7 @@
1
1
  /// <reference types="bn.js" />
2
2
  import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
3
3
  import { _BalanceMetadata, APIItemState, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
4
- import { _EvmApi, _SubstrateApi, _TonApi } from '@subwallet/extension-base/services/chain-service/types';
4
+ import { _CardanoApi, _EvmApi, _SubstrateApi, _TonApi } from '@subwallet/extension-base/services/chain-service/types';
5
5
  import { BN } from '@polkadot/util';
6
6
  export interface TokenBalanceRaw {
7
7
  reserved: BN;
@@ -52,3 +52,6 @@ export interface SubscribeEvmPalletBalance extends SubscribeBasePalletBalance {
52
52
  export interface SubscribeTonPalletBalance extends SubscribeBasePalletBalance {
53
53
  tonApi: _TonApi;
54
54
  }
55
+ export interface SusbcribeCardanoPalletBalance extends SubscribeBasePalletBalance {
56
+ cardanoApi: _CardanoApi;
57
+ }
@@ -1,4 +1,4 @@
1
- export declare type FeeChainType = 'evm' | 'substrate' | 'ton';
1
+ export declare type FeeChainType = 'evm' | 'substrate' | 'ton' | 'cardano';
2
2
  export interface BaseFeeInfo {
3
3
  busyNetwork: boolean;
4
4
  type: FeeChainType;
@@ -0,0 +1,18 @@
1
+ import { BaseFeeDetail, BaseFeeInfo } from './base';
2
+ import { FeeDefaultOption } from './option';
3
+ /** @deprecated */
4
+ export interface CardanoTipInfo {
5
+ tip: string;
6
+ }
7
+ /** @deprecated */
8
+ export interface CardanoFeeInfo extends BaseFeeInfo {
9
+ type: 'ton';
10
+ options: {
11
+ slow: CardanoTipInfo;
12
+ average: CardanoTipInfo;
13
+ fast: CardanoTipInfo;
14
+ default: FeeDefaultOption;
15
+ };
16
+ }
17
+ /** @deprecated */
18
+ export declare type CardanoFeeDetail = CardanoFeeInfo & BaseFeeDetail;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,11 @@
1
1
  import { BehaviorSubject } from 'rxjs';
2
+ import { CardanoFeeDetail, CardanoFeeInfo, CardanoTipInfo } from './cardano';
2
3
  import { EvmEIP1559FeeOption, EvmFeeDetail, EvmFeeInfo } from './evm';
3
4
  import { SubstrateFeeDetail, SubstrateFeeInfo, SubstrateTipInfo } from './substrate';
4
5
  import { TonFeeDetail, TonFeeInfo, TonTipInfo } from './ton';
5
- export declare type FeeInfo = EvmFeeInfo | SubstrateFeeInfo | TonFeeInfo;
6
- export declare type FeeDetail = EvmFeeDetail | SubstrateFeeDetail | TonFeeDetail;
7
- export declare type FeeCustom = EvmEIP1559FeeOption | SubstrateTipInfo | TonTipInfo;
6
+ export declare type FeeInfo = EvmFeeInfo | SubstrateFeeInfo | TonFeeInfo | CardanoFeeInfo;
7
+ export declare type FeeDetail = EvmFeeDetail | SubstrateFeeDetail | TonFeeDetail | CardanoFeeDetail;
8
+ export declare type FeeCustom = EvmEIP1559FeeOption | SubstrateTipInfo | TonTipInfo | CardanoTipInfo;
8
9
  export interface FeeSubscription {
9
10
  observer: BehaviorSubject<FeeInfo | undefined>;
10
11
  subscription: Record<string, VoidFunction>;
@@ -1,7 +1,7 @@
1
1
  import { _ChainInfo } from '@subwallet/chain-list/types';
2
2
  import { SwapError } from '@subwallet/extension-base/background/errors/SwapError';
3
3
  import { AmountData, ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
4
- import { BaseStepDetail, CommonOptimalPath, CommonStepFeeInfo } from '@subwallet/extension-base/types/service-base';
4
+ import { BaseStepDetail, BaseStepType, CommonOptimalPath, CommonStepFeeInfo } from '@subwallet/extension-base/types/service-base';
5
5
  import BigN from 'bignumber.js';
6
6
  import { BaseProcessRequestSign, TransactionData } from '../transaction';
7
7
  export declare type SwapRate = number;
@@ -44,7 +44,8 @@ export declare enum SwapErrorType {
44
44
  NOT_MEET_MIN_EXPECTED = "NOT_MEET_MIN_EXPECTED"
45
45
  }
46
46
  export declare enum SwapStepType {
47
- SWAP = "SWAP"
47
+ SWAP = "SWAP",
48
+ PERMIT = "PERMIT"
48
49
  }
49
50
  export declare enum SwapProviderId {
50
51
  CHAIN_FLIP_TESTNET = "CHAIN_FLIP_TESTNET",
@@ -55,7 +56,8 @@ export declare enum SwapProviderId {
55
56
  KUSAMA_ASSET_HUB = "KUSAMA_ASSET_HUB",
56
57
  ROCOCO_ASSET_HUB = "ROCOCO_ASSET_HUB",
57
58
  WESTEND_ASSET_HUB = "WESTEND_ASSET_HUB",
58
- SIMPLE_SWAP = "SIMPLE_SWAP"
59
+ SIMPLE_SWAP = "SIMPLE_SWAP",
60
+ UNISWAP = "UNISWAP"
59
61
  }
60
62
  export declare const _SUPPORTED_SWAP_PROVIDERS: SwapProviderId[];
61
63
  export interface SwapProvider {
@@ -139,6 +141,7 @@ export interface SwapSubmitParams extends BaseProcessRequestSign {
139
141
  address: string;
140
142
  slippage: number;
141
143
  recipient?: string;
144
+ cacheProcessId: string;
142
145
  }
143
146
  export interface SwapSubmitStepData {
144
147
  txChain: string;
@@ -147,6 +150,7 @@ export interface SwapSubmitStepData {
147
150
  transferNativeAmount: string;
148
151
  extrinsicType: ExtrinsicType;
149
152
  chainType: ChainType;
153
+ isPermit?: boolean;
150
154
  }
151
155
  export interface OptimalSwapPathParams {
152
156
  request: SwapRequest;
@@ -169,5 +173,9 @@ export interface SlippageType {
169
173
  slippage: BigN;
170
174
  isCustomType: boolean;
171
175
  }
176
+ export interface PermitSwapData {
177
+ processId: string;
178
+ step: BaseStepType;
179
+ }
172
180
  export declare const CHAINFLIP_SLIPPAGE = 0.02;
173
181
  export declare const SIMPLE_SWAP_SLIPPAGE = 0.05;
@@ -21,6 +21,7 @@ export let SwapErrorType;
21
21
  export let SwapStepType;
22
22
  (function (SwapStepType) {
23
23
  SwapStepType["SWAP"] = "SWAP";
24
+ SwapStepType["PERMIT"] = "PERMIT";
24
25
  })(SwapStepType || (SwapStepType = {}));
25
26
  export let SwapProviderId;
26
27
  (function (SwapProviderId) {
@@ -33,10 +34,14 @@ export let SwapProviderId;
33
34
  SwapProviderId["ROCOCO_ASSET_HUB"] = "ROCOCO_ASSET_HUB";
34
35
  SwapProviderId["WESTEND_ASSET_HUB"] = "WESTEND_ASSET_HUB";
35
36
  SwapProviderId["SIMPLE_SWAP"] = "SIMPLE_SWAP";
37
+ SwapProviderId["UNISWAP"] = "UNISWAP";
36
38
  })(SwapProviderId || (SwapProviderId = {}));
37
- export const _SUPPORTED_SWAP_PROVIDERS = [SwapProviderId.CHAIN_FLIP_TESTNET, SwapProviderId.CHAIN_FLIP_MAINNET, SwapProviderId.HYDRADX_MAINNET, SwapProviderId.HYDRADX_TESTNET, SwapProviderId.POLKADOT_ASSET_HUB, SwapProviderId.KUSAMA_ASSET_HUB, SwapProviderId.ROCOCO_ASSET_HUB,
39
+ export const _SUPPORTED_SWAP_PROVIDERS = [SwapProviderId.CHAIN_FLIP_TESTNET, SwapProviderId.CHAIN_FLIP_MAINNET, SwapProviderId.HYDRADX_MAINNET,
40
+ // SwapProviderId.HYDRADX_TESTNET,
41
+ SwapProviderId.POLKADOT_ASSET_HUB, SwapProviderId.KUSAMA_ASSET_HUB,
42
+ // SwapProviderId.ROCOCO_ASSET_HUB,
38
43
  // SwapProviderId.WESTEND_ASSET_HUB,
39
- SwapProviderId.SIMPLE_SWAP];
44
+ SwapProviderId.SIMPLE_SWAP, SwapProviderId.UNISWAP];
40
45
  // process handling
41
46
  export let SwapFeeType;
42
47
  (function (SwapFeeType) {
@@ -15,7 +15,8 @@ const isStrValidWithAddress = (str, account, chainInfo) => {
15
15
  } else if (account.address.toLowerCase().includes(str) || reformated.toLowerCase().includes(str)) {
16
16
  return 'valid';
17
17
  }
18
- } else if (account.chainType === AccountChainType.TON) {
18
+ } else if (account.chainType === AccountChainType.TON || account.chainType === AccountChainType.CARDANO) {
19
+ // todo: recheck for Cardano
19
20
  const isTestnet = chainInfo.isTestnet;
20
21
  const reformated = reformatAddress(account.address, isTestnet ? 0 : 1);
21
22
  if (account.address.toLowerCase() === str || reformated.toLowerCase() === str) {
@@ -1,16 +1,21 @@
1
1
  import { _ChainInfo } from '@subwallet/chain-list/types';
2
+ import { ChainType } from '@subwallet/extension-base/background/KoniTypes';
2
3
  import { AccountChainType } from '@subwallet/extension-base/types';
3
4
  import { KeypairType } from '@subwallet/keyring/types';
4
5
  export declare function isAccountAll(address?: string): boolean;
5
6
  export declare function reformatAddress(address: string, networkPrefix?: number, isEthereum?: boolean): string;
6
7
  export declare const _reformatAddressWithChain: (address: string, chainInfo: _ChainInfo) => string;
7
8
  export declare const getAccountChainTypeForAddress: (address: string) => AccountChainType;
8
- export declare function categoryAddresses(addresses: string[]): {
9
- substrate: string[];
10
- evm: string[];
11
- ton: string[];
12
- bitcoin: string[];
13
- };
9
+ interface AddressesByChainType {
10
+ [ChainType.SUBSTRATE]: string[];
11
+ [ChainType.EVM]: string[];
12
+ [ChainType.BITCOIN]: string[];
13
+ [ChainType.TON]: string[];
14
+ [ChainType.CARDANO]: string[];
15
+ }
16
+ export declare function getAddressesByChainType(addresses: string[], chainTypes: ChainType[]): string[];
17
+ export declare function getAddressesByChainTypeMap(addresses: string[]): AddressesByChainType;
14
18
  export declare function quickFormatAddressToCompare(address?: string): string | undefined;
15
19
  /** @deprecated */
16
20
  export declare const modifyAccountName: (type: KeypairType, name: string, modify: boolean) => string;
21
+ export {};
@@ -1,11 +1,12 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { ChainType } from '@subwallet/extension-base/background/KoniTypes';
4
5
  import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
5
6
  import { _chainInfoToChainType, _getChainSubstrateAddressPrefix } from '@subwallet/extension-base/services/chain-service/utils';
6
7
  import { AccountChainType } from '@subwallet/extension-base/types';
7
- import { getAccountChainType } from '@subwallet/extension-base/utils';
8
- import { decodeAddress, encodeAddress, getKeypairTypeByAddress, isAddress, isBitcoinAddress, isTonAddress } from '@subwallet/keyring';
8
+ import { getAccountChainTypeFromKeypairType } from '@subwallet/extension-base/utils';
9
+ import { decodeAddress, encodeAddress, getKeypairTypeByAddress, isAddress, isBitcoinAddress, isCardanoAddress, isTonAddress } from '@subwallet/keyring';
9
10
  import { ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
10
11
  export function isAccountAll(address) {
11
12
  return address === ALL_ACCOUNT_KEY;
@@ -36,10 +37,11 @@ export function reformatAddress(address, networkPrefix = 42, isEthereum = false)
36
37
  }
37
38
  }
38
39
  export const _reformatAddressWithChain = (address, chainInfo) => {
40
+ // todo: check for cardano
39
41
  const chainType = _chainInfoToChainType(chainInfo);
40
42
  if (chainType === AccountChainType.SUBSTRATE) {
41
43
  return reformatAddress(address, _getChainSubstrateAddressPrefix(chainInfo));
42
- } else if (chainType === AccountChainType.TON) {
44
+ } else if (chainType === AccountChainType.TON || chainType === AccountChainType.CARDANO) {
43
45
  const isTestnet = chainInfo.isTestnet;
44
46
  return reformatAddress(address, isTestnet ? 0 : 1);
45
47
  } else {
@@ -48,30 +50,37 @@ export const _reformatAddressWithChain = (address, chainInfo) => {
48
50
  };
49
51
  export const getAccountChainTypeForAddress = address => {
50
52
  const type = getKeypairTypeByAddress(address);
51
- return getAccountChainType(type);
53
+ return getAccountChainTypeFromKeypairType(type);
52
54
  };
53
- export function categoryAddresses(addresses) {
54
- const substrate = [];
55
- const evm = [];
56
- const ton = [];
57
- const bitcoin = [];
55
+ export function getAddressesByChainType(addresses, chainTypes) {
56
+ const addressByChainTypeMap = getAddressesByChainTypeMap(addresses);
57
+ return chainTypes.map(chainType => {
58
+ return addressByChainTypeMap[chainType];
59
+ }).flat(); // todo: recheck
60
+ }
61
+
62
+ export function getAddressesByChainTypeMap(addresses) {
63
+ const addressByChainType = {
64
+ substrate: [],
65
+ evm: [],
66
+ bitcoin: [],
67
+ ton: [],
68
+ cardano: []
69
+ };
58
70
  addresses.forEach(address => {
59
71
  if (isEthereumAddress(address)) {
60
- evm.push(address);
72
+ addressByChainType.evm.push(address);
61
73
  } else if (isTonAddress(address)) {
62
- ton.push(address);
74
+ addressByChainType.ton.push(address);
63
75
  } else if (isBitcoinAddress(address)) {
64
- bitcoin.push(address);
76
+ addressByChainType.bitcoin.push(address);
77
+ } else if (isCardanoAddress(address)) {
78
+ addressByChainType.cardano.push(address);
65
79
  } else {
66
- substrate.push(address);
80
+ addressByChainType.substrate.push(address);
67
81
  }
68
82
  });
69
- return {
70
- bitcoin,
71
- evm,
72
- substrate,
73
- ton
74
- };
83
+ return addressByChainType;
75
84
  }
76
85
  export function quickFormatAddressToCompare(address) {
77
86
  if (!isAddress(address)) {
@@ -6,7 +6,7 @@ import { EthereumKeypairTypes, SubstrateKeypairTypes } from '@subwallet/keyring/
6
6
  import { keyring } from '@subwallet/ui-keyring';
7
7
  import { t } from 'i18next';
8
8
  import { assert } from '@polkadot/util';
9
- import { validateEvmDerivationPath, validateOtherSubstrateDerivationPath, validateSr25519DerivationPath, validateTonDerivationPath, validateUnifiedDerivationPath } from "../validate.js";
9
+ import { validateCardanoDerivationPath, validateEvmDerivationPath, validateOtherSubstrateDerivationPath, validateSr25519DerivationPath, validateTonDerivationPath, validateUnifiedDerivationPath } from "../validate.js";
10
10
  export const parseUnifiedSuriToDerivationPath = (suri, type) => {
11
11
  const reg = /^\/\/(\d+)(\/\/\d+)?$/;
12
12
  if (suri.match(reg)) {
@@ -18,12 +18,16 @@ export const parseUnifiedSuriToDerivationPath = (suri, type) => {
18
18
  return `m/44'/60'/0'/0/${first}/${secondIndex}`;
19
19
  } else if (type === 'ton') {
20
20
  return `m/44'/607'/${first}'/${secondIndex}'`;
21
+ } else if (type === 'cardano') {
22
+ return `m/1852'/1815'/${first}'/${secondIndex}'`;
21
23
  }
22
24
  } else {
23
25
  if (type === 'ethereum') {
24
26
  return `m/44'/60'/0'/0/${first}`;
25
27
  } else if (type === 'ton') {
26
28
  return `m/44'/607'/${first}'`;
29
+ } else if (type === 'cardano') {
30
+ return `m/1852'/1815'/${first}'`;
27
31
  }
28
32
  }
29
33
  if (SubstrateKeypairTypes.includes(type)) {
@@ -40,7 +44,7 @@ export const getSoloDerivationInfo = (type, metadata = {}) => {
40
44
  } = metadata;
41
45
  if (suri) {
42
46
  if (derivePath) {
43
- const validateTypeFunc = type === 'ethereum' ? validateEvmDerivationPath : type === 'ton' ? validateTonDerivationPath : () => undefined;
47
+ const validateTypeFunc = type === 'ethereum' ? validateEvmDerivationPath : type === 'ton' ? validateTonDerivationPath : type === 'cardano' ? validateCardanoDerivationPath : () => undefined;
44
48
  const validateTypeRs = validateTypeFunc(derivePath);
45
49
  if (validateTypeRs) {
46
50
  return {
@@ -97,7 +101,7 @@ export const getSoloDerivationInfo = (type, metadata = {}) => {
97
101
  }
98
102
  } else {
99
103
  if (derivePath) {
100
- const validateTypeFunc = type === 'ethereum' ? validateEvmDerivationPath : type === 'ton' ? validateTonDerivationPath : () => undefined;
104
+ const validateTypeFunc = type === 'ethereum' ? validateEvmDerivationPath : type === 'ton' ? validateTonDerivationPath : type === 'cardano' ? validateCardanoDerivationPath : () => undefined;
101
105
  const validateTypeRs = validateTypeFunc(derivePath);
102
106
  if (validateTypeRs) {
103
107
  return {
@@ -210,6 +214,7 @@ export const derivePair = (parentPair, name, suri, derivationPath) => {
210
214
  }
211
215
  const isEvm = EthereumKeypairTypes.includes(parentPair.type);
212
216
  const isTon = parentPair.type === 'ton';
217
+ const isCardano = parentPair.type === 'cardano';
213
218
  const meta = {
214
219
  name,
215
220
  parentAddress: parentPair.address,
@@ -220,8 +225,8 @@ export const derivePair = (parentPair, name, suri, derivationPath) => {
220
225
  if (isTon && (_parentPair$ton = parentPair.ton) !== null && _parentPair$ton !== void 0 && _parentPair$ton.contractVersion) {
221
226
  meta.tonContractVersion = parentPair.ton.contractVersion;
222
227
  }
223
- if (derivationPath && (isEvm || isTon)) {
224
- return isEvm ? parentPair.evm.deriveCustom(derivationPath, meta) : parentPair.ton.deriveCustom(derivationPath, meta);
228
+ if (derivationPath && (isEvm || isTon || isCardano)) {
229
+ return isEvm ? parentPair.evm.deriveCustom(derivationPath, meta) : isTon ? parentPair.ton.deriveCustom(derivationPath, meta) : parentPair.cardano.deriveCustom(derivationPath, meta);
225
230
  } else {
226
231
  return parentPair.substrate.derive(suri, meta);
227
232
  }
@@ -3,6 +3,7 @@ import { KeypairType, SubstrateKeypairType } from '@subwallet/keyring/types';
3
3
  export declare const validateUnifiedDerivationPath: (raw: string) => DerivePathInfo | undefined;
4
4
  export declare const validateEvmDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
5
5
  export declare const validateTonDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
6
+ export declare const validateCardanoDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
6
7
  export declare const validateSr25519DerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
7
8
  export declare const validateOtherSubstrateDerivationPath: (raw: string, type: Exclude<SubstrateKeypairType, 'sr25519'>) => IDerivePathInfo_ | undefined;
8
9
  export declare const validateDerivationPath: (raw: string, type?: KeypairType) => DerivePathInfo | undefined;
@@ -96,6 +96,37 @@ export const validateTonDerivationPath = raw => {
96
96
  return undefined;
97
97
  }
98
98
  };
99
+ export const validateCardanoDerivationPath = raw => {
100
+ const reg = /^m\/1852'\/1815'\/(\d+)'(\/\d+')?$/;
101
+ if (raw.match(reg)) {
102
+ const [, firstIndex, secondData] = raw.match(reg);
103
+ const first = parseInt(firstIndex, 10);
104
+ const autoIndexes = [first];
105
+ let depth;
106
+ let suri = `//${first}`;
107
+ if (first === 0) {
108
+ depth = 0;
109
+ } else {
110
+ depth = 1;
111
+ }
112
+ if (secondData) {
113
+ const [, secondIndex] = secondData.match(/\/(\d+)/);
114
+ const second = parseInt(secondIndex, 10);
115
+ autoIndexes.push(second);
116
+ depth = 2;
117
+ suri += `//${second}`;
118
+ }
119
+ return {
120
+ depth,
121
+ type: 'cardano',
122
+ suri,
123
+ derivationPath: raw,
124
+ autoIndexes
125
+ };
126
+ } else {
127
+ return undefined;
128
+ }
129
+ };
99
130
  export const validateSr25519DerivationPath = raw => {
100
131
  const reg = /\/(\/?)([^/]+)/g;
101
132
  const parts = raw.match(reg);
@@ -156,10 +187,12 @@ export const validateDerivationPath = (raw, type) => {
156
187
  return validateSr25519DerivationPath(raw);
157
188
  } else if (type === 'ed25519' || type === 'ecdsa') {
158
189
  return validateOtherSubstrateDerivationPath(raw, type);
190
+ } else if (type === 'cardano') {
191
+ return validateCardanoDerivationPath(raw);
159
192
  } else {
160
193
  return undefined;
161
194
  }
162
195
  } else {
163
- return validateUnifiedDerivationPath(raw) || validateEvmDerivationPath(raw) || validateTonDerivationPath(raw) || validateSr25519DerivationPath(raw);
196
+ return validateUnifiedDerivationPath(raw) || validateEvmDerivationPath(raw) || validateTonDerivationPath(raw) || validateSr25519DerivationPath(raw) || validateCardanoDerivationPath(raw);
164
197
  }
165
198
  };
@@ -4,7 +4,8 @@ import { AccountActions, AccountChainType, AccountJson, AccountProxy, AccountPro
4
4
  import { KeypairType, KeyringPair, KeyringPair$Meta } from '@subwallet/keyring/types';
5
5
  import { SingleAddress, SubjectInfo } from '@subwallet/ui-keyring/observable/types';
6
6
  export declare const createAccountProxyId: (_suri: string, derivationPath?: string) => `0x${string}`;
7
- export declare const getAccountChainType: (type: KeypairType) => AccountChainType;
7
+ export declare const getAccountChainTypeFromKeypairType: (type: KeypairType) => AccountChainType;
8
+ export declare const getDefaultKeypairTypeFromAccountChainType: (type: AccountChainType) => KeypairType;
8
9
  export declare const getAccountSignMode: (address: string, _meta?: KeyringPair$Meta) => AccountSignMode;
9
10
  export declare const getAccountActions: (signMode: AccountSignMode, networkType: AccountChainType, type: KeypairType, _meta?: KeyringPair$Meta, parentAccount?: AccountJson) => AccountActions[];
10
11
  export declare const getAccountTransactionActions: (signMode: AccountSignMode, networkType: AccountChainType, type?: KeypairType, _meta?: KeyringPair$Meta, _specialNetwork?: string) => ExtrinsicType[];
@@ -5,9 +5,9 @@ import { _AssetType } from '@subwallet/chain-list/types';
5
5
  import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
6
6
  import { ALL_ACCOUNT_KEY, isProductionMode } from '@subwallet/extension-base/constants';
7
7
  import { _getSubstrateGenesisHash } from '@subwallet/extension-base/services/chain-service/utils';
8
- import { AccountActions, AccountChainType, AccountProxyType, AccountSignMode } from '@subwallet/extension-base/types';
8
+ import { AccountActions, AccountChainType, AccountProxyType, AccountSignMode, SUPPORTED_ACCOUNT_CHAIN_TYPES } from '@subwallet/extension-base/types';
9
9
  import { getKeypairTypeByAddress, tonMnemonicToEntropy } from '@subwallet/keyring';
10
- import { BitcoinKeypairTypes, EthereumKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
10
+ import { BitcoinKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
11
11
  import { tonMnemonicValidate } from '@subwallet/keyring/utils';
12
12
  import { hexStripPrefix, u8aToHex } from '@polkadot/util';
13
13
  import { blake2AsHex, mnemonicToEntropy, mnemonicValidate } from '@polkadot/util-crypto';
@@ -32,8 +32,21 @@ export const createAccountProxyId = (_suri, derivationPath) => {
32
32
  }
33
33
  return blake2AsHex(data, 256);
34
34
  };
35
- export const getAccountChainType = type => {
36
- return type ? EthereumKeypairTypes.includes(type) ? AccountChainType.ETHEREUM : TonKeypairTypes.includes(type) ? AccountChainType.TON : BitcoinKeypairTypes.includes(type) ? AccountChainType.BITCOIN : AccountChainType.SUBSTRATE : AccountChainType.SUBSTRATE;
35
+ export const getAccountChainTypeFromKeypairType = type => {
36
+ return type ? EthereumKeypairTypes.includes(type) ? AccountChainType.ETHEREUM : TonKeypairTypes.includes(type) ? AccountChainType.TON : BitcoinKeypairTypes.includes(type) ? AccountChainType.BITCOIN : CardanoKeypairTypes.includes(type) ? AccountChainType.CARDANO : AccountChainType.SUBSTRATE : AccountChainType.SUBSTRATE;
37
+ };
38
+ export const getDefaultKeypairTypeFromAccountChainType = type => {
39
+ if (type === AccountChainType.ETHEREUM) {
40
+ return 'ethereum';
41
+ } else if (type === AccountChainType.TON) {
42
+ return 'ton';
43
+ } else if (type === AccountChainType.BITCOIN) {
44
+ return 'bitcoin-84';
45
+ } else if (type === AccountChainType.CARDANO) {
46
+ return 'cardano';
47
+ } else {
48
+ return 'sr25519';
49
+ }
37
50
  };
38
51
  export const getAccountSignMode = (address, _meta) => {
39
52
  const meta = _meta;
@@ -68,6 +81,7 @@ export const getAccountActions = (signMode, networkType, type, _meta, parentAcco
68
81
  const result = [];
69
82
  const meta = _meta;
70
83
 
84
+ // todo: check this function for Cardano
71
85
  // JSON
72
86
  if (signMode === AccountSignMode.PASSWORD) {
73
87
  result.push(AccountActions.EXPORT_JSON);
@@ -146,6 +160,8 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
146
160
  return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...EVM_ACTIONS];
147
161
  case AccountChainType.TON:
148
162
  return [...BASE_TRANSFER_ACTIONS];
163
+ case AccountChainType.CARDANO:
164
+ return [...BASE_TRANSFER_ACTIONS];
149
165
  }
150
166
  } else if (signMode === AccountSignMode.QR) {
151
167
  switch (networkType) {
@@ -155,6 +171,8 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
155
171
  return [...(isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
156
172
  case AccountChainType.TON:
157
173
  return [];
174
+ case AccountChainType.CARDANO:
175
+ return [];
158
176
  }
159
177
  } else if (signMode === AccountSignMode.GENERIC_LEDGER) {
160
178
  switch (networkType) {
@@ -170,6 +188,8 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
170
188
  ExtrinsicType.SEND_NFT, ExtrinsicType.SWAP];
171
189
  case AccountChainType.TON:
172
190
  return [...BASE_TRANSFER_ACTIONS];
191
+ case AccountChainType.CARDANO:
192
+ return [];
173
193
  }
174
194
  } else if (signMode === AccountSignMode.LEGACY_LEDGER) {
175
195
  // Only for Substrate
@@ -229,6 +249,8 @@ export const getAccountTokenTypes = type => {
229
249
  case 'bitcoin-86':
230
250
  case 'bittest-86':
231
251
  return [_AssetType.NATIVE, _AssetType.RUNE, _AssetType.BRC20];
252
+ case 'cardano':
253
+ return [_AssetType.NATIVE, _AssetType.CIP26];
232
254
  default:
233
255
  return [];
234
256
  }
@@ -253,7 +275,7 @@ export const getAccountTokenTypes = type => {
253
275
  export const transformAccount = (address, _type, meta, chainInfoMap, parentAccount) => {
254
276
  const signMode = getAccountSignMode(address, meta);
255
277
  const type = _type || getKeypairTypeByAddress(address);
256
- const chainType = getAccountChainType(type);
278
+ const chainType = getAccountChainTypeFromKeypairType(type);
257
279
  let specialChain;
258
280
  if (!chainInfoMap) {
259
281
  return {
@@ -307,7 +329,7 @@ export const pairToAccount = ({
307
329
  export const transformAccounts = accounts => Object.values(accounts).map(data => singleAddressToAccount(data));
308
330
  export const transformAddress = (address, meta) => {
309
331
  const type = getKeypairTypeByAddress(address);
310
- const chainType = getAccountChainType(type);
332
+ const chainType = getAccountChainTypeFromKeypairType(type);
311
333
  return {
312
334
  address,
313
335
  ...meta,
@@ -382,6 +404,7 @@ export const _combineAccounts = (accounts, modifyPairs, accountProxies) => {
382
404
  let tokenTypes = [];
383
405
  let accountActions = [];
384
406
  let specialChain;
407
+ let isNeedMigrateUnifiedAccount;
385
408
  if (value.accounts.length > 1) {
386
409
  accountType = AccountProxyType.UNIFIED;
387
410
  chainTypes = Array.from(value.accounts.reduce((rs, account) => rs.add(account.chainType), new Set()));
@@ -391,6 +414,9 @@ export const _combineAccounts = (accounts, modifyPairs, accountProxies) => {
391
414
  }
392
415
  return rs;
393
416
  }, new Set()));
417
+ if (chainTypes.length < SUPPORTED_ACCOUNT_CHAIN_TYPES.length) {
418
+ isNeedMigrateUnifiedAccount = true;
419
+ }
394
420
 
395
421
  /* Account actions */
396
422
 
@@ -422,6 +448,9 @@ export const _combineAccounts = (accounts, modifyPairs, accountProxies) => {
422
448
  if (account.chainType === AccountChainType.TON) {
423
449
  accountActions = accountActions.filter(action => action !== AccountActions.DERIVE);
424
450
  }
451
+ if (chainTypes.length === 1 && accountActions.includes(AccountActions.EXPORT_MNEMONIC) && account.isMasterAccount && account.type !== 'ton-native') {
452
+ isNeedMigrateUnifiedAccount = true;
453
+ }
425
454
  switch (account.signMode) {
426
455
  case AccountSignMode.GENERIC_LEDGER:
427
456
  case AccountSignMode.LEGACY_LEDGER:
@@ -435,7 +464,8 @@ export const _combineAccounts = (accounts, modifyPairs, accountProxies) => {
435
464
  chainTypes,
436
465
  specialChain,
437
466
  tokenTypes,
438
- accountActions
467
+ accountActions,
468
+ isNeedMigrateUnifiedAccount
439
469
  }];
440
470
  }));
441
471
  const deepSearchParentId = parentId => {
@@ -511,15 +541,9 @@ export const combineAllAccountProxy = accountProxies => {
511
541
  const tokenTypes = new Set();
512
542
  const specialChain = accountProxies.length === 1 ? accountProxies[0].specialChain : undefined;
513
543
  for (const accountProxy of accountProxies) {
514
- // Have 4 network types, but at the moment, we only support 3 network types
515
- if (chainTypes.size === 3) {
516
- break;
517
- }
518
544
  for (const chainType of accountProxy.chainTypes) {
519
545
  chainTypes.add(chainType);
520
546
  }
521
- }
522
- for (const accountProxy of accountProxies) {
523
547
  for (const tokenType of accountProxy.tokenTypes) {
524
548
  tokenTypes.add(tokenType);
525
549
  }
@@ -1,6 +1,6 @@
1
1
  import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
2
2
  import { AmountData } from '@subwallet/extension-base/background/KoniTypes';
3
- import { _EvmApi, _SubstrateApi, _TonApi } from '@subwallet/extension-base/services/chain-service/types';
3
+ import { _CardanoApi, _EvmApi, _SubstrateApi, _TonApi } from '@subwallet/extension-base/services/chain-service/types';
4
4
  import { FeeChainType, FeeInfo, TransactionFee } from '@subwallet/extension-base/types';
5
5
  import { ResponseSubscribeTransfer } from '@subwallet/extension-base/types/balance/transfer';
6
6
  export interface CalculateMaxTransferable extends TransactionFee {
@@ -12,6 +12,7 @@ export interface CalculateMaxTransferable extends TransactionFee {
12
12
  substrateApi: _SubstrateApi;
13
13
  evmApi: _EvmApi;
14
14
  tonApi: _TonApi;
15
+ cardanoApi: _CardanoApi;
15
16
  isTransferLocalTokenAndPayThatTokenAsFee: boolean;
16
17
  isTransferNativeTokenAndPayLocalTokenAsFee: boolean;
17
18
  nativeToken: _ChainAsset;