@subwallet/extension-base 1.1.33-beta.1 → 1.1.34-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 (316) hide show
  1. package/background/KoniTypes.d.ts +69 -120
  2. package/background/KoniTypes.js +13 -22
  3. package/background/errors/TransactionError.js +0 -9
  4. package/cjs/background/KoniTypes.js +16 -23
  5. package/cjs/background/errors/TransactionError.js +0 -9
  6. package/cjs/constants/index.js +4 -19
  7. package/cjs/koni/api/nft/config.js +23 -33
  8. package/cjs/koni/api/nft/index.js +0 -14
  9. package/cjs/koni/api/nft/nft.js +22 -1
  10. package/cjs/koni/api/staking/bonding/amplitude.js +16 -19
  11. package/cjs/koni/api/staking/bonding/astar.js +10 -11
  12. package/cjs/koni/api/staking/bonding/index.js +1 -4
  13. package/cjs/koni/api/staking/bonding/paraChain.js +23 -25
  14. package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
  15. package/cjs/koni/api/staking/bonding/utils.js +86 -104
  16. package/cjs/koni/api/staking/index.js +5 -6
  17. package/cjs/koni/api/staking/paraChain.js +17 -10
  18. package/cjs/koni/api/staking/relayChain.js +2 -3
  19. package/cjs/koni/background/cron.js +21 -3
  20. package/cjs/koni/background/handlers/Extension.js +69 -368
  21. package/cjs/koni/background/handlers/State.js +12 -18
  22. package/cjs/koni/background/handlers/index.js +2 -4
  23. package/cjs/koni/background/subscription.js +104 -7
  24. package/cjs/packageInfo.js +1 -1
  25. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +1 -3
  26. package/cjs/services/campaign-service/index.js +6 -9
  27. package/cjs/services/chain-service/constants.js +17 -2
  28. package/cjs/services/chain-service/index.js +3 -25
  29. package/cjs/services/chain-service/utils.js +1 -7
  30. package/cjs/services/event-service/index.js +0 -5
  31. package/cjs/services/keyring-service/index.js +2 -14
  32. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  33. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  34. package/cjs/services/migration-service/scripts/index.js +1 -6
  35. package/cjs/services/notification-service/NotificationService.js +1 -1
  36. package/cjs/services/storage-service/DatabaseService.js +1 -92
  37. package/cjs/services/storage-service/databases/index.js +0 -7
  38. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  39. package/cjs/services/subscan-service/index.js +0 -16
  40. package/cjs/services/transaction-service/event-parser/index.js +0 -58
  41. package/cjs/services/transaction-service/helpers/index.js +1 -3
  42. package/cjs/services/transaction-service/index.js +75 -252
  43. package/cjs/services/transaction-service/utils.js +0 -1
  44. package/cjs/types/index.js +0 -44
  45. package/cjs/utils/fetchStaticData.js +1 -2
  46. package/cjs/utils/index.js +1 -89
  47. package/cjs/utils/number.js +2 -6
  48. package/constants/index.d.ts +1 -6
  49. package/constants/index.js +1 -6
  50. package/koni/api/nft/config.js +23 -33
  51. package/koni/api/nft/index.js +1 -15
  52. package/koni/api/nft/nft.js +23 -2
  53. package/koni/api/staking/bonding/amplitude.js +10 -13
  54. package/koni/api/staking/bonding/astar.js +8 -9
  55. package/koni/api/staking/bonding/index.d.ts +1 -1
  56. package/koni/api/staking/bonding/index.js +1 -5
  57. package/koni/api/staking/bonding/paraChain.js +10 -12
  58. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  59. package/koni/api/staking/bonding/relayChain.js +30 -33
  60. package/koni/api/staking/bonding/utils.d.ts +38 -15
  61. package/koni/api/staking/bonding/utils.js +69 -85
  62. package/koni/api/staking/index.js +1 -2
  63. package/koni/api/staking/paraChain.js +18 -11
  64. package/koni/api/staking/relayChain.js +3 -4
  65. package/koni/background/cron.d.ts +4 -0
  66. package/koni/background/cron.js +22 -4
  67. package/koni/background/handlers/Extension.d.ts +1 -17
  68. package/koni/background/handlers/Extension.js +30 -327
  69. package/koni/background/handlers/State.d.ts +1 -6
  70. package/koni/background/handlers/State.js +12 -17
  71. package/koni/background/handlers/index.js +2 -4
  72. package/koni/background/subscription.d.ts +6 -1
  73. package/koni/background/subscription.js +104 -8
  74. package/package.json +8 -331
  75. package/packageInfo.js +1 -1
  76. package/services/balance-service/helpers/subscribe/substrate/index.js +2 -4
  77. package/services/campaign-service/index.js +6 -9
  78. package/services/chain-service/constants.d.ts +13 -1
  79. package/services/chain-service/constants.js +15 -1
  80. package/services/chain-service/index.d.ts +0 -2
  81. package/services/chain-service/index.js +3 -25
  82. package/services/chain-service/utils.d.ts +0 -1
  83. package/services/chain-service/utils.js +1 -5
  84. package/services/event-service/index.d.ts +0 -2
  85. package/services/event-service/index.js +0 -5
  86. package/services/event-service/types.d.ts +0 -9
  87. package/services/keyring-service/index.d.ts +1 -2
  88. package/services/keyring-service/index.js +2 -14
  89. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  90. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  91. package/services/migration-service/scripts/index.js +1 -6
  92. package/services/notification-service/NotificationService.js +1 -1
  93. package/services/storage-service/DatabaseService.d.ts +3 -30
  94. package/services/storage-service/DatabaseService.js +1 -91
  95. package/services/storage-service/databases/index.d.ts +2 -8
  96. package/services/storage-service/databases/index.js +0 -7
  97. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  98. package/services/subscan-service/index.d.ts +2 -3
  99. package/services/subscan-service/index.js +0 -15
  100. package/services/subscan-service/types.d.ts +0 -20
  101. package/services/transaction-service/event-parser/index.d.ts +1 -3
  102. package/services/transaction-service/event-parser/index.js +1 -57
  103. package/services/transaction-service/helpers/index.js +1 -3
  104. package/services/transaction-service/index.d.ts +13 -6
  105. package/services/transaction-service/index.js +73 -250
  106. package/services/transaction-service/types.d.ts +0 -2
  107. package/services/transaction-service/utils.js +0 -1
  108. package/types/index.d.ts +0 -5
  109. package/types/index.js +1 -5
  110. package/utils/fetchStaticData.js +1 -2
  111. package/utils/index.d.ts +0 -5
  112. package/utils/index.js +0 -52
  113. package/utils/number.d.ts +1 -2
  114. package/utils/number.js +1 -2
  115. package/cjs/koni/api/dotsama/balance.js +0 -464
  116. package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
  117. package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
  118. package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
  119. package/cjs/koni/api/yield/helper/utils.js +0 -49
  120. package/cjs/services/earning-service/constants/chains.js +0 -30
  121. package/cjs/services/earning-service/constants/index.js +0 -27
  122. package/cjs/services/earning-service/constants/step.js +0 -18
  123. package/cjs/services/earning-service/handlers/base.js +0 -262
  124. package/cjs/services/earning-service/handlers/index.js +0 -60
  125. package/cjs/services/earning-service/handlers/lending/base.js +0 -81
  126. package/cjs/services/earning-service/handlers/lending/index.js +0 -13
  127. package/cjs/services/earning-service/handlers/lending/interlay.js +0 -192
  128. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -240
  129. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -98
  130. package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -140
  131. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -299
  132. package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -41
  133. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -227
  134. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -404
  135. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -434
  136. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -466
  137. package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
  138. package/cjs/services/earning-service/handlers/native-staking/base.js +0 -161
  139. package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
  140. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -390
  141. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -567
  142. package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -566
  143. package/cjs/services/earning-service/handlers/special.js +0 -497
  144. package/cjs/services/earning-service/service.js +0 -741
  145. package/cjs/services/earning-service/utils/index.js +0 -128
  146. package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
  147. package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
  148. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
  149. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
  150. package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
  151. package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
  152. package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
  153. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
  154. package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
  155. package/cjs/services/mint-campaign-service/constants.js +0 -11
  156. package/cjs/services/mint-campaign-service/index.js +0 -18
  157. package/cjs/services/storage-service/db-stores/AssetRef.js +0 -24
  158. package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
  159. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -71
  160. package/cjs/services/storage-service/index.js +0 -241
  161. package/cjs/types/campaigns/index.js +0 -16
  162. package/cjs/types/campaigns/unlock-dot.js +0 -1
  163. package/cjs/types/ordinal.js +0 -1
  164. package/cjs/types/transaction.js +0 -1
  165. package/cjs/types/yield/actions/index.js +0 -27
  166. package/cjs/types/yield/actions/join/index.js +0 -38
  167. package/cjs/types/yield/actions/join/step.js +0 -48
  168. package/cjs/types/yield/actions/join/submit.js +0 -1
  169. package/cjs/types/yield/actions/join/validate.js +0 -16
  170. package/cjs/types/yield/actions/others.js +0 -1
  171. package/cjs/types/yield/index.js +0 -27
  172. package/cjs/types/yield/info/account/index.js +0 -49
  173. package/cjs/types/yield/info/account/info.js +0 -1
  174. package/cjs/types/yield/info/account/reward.js +0 -1
  175. package/cjs/types/yield/info/account/target.js +0 -32
  176. package/cjs/types/yield/info/account/unstake.js +0 -27
  177. package/cjs/types/yield/info/base.js +0 -41
  178. package/cjs/types/yield/info/chain/index.js +0 -27
  179. package/cjs/types/yield/info/chain/info.js +0 -1
  180. package/cjs/types/yield/info/chain/target.js +0 -1
  181. package/cjs/types/yield/info/index.js +0 -49
  182. package/cjs/types/yield/info/pallet.js +0 -15
  183. package/cjs/types.js +0 -1
  184. package/cjs/utils/address.js +0 -34
  185. package/cjs/utils/keyring.js +0 -57
  186. package/cjs/utils/object.js +0 -12
  187. package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
  188. package/koni/api/nft/ordinal_nft/constants.js +0 -12
  189. package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
  190. package/koni/api/nft/ordinal_nft/index.js +0 -114
  191. package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
  192. package/koni/api/nft/ordinal_nft/utils.js +0 -33
  193. package/koni/api/yield/helper/utils.d.ts +0 -10
  194. package/koni/api/yield/helper/utils.js +0 -34
  195. package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
  196. package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
  197. package/services/earning-service/constants/chains.d.ts +0 -15
  198. package/services/earning-service/constants/chains.js +0 -22
  199. package/services/earning-service/constants/index.d.ts +0 -2
  200. package/services/earning-service/constants/index.js +0 -5
  201. package/services/earning-service/constants/step.d.ts +0 -3
  202. package/services/earning-service/constants/step.js +0 -10
  203. package/services/earning-service/handlers/base.d.ts +0 -113
  204. package/services/earning-service/handlers/base.js +0 -256
  205. package/services/earning-service/handlers/index.d.ts +0 -5
  206. package/services/earning-service/handlers/index.js +0 -8
  207. package/services/earning-service/handlers/lending/base.d.ts +0 -8
  208. package/services/earning-service/handlers/lending/base.js +0 -73
  209. package/services/earning-service/handlers/lending/index.d.ts +0 -1
  210. package/services/earning-service/handlers/lending/index.js +0 -4
  211. package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
  212. package/services/earning-service/handlers/lending/interlay.js +0 -184
  213. package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
  214. package/services/earning-service/handlers/liquid-staking/acala.js +0 -232
  215. package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -11
  216. package/services/earning-service/handlers/liquid-staking/base.js +0 -90
  217. package/services/earning-service/handlers/liquid-staking/bifrost-manta.d.ts +0 -37
  218. package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -132
  219. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
  220. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -288
  221. package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -5
  222. package/services/earning-service/handlers/liquid-staking/index.js +0 -8
  223. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
  224. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -219
  225. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
  226. package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -394
  227. package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
  228. package/services/earning-service/handlers/native-staking/amplitude.js +0 -425
  229. package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
  230. package/services/earning-service/handlers/native-staking/astar.js +0 -456
  231. package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
  232. package/services/earning-service/handlers/native-staking/base-para.js +0 -138
  233. package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
  234. package/services/earning-service/handlers/native-staking/base.js +0 -152
  235. package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
  236. package/services/earning-service/handlers/native-staking/index.js +0 -7
  237. package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
  238. package/services/earning-service/handlers/native-staking/para-chain.js +0 -382
  239. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
  240. package/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
  241. package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
  242. package/services/earning-service/handlers/nomination-pool/index.js +0 -556
  243. package/services/earning-service/handlers/special.d.ts +0 -64
  244. package/services/earning-service/handlers/special.js +0 -489
  245. package/services/earning-service/service.d.ts +0 -94
  246. package/services/earning-service/service.js +0 -730
  247. package/services/earning-service/utils/index.d.ts +0 -18
  248. package/services/earning-service/utils/index.js +0 -112
  249. package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
  250. package/services/migration-service/scripts/DeleteEarningData.js +0 -13
  251. package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
  252. package/services/migration-service/scripts/EnableEarningChains.js +0 -13
  253. package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
  254. package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
  255. package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
  256. package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
  257. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
  258. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
  259. package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
  260. package/services/mint-campaign-service/campaigns/index.js +0 -4
  261. package/services/mint-campaign-service/constants.d.ts +0 -1
  262. package/services/mint-campaign-service/constants.js +0 -4
  263. package/services/mint-campaign-service/index.d.ts +0 -7
  264. package/services/mint-campaign-service/index.js +0 -11
  265. package/services/storage-service/db-stores/AssetRef.d.ts +0 -7
  266. package/services/storage-service/db-stores/AssetRef.js +0 -16
  267. package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
  268. package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
  269. package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -11
  270. package/services/storage-service/db-stores/YieldPositionStore.js +0 -63
  271. package/types/campaigns/index.d.ts +0 -1
  272. package/types/campaigns/index.js +0 -4
  273. package/types/campaigns/unlock-dot.d.ts +0 -71
  274. package/types/campaigns/unlock-dot.js +0 -1
  275. package/types/ordinal.d.ts +0 -69
  276. package/types/ordinal.js +0 -1
  277. package/types/transaction.d.ts +0 -3
  278. package/types/transaction.js +0 -1
  279. package/types/yield/actions/index.d.ts +0 -2
  280. package/types/yield/actions/index.js +0 -5
  281. package/types/yield/actions/join/index.d.ts +0 -3
  282. package/types/yield/actions/join/index.js +0 -6
  283. package/types/yield/actions/join/step.d.ts +0 -96
  284. package/types/yield/actions/join/step.js +0 -47
  285. package/types/yield/actions/join/submit.d.ts +0 -58
  286. package/types/yield/actions/join/submit.js +0 -1
  287. package/types/yield/actions/join/validate.d.ts +0 -18
  288. package/types/yield/actions/join/validate.js +0 -10
  289. package/types/yield/actions/others.d.ts +0 -85
  290. package/types/yield/actions/others.js +0 -1
  291. package/types/yield/index.d.ts +0 -2
  292. package/types/yield/index.js +0 -5
  293. package/types/yield/info/account/index.d.ts +0 -4
  294. package/types/yield/info/account/index.js +0 -7
  295. package/types/yield/info/account/info.d.ts +0 -92
  296. package/types/yield/info/account/info.js +0 -1
  297. package/types/yield/info/account/reward.d.ts +0 -47
  298. package/types/yield/info/account/reward.js +0 -1
  299. package/types/yield/info/account/target.d.ts +0 -43
  300. package/types/yield/info/account/target.js +0 -27
  301. package/types/yield/info/account/unstake.d.ts +0 -31
  302. package/types/yield/info/account/unstake.js +0 -22
  303. package/types/yield/info/base.d.ts +0 -45
  304. package/types/yield/info/base.js +0 -36
  305. package/types/yield/info/chain/index.d.ts +0 -2
  306. package/types/yield/info/chain/index.js +0 -5
  307. package/types/yield/info/chain/info.d.ts +0 -252
  308. package/types/yield/info/chain/info.js +0 -1
  309. package/types/yield/info/chain/target.d.ts +0 -37
  310. package/types/yield/info/chain/target.js +0 -1
  311. package/types/yield/info/index.d.ts +0 -4
  312. package/types/yield/info/index.js +0 -7
  313. package/types/yield/info/pallet.d.ts +0 -143
  314. package/types/yield/info/pallet.js +0 -9
  315. package/utils/object.d.ts +0 -1
  316. package/utils/object.js +0 -6
@@ -1,121 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _constants = require("@subwallet/extension-base/constants");
8
- var _nft = require("@subwallet/extension-base/koni/api/nft/nft");
9
- var _utils = require("@subwallet/extension-base/koni/api/nft/ordinal_nft/utils");
10
- var _handlers = require("@subwallet/extension-base/koni/background/handlers");
11
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
12
- // SPDX-License-Identifier: Apache-2.0
13
-
14
- const parseParamData = (param, event, chain, address) => {
15
- const ordinalData = JSON.parse(param.value);
16
- if ('p' in ordinalData) {
17
- const properties = {};
18
- for (const [key, value] of Object.entries(ordinalData)) {
19
- const _name = key.charAt(0).toUpperCase() + key.slice(1);
20
- properties[_name] = {
21
- value: value
22
- };
23
- }
24
- properties['Block number'] = {
25
- value: event.extrinsic_index.split('-')[0]
26
- };
27
- properties.Timestamp = {
28
- value: event.block_timestamp
29
- };
30
- const op = ordinalData.op.charAt(0).toUpperCase() + ordinalData.op.slice(1);
31
- const nameParams = [op];
32
- if (ordinalData.amt !== undefined) {
33
- nameParams.push(ordinalData.amt);
34
- }
35
- nameParams.push(ordinalData.tick);
36
- const name = nameParams.join(' ');
37
- return {
38
- chain: chain,
39
- collectionId: _constants.ORDINAL_COLLECTION,
40
- id: event.extrinsic_hash,
41
- description: JSON.stringify(ordinalData),
42
- name,
43
- owner: address,
44
- properties: properties
45
- };
46
- }
47
- return undefined;
48
- };
49
- class OrdinalNftApi extends _nft.BaseNftApi {
50
- constructor(addresses, chain, subscanChain) {
51
- super(chain, undefined, addresses);
52
- this.subscanChain = subscanChain;
53
- }
54
- async handleNft(address, handleNftParams) {
55
- const events = await _handlers.state.subscanService.addRequest(async () => {
56
- return await (0, _utils.fetchRemarkEvent)(this.subscanChain, address);
57
- });
58
- if (events && events.length) {
59
- const extrinsicIds = events.map(data => data.extrinsic_index);
60
- const extrinsicParams = await _handlers.state.subscanService.addRequest(async () => {
61
- return await (0, _utils.fetchExtrinsicParams)(this.subscanChain, extrinsicIds);
62
- });
63
- const items = [];
64
- for (const data of extrinsicParams) {
65
- const {
66
- extrinsic_index: extrinsicIndex,
67
- params
68
- } = data;
69
- const event = events.find(item => item.extrinsic_index === extrinsicIndex);
70
- if (params.length === 1 && event) {
71
- const [param] = params;
72
- if (param.name === 'remark') {
73
- const childParam = {
74
- name: param.name,
75
- type: param.type,
76
- value: param.value
77
- };
78
- const item = parseParamData(childParam, event, this.chain, address);
79
- if (item) {
80
- items.push(item);
81
- }
82
- } else if (param.name === 'calls') {
83
- const children = param.value;
84
- for (const child of children) {
85
- if (child.call_module === 'System' && child.call_name === 'remark_with_event') {
86
- for (const childParam of child.params) {
87
- const item = parseParamData(childParam, event, this.chain, address);
88
- if (item) {
89
- items.push(item);
90
- }
91
- }
92
- }
93
- }
94
- }
95
- }
96
- }
97
- if (items.length) {
98
- // handleNftParams.updateCollection(this.chain, {
99
- // chain: this.chain,
100
- // collectionId: ORDINAL_COLLECTION
101
- // });
102
-
103
- for (const item of items) {
104
- handleNftParams.updateItem(this.chain, item, address);
105
- }
106
- }
107
- }
108
- }
109
- async handleNfts(params) {
110
- await Promise.all(this.addresses.map(address => this.handleNft(address, params)));
111
- }
112
- async fetchNfts(params) {
113
- try {
114
- await this.handleNfts(params);
115
- } catch (e) {
116
- return 0;
117
- }
118
- return 1;
119
- }
120
- }
121
- exports.default = OrdinalNftApi;
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fetchRemarkEvent = exports.fetchExtrinsicParams = void 0;
7
- var _constants = require("./constants");
8
- // Copyright 2019-2022 @subwallet/extension-base authors & contributors
9
- // SPDX-License-Identifier: Apache-2.0
10
-
11
- const fetchRemarkEvent = async (chain, address) => {
12
- const params = {
13
- ..._constants.BASE_FETCH_ORDINAL_EVENT_DATA,
14
- address
15
- };
16
- const response = await fetch(_constants.GET_EVENT_LIST_API.replace('{{chain}}', chain), {
17
- method: 'POST',
18
- headers: {
19
- 'Content-Type': 'application/json'
20
- },
21
- body: JSON.stringify(params)
22
- });
23
- const data = await response.json();
24
- return data.data.events;
25
- };
26
- exports.fetchRemarkEvent = fetchRemarkEvent;
27
- const fetchExtrinsicParams = async (chain, extrinsicIndexes) => {
28
- const params = {
29
- extrinsic_index: extrinsicIndexes
30
- };
31
- const response = await fetch(_constants.GET_EXTRINSIC_PARAMS_API.replace('{{chain}}', chain), {
32
- method: 'POST',
33
- headers: {
34
- 'Content-Type': 'application/json'
35
- },
36
- body: JSON.stringify(params)
37
- });
38
- const data = await response.json();
39
- return data.data;
40
- };
41
- exports.fetchExtrinsicParams = fetchExtrinsicParams;
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.YIELD_POOL_STAT_REFRESH_INTERVAL = exports.YIELD_POOL_MIN_AMOUNT_PERCENT = exports.YIELD_EXTRINSIC_TYPES = exports.DEFAULT_YIELD_FIRST_STEP = void 0;
8
- exports.calculateAlternativeFee = calculateAlternativeFee;
9
- exports.convertDerivativeToOriginToken = convertDerivativeToOriginToken;
10
- exports.syntheticSelectedValidators = void 0;
11
- var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
12
- var _utils = require("@subwallet/extension-base/services/chain-service/utils");
13
- var _types = require("@subwallet/extension-base/types");
14
- var _utils2 = require("@subwallet/extension-base/utils");
15
- var _bignumber = _interopRequireDefault(require("bignumber.js"));
16
- // Copyright 2019-2022 @subwallet/extension-base
17
- // SPDX-License-Identifier: Apache-2.0
18
-
19
- const syntheticSelectedValidators = ['15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6', '1REAJ1k691g5Eqqg9gL7vvZCBG7FCCZ8zgQkZWd4va5ESih', '1yGJ3h7TQuJWLYSsUVPZbM8aR8UsQXCqMvrFx5Fn1ktiAmq', '16GDRhRYxk42paoK6TfHAqWej8PdDDUwdDazjv4bAn4KGNeb', '13Ybj8CPEArUee78DxUAP9yX3ABmFNVQME1ZH4w8HVncHGzc', '14yx4vPAACZRhoDQm1dyvXD3QdRQyCRRCe5tj1zPomhhS29a', '14Vh8S1DzzycngbAB9vqEgPFR9JpSvmF1ezihTUES1EaHAV', '153YD8ZHD9dRh82U419bSCB5SzWhbdAFzjj4NtA5pMazR2yC', '1LUckyocmz9YzeQZHVpBvYYRGXb3rnSm2tvfz79h3G3JDgP', '14oRE62MB1SWR6h5RTx3GY5HK2oZipi1Gp3zdiLwVYLfEyRZ', '1cFsLn7o74nmjbRyDtMAnMpQMc5ZLsjgCSz9Np2mcejUK83', '15ZvLonEseaWZNy8LDkXXj3Y8bmAjxCjwvpy4pXWSL4nGSBs', '1NebF2xZHb4TJJpiqZZ3reeTo8dZov6LZ49qZqcHHbsmHfo', '1HmAqbBRrWvsqbLkvpiVDkdA2PcctUE5JUe3qokEh1FN455', '15tfUt4iQNjMyhZiJGBf4EpETE2KqtW1nfJwbBT1MvWjvcK9', '12RXTLiaYh59PokjZVhQvKzcfBEB5CvDnjKKUmDUotzcTH3S'];
20
- exports.syntheticSelectedValidators = syntheticSelectedValidators;
21
- function calculateAlternativeFee(feeInfo) {
22
- return feeInfo.partialFee;
23
- }
24
- const DEFAULT_YIELD_FIRST_STEP = {
25
- id: 0,
26
- name: 'Fill information',
27
- type: _types.YieldStepType.DEFAULT
28
- };
29
- exports.DEFAULT_YIELD_FIRST_STEP = DEFAULT_YIELD_FIRST_STEP;
30
- const YIELD_EXTRINSIC_TYPES = [_KoniTypes.ExtrinsicType.MINT_VDOT, _KoniTypes.ExtrinsicType.MINT_LDOT, _KoniTypes.ExtrinsicType.MINT_SDOT, _KoniTypes.ExtrinsicType.MINT_QDOT, _KoniTypes.ExtrinsicType.MINT_STDOT, _KoniTypes.ExtrinsicType.REDEEM_QDOT, _KoniTypes.ExtrinsicType.REDEEM_SDOT, _KoniTypes.ExtrinsicType.REDEEM_VDOT, _KoniTypes.ExtrinsicType.REDEEM_LDOT, _KoniTypes.ExtrinsicType.REDEEM_STDOT, _KoniTypes.ExtrinsicType.STAKING_JOIN_POOL, _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD, _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL, _KoniTypes.ExtrinsicType.STAKING_POOL_WITHDRAW];
31
- exports.YIELD_EXTRINSIC_TYPES = YIELD_EXTRINSIC_TYPES;
32
- const YIELD_POOL_STAT_REFRESH_INTERVAL = 90000;
33
- exports.YIELD_POOL_STAT_REFRESH_INTERVAL = YIELD_POOL_STAT_REFRESH_INTERVAL;
34
- const YIELD_POOL_MIN_AMOUNT_PERCENT = {
35
- DOT___acala_liquid_staking: 0.98,
36
- DOT___bifrost_liquid_staking: 0.99,
37
- DOT___parallel_liquid_staking: 0.97,
38
- default: 0.98
39
- };
40
- exports.YIELD_POOL_MIN_AMOUNT_PERCENT = YIELD_POOL_MIN_AMOUNT_PERCENT;
41
- function convertDerivativeToOriginToken(amount, poolInfo, derivativeTokenInfo, originTokenInfo) {
42
- var _poolInfo$statistic, _poolInfo$statistic$a;
43
- const derivativeDecimals = (0, _utils._getAssetDecimals)(derivativeTokenInfo);
44
- const originDecimals = (0, _utils._getAssetDecimals)(originTokenInfo);
45
- const exchangeRate = ((_poolInfo$statistic = poolInfo.statistic) === null || _poolInfo$statistic === void 0 ? void 0 : (_poolInfo$statistic$a = _poolInfo$statistic.assetEarning) === null || _poolInfo$statistic$a === void 0 ? void 0 : _poolInfo$statistic$a[0].exchangeRate) || 1;
46
- const formattedAmount = new _bignumber.default(amount).dividedBy(_utils2.BN_TEN.pow(derivativeDecimals)); // TODO: decimals
47
- const minAmount = formattedAmount.multipliedBy(exchangeRate);
48
- return minAmount.multipliedBy(_utils2.BN_TEN.pow(originDecimals)).toFixed(0);
49
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports._STAKING_CHAIN_GROUP = exports.ST_LIQUID_TOKEN_ABI = void 0;
7
- // Copyright 2019-2022 @subwallet/extension-base
8
- // SPDX-License-Identifier: Apache-2.0
9
-
10
- const _STAKING_CHAIN_GROUP = {
11
- relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet'],
12
- para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari', 'manta_network'],
13
- astar: ['astar', 'shiden', 'shibuya'],
14
- amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum', 'krest_network'],
15
- // amplitude and kilt only share some common logic
16
- kilt: ['kilt', 'kilt_peregrine'],
17
- nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet'],
18
- bifrost: ['bifrost', 'bifrost_testnet'],
19
- aleph: ['aleph', 'alephTest'],
20
- // A0 has distinct tokenomics
21
- ternoa: ['ternoa', 'ternoa_alphanet'],
22
- liquidStaking: ['bifrost_dot', 'acala', 'parallel', 'moonbeam'],
23
- lending: ['interlay'],
24
- krest_network: ['krest_network']
25
- };
26
-
27
- // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
28
- exports._STAKING_CHAIN_GROUP = _STAKING_CHAIN_GROUP;
29
- const ST_LIQUID_TOKEN_ABI = require('./abis/st_liquid_token_abi.json');
30
- exports.ST_LIQUID_TOKEN_ABI = ST_LIQUID_TOKEN_ABI;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _chains = require("./chains");
7
- Object.keys(_chains).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _chains[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _chains[key];
14
- }
15
- });
16
- });
17
- var _step = require("./step");
18
- Object.keys(_step).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _step[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _step[key];
25
- }
26
- });
27
- });
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fakeAddress = exports.DEFAULT_YIELD_FIRST_STEP = void 0;
7
- var _types = require("@subwallet/extension-base/types");
8
- // Copyright 2019-2022 @subwallet/extension-base
9
- // SPDX-License-Identifier: Apache-2.0
10
-
11
- const DEFAULT_YIELD_FIRST_STEP = {
12
- id: 0,
13
- name: 'Fill information',
14
- type: _types.YieldStepType.DEFAULT
15
- };
16
- exports.DEFAULT_YIELD_FIRST_STEP = DEFAULT_YIELD_FIRST_STEP;
17
- const fakeAddress = '15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6';
18
- exports.fakeAddress = fakeAddress;
@@ -1,262 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
8
- var _constants = require("@subwallet/extension-base/constants");
9
- var _constants2 = require("@subwallet/extension-base/services/earning-service/constants");
10
- var _utils = require("@subwallet/extension-base/utils");
11
- var _util = require("@polkadot/util");
12
- // Copyright 2019-2022 @subwallet/extension-base
13
- // SPDX-License-Identifier: Apache-2.0
14
-
15
- /**
16
- * @class BasePoolHandler
17
- * @description Base pool handler
18
- * */
19
- class BasePoolHandler {
20
- /** Koni state */
21
-
22
- /** Pool's chain */
23
-
24
- /** Pool's logo */
25
-
26
- /** Pool's slug */
27
-
28
- /** Pool's type */
29
-
30
- /** Pool's name */
31
-
32
- /** Pool's short name */
33
-
34
- /** Pool's transaction type */
35
- transactionChainType = _KoniTypes.ChainType.SUBSTRATE;
36
-
37
- /** Pool's available method */
38
-
39
- /**
40
- * @constructor
41
- * @param {KoniState} state - Koni state
42
- * @param {string} chain - Pool's chain
43
- * */
44
- constructor(state, chain) {
45
- this.state = state;
46
- this.chain = chain;
47
- this._logo = chain;
48
- }
49
- get logo() {
50
- return this._logo;
51
- }
52
- get group() {
53
- const groupSlug = this.nativeToken.multiChainAsset;
54
- return groupSlug || this.nativeToken.slug;
55
- }
56
- get isActive() {
57
- return this.state.activeChainSlugs.includes(this.chain);
58
- }
59
- get substrateApi() {
60
- return this.state.getSubstrateApi(this.chain);
61
- }
62
- get evmApi() {
63
- return this.state.getEvmApi(this.chain);
64
- }
65
- get chainInfo() {
66
- return this.state.getChainInfo(this.chain);
67
- }
68
- get nativeToken() {
69
- return this.state.getNativeTokenInfo(this.chain);
70
- }
71
- get baseInfo() {
72
- return {
73
- group: this.group,
74
- chain: this.chain,
75
- slug: this.slug
76
- };
77
- }
78
- getAssetBySlug(slug) {
79
- return this.state.getAssetBySlug(slug);
80
- }
81
- get maintainBalance() {
82
- const decimals = this.nativeToken.decimals || 0;
83
- const defaultMaintainBalance = new _util.BN(1).mul(_util.BN_TEN.pow(new _util.BN(decimals)));
84
- const ed = new _util.BN(this.nativeToken.minAmount || '0');
85
- const maintainBalance = ed.gte(defaultMaintainBalance) ? new _util.BN(15).mul(ed).div(_util.BN_TEN) : defaultMaintainBalance;
86
- return maintainBalance.toString();
87
- }
88
- get metadataInfo() {
89
- return {
90
- name: this.name,
91
- shortName: this.shortName,
92
- logo: this.logo,
93
- inputAsset: this.nativeToken.slug,
94
- isAvailable: true,
95
- maintainAsset: this.nativeToken.slug,
96
- maintainBalance: this.maintainBalance,
97
- availableMethod: this.availableMethod
98
- };
99
- }
100
-
101
- /** Can mint when haven't enough native token (use input token for fee) */
102
- get isPoolSupportAlternativeFee() {
103
- return false;
104
- }
105
- async getPoolInfo() {
106
- return await this.state.earningService.getYieldPool(this.slug);
107
- }
108
- async getPoolPosition(address) {
109
- return await this.state.earningService.getYieldPosition(address, this.slug);
110
- }
111
-
112
- /* Subscribe data */
113
-
114
- /** Subscribe pool info */
115
-
116
- /* Subscribe data */
117
-
118
- /* Join action */
119
-
120
- /* Early validate */
121
-
122
- async earlyValidate(request) {
123
- var _poolInfo$statistic, _poolInfo$statistic2, _poolInfo$statistic2$;
124
- const poolInfo = await this.getPoolInfo();
125
- if (!poolInfo || !((_poolInfo$statistic = poolInfo.statistic) !== null && _poolInfo$statistic !== void 0 && _poolInfo$statistic.earningThreshold.join)) {
126
- return {
127
- passed: false,
128
- errorMessage: 'There is a problem fetching your data. Check your Internet connection or change the network endpoint and try again.'
129
- };
130
- }
131
- if (request.address === _constants.ALL_ACCOUNT_KEY) {
132
- return {
133
- passed: true
134
- };
135
- }
136
- const nativeTokenInfo = this.state.chainService.getNativeTokenInfo(this.chain);
137
- const nativeTokenBalance = await this.state.balanceService.getTokenFreeBalance(request.address, this.chain);
138
- const bnNativeTokenBalance = new _util.BN(nativeTokenBalance.value);
139
- const bnMinBalanceToJoin = new _util.BN(((_poolInfo$statistic2 = poolInfo.statistic) === null || _poolInfo$statistic2 === void 0 ? void 0 : (_poolInfo$statistic2$ = _poolInfo$statistic2.earningThreshold) === null || _poolInfo$statistic2$ === void 0 ? void 0 : _poolInfo$statistic2$.join) || '0').add(new _util.BN(poolInfo.metadata.maintainBalance));
140
- if (bnNativeTokenBalance.lte(bnMinBalanceToJoin)) {
141
- const minJoin = (0, _utils.formatNumber)(bnMinBalanceToJoin.toString(), this.nativeToken.decimals || 0);
142
- const originChain = this.state.getChainInfo(nativeTokenInfo.originChain);
143
- return {
144
- passed: false,
145
- errorMessage: `You need at least ${minJoin} ${nativeTokenInfo.symbol} (${originChain.name}) to start earning`
146
- };
147
- }
148
- return {
149
- passed: true
150
- };
151
- }
152
-
153
- /* Early validate */
154
-
155
- /* Generate steps */
156
-
157
- /**
158
- * @function firstStepFee
159
- * */
160
- get firstStepFee() {
161
- return {
162
- slug: ''
163
- };
164
- }
165
-
166
- /**
167
- * @function defaultSubmitStep
168
- * @description Default submit step data
169
- * */
170
-
171
- /**
172
- * @async
173
- * @function getTokenApproveStep
174
- * @param {OptimalYieldPathParams} params - base param to join pool
175
- * @description Generate token approve step data
176
- * */
177
- async getTokenApproveStep(params) {
178
- return Promise.resolve(undefined);
179
- }
180
-
181
- /**
182
- * @async
183
- * @function getXcmStep
184
- * @param {OptimalYieldPathParams} params - base param to join pool
185
- * @description Generate token approve step data
186
- * */
187
- async getXcmStep(params) {
188
- return Promise.resolve(undefined);
189
- }
190
-
191
- /**
192
- * @async
193
- * @function getSubmitStep
194
- * @param {OptimalYieldPathParams} params - base param to join pool
195
- * @description Generate token approve step data
196
- * */
197
-
198
- /** Generate the optimal steps to join pool */
199
- async generateOptimalPath(params) {
200
- const result = {
201
- totalFee: [this.firstStepFee],
202
- steps: [_constants2.DEFAULT_YIELD_FIRST_STEP]
203
- };
204
- try {
205
- const stepFunctions = [this.getTokenApproveStep, this.getXcmStep, this.getSubmitStep];
206
- for (const stepFunction of stepFunctions) {
207
- const step = await stepFunction.bind(this, params)();
208
- if (step) {
209
- const [info, fee] = step;
210
- result.steps.push({
211
- id: result.steps.length,
212
- ...info
213
- });
214
- result.totalFee.push(fee);
215
- }
216
- }
217
- return result;
218
- } catch (e) {
219
- const errorMessage = e.message;
220
- if (errorMessage.includes('network')) {
221
- result.connectionError = errorMessage.split(' ')[0];
222
- }
223
-
224
- /* Submit step */
225
-
226
- const [step, fee] = this.defaultSubmitStep;
227
- result.steps.push({
228
- id: result.steps.length,
229
- ...step
230
- });
231
- result.totalFee.push(fee);
232
-
233
- /* Submit step */
234
-
235
- return result;
236
- }
237
- }
238
-
239
- /* Generate steps */
240
-
241
- /* Validate */
242
-
243
- /** Validate param to join the pool */
244
-
245
- /** Create `transaction` to leave the pool */
246
- async handleYieldLeave(fastLeave, amount, address, selectedTarget) {
247
- if (fastLeave) {
248
- return this.handleYieldRedeem(amount, address, selectedTarget);
249
- } else {
250
- return this.handleYieldUnstake(amount, address, selectedTarget);
251
- }
252
- }
253
-
254
- /* Leave action */
255
-
256
- /* Other actions */
257
-
258
- /** Create `transaction` to withdraw unstaked amount */
259
-
260
- /* Other actions */
261
- }
262
- exports.default = BasePoolHandler;
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- var _exportNames = {
8
- BasePoolHandler: true,
9
- NominationPoolHandler: true
10
- };
11
- Object.defineProperty(exports, "BasePoolHandler", {
12
- enumerable: true,
13
- get: function () {
14
- return _base.default;
15
- }
16
- });
17
- Object.defineProperty(exports, "NominationPoolHandler", {
18
- enumerable: true,
19
- get: function () {
20
- return _nominationPool.default;
21
- }
22
- });
23
- var _base = _interopRequireDefault(require("./base"));
24
- var _nominationPool = _interopRequireDefault(require("./nomination-pool"));
25
- var _lending = require("./lending");
26
- Object.keys(_lending).forEach(function (key) {
27
- if (key === "default" || key === "__esModule") return;
28
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
29
- if (key in exports && exports[key] === _lending[key]) return;
30
- Object.defineProperty(exports, key, {
31
- enumerable: true,
32
- get: function () {
33
- return _lending[key];
34
- }
35
- });
36
- });
37
- var _liquidStaking = require("./liquid-staking");
38
- Object.keys(_liquidStaking).forEach(function (key) {
39
- if (key === "default" || key === "__esModule") return;
40
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
41
- if (key in exports && exports[key] === _liquidStaking[key]) return;
42
- Object.defineProperty(exports, key, {
43
- enumerable: true,
44
- get: function () {
45
- return _liquidStaking[key];
46
- }
47
- });
48
- });
49
- var _nativeStaking = require("./native-staking");
50
- Object.keys(_nativeStaking).forEach(function (key) {
51
- if (key === "default" || key === "__esModule") return;
52
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
53
- if (key in exports && exports[key] === _nativeStaking[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _nativeStaking[key];
58
- }
59
- });
60
- });