@subwallet/extension-base 1.1.28-beta.1 → 1.1.30-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 (292) hide show
  1. package/background/KoniTypes.d.ts +70 -93
  2. package/background/KoniTypes.js +14 -16
  3. package/background/errors/TransactionError.js +4 -9
  4. package/cjs/background/KoniTypes.js +17 -17
  5. package/cjs/background/errors/TransactionError.js +4 -9
  6. package/cjs/constants/index.js +3 -9
  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 +15 -17
  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 +5 -6
  18. package/cjs/koni/api/staking/relayChain.js +2 -3
  19. package/cjs/koni/background/cron.js +0 -2
  20. package/cjs/koni/background/handlers/Extension.js +88 -326
  21. package/cjs/koni/background/handlers/State.js +3 -51
  22. package/cjs/koni/background/handlers/index.js +2 -4
  23. package/cjs/koni/background/subscription.js +18 -88
  24. package/cjs/packageInfo.js +1 -1
  25. package/cjs/services/campaign-service/index.js +6 -9
  26. package/cjs/services/chain-service/constants.js +16 -2
  27. package/cjs/services/chain-service/utils.js +1 -7
  28. package/cjs/services/event-service/index.js +0 -4
  29. package/cjs/services/keyring-service/index.js +2 -14
  30. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  31. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  32. package/cjs/services/migration-service/scripts/index.js +0 -4
  33. package/cjs/services/notification-service/NotificationService.js +1 -1
  34. package/cjs/services/storage-service/DatabaseService.js +0 -47
  35. package/cjs/services/storage-service/databases/index.js +0 -4
  36. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  37. package/cjs/services/transaction-service/event-parser/index.js +0 -58
  38. package/cjs/services/transaction-service/helpers/index.js +1 -3
  39. package/cjs/services/transaction-service/index.js +74 -180
  40. package/cjs/services/transaction-service/utils.js +0 -1
  41. package/cjs/types/index.js +0 -44
  42. package/cjs/utils/fetchStaticData.js +1 -2
  43. package/cjs/utils/index.js +1 -89
  44. package/constants/index.d.ts +0 -2
  45. package/constants/index.js +0 -2
  46. package/koni/api/nft/config.js +23 -33
  47. package/koni/api/nft/index.js +1 -15
  48. package/koni/api/nft/nft.js +23 -2
  49. package/koni/api/staking/bonding/amplitude.js +9 -11
  50. package/koni/api/staking/bonding/astar.js +8 -9
  51. package/koni/api/staking/bonding/index.d.ts +1 -1
  52. package/koni/api/staking/bonding/index.js +1 -5
  53. package/koni/api/staking/bonding/paraChain.js +10 -12
  54. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  55. package/koni/api/staking/bonding/relayChain.js +30 -33
  56. package/koni/api/staking/bonding/utils.d.ts +38 -15
  57. package/koni/api/staking/bonding/utils.js +69 -85
  58. package/koni/api/staking/index.js +1 -2
  59. package/koni/api/staking/paraChain.js +6 -7
  60. package/koni/api/staking/relayChain.js +3 -4
  61. package/koni/background/cron.js +0 -2
  62. package/koni/background/handlers/Extension.d.ts +1 -14
  63. package/koni/background/handlers/Extension.js +50 -286
  64. package/koni/background/handlers/State.d.ts +2 -18
  65. package/koni/background/handlers/State.js +3 -50
  66. package/koni/background/handlers/index.js +2 -4
  67. package/koni/background/subscription.d.ts +1 -5
  68. package/koni/background/subscription.js +20 -90
  69. package/package.json +8 -311
  70. package/packageInfo.js +1 -1
  71. package/services/campaign-service/index.js +6 -9
  72. package/services/chain-service/constants.d.ts +11 -0
  73. package/services/chain-service/constants.js +14 -1
  74. package/services/chain-service/utils.d.ts +0 -1
  75. package/services/chain-service/utils.js +1 -5
  76. package/services/event-service/index.d.ts +0 -1
  77. package/services/event-service/index.js +0 -4
  78. package/services/event-service/types.d.ts +0 -8
  79. package/services/keyring-service/index.d.ts +1 -2
  80. package/services/keyring-service/index.js +2 -14
  81. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  82. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  83. package/services/migration-service/scripts/index.js +0 -4
  84. package/services/notification-service/NotificationService.js +1 -1
  85. package/services/storage-service/DatabaseService.d.ts +1 -17
  86. package/services/storage-service/DatabaseService.js +0 -47
  87. package/services/storage-service/databases/index.d.ts +1 -3
  88. package/services/storage-service/databases/index.js +0 -4
  89. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  90. package/services/subscan-service/index.d.ts +2 -2
  91. package/services/transaction-service/event-parser/index.d.ts +1 -3
  92. package/services/transaction-service/event-parser/index.js +1 -57
  93. package/services/transaction-service/helpers/index.js +1 -3
  94. package/services/transaction-service/index.d.ts +15 -4
  95. package/services/transaction-service/index.js +72 -178
  96. package/services/transaction-service/types.d.ts +0 -2
  97. package/services/transaction-service/utils.js +0 -1
  98. package/types/index.d.ts +0 -5
  99. package/types/index.js +1 -5
  100. package/utils/fetchStaticData.js +1 -2
  101. package/utils/index.d.ts +0 -5
  102. package/utils/index.js +1 -53
  103. package/cjs/koni/api/dotsama/balance.js +0 -464
  104. package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
  105. package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
  106. package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
  107. package/cjs/koni/api/yield/helper/utils.js +0 -46
  108. package/cjs/services/earning-service/constants/chains.js +0 -29
  109. package/cjs/services/earning-service/constants/index.js +0 -27
  110. package/cjs/services/earning-service/constants/step.js +0 -18
  111. package/cjs/services/earning-service/handlers/base.js +0 -202
  112. package/cjs/services/earning-service/handlers/index.js +0 -60
  113. package/cjs/services/earning-service/handlers/lending/base.js +0 -20
  114. package/cjs/services/earning-service/handlers/lending/index.js +0 -13
  115. package/cjs/services/earning-service/handlers/lending/interlay.js +0 -168
  116. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -196
  117. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -39
  118. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -257
  119. package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
  120. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -180
  121. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -373
  122. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -359
  123. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -426
  124. package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -137
  125. package/cjs/services/earning-service/handlers/native-staking/base.js +0 -109
  126. package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
  127. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -361
  128. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -512
  129. package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -501
  130. package/cjs/services/earning-service/handlers/special.js +0 -387
  131. package/cjs/services/earning-service/service.js +0 -327
  132. package/cjs/services/earning-service/utils/index.js +0 -111
  133. package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
  134. package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
  135. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
  136. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
  137. package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
  138. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
  139. package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
  140. package/cjs/services/mint-campaign-service/constants.js +0 -11
  141. package/cjs/services/mint-campaign-service/index.js +0 -18
  142. package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
  143. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -65
  144. package/cjs/services/storage-service/index.js +0 -241
  145. package/cjs/types/campaigns/index.js +0 -16
  146. package/cjs/types/campaigns/unlock-dot.js +0 -1
  147. package/cjs/types/ordinal.js +0 -1
  148. package/cjs/types/transaction.js +0 -1
  149. package/cjs/types/yield/actions/index.js +0 -27
  150. package/cjs/types/yield/actions/join/index.js +0 -38
  151. package/cjs/types/yield/actions/join/step.js +0 -37
  152. package/cjs/types/yield/actions/join/submit.js +0 -1
  153. package/cjs/types/yield/actions/join/validate.js +0 -16
  154. package/cjs/types/yield/actions/others.js +0 -1
  155. package/cjs/types/yield/index.js +0 -27
  156. package/cjs/types/yield/info/account/index.js +0 -49
  157. package/cjs/types/yield/info/account/info.js +0 -1
  158. package/cjs/types/yield/info/account/reward.js +0 -1
  159. package/cjs/types/yield/info/account/target.js +0 -32
  160. package/cjs/types/yield/info/account/unstake.js +0 -27
  161. package/cjs/types/yield/info/base.js +0 -34
  162. package/cjs/types/yield/info/chain/index.js +0 -27
  163. package/cjs/types/yield/info/chain/info.js +0 -1
  164. package/cjs/types/yield/info/chain/target.js +0 -1
  165. package/cjs/types/yield/info/index.js +0 -49
  166. package/cjs/types/yield/info/pallet.js +0 -15
  167. package/cjs/types.js +0 -1
  168. package/cjs/utils/address.js +0 -34
  169. package/cjs/utils/keyring.js +0 -57
  170. package/cjs/utils/object.js +0 -12
  171. package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
  172. package/koni/api/nft/ordinal_nft/constants.js +0 -12
  173. package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
  174. package/koni/api/nft/ordinal_nft/index.js +0 -114
  175. package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
  176. package/koni/api/nft/ordinal_nft/utils.js +0 -33
  177. package/koni/api/yield/helper/utils.d.ts +0 -10
  178. package/koni/api/yield/helper/utils.js +0 -32
  179. package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
  180. package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
  181. package/services/earning-service/constants/chains.d.ts +0 -14
  182. package/services/earning-service/constants/chains.js +0 -21
  183. package/services/earning-service/constants/index.d.ts +0 -2
  184. package/services/earning-service/constants/index.js +0 -5
  185. package/services/earning-service/constants/step.d.ts +0 -3
  186. package/services/earning-service/constants/step.js +0 -10
  187. package/services/earning-service/handlers/base.d.ts +0 -105
  188. package/services/earning-service/handlers/base.js +0 -195
  189. package/services/earning-service/handlers/index.d.ts +0 -5
  190. package/services/earning-service/handlers/index.js +0 -8
  191. package/services/earning-service/handlers/lending/base.d.ts +0 -6
  192. package/services/earning-service/handlers/lending/base.js +0 -12
  193. package/services/earning-service/handlers/lending/index.d.ts +0 -1
  194. package/services/earning-service/handlers/lending/index.js +0 -4
  195. package/services/earning-service/handlers/lending/interlay.d.ts +0 -22
  196. package/services/earning-service/handlers/lending/interlay.js +0 -160
  197. package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
  198. package/services/earning-service/handlers/liquid-staking/acala.js +0 -188
  199. package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -8
  200. package/services/earning-service/handlers/liquid-staking/base.js +0 -31
  201. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -44
  202. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -246
  203. package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
  204. package/services/earning-service/handlers/liquid-staking/index.js +0 -7
  205. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -27
  206. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -172
  207. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -36
  208. package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -363
  209. package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
  210. package/services/earning-service/handlers/native-staking/amplitude.js +0 -350
  211. package/services/earning-service/handlers/native-staking/astar.d.ts +0 -18
  212. package/services/earning-service/handlers/native-staking/astar.js +0 -416
  213. package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
  214. package/services/earning-service/handlers/native-staking/base-para.js +0 -129
  215. package/services/earning-service/handlers/native-staking/base.d.ts +0 -19
  216. package/services/earning-service/handlers/native-staking/base.js +0 -101
  217. package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
  218. package/services/earning-service/handlers/native-staking/index.js +0 -7
  219. package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
  220. package/services/earning-service/handlers/native-staking/para-chain.js +0 -353
  221. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
  222. package/services/earning-service/handlers/native-staking/relay-chain.js +0 -503
  223. package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -33
  224. package/services/earning-service/handlers/nomination-pool/index.js +0 -492
  225. package/services/earning-service/handlers/special.d.ts +0 -56
  226. package/services/earning-service/handlers/special.js +0 -379
  227. package/services/earning-service/service.d.ts +0 -36
  228. package/services/earning-service/service.js +0 -320
  229. package/services/earning-service/utils/index.d.ts +0 -14
  230. package/services/earning-service/utils/index.js +0 -100
  231. package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
  232. package/services/migration-service/scripts/DeleteEarningData.js +0 -13
  233. package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
  234. package/services/migration-service/scripts/EnableEarningChains.js +0 -13
  235. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
  236. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
  237. package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
  238. package/services/mint-campaign-service/campaigns/index.js +0 -4
  239. package/services/mint-campaign-service/constants.d.ts +0 -1
  240. package/services/mint-campaign-service/constants.js +0 -4
  241. package/services/mint-campaign-service/index.d.ts +0 -7
  242. package/services/mint-campaign-service/index.js +0 -11
  243. package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
  244. package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
  245. package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -9
  246. package/services/storage-service/db-stores/YieldPositionStore.js +0 -57
  247. package/types/campaigns/index.d.ts +0 -1
  248. package/types/campaigns/index.js +0 -4
  249. package/types/campaigns/unlock-dot.d.ts +0 -71
  250. package/types/campaigns/unlock-dot.js +0 -1
  251. package/types/ordinal.d.ts +0 -69
  252. package/types/ordinal.js +0 -1
  253. package/types/transaction.d.ts +0 -3
  254. package/types/transaction.js +0 -1
  255. package/types/yield/actions/index.d.ts +0 -2
  256. package/types/yield/actions/index.js +0 -5
  257. package/types/yield/actions/join/index.d.ts +0 -3
  258. package/types/yield/actions/join/index.js +0 -6
  259. package/types/yield/actions/join/step.d.ts +0 -75
  260. package/types/yield/actions/join/step.js +0 -34
  261. package/types/yield/actions/join/submit.d.ts +0 -53
  262. package/types/yield/actions/join/submit.js +0 -1
  263. package/types/yield/actions/join/validate.d.ts +0 -18
  264. package/types/yield/actions/join/validate.js +0 -10
  265. package/types/yield/actions/others.d.ts +0 -60
  266. package/types/yield/actions/others.js +0 -1
  267. package/types/yield/index.d.ts +0 -2
  268. package/types/yield/index.js +0 -5
  269. package/types/yield/info/account/index.d.ts +0 -4
  270. package/types/yield/info/account/index.js +0 -7
  271. package/types/yield/info/account/info.d.ts +0 -112
  272. package/types/yield/info/account/info.js +0 -1
  273. package/types/yield/info/account/reward.d.ts +0 -41
  274. package/types/yield/info/account/reward.js +0 -1
  275. package/types/yield/info/account/target.d.ts +0 -43
  276. package/types/yield/info/account/target.js +0 -27
  277. package/types/yield/info/account/unstake.d.ts +0 -31
  278. package/types/yield/info/account/unstake.js +0 -22
  279. package/types/yield/info/base.d.ts +0 -28
  280. package/types/yield/info/base.js +0 -28
  281. package/types/yield/info/chain/index.d.ts +0 -2
  282. package/types/yield/info/chain/index.js +0 -5
  283. package/types/yield/info/chain/info.d.ts +0 -190
  284. package/types/yield/info/chain/info.js +0 -1
  285. package/types/yield/info/chain/target.d.ts +0 -33
  286. package/types/yield/info/chain/target.js +0 -1
  287. package/types/yield/info/index.d.ts +0 -4
  288. package/types/yield/info/index.js +0 -7
  289. package/types/yield/info/pallet.d.ts +0 -143
  290. package/types/yield/info/pallet.js +0 -9
  291. package/utils/object.d.ts +0 -1
  292. package/utils/object.js +0 -6
@@ -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,65 +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
- async getByAddressAndChains(addresses, chains) {
53
- return this.table.where('address').anyOfIgnoreCase(addresses).filter(item => chains.includes(item.chain)).toArray();
54
- }
55
- getByAddressAndSlug(address, slug) {
56
- return this.table.get({
57
- address,
58
- slug
59
- });
60
- }
61
- subscribeYieldPositions(addresses) {
62
- return (0, _dexie.liveQuery)(() => this.getByAddress(addresses));
63
- }
64
- }
65
- exports.default = YieldPositionStore;
@@ -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,37 +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 OptimalYieldPathParams
11
- * @description Params to generate steps
12
- * */
13
- /**
14
- * @enum {string}
15
- * @description Type of join yield step
16
- * */
17
- let YieldStepType;
18
- /**
19
- * @interface BaseYieldStepDetail
20
- * @description Base info of a step
21
- * @prop {string} name - Step's name
22
- * @prop {YieldStepType} type - Step's type
23
- * @prop {Record<string,unknown>} [metadata] - Metadata for generating extrinsic
24
- * */
25
- exports.YieldStepType = YieldStepType;
26
- (function (YieldStepType) {
27
- YieldStepType["DEFAULT"] = "DEFAULT";
28
- YieldStepType["XCM"] = "XCM";
29
- YieldStepType["NOMINATE"] = "NOMINATE";
30
- YieldStepType["JOIN_NOMINATION_POOL"] = "JOIN_NOMINATION_POOL";
31
- YieldStepType["MINT_VDOT"] = "MINT_VDOT";
32
- YieldStepType["MINT_LDOT"] = "MINT_LDOT";
33
- YieldStepType["MINT_QDOT"] = "MINT_QDOT";
34
- YieldStepType["MINT_SDOT"] = "MINT_SDOT";
35
- YieldStepType["MINT_STDOT"] = "MINT_STDOT";
36
- YieldStepType["TOKEN_APPROVAL"] = "TOKEN_APPROVAL";
37
- })(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 = {}));