@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
@@ -0,0 +1,329 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
5
+ import { APIItemState, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
6
+ import { getCommission } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
7
+ import { _EXPECTED_BLOCK_TIME, _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
8
+ import BaseParaStakingPoolHandler from '@subwallet/extension-base/services/earning-service/handlers/native-staking/base-para';
9
+ import { BasicTxErrorType, EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
10
+ import { balanceFormatter, formatNumber, reformatAddress } from '@subwallet/extension-base/utils';
11
+ export default class MythosNativeStakingPoolHandler extends BaseParaStakingPoolHandler {
12
+ availableMethod = {
13
+ join: true,
14
+ defaultUnstake: true,
15
+ fastUnstake: false,
16
+ cancelUnstake: false,
17
+ withdraw: true,
18
+ claimReward: true
19
+ };
20
+
21
+ /* Subscribe pool info */
22
+
23
+ async subscribePoolInfo(callback) {
24
+ let cancel = false;
25
+ const substrateApi = this.substrateApi;
26
+ const nativeToken = this.nativeToken;
27
+ const defaultCallback = async () => {
28
+ const data = {
29
+ ...this.baseInfo,
30
+ type: this.type,
31
+ metadata: {
32
+ ...this.metadataInfo,
33
+ description: this.getDescription()
34
+ }
35
+ };
36
+ const poolInfo = await this.getPoolInfo();
37
+ !poolInfo && callback(data);
38
+ };
39
+ if (!this.isActive) {
40
+ await defaultCallback();
41
+ return () => {
42
+ cancel = true;
43
+ };
44
+ }
45
+ await defaultCallback();
46
+ await substrateApi.isReady;
47
+ const unsub = await substrateApi.api.query.collatorStaking.currentSession(async _session => {
48
+ if (cancel) {
49
+ unsub();
50
+ return;
51
+ }
52
+ const currentSession = _session.toString();
53
+ const maxStakers = substrateApi.api.consts.collatorStaking.maxStakers.toString();
54
+ const unstakeDelay = substrateApi.api.consts.collatorStaking.stakeUnlockDelay.toString();
55
+ const maxStakedCandidates = substrateApi.api.consts.collatorStaking.maxStakedCandidates.toString();
56
+ const sessionTime = _STAKING_ERA_LENGTH_MAP[this.chain] || _STAKING_ERA_LENGTH_MAP.default; // in hours
57
+ const blockTime = _EXPECTED_BLOCK_TIME[this.chain];
58
+ const unstakingPeriod = parseInt(unstakeDelay) * blockTime / 60 / 60;
59
+ const _minStake = await substrateApi.api.query.collatorStaking.minStake();
60
+ const minStake = _minStake.toString();
61
+ const minStakeToHuman = formatNumber(minStake, nativeToken.decimals || 0, balanceFormatter);
62
+ const data = {
63
+ ...this.baseInfo,
64
+ type: this.type,
65
+ metadata: {
66
+ ...this.metadataInfo,
67
+ description: this.getDescription(minStakeToHuman)
68
+ },
69
+ statistic: {
70
+ assetEarning: [{
71
+ slug: this.nativeToken.slug
72
+ }],
73
+ maxCandidatePerFarmer: parseInt(maxStakedCandidates),
74
+ maxWithdrawalRequestPerFarmer: 3,
75
+ earningThreshold: {
76
+ join: minStake,
77
+ defaultUnstake: '0',
78
+ fastUnstake: '0'
79
+ },
80
+ era: parseInt(currentSession),
81
+ eraTime: sessionTime,
82
+ unstakingPeriod: unstakingPeriod,
83
+ totalApy: undefined
84
+ // tvl: totalStake.toString(),
85
+ // inflation
86
+ },
87
+
88
+ maxPoolMembers: parseInt(maxStakers)
89
+ };
90
+ callback(data);
91
+ });
92
+ return () => {
93
+ cancel = true;
94
+ unsub();
95
+ };
96
+ }
97
+
98
+ /* Subscribe pool info */
99
+
100
+ /* Subscribe pool position */
101
+
102
+ async subscribePoolPosition(useAddresses, resultCallback) {
103
+ let cancel = false;
104
+ const substrateApi = await this.substrateApi.isReady;
105
+ const defaultInfo = this.baseInfo;
106
+ const unsub = await substrateApi.api.query.collatorStaking.userStake.multi(useAddresses, async userStakes => {
107
+ if (cancel) {
108
+ unsub();
109
+ return;
110
+ }
111
+ if (userStakes) {
112
+ await Promise.all(userStakes.map(async (_userStake, i) => {
113
+ const userStake = _userStake.toPrimitive();
114
+ const owner = reformatAddress(useAddresses[i], 42);
115
+ if (userStake) {
116
+ const nominatorMetadata = await this.parseCollatorMetadata(this.chainInfo, useAddresses[i], substrateApi, userStake);
117
+ resultCallback({
118
+ ...defaultInfo,
119
+ ...nominatorMetadata,
120
+ address: owner,
121
+ type: this.type
122
+ });
123
+ } else {
124
+ resultCallback({
125
+ ...defaultInfo,
126
+ type: this.type,
127
+ address: owner,
128
+ balanceToken: this.nativeToken.slug,
129
+ totalStake: '0',
130
+ activeStake: '0',
131
+ unstakeBalance: '0',
132
+ status: EarningStatus.NOT_STAKING,
133
+ isBondedBefore: false,
134
+ nominations: [],
135
+ unstakings: []
136
+ });
137
+ }
138
+ }));
139
+ }
140
+ });
141
+ return () => {
142
+ cancel = true;
143
+ unsub();
144
+ };
145
+ }
146
+ async parseCollatorMetadata(chainInfo, stakerAddress, substrateApi, userStake) {
147
+ const nominationList = [];
148
+ const unstakingList = [];
149
+ let unstakingBalance = BigInt(0);
150
+ const {
151
+ candidates,
152
+ stake
153
+ } = userStake;
154
+ const [_minStake, _unstaking, _currentBlock, _currentTimestamp] = await Promise.all([substrateApi.api.query.collatorStaking.minStake(), substrateApi.api.query.collatorStaking.releaseQueues(stakerAddress), substrateApi.api.query.system.number(), substrateApi.api.query.timestamp.now()]);
155
+ const minStake = _minStake.toPrimitive();
156
+ const stakingStatus = candidates && !!candidates.length ? EarningStatus.EARNING_REWARD : EarningStatus.NOT_EARNING;
157
+ const isBondedBefore = candidates && !!candidates.length;
158
+ const unstakings = _unstaking.toPrimitive();
159
+ const currentBlock = _currentBlock.toPrimitive();
160
+ const currentTimestamp = _currentTimestamp.toPrimitive();
161
+ const blockDuration = _EXPECTED_BLOCK_TIME[chainInfo.slug];
162
+ if (candidates.length) {
163
+ await Promise.all(candidates.map(async collatorAddress => {
164
+ const _stakeInfo = await substrateApi.api.query.collatorStaking.candidateStake(collatorAddress, stakerAddress);
165
+ const stakeInfo = _stakeInfo.toPrimitive();
166
+ const activeStake = stakeInfo.stake.toString();
167
+ const earningStatus = BigInt(activeStake) > BigInt(0) && BigInt(activeStake) >= BigInt(minStake) ? EarningStatus.EARNING_REWARD : EarningStatus.NOT_EARNING;
168
+ nominationList.push({
169
+ status: earningStatus,
170
+ chain: chainInfo.slug,
171
+ validatorAddress: collatorAddress,
172
+ activeStake,
173
+ validatorMinStake: minStake,
174
+ hasUnstaking: !!unstakings.length
175
+ });
176
+ }));
177
+ }
178
+ if (unstakings.length) {
179
+ unstakings.forEach(unstaking => {
180
+ const releaseBlock = unstaking.block;
181
+ const unstakeAmount = unstaking.amount;
182
+ const isClaimable = currentBlock >= releaseBlock;
183
+ const targetTimestampMs = (releaseBlock - currentBlock) * blockDuration * 1000 + currentTimestamp;
184
+ unstakingBalance = unstakingBalance + BigInt(unstakeAmount);
185
+ unstakingList.push({
186
+ chain: chainInfo.slug,
187
+ status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
188
+ claimable: unstakeAmount,
189
+ targetTimestampMs
190
+ });
191
+ });
192
+ }
193
+ return {
194
+ status: stakingStatus,
195
+ balanceToken: this.nativeToken.slug,
196
+ totalStake: (BigInt(stake) + unstakingBalance).toString(),
197
+ activeStake: stake,
198
+ unstakeBalance: unstakingBalance.toString() || '0',
199
+ isBondedBefore: isBondedBefore,
200
+ nominations: nominationList,
201
+ unstakings: unstakingList
202
+ };
203
+ }
204
+
205
+ /* Subscribe pool position */
206
+
207
+ /* Get pool targets */
208
+
209
+ async getPoolTargets() {
210
+ const substrateApi = await this.substrateApi.isReady;
211
+ const [_allCollators, _minStake, _commission] = await Promise.all([substrateApi.api.query.collatorStaking.candidates.entries(), substrateApi.api.query.collatorStaking.minStake(), substrateApi.api.query.collatorStaking.collatorRewardPercentage()]);
212
+ const maxStakersPerCollator = substrateApi.api.consts.collatorStaking.maxStakers.toPrimitive();
213
+ return _allCollators.map(_collator => {
214
+ const _collatorAddress = _collator[0].toHuman();
215
+ const collatorAddress = _collatorAddress[0];
216
+ const collatorInfo = _collator[1].toPrimitive();
217
+ const bnTotalStake = BigInt(collatorInfo.stake);
218
+ const numOfStakers = parseInt(collatorInfo.stakers);
219
+ const isCrowded = numOfStakers >= maxStakersPerCollator;
220
+ return {
221
+ address: collatorAddress,
222
+ chain: this.chain,
223
+ totalStake: bnTotalStake.toString(),
224
+ ownStake: '0',
225
+ otherStake: bnTotalStake.toString(),
226
+ minBond: _minStake.toPrimitive(),
227
+ nominatorCount: numOfStakers,
228
+ commission: getCommission(_commission.toString()),
229
+ blocked: false,
230
+ isVerified: false,
231
+ isCrowded
232
+ };
233
+ });
234
+ }
235
+
236
+ /* Get pool targets */
237
+
238
+ /* Join pool action */
239
+
240
+ async createJoinExtrinsic(data, positionInfo) {
241
+ var _substrateApi$api$cal, _substrateApi$api$cal2;
242
+ const substrateApi = await this.substrateApi.isReady;
243
+ const {
244
+ address,
245
+ amount,
246
+ selectedValidators
247
+ } = data;
248
+ const selectedValidatorInfo = selectedValidators[0];
249
+ const _hasReward = await ((_substrateApi$api$cal = substrateApi.api.call) === null || _substrateApi$api$cal === void 0 ? void 0 : (_substrateApi$api$cal2 = _substrateApi$api$cal.collatorStakingApi) === null || _substrateApi$api$cal2 === void 0 ? void 0 : _substrateApi$api$cal2.shouldClaim(address));
250
+ const hasReward = _hasReward === null || _hasReward === void 0 ? void 0 : _hasReward.toPrimitive();
251
+ const extrinsicList = [];
252
+ if (positionInfo !== null && positionInfo !== void 0 && positionInfo.isBondedBefore && hasReward) {
253
+ extrinsicList.push(substrateApi.api.tx.collatorStaking.claimRewards());
254
+ }
255
+ extrinsicList.push(...[substrateApi.api.tx.collatorStaking.lock(amount), substrateApi.api.tx.collatorStaking.stake([{
256
+ candidate: selectedValidatorInfo.address,
257
+ stake: amount
258
+ }])]);
259
+ return [substrateApi.api.tx.utility.batchAll(extrinsicList), {
260
+ slug: this.nativeToken.slug,
261
+ amount: '0'
262
+ }];
263
+ }
264
+
265
+ /* Join pool action */
266
+
267
+ /* Leave pool action */
268
+
269
+ async handleYieldUnstake(amount, address, selectedTarget) {
270
+ var _substrateApi$api$cal3, _substrateApi$api$cal4;
271
+ const substrateApi = await this.substrateApi.isReady;
272
+ const _hasReward = await ((_substrateApi$api$cal3 = substrateApi.api.call) === null || _substrateApi$api$cal3 === void 0 ? void 0 : (_substrateApi$api$cal4 = _substrateApi$api$cal3.collatorStakingApi) === null || _substrateApi$api$cal4 === void 0 ? void 0 : _substrateApi$api$cal4.shouldClaim(address));
273
+ const hasReward = _hasReward === null || _hasReward === void 0 ? void 0 : _hasReward.toPrimitive();
274
+ const extrinsicList = [];
275
+ if (hasReward) {
276
+ extrinsicList.push(substrateApi.api.tx.collatorStaking.claimRewards());
277
+ }
278
+ extrinsicList.push(...[substrateApi.api.tx.collatorStaking.unstakeFrom(selectedTarget), substrateApi.api.tx.collatorStaking.unlock(null) // ignore amount to unlock all
279
+ ]);
280
+
281
+ return [ExtrinsicType.STAKING_UNBOND, substrateApi.api.tx.utility.batchAll(extrinsicList)];
282
+ }
283
+
284
+ /* Leave pool action */
285
+
286
+ /* Get pool reward */
287
+ async getPoolReward(useAddresses, callback) {
288
+ let cancel = false;
289
+ const substrateApi = this.substrateApi;
290
+ await substrateApi.isReady;
291
+ if (substrateApi.api.call.collatorStakingApi) {
292
+ await Promise.all(useAddresses.map(async address => {
293
+ if (!cancel) {
294
+ const _unclaimedReward = await substrateApi.api.call.collatorStakingApi.totalRewards(address);
295
+ const earningRewardItem = {
296
+ ...this.baseInfo,
297
+ address: address,
298
+ type: this.type,
299
+ unclaimedReward: (_unclaimedReward === null || _unclaimedReward === void 0 ? void 0 : _unclaimedReward.toString()) || '0',
300
+ state: APIItemState.READY
301
+ };
302
+ if (_unclaimedReward.toString() !== '0') {
303
+ await this.createClaimNotification(earningRewardItem, this.nativeToken);
304
+ }
305
+ callback(earningRewardItem);
306
+ }
307
+ }));
308
+ }
309
+ return () => {
310
+ cancel = false;
311
+ };
312
+ }
313
+ /* Get pool reward */
314
+
315
+ /* Other action */
316
+
317
+ async handleYieldCancelUnstake() {
318
+ return Promise.reject(new TransactionError(BasicTxErrorType.UNSUPPORTED));
319
+ }
320
+ async handleYieldWithdraw(address, unstakingInfo) {
321
+ const substrateApi = await this.substrateApi.isReady;
322
+ return substrateApi.api.tx.collatorStaking.release();
323
+ }
324
+ async handleYieldClaimReward(address, bondReward) {
325
+ const substrateApi = await this.substrateApi.isReady;
326
+ return substrateApi.api.tx.collatorStaking.claimRewards();
327
+ }
328
+ /* Other action */
329
+ }
@@ -2,14 +2,15 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
5
- import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
5
+ import { ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
6
6
  import { CRON_REFRESH_CHAIN_STAKING_METADATA, CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL, CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL } from '@subwallet/extension-base/constants';
7
7
  import { ServiceStatus } from '@subwallet/extension-base/services/base/types';
8
8
  import { _isChainEnabled, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
9
9
  import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
10
10
  import BaseLiquidStakingPoolHandler from '@subwallet/extension-base/services/earning-service/handlers/liquid-staking/base';
11
+ import MythosNativeStakingPoolHandler from '@subwallet/extension-base/services/earning-service/handlers/native-staking/mythos';
11
12
  import { BasicTxErrorType, YieldPoolType } from '@subwallet/extension-base/types';
12
- import { addLazy, categoryAddresses, createPromiseHandler, removeLazy } from '@subwallet/extension-base/utils';
13
+ import { addLazy, createPromiseHandler, getAddressesByChainType, removeLazy } from '@subwallet/extension-base/utils';
13
14
  import { fetchStaticCache } from '@subwallet/extension-base/utils/fetchStaticCache';
14
15
  import { BehaviorSubject } from 'rxjs';
15
16
  import { AcalaLiquidStakingPoolHandler, AmplitudeNativeStakingPoolHandler, AstarNativeStakingPoolHandler, BifrostLiquidStakingPoolHandler, BifrostMantaLiquidStakingPoolHandler, InterlayLendingPoolHandler, NominationPoolHandler, ParallelLiquidStakingPoolHandler, ParaNativeStakingPoolHandler, RelayNativeStakingPoolHandler, StellaSwapLiquidStakingPoolHandler, TaoNativeStakingPoolHandler } from "./handlers/index.js";
@@ -68,6 +69,9 @@ export default class EarningService {
68
69
  if (_STAKING_CHAIN_GROUP.bittensor.includes(chain)) {
69
70
  handlers.push(new TaoNativeStakingPoolHandler(this.state, chain));
70
71
  }
72
+ if (_STAKING_CHAIN_GROUP.mythos.includes(chain)) {
73
+ handlers.push(new MythosNativeStakingPoolHandler(this.state, chain));
74
+ }
71
75
  if (_STAKING_CHAIN_GROUP.nominationPool.includes(chain)) {
72
76
  handlers.push(new NominationPoolHandler(this.state, chain));
73
77
  }
@@ -376,10 +380,8 @@ export default class EarningService {
376
380
  async subscribePoolPositions(addresses, callback) {
377
381
  let cancel = false;
378
382
  await this.eventService.waitChainReady;
379
- const {
380
- evm: evmAddresses,
381
- substrate: substrateAddresses
382
- } = categoryAddresses(addresses);
383
+ const evmAddresses = getAddressesByChainType(addresses, [ChainType.EVM]);
384
+ const substrateAddresses = getAddressesByChainType(addresses, [ChainType.SUBSTRATE]);
383
385
  const activeChains = this.state.activeChainSlugs;
384
386
  const unsubList = [];
385
387
  for (const handler of Object.values(this.handlers)) {
@@ -522,10 +524,8 @@ export default class EarningService {
522
524
  async getPoolReward(addresses, callback) {
523
525
  let cancel = false;
524
526
  await this.eventService.waitChainReady;
525
- const {
526
- evm: evmAddresses,
527
- substrate: substrateAddresses
528
- } = categoryAddresses(addresses);
527
+ const evmAddresses = getAddressesByChainType(addresses, [ChainType.EVM]);
528
+ const substrateAddresses = getAddressesByChainType(addresses, [ChainType.SUBSTRATE]);
529
529
  const activeChains = this.state.activeChainSlugs;
530
530
  const unsubList = [];
531
531
  for (const handler of Object.values(this.handlers)) {
@@ -580,10 +580,8 @@ export default class EarningService {
580
580
  async fetchPoolRewardHistory(addresses, callback) {
581
581
  let cancel = false;
582
582
  await this.eventService.waitChainReady;
583
- const {
584
- evm: evmAddresses,
585
- substrate: substrateAddresses
586
- } = categoryAddresses(addresses);
583
+ const evmAddresses = getAddressesByChainType(addresses, [ChainType.EVM]);
584
+ const substrateAddresses = getAddressesByChainType(addresses, [ChainType.SUBSTRATE]);
587
585
  const activeChains = this.state.activeChainSlugs;
588
586
  const unsubList = [];
589
587
  for (const handler of Object.values(this.handlers)) {
@@ -105,6 +105,8 @@ export function isActionFromValidator(stakingType, chain) {
105
105
  return true;
106
106
  } else if (_STAKING_CHAIN_GROUP.bittensor.includes(chain)) {
107
107
  return true;
108
+ } else if (_STAKING_CHAIN_GROUP.mythos.includes(chain)) {
109
+ return true;
108
110
  }
109
111
  return false;
110
112
  }
@@ -9,7 +9,8 @@ export default class FeeService {
9
9
  chainFeeSubscriptionMap = {
10
10
  evm: {},
11
11
  substrate: {},
12
- ton: {}
12
+ ton: {},
13
+ cardano: {}
13
14
  };
14
15
  constructor(state) {
15
16
  this.state = state;
@@ -103,21 +104,31 @@ export default class FeeService {
103
104
  const api = this.state.getEvmApi(chain);
104
105
 
105
106
  // TODO: Handle case type === evm and not have api
106
- if (type === 'evm' && api) {
107
- calculateGasFeeParams(api, chain).then(info => {
108
- observer.next(info);
109
- }).catch(e => {
110
- console.warn(`Cannot get fee param for ${chain}`, e);
107
+ if (type === 'evm') {
108
+ if (api) {
109
+ calculateGasFeeParams(api, chain).then(info => {
110
+ observer.next(info);
111
+ }).catch(e => {
112
+ console.warn(`Cannot get fee param for ${chain}`, e);
113
+ observer.next({
114
+ type: 'evm',
115
+ gasPrice: '0',
116
+ baseGasFee: undefined,
117
+ options: undefined
118
+ });
119
+ });
120
+ } else {
121
+ console.warn(`Cannot get fee param for ${chain}`, 'Cannot get api');
111
122
  observer.next({
112
123
  type: 'evm',
113
124
  gasPrice: '0',
114
125
  baseGasFee: undefined,
115
126
  options: undefined
116
127
  });
117
- });
128
+ }
118
129
  } else {
119
130
  observer.next({
120
- type: type,
131
+ type,
121
132
  busyNetwork: false,
122
133
  options: {
123
134
  slow: {
@@ -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
  }