@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,241 +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.DatabaseService = void 0;
8
- var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
9
- var _databases = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/databases"));
10
- var _dbStores = require("@subwallet/extension-base/services/storage-service/db-stores");
11
- var _ChainStakingMetadata = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/ChainStakingMetadata"));
12
- var _NominatorMetadata = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata"));
13
- var _utils = require("@subwallet/extension-base/utils");
14
- var _util = require("@polkadot/util");
15
- // Copyright 2019-2022 @subwallet/extension-base authors & contributors
16
- // SPDX-License-Identifier: Apache-2.0
17
-
18
- class DatabaseService {
19
- // TODO: might remove this
20
-
21
- constructor(eventService) {
22
- this.eventService = eventService;
23
- this.logger = (0, _util.logger)('DB-Service');
24
- this._db = new _databases.default();
25
- this._db.on('ready', () => {
26
- this.eventService.emit('database.ready', true);
27
- });
28
- this.stores = {
29
- price: new _dbStores.PriceStore(this._db.price),
30
- balance: new _dbStores.BalanceStore(this._db.balances),
31
- nft: new _dbStores.NftStore(this._db.nfts),
32
- nftCollection: new _dbStores.NftCollectionStore(this._db.nftCollections),
33
- crowdloan: new _dbStores.CrowdloanStore(this._db.crowdloans),
34
- staking: new _dbStores.StakingStore(this._db.stakings),
35
- transaction: new _dbStores.TransactionStore(this._db.transactions),
36
- migration: new _dbStores.MigrationStore(this._db.migrations),
37
- metadata: new _dbStores.MetadataStore(this._db.metadata),
38
- chain: new _dbStores.ChainStore(this._db.chain),
39
- asset: new _dbStores.AssetStore(this._db.asset),
40
- // staking
41
- chainStakingMetadata: new _ChainStakingMetadata.default(this._db.chainStakingMetadata),
42
- nominatorMetadata: new _NominatorMetadata.default(this._db.nominatorMetadata)
43
- };
44
- }
45
- async updatePriceStore(priceData) {
46
- await this.stores.price.table.put(priceData);
47
- }
48
- async getPriceStore() {
49
- try {
50
- const rs = await this.stores.price.table.get('usd');
51
- return rs;
52
- } catch (e) {
53
- this.logger.error(e);
54
- return undefined;
55
- }
56
- }
57
-
58
- // Balance
59
- async getStoredBalance() {
60
- return this.stores.balance.table.toArray();
61
- }
62
- async updateBalanceStore(address, item) {
63
- if (item.state === _KoniTypes.APIItemState.READY) {
64
- return this.stores.balance.upsert({
65
- address,
66
- ...item
67
- });
68
- }
69
- }
70
- async removeFromBalanceStore(assets) {
71
- return this.stores.balance.removeBySlugs(assets);
72
- }
73
-
74
- // Crowdloan
75
- async updateCrowdloanStore(chain, address, item) {
76
- if (item.state === _KoniTypes.APIItemState.READY && item.contribute !== '0') {
77
- return this.stores.crowdloan.upsert({
78
- chain,
79
- address,
80
- ...item
81
- });
82
- } else {
83
- return this.stores.crowdloan.deleteByChainAndAddress(chain, address);
84
- }
85
- }
86
-
87
- // Staking
88
- async updateStaking(chain, address, item) {
89
- if (item.state === _KoniTypes.APIItemState.READY) {
90
- return this.stores.staking.upsert(item);
91
- }
92
- }
93
- async getStakings(addresses, chains) {
94
- return this.stores.staking.getStakings(addresses, chains);
95
- }
96
- async getStakingsByChains(chains) {
97
- return this.stores.staking.getStakingsByChains(chains);
98
- }
99
- async getPooledStakings(addresses, chainHashes) {
100
- return this.stores.staking.getPooledStakings(addresses, chainHashes);
101
- }
102
- subscribeStaking(addresses, chainList, callback) {
103
- this.stakingSubscription && this.stakingSubscription.unsubscribe();
104
- this.stakingSubscription = this.stores.staking.subscribeStaking(addresses, chainList).subscribe({
105
- next: stakings => callback && callback(stakings)
106
- });
107
- return this.stakingSubscription;
108
- }
109
- subscribeChainStakingMetadata(chains, callback) {
110
- this.stores.chainStakingMetadata.subscribeByChain(chains).subscribe({
111
- next: data => callback && callback(data)
112
- });
113
- }
114
- subscribeNominatorMetadata(addresses, callback) {
115
- return this.stores.nominatorMetadata.subscribeByAddresses(addresses).subscribe({
116
- next: data => callback && callback(data)
117
- });
118
- }
119
-
120
- // Transaction histories
121
- async getHistories(query) {
122
- return this.stores.transaction.queryHistory(query);
123
- }
124
- async upsertHistory(histories) {
125
- const cleanedHistory = histories.filter(x => x && x.address && x.chain && x.extrinsicHash);
126
- return this.stores.transaction.bulkUpsert(cleanedHistory);
127
- }
128
- async updateHistoryByExtrinsicHash(extrinsicHash, updateData) {
129
- const canUpdate = updateData && extrinsicHash;
130
- if (!canUpdate) {
131
- return;
132
- }
133
- return this.stores.transaction.updateWithQuery({
134
- extrinsicHash
135
- }, updateData);
136
- }
137
-
138
- // NFT Collection
139
- async addNftCollection(collection) {
140
- return this.stores.nftCollection.upsert(collection);
141
- }
142
- async deleteNftCollection(chain, collectionId) {
143
- await this.stores.nftCollection.removeCollection(chain, collectionId);
144
- await this.stores.nft.deleteNftsByCollection(chain, collectionId);
145
- }
146
- getAllNftCollection(chainHashes) {
147
- return this.stores.nftCollection.getNftCollection(chainHashes);
148
- }
149
-
150
- // NFT
151
- subscribeNft(addresses, chainHashes, callback) {
152
- this.nftSubscription && this.nftSubscription.unsubscribe();
153
- this.nftSubscription = this.stores.nft.subscribeNft(addresses, chainHashes).subscribe({
154
- next: nfts => callback && callback(nfts)
155
- });
156
- return this.nftSubscription;
157
- }
158
- async cleanUpNft(chain, owner, collectionIds, nftIds, ownNothing) {
159
- if (ownNothing) {
160
- return this.stores.nft.deleteNftsByChainAndOwner(chain, (0, _utils.reformatAddress)(owner, 42), collectionIds);
161
- }
162
- return this.stores.nft.cleanUpNfts(chain, (0, _utils.reformatAddress)(owner, 42), collectionIds, nftIds);
163
- }
164
- async getNft(addresses, chainHashes) {
165
- return this.stores.nft.getNft(addresses, chainHashes);
166
- }
167
- async addNft(address, nft) {
168
- return this.stores.nft.upsert({
169
- ...nft,
170
- address
171
- });
172
- }
173
- handleNftTransfer(chain, addresses, nftItem) {
174
- return this.stores.nft.deleteNftItem(chain, addresses, nftItem);
175
- }
176
- removeNfts(chain, address, collectionId, nftIds) {
177
- return this.stores.nft.removeNfts(chain, address, collectionId, nftIds);
178
- }
179
-
180
- // Chain
181
- async updateChainStore(item) {
182
- return this.stores.chain.upsert(item);
183
- }
184
- async bulkUpdateChainStore(data) {
185
- return this.stores.chain.bulkUpsert(data);
186
- }
187
- async removeFromChainStore(chains) {
188
- return this.stores.chain.removeChains(chains);
189
- }
190
- async getAllChainStore() {
191
- return this.stores.chain.getAll();
192
- }
193
-
194
- // Asset
195
- async updateAssetStore(item) {
196
- return this.stores.asset.upsert(item);
197
- }
198
- async getAllAssetStore() {
199
- return this.stores.asset.getAll();
200
- }
201
- async removeFromAssetStore(items) {
202
- return this.stores.asset.removeAssets(items);
203
- }
204
-
205
- // Staking
206
- async updateChainStakingMetadata(item, changes) {
207
- const existingRecord = await this.stores.chainStakingMetadata.getByChainAndType(item.chain, item.type);
208
- if (existingRecord && changes) {
209
- return this.stores.chainStakingMetadata.updateByChainAndType(item.chain, item.type, changes);
210
- }
211
- return this.stores.chainStakingMetadata.upsert(item);
212
- }
213
- async getChainStakingMetadata() {
214
- return this.stores.chainStakingMetadata.getAll();
215
- }
216
- async getStakingMetadataByChain(chain) {
217
- let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _KoniTypes.StakingType.NOMINATED;
218
- return this.stores.chainStakingMetadata.getByChainAndType(chain, type);
219
- }
220
- async updateNominatorMetadata(item) {
221
- return this.stores.nominatorMetadata.upsert(item);
222
- }
223
- async getNominatorMetadata() {
224
- return this.stores.nominatorMetadata.getAll();
225
- }
226
- async resetWallet(resetAll) {
227
- return new Promise((resolve, reject) => {
228
- const stores = [this.stores.balance, this.stores.nft, this.stores.nftCollection, this.stores.crowdloan, this.stores.staking, this.stores.transaction, this.stores.nominatorMetadata];
229
- if (resetAll) {
230
- stores.push(this.stores.chain, this.stores.asset);
231
- }
232
- const promises = stores.map(store => store.clear());
233
- Promise.all(promises).then(() => {
234
- resolve();
235
- }).catch(e => {
236
- reject(e);
237
- });
238
- });
239
- }
240
- }
241
- exports.DatabaseService = DatabaseService;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _unlockDot = require("./unlock-dot");
7
- Object.keys(_unlockDot).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _unlockDot[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _unlockDot[key];
14
- }
15
- });
16
- });
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _join = require("./join");
7
- Object.keys(_join).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _join[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _join[key];
14
- }
15
- });
16
- });
17
- var _others = require("./others");
18
- Object.keys(_others).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _others[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _others[key];
25
- }
26
- });
27
- });
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _step = require("./step");
7
- Object.keys(_step).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _step[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _step[key];
14
- }
15
- });
16
- });
17
- var _submit = require("./submit");
18
- Object.keys(_submit).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _submit[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _submit[key];
25
- }
26
- });
27
- });
28
- var _validate = require("./validate");
29
- Object.keys(_validate).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _validate[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _validate[key];
36
- }
37
- });
38
- });
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.YieldStepType = void 0;
7
- // Copyright 2019-2022 @subwallet/extension-base
8
- // SPDX-License-Identifier: Apache-2.0
9
- /**
10
- * @interface RequestEarlyValidateYield
11
- * @description Params to early validate join pool
12
- * @prop {string} slug - Pool's slug
13
- * @prop {string} address - Account's address
14
- * */
15
- /**
16
- * @interface ResponseEarlyValidateYield
17
- * @prop {boolean} passed - Passed validate
18
- * */
19
- /**
20
- * @interface OptimalYieldPathParams
21
- * @description Params to generate steps
22
- * */
23
- /**
24
- * @enum {string}
25
- * @description Type of join yield step
26
- * */
27
- let YieldStepType;
28
- /**
29
- * @interface BaseYieldStepDetail
30
- * @description Base info of a step
31
- * @prop {string} name - Step's name
32
- * @prop {YieldStepType} type - Step's type
33
- * @prop {Record<string,unknown>} [metadata] - Metadata for generating extrinsic
34
- * */
35
- exports.YieldStepType = YieldStepType;
36
- (function (YieldStepType) {
37
- YieldStepType["DEFAULT"] = "DEFAULT";
38
- YieldStepType["XCM"] = "XCM";
39
- YieldStepType["NOMINATE"] = "NOMINATE";
40
- YieldStepType["JOIN_NOMINATION_POOL"] = "JOIN_NOMINATION_POOL";
41
- YieldStepType["MINT_VDOT"] = "MINT_VDOT";
42
- YieldStepType["MINT_LDOT"] = "MINT_LDOT";
43
- YieldStepType["MINT_QDOT"] = "MINT_QDOT";
44
- YieldStepType["MINT_SDOT"] = "MINT_SDOT";
45
- YieldStepType["MINT_STDOT"] = "MINT_STDOT";
46
- YieldStepType["TOKEN_APPROVAL"] = "TOKEN_APPROVAL";
47
- })(YieldStepType || (exports.YieldStepType = YieldStepType = {}));
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.YieldValidationStatus = void 0;
7
- // Copyright 2019-2022 @subwallet/extension-base
8
- // SPDX-License-Identifier: Apache-2.0
9
- let YieldValidationStatus;
10
- exports.YieldValidationStatus = YieldValidationStatus;
11
- (function (YieldValidationStatus) {
12
- YieldValidationStatus["NOT_ENOUGH_FEE"] = "NOT_ENOUGH_FEE";
13
- YieldValidationStatus["NOT_ENOUGH_BALANCE"] = "NOT_ENOUGH_BALANCE";
14
- YieldValidationStatus["NOT_ENOUGH_MIN_JOIN_POOL"] = "NOT_ENOUGH_MIN_JOIN_POOL";
15
- YieldValidationStatus["OK"] = "OK";
16
- })(YieldValidationStatus || (exports.YieldValidationStatus = YieldValidationStatus = {}));
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _info = require("./info");
7
- Object.keys(_info).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _info[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _info[key];
14
- }
15
- });
16
- });
17
- var _actions = require("./actions");
18
- Object.keys(_actions).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _actions[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _actions[key];
25
- }
26
- });
27
- });
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _info = require("./info");
7
- Object.keys(_info).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _info[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _info[key];
14
- }
15
- });
16
- });
17
- var _reward = require("./reward");
18
- Object.keys(_reward).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _reward[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _reward[key];
25
- }
26
- });
27
- });
28
- var _target = require("./target");
29
- Object.keys(_target).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _target[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _target[key];
36
- }
37
- });
38
- });
39
- var _unstake = require("./unstake");
40
- Object.keys(_unstake).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _unstake[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _unstake[key];
47
- }
48
- });
49
- });
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.EarningStatus = void 0;
7
- // Copyright 2019-2022 @subwallet/extension-base
8
- // SPDX-License-Identifier: Apache-2.0
9
- /**
10
- * @enum {string}
11
- * @description The earning status of an account in a pool.
12
- * */
13
- let EarningStatus;
14
- /**
15
- * @interface NominationInfo
16
- * @description Info of the validator account joined
17
- * @prop {string} chain - Slug of chain
18
- * @prop {string} validatorAddress - Validator's address or nomination pool's id
19
- * @prop {string} [validatorIdentity] - Validator's identity
20
- * @prop {string} activeStake - Active staked value
21
- * @prop {boolean} [hasUnstaking] - Does the account have unstake request with validator?
22
- * @prop {string} [validatorMinStake] - Min amount to join with validator
23
- * @prop {EarningStatus} status - The staking status of the account
24
- * */
25
- exports.EarningStatus = EarningStatus;
26
- (function (EarningStatus) {
27
- EarningStatus["EARNING_REWARD"] = "EARNING_REWARD";
28
- EarningStatus["PARTIALLY_EARNING"] = "PARTIALLY_EARNING";
29
- EarningStatus["NOT_EARNING"] = "NOT_EARNING";
30
- EarningStatus["WAITING"] = "WAITING";
31
- EarningStatus["NOT_STAKING"] = "NOT_STAKING";
32
- })(EarningStatus || (exports.EarningStatus = EarningStatus = {}));
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.UnstakingStatus = void 0;
7
- // Copyright 2019-2022 @subwallet/extension-base
8
- // SPDX-License-Identifier: Apache-2.0
9
- /**
10
- * @enum {string}
11
- * @description The status of un-staked request.
12
- * */
13
- let UnstakingStatus;
14
- /**
15
- * @interface UnstakingInfo
16
- * @description Info of un-stake request
17
- * @prop {string} chain - Slug of chain
18
- * @prop {UnstakingStatus} status - Status of request
19
- * @prop {string} claimable - Amount to be withdrawn
20
- * @prop {number} [waitingTime] - Time remains to wait (in hours)
21
- * @prop {string} [validatorAddress] - Address of validator
22
- * */
23
- exports.UnstakingStatus = UnstakingStatus;
24
- (function (UnstakingStatus) {
25
- UnstakingStatus["CLAIMABLE"] = "CLAIMABLE";
26
- UnstakingStatus["UNLOCKING"] = "UNLOCKING";
27
- })(UnstakingStatus || (exports.UnstakingStatus = UnstakingStatus = {}));
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.YieldPoolType = exports.YieldCompoundingPeriod = void 0;
7
- // Copyright 2019-2022 @subwallet/extension-base
8
- // SPDX-License-Identifier: Apache-2.0
9
- /**
10
- * @enum {string}
11
- * @description The types of yield pool.
12
- * */
13
- let YieldPoolType;
14
- /**
15
- * @enum {number}
16
- * @description Time to calculate profit
17
- * */
18
- exports.YieldPoolType = YieldPoolType;
19
- (function (YieldPoolType) {
20
- YieldPoolType["LIQUID_STAKING"] = "LIQUID_STAKING";
21
- YieldPoolType["LENDING"] = "LENDING";
22
- YieldPoolType["SINGLE_FARMING"] = "SINGLE_FARMING";
23
- YieldPoolType["NOMINATION_POOL"] = "NOMINATION_POOL";
24
- YieldPoolType["NATIVE_STAKING"] = "NATIVE_STAKING";
25
- YieldPoolType["PARACHAIN_STAKING"] = "PARACHAIN_STAKING";
26
- })(YieldPoolType || (exports.YieldPoolType = YieldPoolType = {}));
27
- let YieldCompoundingPeriod;
28
- /**
29
- * @interface BasePoolInfo
30
- * @prop {string} slug - Pool's slug
31
- * @prop {string} chain - Pool's chain
32
- * @prop {string} type - Pool's type
33
- * @prop {string} group - Pool's group (by token)
34
- * */
35
- exports.YieldCompoundingPeriod = YieldCompoundingPeriod;
36
- (function (YieldCompoundingPeriod) {
37
- YieldCompoundingPeriod[YieldCompoundingPeriod["DAILY"] = 1] = "DAILY";
38
- YieldCompoundingPeriod[YieldCompoundingPeriod["WEEKLY"] = 7] = "WEEKLY";
39
- YieldCompoundingPeriod[YieldCompoundingPeriod["MONTHLY"] = 30] = "MONTHLY";
40
- YieldCompoundingPeriod[YieldCompoundingPeriod["YEARLY"] = 365] = "YEARLY";
41
- })(YieldCompoundingPeriod || (exports.YieldCompoundingPeriod = YieldCompoundingPeriod = {}));
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _info = require("./info");
7
- Object.keys(_info).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _info[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _info[key];
14
- }
15
- });
16
- });
17
- var _target = require("./target");
18
- Object.keys(_target).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _target[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _target[key];
25
- }
26
- });
27
- });
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _account = require("./account");
7
- Object.keys(_account).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _account[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _account[key];
14
- }
15
- });
16
- });
17
- var _base = require("./base");
18
- Object.keys(_base).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _base[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _base[key];
25
- }
26
- });
27
- });
28
- var _chain = require("./chain");
29
- Object.keys(_chain).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _chain[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _chain[key];
36
- }
37
- });
38
- });
39
- var _pallet = require("./pallet");
40
- Object.keys(_pallet).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _pallet[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _pallet[key];
47
- }
48
- });
49
- });