@subwallet/extension-base 1.1.33-beta.0 → 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 (312) hide show
  1. package/background/KoniTypes.d.ts +69 -111
  2. package/background/KoniTypes.js +13 -19
  3. package/background/errors/TransactionError.js +0 -9
  4. package/cjs/background/KoniTypes.js +16 -20
  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 +19 -2
  28. package/cjs/services/chain-service/handler/SubstrateApi.js +10 -5
  29. package/cjs/services/chain-service/index.js +101 -40
  30. package/cjs/services/chain-service/utils.js +69 -7
  31. package/cjs/services/event-service/index.js +0 -5
  32. package/cjs/services/keyring-service/index.js +2 -14
  33. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  34. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  35. package/cjs/services/migration-service/scripts/index.js +1 -6
  36. package/cjs/services/notification-service/NotificationService.js +1 -1
  37. package/cjs/services/storage-service/DatabaseService.js +0 -63
  38. package/cjs/services/storage-service/databases/index.js +0 -4
  39. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  40. package/cjs/services/subscan-service/index.js +0 -16
  41. package/cjs/services/transaction-service/event-parser/index.js +0 -58
  42. package/cjs/services/transaction-service/helpers/index.js +1 -3
  43. package/cjs/services/transaction-service/index.js +75 -249
  44. package/cjs/services/transaction-service/utils.js +0 -1
  45. package/cjs/types/index.js +0 -44
  46. package/cjs/utils/fetchStaticData.js +1 -2
  47. package/cjs/utils/index.js +1 -89
  48. package/cjs/utils/number.js +2 -6
  49. package/constants/index.d.ts +1 -6
  50. package/constants/index.js +1 -6
  51. package/koni/api/nft/config.js +23 -33
  52. package/koni/api/nft/index.js +1 -15
  53. package/koni/api/nft/nft.js +23 -2
  54. package/koni/api/staking/bonding/amplitude.js +10 -13
  55. package/koni/api/staking/bonding/astar.js +8 -9
  56. package/koni/api/staking/bonding/index.d.ts +1 -1
  57. package/koni/api/staking/bonding/index.js +1 -5
  58. package/koni/api/staking/bonding/paraChain.js +10 -12
  59. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  60. package/koni/api/staking/bonding/relayChain.js +30 -33
  61. package/koni/api/staking/bonding/utils.d.ts +38 -15
  62. package/koni/api/staking/bonding/utils.js +69 -85
  63. package/koni/api/staking/index.js +1 -2
  64. package/koni/api/staking/paraChain.js +18 -11
  65. package/koni/api/staking/relayChain.js +3 -4
  66. package/koni/background/cron.d.ts +4 -0
  67. package/koni/background/cron.js +22 -4
  68. package/koni/background/handlers/Extension.d.ts +1 -17
  69. package/koni/background/handlers/Extension.js +30 -327
  70. package/koni/background/handlers/State.d.ts +1 -6
  71. package/koni/background/handlers/State.js +12 -17
  72. package/koni/background/handlers/index.js +2 -4
  73. package/koni/background/subscription.d.ts +6 -1
  74. package/koni/background/subscription.js +104 -8
  75. package/package.json +7 -320
  76. package/packageInfo.js +1 -1
  77. package/services/balance-service/helpers/subscribe/substrate/index.js +2 -4
  78. package/services/campaign-service/index.js +6 -9
  79. package/services/chain-service/constants.d.ts +13 -0
  80. package/services/chain-service/constants.js +15 -0
  81. package/services/chain-service/handler/SubstrateApi.js +10 -5
  82. package/services/chain-service/index.d.ts +9 -1
  83. package/services/chain-service/index.js +97 -37
  84. package/services/chain-service/utils.d.ts +10 -2
  85. package/services/chain-service/utils.js +67 -6
  86. package/services/event-service/index.d.ts +0 -2
  87. package/services/event-service/index.js +0 -5
  88. package/services/event-service/types.d.ts +0 -9
  89. package/services/keyring-service/index.d.ts +1 -2
  90. package/services/keyring-service/index.js +2 -14
  91. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  92. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  93. package/services/migration-service/scripts/index.js +1 -6
  94. package/services/notification-service/NotificationService.js +1 -1
  95. package/services/storage-service/DatabaseService.d.ts +1 -22
  96. package/services/storage-service/DatabaseService.js +0 -63
  97. package/services/storage-service/databases/index.d.ts +1 -3
  98. package/services/storage-service/databases/index.js +0 -4
  99. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  100. package/services/subscan-service/index.d.ts +2 -3
  101. package/services/subscan-service/index.js +0 -15
  102. package/services/subscan-service/types.d.ts +0 -20
  103. package/services/transaction-service/event-parser/index.d.ts +1 -3
  104. package/services/transaction-service/event-parser/index.js +1 -57
  105. package/services/transaction-service/helpers/index.js +1 -3
  106. package/services/transaction-service/index.d.ts +13 -6
  107. package/services/transaction-service/index.js +73 -247
  108. package/services/transaction-service/types.d.ts +0 -2
  109. package/services/transaction-service/utils.js +0 -1
  110. package/types/index.d.ts +0 -5
  111. package/types/index.js +1 -5
  112. package/utils/fetchStaticData.js +1 -2
  113. package/utils/index.d.ts +0 -5
  114. package/utils/index.js +0 -52
  115. package/utils/number.d.ts +1 -2
  116. package/utils/number.js +1 -2
  117. package/cjs/koni/api/dotsama/balance.js +0 -464
  118. package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
  119. package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
  120. package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
  121. package/cjs/koni/api/yield/helper/utils.js +0 -46
  122. package/cjs/services/earning-service/constants/chains.js +0 -30
  123. package/cjs/services/earning-service/constants/index.js +0 -27
  124. package/cjs/services/earning-service/constants/step.js +0 -18
  125. package/cjs/services/earning-service/handlers/base.js +0 -262
  126. package/cjs/services/earning-service/handlers/index.js +0 -60
  127. package/cjs/services/earning-service/handlers/lending/base.js +0 -81
  128. package/cjs/services/earning-service/handlers/lending/index.js +0 -13
  129. package/cjs/services/earning-service/handlers/lending/interlay.js +0 -192
  130. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -240
  131. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -97
  132. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -298
  133. package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
  134. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -227
  135. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -404
  136. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -434
  137. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -466
  138. package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
  139. package/cjs/services/earning-service/handlers/native-staking/base.js +0 -161
  140. package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
  141. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -390
  142. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -567
  143. package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -566
  144. package/cjs/services/earning-service/handlers/special.js +0 -493
  145. package/cjs/services/earning-service/service.js +0 -740
  146. package/cjs/services/earning-service/utils/index.js +0 -128
  147. package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
  148. package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
  149. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
  150. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
  151. package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
  152. package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
  153. package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
  154. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
  155. package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
  156. package/cjs/services/mint-campaign-service/constants.js +0 -11
  157. package/cjs/services/mint-campaign-service/index.js +0 -18
  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 -47
  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 -32
  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 -89
  217. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
  218. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -287
  219. package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
  220. package/services/earning-service/handlers/liquid-staking/index.js +0 -7
  221. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
  222. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -219
  223. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
  224. package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -394
  225. package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
  226. package/services/earning-service/handlers/native-staking/amplitude.js +0 -425
  227. package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
  228. package/services/earning-service/handlers/native-staking/astar.js +0 -456
  229. package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
  230. package/services/earning-service/handlers/native-staking/base-para.js +0 -138
  231. package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
  232. package/services/earning-service/handlers/native-staking/base.js +0 -152
  233. package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
  234. package/services/earning-service/handlers/native-staking/index.js +0 -7
  235. package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
  236. package/services/earning-service/handlers/native-staking/para-chain.js +0 -382
  237. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
  238. package/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
  239. package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
  240. package/services/earning-service/handlers/nomination-pool/index.js +0 -556
  241. package/services/earning-service/handlers/special.d.ts +0 -64
  242. package/services/earning-service/handlers/special.js +0 -485
  243. package/services/earning-service/service.d.ts +0 -94
  244. package/services/earning-service/service.js +0 -729
  245. package/services/earning-service/utils/index.d.ts +0 -18
  246. package/services/earning-service/utils/index.js +0 -112
  247. package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
  248. package/services/migration-service/scripts/DeleteEarningData.js +0 -13
  249. package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
  250. package/services/migration-service/scripts/EnableEarningChains.js +0 -13
  251. package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
  252. package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
  253. package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
  254. package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
  255. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
  256. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
  257. package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
  258. package/services/mint-campaign-service/campaigns/index.js +0 -4
  259. package/services/mint-campaign-service/constants.d.ts +0 -1
  260. package/services/mint-campaign-service/constants.js +0 -4
  261. package/services/mint-campaign-service/index.d.ts +0 -7
  262. package/services/mint-campaign-service/index.js +0 -11
  263. package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
  264. package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
  265. package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -11
  266. package/services/storage-service/db-stores/YieldPositionStore.js +0 -63
  267. package/types/campaigns/index.d.ts +0 -1
  268. package/types/campaigns/index.js +0 -4
  269. package/types/campaigns/unlock-dot.d.ts +0 -71
  270. package/types/campaigns/unlock-dot.js +0 -1
  271. package/types/ordinal.d.ts +0 -69
  272. package/types/ordinal.js +0 -1
  273. package/types/transaction.d.ts +0 -3
  274. package/types/transaction.js +0 -1
  275. package/types/yield/actions/index.d.ts +0 -2
  276. package/types/yield/actions/index.js +0 -5
  277. package/types/yield/actions/join/index.d.ts +0 -3
  278. package/types/yield/actions/join/index.js +0 -6
  279. package/types/yield/actions/join/step.d.ts +0 -95
  280. package/types/yield/actions/join/step.js +0 -46
  281. package/types/yield/actions/join/submit.d.ts +0 -58
  282. package/types/yield/actions/join/submit.js +0 -1
  283. package/types/yield/actions/join/validate.d.ts +0 -18
  284. package/types/yield/actions/join/validate.js +0 -10
  285. package/types/yield/actions/others.d.ts +0 -85
  286. package/types/yield/actions/others.js +0 -1
  287. package/types/yield/index.d.ts +0 -2
  288. package/types/yield/index.js +0 -5
  289. package/types/yield/info/account/index.d.ts +0 -4
  290. package/types/yield/info/account/index.js +0 -7
  291. package/types/yield/info/account/info.d.ts +0 -92
  292. package/types/yield/info/account/info.js +0 -1
  293. package/types/yield/info/account/reward.d.ts +0 -47
  294. package/types/yield/info/account/reward.js +0 -1
  295. package/types/yield/info/account/target.d.ts +0 -43
  296. package/types/yield/info/account/target.js +0 -27
  297. package/types/yield/info/account/unstake.d.ts +0 -31
  298. package/types/yield/info/account/unstake.js +0 -22
  299. package/types/yield/info/base.d.ts +0 -45
  300. package/types/yield/info/base.js +0 -36
  301. package/types/yield/info/chain/index.d.ts +0 -2
  302. package/types/yield/info/chain/index.js +0 -5
  303. package/types/yield/info/chain/info.d.ts +0 -252
  304. package/types/yield/info/chain/info.js +0 -1
  305. package/types/yield/info/chain/target.d.ts +0 -37
  306. package/types/yield/info/chain/target.js +0 -1
  307. package/types/yield/info/index.d.ts +0 -4
  308. package/types/yield/info/index.js +0 -7
  309. package/types/yield/info/pallet.d.ts +0 -143
  310. package/types/yield/info/pallet.js +0 -9
  311. package/utils/object.d.ts +0 -1
  312. package/utils/object.js +0 -6
@@ -1,128 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.calculateReward = calculateReward;
7
- exports.isActionFromValidator = isActionFromValidator;
8
- exports.isNominationPool = exports.isNativeStakingPool = exports.isLiquidPool = exports.isLendingPool = void 0;
9
- exports.parseIdentity = parseIdentity;
10
- var _constants = require("@subwallet/extension-base/services/earning-service/constants");
11
- var _types = require("@subwallet/extension-base/types");
12
- var _util = require("@polkadot/util");
13
- // Copyright 2019-2022 @subwallet/extension-base
14
- // SPDX-License-Identifier: Apache-2.0
15
-
16
- function calculateReward(apr) {
17
- let amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
18
- let compoundingPeriod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _types.YieldCompoundingPeriod.YEARLY;
19
- let isApy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
20
- if (!apr) {
21
- return {};
22
- }
23
- if (!isApy) {
24
- const periodApr = apr / 365 * compoundingPeriod; // APR is always annually
25
- const earningRatio = periodApr / 100 / compoundingPeriod;
26
- const periodApy = (1 + earningRatio) ** compoundingPeriod - 1;
27
- const reward = periodApy * amount;
28
- return {
29
- apy: periodApy * 100,
30
- rewardInToken: reward
31
- };
32
- } else {
33
- const reward = apr / 100 * amount;
34
- return {
35
- apy: apr,
36
- rewardInToken: reward * (compoundingPeriod / _types.YieldCompoundingPeriod.YEARLY)
37
- };
38
- }
39
- }
40
-
41
- /**
42
- * @returns
43
- * <p>
44
- * [0] - identity
45
- * </p>
46
- * <p>
47
- * [1] - isReasonable (isVerified)
48
- * </p>
49
- * */
50
- async function parseIdentity(substrateApi, address, children) {
51
- const compactResult = rs => {
52
- const result = [];
53
- if (rs) {
54
- result.push(rs);
55
- }
56
- if (children) {
57
- result.push(children);
58
- }
59
- if (result.length > 0) {
60
- return result.join('/');
61
- } else {
62
- return undefined;
63
- }
64
- };
65
- if (substrateApi.api.query.identity) {
66
- let identity;
67
- const _parent = await substrateApi.api.query.identity.superOf(address);
68
- const parentInfo = _parent.toHuman();
69
- if (parentInfo) {
70
- const [parentAddress, {
71
- Raw: data
72
- }] = parentInfo;
73
- const child = (0, _util.isHex)(data) ? (0, _util.hexToString)(data) : data;
74
-
75
- // TODO: Re-check
76
- if (address !== parentAddress) {
77
- const [rs, isReasonable] = await parseIdentity(substrateApi, parentAddress, child);
78
- return [compactResult(rs), isReasonable];
79
- }
80
- }
81
- const _identity = await substrateApi.api.query.identity.identityOf(address);
82
- const identityInfo = _identity.toHuman();
83
- if (identityInfo) {
84
- var _identityInfo$info, _identityInfo$info$di, _identityInfo$info2, _identityInfo$info2$w, _identityInfo$info3, _identityInfo$info3$r, _identityInfo$info4, _identityInfo$info4$t;
85
- const displayName = (_identityInfo$info = identityInfo.info) === null || _identityInfo$info === void 0 ? void 0 : (_identityInfo$info$di = _identityInfo$info.display) === null || _identityInfo$info$di === void 0 ? void 0 : _identityInfo$info$di.Raw;
86
- const web = (_identityInfo$info2 = identityInfo.info) === null || _identityInfo$info2 === void 0 ? void 0 : (_identityInfo$info2$w = _identityInfo$info2.web) === null || _identityInfo$info2$w === void 0 ? void 0 : _identityInfo$info2$w.Raw;
87
- const riot = (_identityInfo$info3 = identityInfo.info) === null || _identityInfo$info3 === void 0 ? void 0 : (_identityInfo$info3$r = _identityInfo$info3.riot) === null || _identityInfo$info3$r === void 0 ? void 0 : _identityInfo$info3$r.Raw;
88
- const twitter = (_identityInfo$info4 = identityInfo.info) === null || _identityInfo$info4 === void 0 ? void 0 : (_identityInfo$info4$t = _identityInfo$info4.twitter) === null || _identityInfo$info4$t === void 0 ? void 0 : _identityInfo$info4$t.Raw;
89
- const isReasonable = identityInfo.judgements.length > 0;
90
- if (displayName) {
91
- identity = (0, _util.isHex)(displayName) ? (0, _util.hexToString)(displayName) : displayName;
92
- } else {
93
- identity = twitter || web || riot;
94
- }
95
- return [compactResult(identity), isReasonable];
96
- }
97
- }
98
- return [undefined, false];
99
- }
100
- function isActionFromValidator(stakingType, chain) {
101
- if (stakingType === _types.YieldPoolType.NOMINATION_POOL || stakingType === _types.YieldPoolType.LIQUID_STAKING || stakingType === _types.YieldPoolType.LENDING) {
102
- return false;
103
- }
104
- if (_constants._STAKING_CHAIN_GROUP.astar.includes(chain)) {
105
- return true;
106
- } else if (_constants._STAKING_CHAIN_GROUP.amplitude.includes(chain)) {
107
- return true;
108
- } else if (_constants._STAKING_CHAIN_GROUP.para.includes(chain)) {
109
- return true;
110
- }
111
- return false;
112
- }
113
- const isNominationPool = pool => {
114
- return pool.type === _types.YieldPoolType.NOMINATION_POOL;
115
- };
116
- exports.isNominationPool = isNominationPool;
117
- const isNativeStakingPool = pool => {
118
- return pool.type === _types.YieldPoolType.NATIVE_STAKING;
119
- };
120
- exports.isNativeStakingPool = isNativeStakingPool;
121
- const isLiquidPool = pool => {
122
- return pool.type === _types.YieldPoolType.LIQUID_STAKING;
123
- };
124
- exports.isLiquidPool = isLiquidPool;
125
- const isLendingPool = pool => {
126
- return pool.type === _types.YieldPoolType.LENDING;
127
- };
128
- exports.isLendingPool = isLendingPool;
@@ -1,21 +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.default = void 0;
8
- var _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
9
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
10
- // SPDX-License-Identifier: Apache-2.0
11
-
12
- class DeleteEarningData extends _Base.default {
13
- async run() {
14
- try {
15
- await this.state.dbService.deleteYieldPoolInfo(['LcDOT___acala_euphrates_liquid_staking', 'xcDOT___moonwell_lending']);
16
- } catch (e) {
17
- console.error(e);
18
- }
19
- }
20
- }
21
- exports.default = DeleteEarningData;
@@ -1,21 +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.default = void 0;
8
- var _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
9
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
10
- // SPDX-License-Identifier: Apache-2.0
11
-
12
- class EnableEarningChains extends _Base.default {
13
- async run() {
14
- try {
15
- await this.state.chainService.enableChains(['moonbeam', 'acala', 'bifrost_dot', 'interlay', 'parallel']);
16
- } catch (e) {
17
- console.error(e);
18
- }
19
- }
20
- }
21
- exports.default = EnableEarningChains;
@@ -1,17 +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.default = void 0;
8
- var _MigrateProvider = _interopRequireDefault(require("./MigrateProvider"));
9
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
10
- // SPDX-License-Identifier: Apache-2.0
11
-
12
- class MigrateEthProvider extends _MigrateProvider.default {
13
- newProvider = 'ethereum';
14
- oldProvider = 'Cloudflare';
15
- slug = 'Llamarpc';
16
- }
17
- exports.default = MigrateEthProvider;
@@ -1,17 +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.default = void 0;
8
- var _MigrateProvider = _interopRequireDefault(require("./MigrateProvider"));
9
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
10
- // SPDX-License-Identifier: Apache-2.0
11
-
12
- class MigratePioneerProvider extends _MigrateProvider.default {
13
- slug = 'pioneer';
14
- oldProvider = 'OnFinality';
15
- newProvider = 'Pioneer';
16
- }
17
- exports.default = MigratePioneerProvider;
@@ -1,29 +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.default = void 0;
8
- var _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
9
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
10
- // SPDX-License-Identifier: Apache-2.0
11
-
12
- class MigrateProvider extends _Base.default {
13
- async run() {
14
- const state = this.state;
15
- const chainState = state.getChainStateByKey(this.slug);
16
- const chainInfo = state.getChainInfo(this.slug);
17
- if (chainState && chainState.active && chainState.currentProvider === this.oldProvider) {
18
- await state.upsertChainInfo({
19
- mode: 'update',
20
- chainEditInfo: {
21
- currentProvider: this.newProvider,
22
- slug: this.slug,
23
- providers: chainInfo.providers
24
- }
25
- });
26
- }
27
- }
28
- }
29
- exports.default = MigrateProvider;
@@ -1,21 +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.default = void 0;
8
- var _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
9
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
10
- // SPDX-License-Identifier: Apache-2.0
11
-
12
- class MigrateEarningHistory extends _Base.default {
13
- async run() {
14
- try {
15
- await this.state.dbService.removeOldEarningData();
16
- } catch (e) {
17
- console.error(e);
18
- }
19
- }
20
- }
21
- exports.default = MigrateEarningHistory;
@@ -1,21 +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.default = void 0;
8
- var _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
9
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
10
- // SPDX-License-Identifier: Apache-2.0
11
-
12
- class MigrateEarningVersion extends _Base.default {
13
- async run() {
14
- try {
15
- await this.state.dbService.removeOldEarningData();
16
- } catch (e) {
17
- console.error(e);
18
- }
19
- }
20
- }
21
- exports.default = MigrateEarningVersion;
@@ -1,149 +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.default = void 0;
8
- var _utils = require("@subwallet/extension-base/utils");
9
- var _axios = _interopRequireDefault(require("axios"));
10
- var _rxjs = require("rxjs");
11
- var _constants = require("../constants");
12
- // Copyright 2019-2022 @subwallet/extension-base authors & contributors
13
- // SPDX-License-Identifier: Apache-2.0
14
-
15
- class UnlockDotCampaign {
16
- #host = _constants.MINT_HOST;
17
- #campaignId = 4;
18
- #state;
19
- #transactionNftSubject = new _rxjs.BehaviorSubject({});
20
- #transactionNftState = {};
21
- constructor(state) {
22
- this.#state = state;
23
- }
24
- async mintNft(_ref) {
25
- var _result;
26
- let {
27
- address,
28
- extrinsicHash,
29
- network,
30
- slug,
31
- transactionId
32
- } = _ref;
33
- this.#transactionNftState[transactionId] = undefined;
34
- this.#transactionNftSubject.next(this.#transactionNftState);
35
- const requestId = await this.checkMint({
36
- address,
37
- extrinsicHash,
38
- network,
39
- slug
40
- });
41
- let result;
42
- if (requestId) {
43
- result = await this.submitNft(address, requestId);
44
- await this.#state.reloadNft();
45
- // } else {
46
- // result = await this.getMinted(address, slug);
47
- }
48
-
49
- this.#transactionNftState[transactionId] = (_result = result) !== null && _result !== void 0 ? _result : {
50
- nftImage: ''
51
- };
52
- this.#transactionNftSubject.next(this.#transactionNftState);
53
- }
54
- async checkMint(_ref2) {
55
- let {
56
- address,
57
- extrinsicHash,
58
- network,
59
- slug
60
- } = _ref2;
61
- const data = {
62
- address,
63
- campaignId: this.#campaignId,
64
- category: slug,
65
- additionalData: {
66
- slug,
67
- extrinsicHash,
68
- network
69
- }
70
- };
71
- const response = await _axios.default.request({
72
- baseURL: this.#host,
73
- url: '/api/mint/check',
74
- method: 'POST',
75
- data
76
- });
77
- const respData = response.data;
78
- if (respData.inMintingTime && respData.hasBalance && respData.validCampaign && respData.validCategory && respData.validUser && respData.notDuplicated && respData.requestId && respData.requestId > 1) {
79
- return respData.requestId;
80
- }
81
- return null;
82
- }
83
- async submitNft(address, id) {
84
- const data = {
85
- requestId: id,
86
- recipient: address
87
- };
88
- const response = await _axios.default.request({
89
- baseURL: this.#host,
90
- url: '/api/mint/submit',
91
- method: 'POST',
92
- data
93
- });
94
- return response.data;
95
- }
96
-
97
- // @ts-ignore
98
- async getMinted(address, slug) {
99
- const params = {
100
- address
101
- };
102
- const response = await _axios.default.request({
103
- baseURL: this.#host,
104
- url: '/api/mint/fetch',
105
- method: 'GET',
106
- params: params
107
- });
108
- const data = response.data;
109
- for (const item of data) {
110
- if ((0, _utils.isSameAddress)(item.address, address) && slug === item.mintCategory && item.status === 'success' && item.campaignId === this.#campaignId) {
111
- return item;
112
- }
113
- }
114
- return undefined;
115
- }
116
- async canMint(address, slug, network) {
117
- const data = {
118
- address,
119
- campaignId: this.#campaignId,
120
- category: slug,
121
- additionalData: {
122
- slug,
123
- network
124
- }
125
- };
126
- const response = await _axios.default.request({
127
- baseURL: this.#host,
128
- url: '/api/mint/check',
129
- method: 'POST',
130
- data
131
- });
132
- const respData = response.data;
133
- if (respData.inMintingTime && respData.validCampaign && respData.validCategory && respData.validUser && respData.notDuplicated) {
134
- return true;
135
- }
136
- return false;
137
- }
138
- subscribeMintedNft(transactionId, cb) {
139
- return this.#transactionNftSubject.subscribe({
140
- next: map => {
141
- cb(map[transactionId]);
142
- }
143
- });
144
- }
145
- getMintedNft(transactionId) {
146
- return this.#transactionNftSubject.value[transactionId];
147
- }
148
- }
149
- exports.default = UnlockDotCampaign;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "UnlockDotCampaign", {
8
- enumerable: true,
9
- get: function () {
10
- return _UnlockDotCampaign.default;
11
- }
12
- });
13
- var _UnlockDotCampaign = _interopRequireDefault(require("./UnlockDotCampaign"));
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MINT_HOST = void 0;
7
- // Copyright 2019-2022 @polkadot/extension-base authors & contributors
8
- // SPDX-License-Identifier: Apache-2.0
9
-
10
- const MINT_HOST = process.env.NFT_MINTING_HOST || '';
11
- exports.MINT_HOST = MINT_HOST;
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _campaigns = require("./campaigns");
8
- // Copyright 2019-2022 @polkadot/extension-base authors & contributors
9
- // SPDX-License-Identifier: Apache-2.0
10
-
11
- class MintCampaignService {
12
- #state;
13
- constructor(state) {
14
- this.#state = state;
15
- this.unlockDotCampaign = new _campaigns.UnlockDotCampaign(this.#state);
16
- }
17
- }
18
- exports.default = MintCampaignService;
@@ -1,36 +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.default = void 0;
8
- var _BaseStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/BaseStore"));
9
- var _dexie = require("dexie");
10
- // Copyright 2019-2022 @subwallet/extension-base authors & contributors
11
- // SPDX-License-Identifier: Apache-2.0
12
-
13
- class YieldPoolStore extends _BaseStore.default {
14
- async getAll() {
15
- return this.table.toArray();
16
- }
17
- async getByChains(chains) {
18
- if (chains.length === 0) {
19
- return this.getAll();
20
- }
21
- return this.table.where('chain').anyOfIgnoreCase(chains).toArray();
22
- }
23
- async getByChainAndType(chain, poolType) {
24
- return this.table.where('chain').equals(chain).and(item => item.type === poolType).first();
25
- }
26
- async bulkDelete(slugs) {
27
- return this.table.bulkDelete(slugs);
28
- }
29
- async getBySlug(slug) {
30
- return this.table.get(slug);
31
- }
32
- subscribeYieldPoolInfo(chains) {
33
- return (0, _dexie.liveQuery)(() => this.getByChains(chains));
34
- }
35
- }
36
- exports.default = YieldPoolStore;
@@ -1,71 +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.default = void 0;
8
- var _BaseStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/BaseStore"));
9
- var _dexie = require("dexie");
10
- // Copyright 2019-2022 @subwallet/extension-base authors & contributors
11
- // SPDX-License-Identifier: Apache-2.0
12
-
13
- class YieldPositionStore extends _BaseStore.default {
14
- async getAll() {
15
- return this.table
16
- // .filter((item) => {
17
- // let isValidLiquidStaking = false;
18
- //
19
- // if (item.type === YieldPoolType.LIQUID_STAKING) {
20
- // const nominatorMetadata = item.metadata as NominatorMetadata;
21
- //
22
- // if (nominatorMetadata.unstakings.length > 0) {
23
- // console.log('true', item);
24
- // isValidLiquidStaking = true;
25
- // }
26
- // }
27
- //
28
- // return parseInt(item.balance[0].activeBalance) > 0 || isValidLiquidStaking;
29
- // })
30
- .toArray();
31
- }
32
- async getByAddress(addresses) {
33
- if (addresses.length === 0) {
34
- return this.getAll();
35
- }
36
- return this.table.where('address').anyOfIgnoreCase(addresses)
37
- // .filter((item) => {
38
- // let isValidLiquidStaking = false;
39
- //
40
- // if (item.type === YieldPoolType.LIQUID_STAKING) {
41
- // const nominatorMetadata = item.metadata as NominatorMetadata;
42
- //
43
- // if (nominatorMetadata && nominatorMetadata?.unstakings?.length > 0) {
44
- // isValidLiquidStaking = true;
45
- // }
46
- // }
47
- //
48
- // return parseInt(item.balance[0].activeBalance) > 0 || isValidLiquidStaking;
49
- // })
50
- .toArray();
51
- }
52
- removeByAddresses(addresses) {
53
- return this.table.where('address').anyOf(addresses).delete();
54
- }
55
- removeByChains(chains) {
56
- return this.table.where('chain').anyOf(chains).delete();
57
- }
58
- async getByAddressAndChains(addresses, chains) {
59
- return this.table.where('address').anyOfIgnoreCase(addresses).filter(item => chains.includes(item.chain)).toArray();
60
- }
61
- getByAddressAndSlug(address, slug) {
62
- return this.table.get({
63
- address,
64
- slug
65
- });
66
- }
67
- subscribeYieldPositions(addresses) {
68
- return (0, _dexie.liveQuery)(() => this.getByAddress(addresses));
69
- }
70
- }
71
- exports.default = YieldPositionStore;