@subwallet/extension-base 1.1.33-0 → 1.1.33-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/background/KoniTypes.d.ts +120 -69
  2. package/background/KoniTypes.js +22 -13
  3. package/background/errors/TransactionError.js +9 -0
  4. package/cjs/background/KoniTypes.js +23 -16
  5. package/cjs/background/errors/TransactionError.js +9 -0
  6. package/cjs/constants/index.js +19 -4
  7. package/cjs/koni/api/dotsama/balance.js +464 -0
  8. package/cjs/koni/api/nft/config.js +33 -23
  9. package/cjs/koni/api/nft/index.js +14 -0
  10. package/cjs/koni/api/nft/nft.js +1 -22
  11. package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
  12. package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
  13. package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
  14. package/cjs/koni/api/staking/bonding/amplitude.js +31 -28
  15. package/cjs/koni/api/staking/bonding/astar.js +11 -10
  16. package/cjs/koni/api/staking/bonding/index.js +4 -1
  17. package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
  18. package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
  19. package/cjs/koni/api/staking/bonding/utils.js +104 -86
  20. package/cjs/koni/api/staking/index.js +6 -5
  21. package/cjs/koni/api/staking/paraChain.js +6 -5
  22. package/cjs/koni/api/staking/relayChain.js +3 -2
  23. package/cjs/koni/api/yield/helper/utils.js +49 -0
  24. package/cjs/koni/background/cron.js +3 -21
  25. package/cjs/koni/background/handlers/Extension.js +368 -69
  26. package/cjs/koni/background/handlers/State.js +18 -12
  27. package/cjs/koni/background/handlers/index.js +4 -2
  28. package/cjs/koni/background/subscription.js +7 -104
  29. package/cjs/services/campaign-service/index.js +9 -6
  30. package/cjs/services/chain-service/constants.js +4 -17
  31. package/cjs/services/chain-service/handler/SubstrateApi.js +10 -5
  32. package/cjs/services/chain-service/index.js +123 -39
  33. package/cjs/services/chain-service/utils.js +75 -1
  34. package/cjs/services/earning-service/constants/chains.js +30 -0
  35. package/cjs/services/earning-service/constants/index.js +27 -0
  36. package/cjs/services/earning-service/constants/step.js +18 -0
  37. package/cjs/services/earning-service/handlers/base.js +262 -0
  38. package/cjs/services/earning-service/handlers/index.js +60 -0
  39. package/cjs/services/earning-service/handlers/lending/base.js +81 -0
  40. package/cjs/services/earning-service/handlers/lending/index.js +13 -0
  41. package/cjs/services/earning-service/handlers/lending/interlay.js +192 -0
  42. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +240 -0
  43. package/cjs/services/earning-service/handlers/liquid-staking/base.js +98 -0
  44. package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +140 -0
  45. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +299 -0
  46. package/cjs/services/earning-service/handlers/liquid-staking/index.js +41 -0
  47. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +227 -0
  48. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +404 -0
  49. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +434 -0
  50. package/cjs/services/earning-service/handlers/native-staking/astar.js +466 -0
  51. package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
  52. package/cjs/services/earning-service/handlers/native-staking/base.js +161 -0
  53. package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
  54. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +390 -0
  55. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +567 -0
  56. package/cjs/services/earning-service/handlers/nomination-pool/index.js +566 -0
  57. package/cjs/services/earning-service/handlers/special.js +497 -0
  58. package/cjs/services/earning-service/service.js +741 -0
  59. package/cjs/services/earning-service/utils/index.js +128 -0
  60. package/cjs/services/event-service/index.js +5 -0
  61. package/cjs/services/keyring-service/index.js +14 -2
  62. package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
  63. package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
  64. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
  65. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  66. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
  67. package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
  68. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  69. package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
  70. package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
  71. package/cjs/services/migration-service/scripts/index.js +6 -1
  72. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
  73. package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
  74. package/cjs/services/mint-campaign-service/constants.js +11 -0
  75. package/cjs/services/mint-campaign-service/index.js +18 -0
  76. package/cjs/services/notification-service/NotificationService.js +1 -1
  77. package/cjs/services/storage-service/DatabaseService.js +92 -1
  78. package/cjs/services/storage-service/databases/index.js +7 -0
  79. package/cjs/services/storage-service/db-stores/AssetRef.js +24 -0
  80. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  81. package/cjs/services/storage-service/db-stores/YieldPoolStore.js +36 -0
  82. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +71 -0
  83. package/cjs/services/storage-service/index.js +241 -0
  84. package/cjs/services/subscan-service/index.js +16 -0
  85. package/cjs/services/transaction-service/event-parser/index.js +58 -0
  86. package/cjs/services/transaction-service/helpers/index.js +3 -1
  87. package/cjs/services/transaction-service/index.js +252 -75
  88. package/cjs/services/transaction-service/utils.js +1 -0
  89. package/cjs/types/campaigns/index.js +16 -0
  90. package/cjs/types/campaigns/unlock-dot.js +1 -0
  91. package/cjs/types/index.js +44 -0
  92. package/cjs/types/ordinal.js +1 -0
  93. package/cjs/types/transaction.js +1 -0
  94. package/cjs/types/yield/actions/index.js +27 -0
  95. package/cjs/types/yield/actions/join/index.js +38 -0
  96. package/cjs/types/yield/actions/join/step.js +48 -0
  97. package/cjs/types/yield/actions/join/submit.js +1 -0
  98. package/cjs/types/yield/actions/join/validate.js +16 -0
  99. package/cjs/types/yield/actions/others.js +1 -0
  100. package/cjs/types/yield/index.js +27 -0
  101. package/cjs/types/yield/info/account/index.js +49 -0
  102. package/cjs/types/yield/info/account/info.js +1 -0
  103. package/cjs/types/yield/info/account/reward.js +1 -0
  104. package/cjs/types/yield/info/account/target.js +32 -0
  105. package/cjs/types/yield/info/account/unstake.js +27 -0
  106. package/cjs/types/yield/info/base.js +41 -0
  107. package/cjs/types/yield/info/chain/index.js +27 -0
  108. package/cjs/types/yield/info/chain/info.js +1 -0
  109. package/cjs/types/yield/info/chain/target.js +1 -0
  110. package/cjs/types/yield/info/index.js +49 -0
  111. package/cjs/types/yield/info/pallet.js +15 -0
  112. package/cjs/types.js +1 -0
  113. package/cjs/utils/address.js +34 -0
  114. package/cjs/utils/fetchStaticData.js +2 -1
  115. package/cjs/utils/index.js +89 -1
  116. package/cjs/utils/keyring.js +57 -0
  117. package/cjs/utils/number.js +6 -2
  118. package/cjs/utils/object.js +12 -0
  119. package/constants/index.d.ts +6 -1
  120. package/constants/index.js +6 -1
  121. package/koni/api/nft/config.js +33 -23
  122. package/koni/api/nft/index.js +15 -1
  123. package/koni/api/nft/nft.js +2 -23
  124. package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
  125. package/koni/api/nft/ordinal_nft/constants.js +12 -0
  126. package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
  127. package/koni/api/nft/ordinal_nft/index.js +114 -0
  128. package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
  129. package/koni/api/nft/ordinal_nft/utils.js +33 -0
  130. package/koni/api/staking/bonding/amplitude.js +25 -22
  131. package/koni/api/staking/bonding/astar.js +9 -8
  132. package/koni/api/staking/bonding/index.d.ts +1 -1
  133. package/koni/api/staking/bonding/index.js +5 -1
  134. package/koni/api/staking/bonding/paraChain.js +12 -10
  135. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  136. package/koni/api/staking/bonding/relayChain.js +33 -30
  137. package/koni/api/staking/bonding/utils.d.ts +15 -38
  138. package/koni/api/staking/bonding/utils.js +85 -69
  139. package/koni/api/staking/index.js +2 -1
  140. package/koni/api/staking/paraChain.js +7 -6
  141. package/koni/api/staking/relayChain.js +4 -3
  142. package/koni/api/yield/helper/utils.d.ts +10 -0
  143. package/koni/api/yield/helper/utils.js +34 -0
  144. package/koni/background/cron.d.ts +0 -4
  145. package/koni/background/cron.js +4 -22
  146. package/koni/background/handlers/Extension.d.ts +17 -1
  147. package/koni/background/handlers/Extension.js +327 -30
  148. package/koni/background/handlers/State.d.ts +6 -1
  149. package/koni/background/handlers/State.js +17 -12
  150. package/koni/background/handlers/index.js +4 -2
  151. package/koni/background/subscription.d.ts +1 -6
  152. package/koni/background/subscription.js +8 -104
  153. package/package.json +327 -4
  154. package/services/campaign-service/index.js +9 -6
  155. package/services/chain-service/constants.d.ts +1 -12
  156. package/services/chain-service/constants.js +1 -14
  157. package/services/chain-service/handler/SubstrateApi.js +10 -5
  158. package/services/chain-service/index.d.ts +11 -1
  159. package/services/chain-service/index.js +119 -36
  160. package/services/chain-service/utils.d.ts +11 -1
  161. package/services/chain-service/utils.js +71 -2
  162. package/services/earning-service/constants/abis/compound_finance_v2_abi.json +1235 -0
  163. package/services/earning-service/constants/abis/st_liquid_token_abi.json +1355 -0
  164. package/services/earning-service/constants/chains.d.ts +15 -0
  165. package/services/earning-service/constants/chains.js +22 -0
  166. package/services/earning-service/constants/index.d.ts +2 -0
  167. package/services/earning-service/constants/index.js +5 -0
  168. package/services/earning-service/constants/step.d.ts +3 -0
  169. package/services/earning-service/constants/step.js +10 -0
  170. package/services/earning-service/handlers/base.d.ts +113 -0
  171. package/services/earning-service/handlers/base.js +256 -0
  172. package/services/earning-service/handlers/index.d.ts +5 -0
  173. package/services/earning-service/handlers/index.js +8 -0
  174. package/services/earning-service/handlers/lending/base.d.ts +8 -0
  175. package/services/earning-service/handlers/lending/base.js +73 -0
  176. package/services/earning-service/handlers/lending/index.d.ts +1 -0
  177. package/services/earning-service/handlers/lending/index.js +4 -0
  178. package/services/earning-service/handlers/lending/interlay.d.ts +24 -0
  179. package/services/earning-service/handlers/lending/interlay.js +184 -0
  180. package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
  181. package/services/earning-service/handlers/liquid-staking/acala.js +232 -0
  182. package/services/earning-service/handlers/liquid-staking/base.d.ts +11 -0
  183. package/services/earning-service/handlers/liquid-staking/base.js +90 -0
  184. package/services/earning-service/handlers/liquid-staking/bifrost-manta.d.ts +37 -0
  185. package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +132 -0
  186. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
  187. package/services/earning-service/handlers/liquid-staking/bifrost.js +288 -0
  188. package/services/earning-service/handlers/liquid-staking/index.d.ts +5 -0
  189. package/services/earning-service/handlers/liquid-staking/index.js +8 -0
  190. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +26 -0
  191. package/services/earning-service/handlers/liquid-staking/parallel.js +219 -0
  192. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
  193. package/services/earning-service/handlers/liquid-staking/stella-swap.js +394 -0
  194. package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
  195. package/services/earning-service/handlers/native-staking/amplitude.js +425 -0
  196. package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
  197. package/services/earning-service/handlers/native-staking/astar.js +456 -0
  198. package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
  199. package/services/earning-service/handlers/native-staking/base-para.js +138 -0
  200. package/services/earning-service/handlers/native-staking/base.d.ts +21 -0
  201. package/services/earning-service/handlers/native-staking/base.js +152 -0
  202. package/services/earning-service/handlers/native-staking/index.d.ts +4 -0
  203. package/services/earning-service/handlers/native-staking/index.js +7 -0
  204. package/services/earning-service/handlers/native-staking/para-chain.d.ts +15 -0
  205. package/services/earning-service/handlers/native-staking/para-chain.js +382 -0
  206. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
  207. package/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
  208. package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
  209. package/services/earning-service/handlers/nomination-pool/index.js +556 -0
  210. package/services/earning-service/handlers/special.d.ts +64 -0
  211. package/services/earning-service/handlers/special.js +489 -0
  212. package/services/earning-service/service.d.ts +94 -0
  213. package/services/earning-service/service.js +730 -0
  214. package/services/earning-service/utils/index.d.ts +18 -0
  215. package/services/earning-service/utils/index.js +112 -0
  216. package/services/event-service/index.d.ts +2 -0
  217. package/services/event-service/index.js +5 -0
  218. package/services/event-service/types.d.ts +9 -0
  219. package/services/keyring-service/index.d.ts +2 -1
  220. package/services/keyring-service/index.js +14 -2
  221. package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
  222. package/services/migration-service/scripts/DeleteEarningData.js +13 -0
  223. package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
  224. package/services/migration-service/scripts/EnableEarningChains.js +13 -0
  225. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  226. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  227. package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
  228. package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
  229. package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
  230. package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
  231. package/services/migration-service/scripts/index.js +6 -1
  232. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
  233. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
  234. package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
  235. package/services/mint-campaign-service/campaigns/index.js +4 -0
  236. package/services/mint-campaign-service/constants.d.ts +1 -0
  237. package/services/mint-campaign-service/constants.js +4 -0
  238. package/services/mint-campaign-service/index.d.ts +7 -0
  239. package/services/mint-campaign-service/index.js +11 -0
  240. package/services/notification-service/NotificationService.js +1 -1
  241. package/services/storage-service/DatabaseService.d.ts +30 -3
  242. package/services/storage-service/DatabaseService.js +91 -1
  243. package/services/storage-service/databases/index.d.ts +8 -2
  244. package/services/storage-service/databases/index.js +7 -0
  245. package/services/storage-service/db-stores/AssetRef.d.ts +7 -0
  246. package/services/storage-service/db-stores/AssetRef.js +16 -0
  247. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  248. package/services/storage-service/db-stores/YieldPoolStore.d.ts +10 -0
  249. package/services/storage-service/db-stores/YieldPoolStore.js +28 -0
  250. package/services/storage-service/db-stores/YieldPositionStore.d.ts +11 -0
  251. package/services/storage-service/db-stores/YieldPositionStore.js +63 -0
  252. package/services/subscan-service/index.d.ts +3 -2
  253. package/services/subscan-service/index.js +15 -0
  254. package/services/subscan-service/types.d.ts +20 -0
  255. package/services/transaction-service/event-parser/index.d.ts +3 -1
  256. package/services/transaction-service/event-parser/index.js +57 -1
  257. package/services/transaction-service/helpers/index.js +3 -1
  258. package/services/transaction-service/index.d.ts +6 -13
  259. package/services/transaction-service/index.js +250 -73
  260. package/services/transaction-service/types.d.ts +2 -0
  261. package/services/transaction-service/utils.js +1 -0
  262. package/types/campaigns/index.d.ts +1 -0
  263. package/types/campaigns/index.js +4 -0
  264. package/types/campaigns/unlock-dot.d.ts +71 -0
  265. package/types/campaigns/unlock-dot.js +1 -0
  266. package/types/index.d.ts +5 -0
  267. package/types/index.js +5 -1
  268. package/types/ordinal.d.ts +69 -0
  269. package/types/ordinal.js +1 -0
  270. package/types/transaction.d.ts +3 -0
  271. package/types/transaction.js +1 -0
  272. package/types/yield/actions/index.d.ts +2 -0
  273. package/types/yield/actions/index.js +5 -0
  274. package/types/yield/actions/join/index.d.ts +3 -0
  275. package/types/yield/actions/join/index.js +6 -0
  276. package/types/yield/actions/join/step.d.ts +96 -0
  277. package/types/yield/actions/join/step.js +47 -0
  278. package/types/yield/actions/join/submit.d.ts +58 -0
  279. package/types/yield/actions/join/submit.js +1 -0
  280. package/types/yield/actions/join/validate.d.ts +18 -0
  281. package/types/yield/actions/join/validate.js +10 -0
  282. package/types/yield/actions/others.d.ts +85 -0
  283. package/types/yield/actions/others.js +1 -0
  284. package/types/yield/index.d.ts +2 -0
  285. package/types/yield/index.js +5 -0
  286. package/types/yield/info/account/index.d.ts +4 -0
  287. package/types/yield/info/account/index.js +7 -0
  288. package/types/yield/info/account/info.d.ts +92 -0
  289. package/types/yield/info/account/info.js +1 -0
  290. package/types/yield/info/account/reward.d.ts +47 -0
  291. package/types/yield/info/account/reward.js +1 -0
  292. package/types/yield/info/account/target.d.ts +43 -0
  293. package/types/yield/info/account/target.js +27 -0
  294. package/types/yield/info/account/unstake.d.ts +31 -0
  295. package/types/yield/info/account/unstake.js +22 -0
  296. package/types/yield/info/base.d.ts +45 -0
  297. package/types/yield/info/base.js +36 -0
  298. package/types/yield/info/chain/index.d.ts +2 -0
  299. package/types/yield/info/chain/index.js +5 -0
  300. package/types/yield/info/chain/info.d.ts +252 -0
  301. package/types/yield/info/chain/info.js +1 -0
  302. package/types/yield/info/chain/target.d.ts +37 -0
  303. package/types/yield/info/chain/target.js +1 -0
  304. package/types/yield/info/index.d.ts +4 -0
  305. package/types/yield/info/index.js +7 -0
  306. package/types/yield/info/pallet.d.ts +143 -0
  307. package/types/yield/info/pallet.js +9 -0
  308. package/utils/fetchStaticData.js +2 -1
  309. package/utils/index.d.ts +5 -0
  310. package/utils/index.js +52 -0
  311. package/utils/number.d.ts +2 -1
  312. package/utils/number.js +2 -1
  313. package/utils/object.d.ts +1 -0
  314. package/utils/object.js +6 -0
@@ -6,14 +6,14 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
6
6
  import { BasicTxErrorType, BasicTxWarningCode, ChainType, EvmProviderErrorType, ExtrinsicStatus, ExtrinsicType, NotificationType, TransactionDirection } from '@subwallet/extension-base/background/KoniTypes';
7
7
  import { TransactionWarning } from '@subwallet/extension-base/background/warnings/TransactionWarning';
8
8
  import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
9
- import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
10
- import { _getChainNativeTokenBasicInfo, _getEvmChainId } from '@subwallet/extension-base/services/chain-service/utils';
9
+ import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getEvmChainId, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
11
10
  import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
12
11
  import { TRANSACTION_TIMEOUT } from '@subwallet/extension-base/services/transaction-service/constants';
13
- import { parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
12
+ import { parseLiquidStakingEvents, parseLiquidStakingFastUnstakeEvents, parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
14
13
  import { getBaseTransactionInfo, getTransactionId, isSubstrateTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
15
14
  import { getExplorerLink, parseTransactionData } from '@subwallet/extension-base/services/transaction-service/utils';
16
15
  import { isWalletConnectRequest } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
16
+ import { YieldPoolType } from '@subwallet/extension-base/types';
17
17
  import { reformatAddress } from '@subwallet/extension-base/utils';
18
18
  import { anyNumberToBN, recalculateGasPrice } from '@subwallet/extension-base/utils/eth';
19
19
  import { mergeTransactionAndSignature } from '@subwallet/extension-base/utils/eth/mergeTransactionAndSignature';
@@ -26,20 +26,19 @@ import EventEmitter from 'eventemitter3';
26
26
  import { t } from 'i18next';
27
27
  import { BehaviorSubject } from 'rxjs';
28
28
  import { isHex } from '@polkadot/util';
29
+ import { _TRANSFER_CHAIN_GROUP } from "../chain-service/constants.js";
29
30
  export default class TransactionService {
30
31
  transactionSubject = new BehaviorSubject({});
31
32
  watchTransactionSubscribes = {};
32
33
  get transactions() {
33
34
  return this.transactionSubject.getValue();
34
35
  }
35
- constructor(chainService, eventService, requestService, balanceService, historyService, notificationService, databaseService) {
36
- this.chainService = chainService;
37
- this.eventService = eventService;
38
- this.requestService = requestService;
39
- this.balanceService = balanceService;
40
- this.historyService = historyService;
41
- this.notificationService = notificationService;
42
- this.databaseService = databaseService;
36
+ constructor(state) {
37
+ this.state = state;
38
+ this.eventService = state.eventService;
39
+ this.historyService = state.historyService;
40
+ this.notificationService = state.notificationService;
41
+ this.chainService = state.chainService;
43
42
  }
44
43
  get allTransactions() {
45
44
  return Object.values(this.transactions);
@@ -96,7 +95,7 @@ export default class TransactionService {
96
95
  decimals: 0,
97
96
  value: ''
98
97
  };
99
- const chainInfo = this.chainService.getChainInfoByKey(chain);
98
+ const chainInfo = this.state.chainService.getChainInfoByKey(chain);
100
99
  if (!chainInfo) {
101
100
  validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, t('Cannot find network')));
102
101
  } else {
@@ -111,7 +110,7 @@ export default class TransactionService {
111
110
  if (isSubstrateTransaction(transaction)) {
112
111
  estimateFee.value = (await transaction.paymentInfo(address)).partialFee.toString();
113
112
  } else {
114
- const web3 = this.chainService.getEvmApi(chain);
113
+ const web3 = this.state.chainService.getEvmApi(chain);
115
114
  if (!web3) {
116
115
  validationResponse.errors.push(new TransactionError(BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
117
116
  } else {
@@ -145,32 +144,35 @@ export default class TransactionService {
145
144
 
146
145
  // Balance
147
146
  const transferNative = validationResponse.transferNativeAmount || '0';
148
- const nativeTokenInfo = this.chainService.getNativeTokenInfo(chain);
149
- const balance = await this.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
147
+ const nativeTokenInfo = this.state.chainService.getNativeTokenInfo(chain);
148
+ const balance = await this.state.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
150
149
  const existentialDeposit = nativeTokenInfo.minAmount || '0';
151
150
  const feeNum = parseInt(estimateFee.value);
152
151
  const balanceNum = parseInt(balance.value);
153
152
  const edNum = parseInt(existentialDeposit);
154
153
  const transferNativeNum = parseInt(transferNative);
155
- if (!new BigN(balance.value).gt(0)) {
156
- validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
157
- }
158
- if (transferNativeNum + feeNum > balanceNum) {
159
- if (!isTransferAll) {
154
+ if (!validationInput.skipFeeValidation) {
155
+ // TODO
156
+ if (!new BigN(balance.value).gt(0)) {
160
157
  validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
161
- } else {
162
- if ([..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.genshiro, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.statemine].includes(chain)) {
163
- // Chain not have transfer all function
158
+ }
159
+ if (transferNativeNum + feeNum > balanceNum) {
160
+ if (!isTransferAll) {
164
161
  validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
162
+ } else {
163
+ if ([..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.genshiro, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.statemine].includes(chain)) {
164
+ // Chain not have transfer all function
165
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
166
+ }
165
167
  }
166
168
  }
167
- }
168
- if (!isTransferAll) {
169
- if (balanceNum - (transferNativeNum + feeNum) < edNum) {
170
- if (edAsWarning) {
171
- validationResponse.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
172
- } else {
173
- validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
169
+ if (!isTransferAll) {
170
+ if (balanceNum - (transferNativeNum + feeNum) < edNum) {
171
+ if (edAsWarning) {
172
+ validationResponse.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
173
+ } else {
174
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
175
+ }
174
176
  }
175
177
  }
176
178
  }
@@ -237,12 +239,21 @@ export default class TransactionService {
237
239
  }
238
240
  validatedTransaction.warnings = [];
239
241
  const emitter = await this.addTransaction(validatedTransaction);
240
- await new Promise(resolve => {
241
- emitter.on('signed', data => {
242
- validatedTransaction.id = data.id;
243
- validatedTransaction.extrinsicHash = data.extrinsicHash;
244
- resolve();
245
- });
242
+ await new Promise((resolve, reject) => {
243
+ // TODO
244
+ if (transaction.resolveOnDone) {
245
+ emitter.on('success', data => {
246
+ validatedTransaction.id = data.id;
247
+ validatedTransaction.extrinsicHash = data.extrinsicHash;
248
+ resolve();
249
+ });
250
+ } else {
251
+ emitter.on('signed', data => {
252
+ validatedTransaction.id = data.id;
253
+ validatedTransaction.extrinsicHash = data.extrinsicHash;
254
+ resolve();
255
+ });
256
+ }
246
257
  emitter.on('error', data => {
247
258
  if (data.errors.length > 0) {
248
259
  validatedTransaction.errors.push(...data.errors);
@@ -314,7 +325,7 @@ export default class TransactionService {
314
325
  }
315
326
  getTransactionLink(id) {
316
327
  const transaction = this.getTransaction(id);
317
- const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
328
+ const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
318
329
  return getExplorerLink(chainInfo, transaction.extrinsicHash, 'tx');
319
330
  }
320
331
  transactionToHistories(id, startBlock, nonce, eventLogs) {
@@ -342,7 +353,7 @@ export default class TransactionService {
342
353
  nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
343
354
  startBlock: startBlock || 0
344
355
  };
345
- const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
356
+ const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
346
357
  const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
347
358
  const baseNativeAmount = {
348
359
  value: '0',
@@ -356,7 +367,7 @@ export default class TransactionService {
356
367
  {
357
368
  const inputData = parseTransactionData(transaction.data);
358
369
  historyItem.to = inputData.to;
359
- const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
370
+ const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
360
371
  historyItem.amount = {
361
372
  value: inputData.value || '0',
362
373
  decimals: sendingTokenInfo.decimals || 0,
@@ -369,7 +380,7 @@ export default class TransactionService {
369
380
  {
370
381
  const inputData = parseTransactionData(transaction.data);
371
382
  historyItem.to = inputData.to;
372
- const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
383
+ const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
373
384
  historyItem.amount = {
374
385
  value: inputData.value || '0',
375
386
  decimals: sendingTokenInfo.decimals || 0,
@@ -382,7 +393,7 @@ export default class TransactionService {
382
393
  {
383
394
  const inputData = parseTransactionData(transaction.data);
384
395
  historyItem.to = inputData.to;
385
- const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
396
+ const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
386
397
  historyItem.amount = {
387
398
  value: inputData.value || '0',
388
399
  decimals: sendingTokenInfo.decimals || 0,
@@ -431,17 +442,29 @@ export default class TransactionService {
431
442
  case ExtrinsicType.STAKING_UNBOND:
432
443
  {
433
444
  const data = parseTransactionData(transaction.data);
434
- historyItem.to = data.validatorAddress || '';
435
- historyItem.amount = {
436
- ...baseNativeAmount,
437
- value: data.amount || '0'
438
- };
445
+ if (data.isLiquidStaking && data.derivativeTokenInfo && data.exchangeRate && data.inputTokenInfo) {
446
+ historyItem.amount = {
447
+ decimals: _getAssetDecimals(data.derivativeTokenInfo),
448
+ symbol: _getAssetSymbol(data.derivativeTokenInfo),
449
+ value: data.amount
450
+ };
451
+ historyItem.additionalInfo = {
452
+ inputTokenSlug: data.inputTokenInfo.slug,
453
+ exchangeRate: data.exchangeRate
454
+ };
455
+ } else {
456
+ historyItem.to = data.validatorAddress || '';
457
+ historyItem.amount = {
458
+ ...baseNativeAmount,
459
+ value: data.amount || '0'
460
+ };
461
+ }
439
462
  }
440
463
  break;
441
464
  case ExtrinsicType.STAKING_LEAVE_POOL:
442
465
  {
443
466
  const data = parseTransactionData(transaction.data);
444
- historyItem.to = data.nominatorMetadata.address || '';
467
+ historyItem.to = data.address || '';
445
468
  historyItem.amount = {
446
469
  ...baseNativeAmount,
447
470
  value: data.amount || '0'
@@ -460,11 +483,21 @@ export default class TransactionService {
460
483
  case ExtrinsicType.STAKING_WITHDRAW:
461
484
  {
462
485
  const data = parseTransactionData(transaction.data);
463
- historyItem.to = data.validatorAddress || '';
464
- historyItem.amount = {
486
+ const slug = data.slug;
487
+ const poolHandler = this.state.earningService.getPoolHandler(slug);
488
+ const amount = {
465
489
  ...baseNativeAmount,
466
490
  value: data.unstakingInfo.claimable || '0'
467
491
  };
492
+ if (poolHandler) {
493
+ const asset = this.state.getAssetBySlug(poolHandler.metadataInfo.inputAsset);
494
+ if (asset) {
495
+ amount.decimals = asset.decimals || 0;
496
+ amount.symbol = asset.symbol;
497
+ }
498
+ }
499
+ historyItem.to = data.unstakingInfo.validatorAddress || '';
500
+ historyItem.amount = amount;
468
501
  break;
469
502
  }
470
503
  case ExtrinsicType.STAKING_CANCEL_UNSTAKE:
@@ -485,6 +518,119 @@ export default class TransactionService {
485
518
  historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
486
519
  break;
487
520
  }
521
+ case ExtrinsicType.MINT_STDOT:
522
+ case ExtrinsicType.MINT_QDOT:
523
+ case ExtrinsicType.MINT_LDOT:
524
+ case ExtrinsicType.MINT_SDOT:
525
+ case ExtrinsicType.MINT_VMANTA:
526
+
527
+ // eslint-disable-next-line no-fallthrough
528
+ case ExtrinsicType.MINT_VDOT:
529
+ {
530
+ const params = parseTransactionData(transaction.data);
531
+ const inputTokenInfo = this.state.chainService.getAssetBySlug(params.inputTokenSlug);
532
+ const isFeePaidWithInputAsset = params.feeTokenSlug === params.inputTokenSlug;
533
+ historyItem.amount = {
534
+ value: params.amount,
535
+ symbol: _getAssetSymbol(inputTokenInfo),
536
+ decimals: _getAssetDecimals(inputTokenInfo)
537
+ };
538
+ const additionalInfo = {
539
+ slug: params.slug,
540
+ derivativeTokenSlug: params.derivativeTokenSlug,
541
+ exchangeRate: params.exchangeRate
542
+ };
543
+ historyItem.additionalInfo = additionalInfo;
544
+ eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingEvents(historyItem, eventLogs, inputTokenInfo, chainInfo, isFeePaidWithInputAsset, extrinsicType);
545
+ break;
546
+ }
547
+ case ExtrinsicType.UNSTAKE_QDOT:
548
+
549
+ // eslint-disable-next-line no-fallthrough
550
+ case ExtrinsicType.REDEEM_QDOT:
551
+ {
552
+ const data = parseTransactionData(transaction.data);
553
+ const yieldPoolInfo = data.poolInfo;
554
+ if (yieldPoolInfo.metadata.derivativeAssets) {
555
+ const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
556
+ const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
557
+ historyItem.amount = {
558
+ value: data.amount,
559
+ symbol: _getAssetSymbol(inputTokenInfo),
560
+ decimals: _getAssetDecimals(inputTokenInfo)
561
+ };
562
+ eventLogs && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
563
+ const additionalInfo = {
564
+ minAmountPercent: 1,
565
+ symbol: inputTokenInfo.symbol,
566
+ decimals: inputTokenInfo.decimals || 0,
567
+ exchangeRate: 1,
568
+ slug: yieldPoolInfo.slug,
569
+ type: yieldPoolInfo.type,
570
+ chain: yieldPoolInfo.chain,
571
+ group: yieldPoolInfo.group,
572
+ isFast: data.fastLeave
573
+ };
574
+ historyItem.additionalInfo = additionalInfo;
575
+ }
576
+ break;
577
+ }
578
+ case ExtrinsicType.UNSTAKE_VDOT:
579
+ case ExtrinsicType.UNSTAKE_VMANTA:
580
+ case ExtrinsicType.UNSTAKE_LDOT:
581
+ case ExtrinsicType.UNSTAKE_SDOT:
582
+ case ExtrinsicType.UNSTAKE_STDOT:
583
+ case ExtrinsicType.REDEEM_STDOT:
584
+ case ExtrinsicType.REDEEM_LDOT:
585
+ case ExtrinsicType.REDEEM_SDOT:
586
+ case ExtrinsicType.REDEEM_VMANTA:
587
+
588
+ // eslint-disable-next-line no-fallthrough
589
+ case ExtrinsicType.REDEEM_VDOT:
590
+ {
591
+ const data = parseTransactionData(transaction.data);
592
+ const yieldPoolInfo = data.poolInfo;
593
+ const minAmountPercents = this.state.earningService.getMinAmountPercent();
594
+ if (yieldPoolInfo.metadata.derivativeAssets) {
595
+ var _yieldPoolInfo$statis;
596
+ const derivativeTokenSlug = yieldPoolInfo.metadata.derivativeAssets[0];
597
+ const derivativeTokenInfo = this.state.chainService.getAssetBySlug(derivativeTokenSlug);
598
+ const chainInfo = this.state.chainService.getChainInfoByKey(data.poolInfo.chain);
599
+ historyItem.amount = {
600
+ value: data.amount,
601
+ symbol: _getAssetSymbol(derivativeTokenInfo),
602
+ decimals: _getAssetDecimals(derivativeTokenInfo)
603
+ };
604
+ eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
605
+ const minAmountPercent = minAmountPercents[yieldPoolInfo.slug] || 1;
606
+ const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
607
+ const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
608
+ const additionalInfo = {
609
+ minAmountPercent,
610
+ symbol: inputTokenInfo.symbol,
611
+ decimals: inputTokenInfo.decimals || 0,
612
+ exchangeRate: ((_yieldPoolInfo$statis = yieldPoolInfo.statistic) === null || _yieldPoolInfo$statis === void 0 ? void 0 : _yieldPoolInfo$statis.assetEarning[0].exchangeRate) || 1,
613
+ slug: yieldPoolInfo.slug,
614
+ type: yieldPoolInfo.type,
615
+ chain: yieldPoolInfo.chain,
616
+ group: yieldPoolInfo.group,
617
+ isFast: data.fastLeave
618
+ };
619
+ historyItem.additionalInfo = additionalInfo;
620
+ }
621
+ break;
622
+ }
623
+ case ExtrinsicType.TOKEN_APPROVE:
624
+ {
625
+ const data = parseTransactionData(transaction.data);
626
+ const inputAsset = this.state.chainService.getAssetBySlug(data.inputTokenSlug);
627
+ historyItem.amount = {
628
+ value: '0',
629
+ symbol: _getAssetSymbol(inputAsset),
630
+ decimals: _getAssetDecimals(inputAsset)
631
+ };
632
+ break;
633
+ }
488
634
  case ExtrinsicType.UNKNOWN:
489
635
  break;
490
636
  }
@@ -530,7 +676,7 @@ export default class TransactionService {
530
676
  });
531
677
 
532
678
  // Create Input History Transaction History
533
- this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
679
+ this.state.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
534
680
  console.debug(`Transaction "${id}" is sent`);
535
681
  }
536
682
  onHasTransactionHash({
@@ -547,8 +693,12 @@ export default class TransactionService {
547
693
  this.updateTransaction(id, updateData);
548
694
 
549
695
  // In this case transaction id is the same as extrinsic hash and will change after below update
550
- this.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
696
+ this.state.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
551
697
  console.debug(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
698
+ const transaction = this.getTransaction(id);
699
+ if ([ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.JOIN_YIELD_POOL, ExtrinsicType.MINT_LDOT, ExtrinsicType.MINT_QDOT, ExtrinsicType.MINT_SDOT, ExtrinsicType.MINT_VDOT].includes(transaction.extrinsicType)) {
700
+ this.handlePostEarningTransaction(id);
701
+ }
552
702
  }
553
703
  handlePostProcessing(id) {
554
704
  // must be done after success/failure to make sure the transaction is finalized
@@ -557,15 +707,15 @@ export default class TransactionService {
557
707
  const inputData = parseTransactionData(transaction.data);
558
708
  try {
559
709
  const sender = keyring.getPair(inputData.senderAddress);
560
- sender && this.databaseService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
561
- this.eventService.emit('transaction.transferNft', undefined);
710
+ sender && this.state.dbService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
711
+ this.state.eventService.emit('transaction.transferNft', undefined);
562
712
  }).catch(console.error);
563
713
  } catch (e) {
564
714
  console.error(e);
565
715
  }
566
716
  try {
567
717
  const recipient = keyring.getPair(inputData.recipientAddress);
568
- recipient && this.databaseService.addNft(recipient.address, {
718
+ recipient && this.state.dbService.addNft(recipient.address, {
569
719
  ...inputData.nftItem,
570
720
  owner: recipient.address
571
721
  }).catch(console.error);
@@ -573,7 +723,7 @@ export default class TransactionService {
573
723
  console.error(e);
574
724
  }
575
725
  } else if ([ExtrinsicType.STAKING_BOND, ExtrinsicType.STAKING_UNBOND, ExtrinsicType.STAKING_WITHDRAW, ExtrinsicType.STAKING_CANCEL_UNSTAKE, ExtrinsicType.STAKING_CLAIM_REWARD, ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.STAKING_POOL_WITHDRAW, ExtrinsicType.STAKING_LEAVE_POOL].includes(transaction.extrinsicType)) {
576
- this.eventService.emit('transaction.submitStaking', transaction.chain);
726
+ this.state.eventService.emit('transaction.submitStaking', transaction.chain);
577
727
  }
578
728
  }
579
729
  onSuccess({
@@ -589,14 +739,14 @@ export default class TransactionService {
589
739
  });
590
740
 
591
741
  // Write success transaction history
592
- this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
742
+ this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
593
743
  extrinsicHash,
594
744
  status: ExtrinsicStatus.SUCCESS,
595
745
  blockNumber: blockNumber || 0,
596
746
  blockHash: blockHash || ''
597
747
  }).catch(console.error);
598
- const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
599
- this.notificationService.notify({
748
+ const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.state.chainService.getChainInfoMap());
749
+ this.state.notificationService.notify({
600
750
  type: NotificationType.SUCCESS,
601
751
  title: t('Transaction completed'),
602
752
  message: t('Transaction {{info}} completed', {
@@ -609,7 +759,7 @@ export default class TransactionService {
609
759
  },
610
760
  notifyViaBrowser: true
611
761
  });
612
- this.eventService.emit('transaction.done', transaction);
762
+ this.state.eventService.emit('transaction.done', transaction);
613
763
  }
614
764
  onFailed({
615
765
  blockHash,
@@ -628,14 +778,14 @@ export default class TransactionService {
628
778
  });
629
779
 
630
780
  // Write failed transaction history
631
- this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
781
+ this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
632
782
  extrinsicHash: extrinsicHash || transaction.extrinsicHash,
633
783
  status: nextStatus,
634
784
  blockNumber: blockNumber || 0,
635
785
  blockHash: blockHash || ''
636
786
  }).catch(console.error);
637
- const info = isHex(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
638
- this.notificationService.notify({
787
+ const info = isHex(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : getBaseTransactionInfo(transaction, this.state.chainService.getChainInfoMap());
788
+ this.state.notificationService.notify({
639
789
  type: NotificationType.ERROR,
640
790
  title: t('Transaction failed'),
641
791
  message: t('Transaction {{info}} failed', {
@@ -649,7 +799,7 @@ export default class TransactionService {
649
799
  notifyViaBrowser: true
650
800
  });
651
801
  }
652
- this.eventService.emit('transaction.failed', transaction);
802
+ this.state.eventService.emit('transaction.failed', transaction);
653
803
  }
654
804
  onTimeOut({
655
805
  blockHash,
@@ -691,7 +841,7 @@ export default class TransactionService {
691
841
  }
692
842
  generateHashPayload(chain, transaction) {
693
843
  var _transaction$nonce;
694
- const chainInfo = this.chainService.getChainInfoByKey(chain);
844
+ const chainInfo = this.state.chainService.getChainInfoByKey(chain);
695
845
  const txObject = {
696
846
  nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
697
847
  gasPrice: addHexPrefix(anyNumberToBN(transaction.gasPrice).toString(16)),
@@ -712,8 +862,8 @@ export default class TransactionService {
712
862
  }) {
713
863
  var _payload$nonce;
714
864
  const payload = transaction;
715
- const evmApi = this.chainService.getEvmApi(chain);
716
- const chainInfo = this.chainService.getChainInfoByKey(chain);
865
+ const evmApi = this.state.chainService.getEvmApi(chain);
866
+ const chainInfo = this.state.chainService.getChainInfoByKey(chain);
717
867
  const accountPair = keyring.getPair(address);
718
868
  const account = {
719
869
  address,
@@ -743,7 +893,7 @@ export default class TransactionService {
743
893
 
744
894
  // Set unique nonce to avoid transaction errors
745
895
  if (!payload.nonce) {
746
- const evmApi = this.chainService.getEvmApi(chain);
896
+ const evmApi = this.state.chainService.getEvmApi(chain);
747
897
  payload.nonce = await evmApi.api.eth.getTransactionCount(address);
748
898
  }
749
899
  if (!payload.chainId) {
@@ -778,7 +928,7 @@ export default class TransactionService {
778
928
  extrinsicHash: id
779
929
  };
780
930
  if (isInjected) {
781
- this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
931
+ this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
782
932
  isApproved,
783
933
  payload
784
934
  }) => {
@@ -786,7 +936,7 @@ export default class TransactionService {
786
936
  if (!payload) {
787
937
  throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
788
938
  }
789
- const web3Api = this.chainService.getEvmApi(chain).api;
939
+ const web3Api = this.state.chainService.getEvmApi(chain).api;
790
940
 
791
941
  // Emit signed event
792
942
  emitter.emit('signed', eventData);
@@ -842,7 +992,7 @@ export default class TransactionService {
842
992
  emitter.emit('error', eventData);
843
993
  });
844
994
  } else {
845
- this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
995
+ this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
846
996
  isApproved,
847
997
  payload
848
998
  }) => {
@@ -851,7 +1001,7 @@ export default class TransactionService {
851
1001
  if (!payload) {
852
1002
  throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, t('Failed to sign'));
853
1003
  }
854
- const web3Api = this.chainService.getEvmApi(chain).api;
1004
+ const web3Api = this.state.chainService.getEvmApi(chain).api;
855
1005
  if (!isExternal) {
856
1006
  signedTransaction = payload;
857
1007
  } else {
@@ -918,7 +1068,7 @@ export default class TransactionService {
918
1068
  transaction.signAsync(address, {
919
1069
  signer: {
920
1070
  signPayload: async payload => {
921
- const signing = await this.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
1071
+ const signing = await this.state.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
922
1072
  return {
923
1073
  id: new Date().getTime(),
924
1074
  signature: signing.signature
@@ -930,7 +1080,7 @@ export default class TransactionService {
930
1080
  emitter.emit('signed', eventData);
931
1081
 
932
1082
  // Send transaction
933
- const api = this.chainService.getSubstrateApi(chain);
1083
+ const api = this.state.chainService.getSubstrateApi(chain);
934
1084
  eventData.nonce = rs.nonce.toNumber();
935
1085
  eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
936
1086
  this.handleTransactionTimeout(emitter, eventData);
@@ -998,6 +1148,33 @@ export default class TransactionService {
998
1148
  clearTimeout(timeout);
999
1149
  });
1000
1150
  }
1151
+ handlePostEarningTransaction(id) {
1152
+ const transaction = this.getTransaction(id);
1153
+ let slug;
1154
+
1155
+ // TODO
1156
+ if ('data' in transaction.data) {
1157
+ slug = transaction.data.data.slug;
1158
+ } else {
1159
+ slug = transaction.data.slug;
1160
+ }
1161
+ const poolHandler = this.state.earningService.getPoolHandler(slug);
1162
+ if (poolHandler) {
1163
+ const type = poolHandler.type;
1164
+ if (type === YieldPoolType.NATIVE_STAKING) {
1165
+ return;
1166
+ }
1167
+ } else {
1168
+ return;
1169
+ }
1170
+ this.state.mintCampaignService.unlockDotCampaign.mintNft({
1171
+ transactionId: id,
1172
+ address: transaction.address,
1173
+ slug: slug,
1174
+ network: transaction.chain,
1175
+ extrinsicHash: transaction.extrinsicHash
1176
+ }).catch(console.error);
1177
+ }
1001
1178
  resetWallet() {
1002
1179
  this.transactionSubject.next({});
1003
1180
  }
@@ -30,6 +30,8 @@ export interface SWTransactionInput extends SwInputBase, Partial<Pick<SWTransact
30
30
  errors?: SWTransaction['errors'];
31
31
  edAsWarning?: boolean;
32
32
  isTransferAll?: boolean;
33
+ resolveOnDone?: boolean;
34
+ skipFeeValidation?: boolean;
33
35
  }
34
36
  export declare type SWTransactionResponse = SwInputBase & Pick<SWTransaction, 'warnings' | 'errors'> & Partial<Pick<SWTransaction, 'id' | 'extrinsicHash' | 'status' | 'estimateFee'>>;
35
37
  export declare type ValidateTransactionResponseInput = SWTransactionInput;
@@ -5,6 +5,7 @@ import { _getBlockExplorerFromChain, _isPureEvmChain } from '@subwallet/extensio
5
5
 
6
6
  // @ts-ignore
7
7
  export function parseTransactionData(data) {
8
+ // @ts-ignore
8
9
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
9
10
  return data;
10
11
  }
@@ -0,0 +1 @@
1
+ export * from './unlock-dot';
@@ -0,0 +1,4 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from "./unlock-dot.js";