@subwallet/extension-base 1.1.31-1 → 1.1.31-beta.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 (305) hide show
  1. package/background/KoniTypes.d.ts +111 -69
  2. package/background/KoniTypes.js +19 -13
  3. package/background/errors/TransactionError.js +9 -0
  4. package/cjs/background/KoniTypes.js +20 -16
  5. package/cjs/background/errors/TransactionError.js +9 -0
  6. package/cjs/constants/index.js +19 -4
  7. package/cjs/koni/api/dotsama/balance.js +464 -0
  8. package/cjs/koni/api/nft/config.js +33 -23
  9. package/cjs/koni/api/nft/index.js +14 -0
  10. package/cjs/koni/api/nft/nft.js +1 -22
  11. package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
  12. package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
  13. package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
  14. package/cjs/koni/api/staking/bonding/amplitude.js +17 -15
  15. package/cjs/koni/api/staking/bonding/astar.js +11 -10
  16. package/cjs/koni/api/staking/bonding/index.js +4 -1
  17. package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
  18. package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
  19. package/cjs/koni/api/staking/bonding/utils.js +104 -86
  20. package/cjs/koni/api/staking/index.js +6 -5
  21. package/cjs/koni/api/staking/paraChain.js +6 -5
  22. package/cjs/koni/api/staking/relayChain.js +3 -2
  23. package/cjs/koni/api/yield/helper/utils.js +46 -0
  24. package/cjs/koni/background/cron.js +11 -1
  25. package/cjs/koni/background/handlers/Extension.js +362 -69
  26. package/cjs/koni/background/handlers/State.js +51 -3
  27. package/cjs/koni/background/handlers/index.js +4 -2
  28. package/cjs/koni/background/subscription.js +95 -37
  29. package/cjs/services/campaign-service/index.js +9 -6
  30. package/cjs/services/chain-service/constants.js +2 -16
  31. package/cjs/services/chain-service/index.js +3 -2
  32. package/cjs/services/chain-service/utils.js +7 -1
  33. package/cjs/services/earning-service/constants/chains.js +29 -0
  34. package/cjs/services/earning-service/constants/index.js +27 -0
  35. package/cjs/services/earning-service/constants/step.js +18 -0
  36. package/cjs/services/earning-service/handlers/base.js +259 -0
  37. package/cjs/services/earning-service/handlers/index.js +60 -0
  38. package/cjs/services/earning-service/handlers/lending/base.js +20 -0
  39. package/cjs/services/earning-service/handlers/lending/index.js +13 -0
  40. package/cjs/services/earning-service/handlers/lending/interlay.js +191 -0
  41. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +239 -0
  42. package/cjs/services/earning-service/handlers/liquid-staking/base.js +43 -0
  43. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +297 -0
  44. package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
  45. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +226 -0
  46. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +395 -0
  47. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +384 -0
  48. package/cjs/services/earning-service/handlers/native-staking/astar.js +461 -0
  49. package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
  50. package/cjs/services/earning-service/handlers/native-staking/base.js +159 -0
  51. package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
  52. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +385 -0
  53. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
  54. package/cjs/services/earning-service/handlers/nomination-pool/index.js +560 -0
  55. package/cjs/services/earning-service/handlers/special.js +503 -0
  56. package/cjs/services/earning-service/service.js +387 -0
  57. package/cjs/services/earning-service/utils/index.js +128 -0
  58. package/cjs/services/event-service/index.js +4 -0
  59. package/cjs/services/keyring-service/index.js +14 -2
  60. package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
  61. package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
  62. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
  63. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  64. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
  65. package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
  66. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  67. package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
  68. package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
  69. package/cjs/services/migration-service/scripts/index.js +7 -1
  70. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
  71. package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
  72. package/cjs/services/mint-campaign-service/constants.js +11 -0
  73. package/cjs/services/mint-campaign-service/index.js +18 -0
  74. package/cjs/services/notification-service/NotificationService.js +1 -1
  75. package/cjs/services/storage-service/DatabaseService.js +51 -0
  76. package/cjs/services/storage-service/databases/index.js +4 -0
  77. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  78. package/cjs/services/storage-service/db-stores/YieldPoolStore.js +36 -0
  79. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +65 -0
  80. package/cjs/services/storage-service/index.js +241 -0
  81. package/cjs/services/subscan-service/index.js +16 -0
  82. package/cjs/services/transaction-service/event-parser/index.js +58 -0
  83. package/cjs/services/transaction-service/helpers/index.js +3 -1
  84. package/cjs/services/transaction-service/index.js +231 -75
  85. package/cjs/services/transaction-service/utils.js +1 -0
  86. package/cjs/types/campaigns/index.js +16 -0
  87. package/cjs/types/campaigns/unlock-dot.js +1 -0
  88. package/cjs/types/index.js +44 -0
  89. package/cjs/types/ordinal.js +1 -0
  90. package/cjs/types/transaction.js +1 -0
  91. package/cjs/types/yield/actions/index.js +27 -0
  92. package/cjs/types/yield/actions/join/index.js +38 -0
  93. package/cjs/types/yield/actions/join/step.js +47 -0
  94. package/cjs/types/yield/actions/join/submit.js +1 -0
  95. package/cjs/types/yield/actions/join/validate.js +16 -0
  96. package/cjs/types/yield/actions/others.js +1 -0
  97. package/cjs/types/yield/index.js +27 -0
  98. package/cjs/types/yield/info/account/index.js +49 -0
  99. package/cjs/types/yield/info/account/info.js +1 -0
  100. package/cjs/types/yield/info/account/reward.js +1 -0
  101. package/cjs/types/yield/info/account/target.js +32 -0
  102. package/cjs/types/yield/info/account/unstake.js +27 -0
  103. package/cjs/types/yield/info/base.js +41 -0
  104. package/cjs/types/yield/info/chain/index.js +27 -0
  105. package/cjs/types/yield/info/chain/info.js +1 -0
  106. package/cjs/types/yield/info/chain/target.js +1 -0
  107. package/cjs/types/yield/info/index.js +49 -0
  108. package/cjs/types/yield/info/pallet.js +15 -0
  109. package/cjs/types.js +1 -0
  110. package/cjs/utils/address.js +34 -0
  111. package/cjs/utils/fetchStaticData.js +2 -1
  112. package/cjs/utils/index.js +89 -1
  113. package/cjs/utils/keyring.js +57 -0
  114. package/cjs/utils/number.js +3 -1
  115. package/cjs/utils/object.js +12 -0
  116. package/constants/index.d.ts +6 -1
  117. package/constants/index.js +6 -1
  118. package/koni/api/nft/config.js +33 -23
  119. package/koni/api/nft/index.js +15 -1
  120. package/koni/api/nft/nft.js +2 -23
  121. package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
  122. package/koni/api/nft/ordinal_nft/constants.js +12 -0
  123. package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
  124. package/koni/api/nft/ordinal_nft/index.js +114 -0
  125. package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
  126. package/koni/api/nft/ordinal_nft/utils.js +33 -0
  127. package/koni/api/staking/bonding/amplitude.js +11 -9
  128. package/koni/api/staking/bonding/astar.js +9 -8
  129. package/koni/api/staking/bonding/index.d.ts +1 -1
  130. package/koni/api/staking/bonding/index.js +5 -1
  131. package/koni/api/staking/bonding/paraChain.js +12 -10
  132. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  133. package/koni/api/staking/bonding/relayChain.js +33 -30
  134. package/koni/api/staking/bonding/utils.d.ts +15 -38
  135. package/koni/api/staking/bonding/utils.js +85 -69
  136. package/koni/api/staking/index.js +2 -1
  137. package/koni/api/staking/paraChain.js +7 -6
  138. package/koni/api/staking/relayChain.js +4 -3
  139. package/koni/api/yield/helper/utils.d.ts +10 -0
  140. package/koni/api/yield/helper/utils.js +32 -0
  141. package/koni/background/cron.d.ts +1 -0
  142. package/koni/background/cron.js +12 -2
  143. package/koni/background/handlers/Extension.d.ts +17 -1
  144. package/koni/background/handlers/Extension.js +321 -30
  145. package/koni/background/handlers/State.d.ts +18 -2
  146. package/koni/background/handlers/State.js +50 -3
  147. package/koni/background/handlers/index.js +4 -2
  148. package/koni/background/subscription.d.ts +6 -1
  149. package/koni/background/subscription.js +97 -38
  150. package/package.json +316 -3
  151. package/services/campaign-service/index.js +9 -6
  152. package/services/chain-service/constants.d.ts +0 -11
  153. package/services/chain-service/constants.js +1 -14
  154. package/services/chain-service/index.js +3 -2
  155. package/services/chain-service/utils.d.ts +1 -0
  156. package/services/chain-service/utils.js +5 -1
  157. package/services/earning-service/constants/abis/compound_finance_v2_abi.json +1235 -0
  158. package/services/earning-service/constants/abis/st_liquid_token_abi.json +1355 -0
  159. package/services/earning-service/constants/chains.d.ts +14 -0
  160. package/services/earning-service/constants/chains.js +21 -0
  161. package/services/earning-service/constants/index.d.ts +2 -0
  162. package/services/earning-service/constants/index.js +5 -0
  163. package/services/earning-service/constants/step.d.ts +3 -0
  164. package/services/earning-service/constants/step.js +10 -0
  165. package/services/earning-service/handlers/base.d.ts +112 -0
  166. package/services/earning-service/handlers/base.js +253 -0
  167. package/services/earning-service/handlers/index.d.ts +5 -0
  168. package/services/earning-service/handlers/index.js +8 -0
  169. package/services/earning-service/handlers/lending/base.d.ts +6 -0
  170. package/services/earning-service/handlers/lending/base.js +12 -0
  171. package/services/earning-service/handlers/lending/index.d.ts +1 -0
  172. package/services/earning-service/handlers/lending/index.js +4 -0
  173. package/services/earning-service/handlers/lending/interlay.d.ts +24 -0
  174. package/services/earning-service/handlers/lending/interlay.js +183 -0
  175. package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
  176. package/services/earning-service/handlers/liquid-staking/acala.js +231 -0
  177. package/services/earning-service/handlers/liquid-staking/base.d.ts +9 -0
  178. package/services/earning-service/handlers/liquid-staking/base.js +35 -0
  179. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
  180. package/services/earning-service/handlers/liquid-staking/bifrost.js +286 -0
  181. package/services/earning-service/handlers/liquid-staking/index.d.ts +4 -0
  182. package/services/earning-service/handlers/liquid-staking/index.js +7 -0
  183. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +26 -0
  184. package/services/earning-service/handlers/liquid-staking/parallel.js +218 -0
  185. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
  186. package/services/earning-service/handlers/liquid-staking/stella-swap.js +385 -0
  187. package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
  188. package/services/earning-service/handlers/native-staking/amplitude.js +375 -0
  189. package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
  190. package/services/earning-service/handlers/native-staking/astar.js +451 -0
  191. package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
  192. package/services/earning-service/handlers/native-staking/base-para.js +138 -0
  193. package/services/earning-service/handlers/native-staking/base.d.ts +21 -0
  194. package/services/earning-service/handlers/native-staking/base.js +150 -0
  195. package/services/earning-service/handlers/native-staking/index.d.ts +4 -0
  196. package/services/earning-service/handlers/native-staking/index.js +7 -0
  197. package/services/earning-service/handlers/native-staking/para-chain.d.ts +15 -0
  198. package/services/earning-service/handlers/native-staking/para-chain.js +377 -0
  199. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
  200. package/services/earning-service/handlers/native-staking/relay-chain.js +549 -0
  201. package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
  202. package/services/earning-service/handlers/nomination-pool/index.js +550 -0
  203. package/services/earning-service/handlers/special.d.ts +65 -0
  204. package/services/earning-service/handlers/special.js +495 -0
  205. package/services/earning-service/service.d.ts +45 -0
  206. package/services/earning-service/service.js +379 -0
  207. package/services/earning-service/utils/index.d.ts +18 -0
  208. package/services/earning-service/utils/index.js +112 -0
  209. package/services/event-service/index.d.ts +1 -0
  210. package/services/event-service/index.js +4 -0
  211. package/services/event-service/types.d.ts +8 -0
  212. package/services/keyring-service/index.d.ts +2 -1
  213. package/services/keyring-service/index.js +14 -2
  214. package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
  215. package/services/migration-service/scripts/DeleteEarningData.js +13 -0
  216. package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
  217. package/services/migration-service/scripts/EnableEarningChains.js +13 -0
  218. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  219. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  220. package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
  221. package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
  222. package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
  223. package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
  224. package/services/migration-service/scripts/index.js +7 -1
  225. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
  226. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
  227. package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
  228. package/services/mint-campaign-service/campaigns/index.js +4 -0
  229. package/services/mint-campaign-service/constants.d.ts +1 -0
  230. package/services/mint-campaign-service/constants.js +4 -0
  231. package/services/mint-campaign-service/index.d.ts +7 -0
  232. package/services/mint-campaign-service/index.js +11 -0
  233. package/services/notification-service/NotificationService.js +1 -1
  234. package/services/storage-service/DatabaseService.d.ts +18 -1
  235. package/services/storage-service/DatabaseService.js +51 -0
  236. package/services/storage-service/databases/index.d.ts +3 -1
  237. package/services/storage-service/databases/index.js +4 -0
  238. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  239. package/services/storage-service/db-stores/YieldPoolStore.d.ts +10 -0
  240. package/services/storage-service/db-stores/YieldPoolStore.js +28 -0
  241. package/services/storage-service/db-stores/YieldPositionStore.d.ts +9 -0
  242. package/services/storage-service/db-stores/YieldPositionStore.js +57 -0
  243. package/services/subscan-service/index.d.ts +3 -2
  244. package/services/subscan-service/index.js +15 -0
  245. package/services/subscan-service/types.d.ts +20 -0
  246. package/services/transaction-service/event-parser/index.d.ts +3 -1
  247. package/services/transaction-service/event-parser/index.js +57 -1
  248. package/services/transaction-service/helpers/index.js +3 -1
  249. package/services/transaction-service/index.d.ts +4 -15
  250. package/services/transaction-service/index.js +229 -73
  251. package/services/transaction-service/types.d.ts +2 -0
  252. package/services/transaction-service/utils.js +1 -0
  253. package/types/campaigns/index.d.ts +1 -0
  254. package/types/campaigns/index.js +4 -0
  255. package/types/campaigns/unlock-dot.d.ts +71 -0
  256. package/types/campaigns/unlock-dot.js +1 -0
  257. package/types/index.d.ts +5 -0
  258. package/types/index.js +5 -1
  259. package/types/ordinal.d.ts +69 -0
  260. package/types/ordinal.js +1 -0
  261. package/types/transaction.d.ts +3 -0
  262. package/types/transaction.js +1 -0
  263. package/types/yield/actions/index.d.ts +2 -0
  264. package/types/yield/actions/index.js +5 -0
  265. package/types/yield/actions/join/index.d.ts +3 -0
  266. package/types/yield/actions/join/index.js +6 -0
  267. package/types/yield/actions/join/step.d.ts +95 -0
  268. package/types/yield/actions/join/step.js +46 -0
  269. package/types/yield/actions/join/submit.d.ts +57 -0
  270. package/types/yield/actions/join/submit.js +1 -0
  271. package/types/yield/actions/join/validate.d.ts +18 -0
  272. package/types/yield/actions/join/validate.js +10 -0
  273. package/types/yield/actions/others.d.ts +85 -0
  274. package/types/yield/actions/others.js +1 -0
  275. package/types/yield/index.d.ts +2 -0
  276. package/types/yield/index.js +5 -0
  277. package/types/yield/info/account/index.d.ts +4 -0
  278. package/types/yield/info/account/index.js +7 -0
  279. package/types/yield/info/account/info.d.ts +92 -0
  280. package/types/yield/info/account/info.js +1 -0
  281. package/types/yield/info/account/reward.d.ts +45 -0
  282. package/types/yield/info/account/reward.js +1 -0
  283. package/types/yield/info/account/target.d.ts +43 -0
  284. package/types/yield/info/account/target.js +27 -0
  285. package/types/yield/info/account/unstake.d.ts +31 -0
  286. package/types/yield/info/account/unstake.js +22 -0
  287. package/types/yield/info/base.d.ts +45 -0
  288. package/types/yield/info/base.js +36 -0
  289. package/types/yield/info/chain/index.d.ts +2 -0
  290. package/types/yield/info/chain/index.js +5 -0
  291. package/types/yield/info/chain/info.d.ts +251 -0
  292. package/types/yield/info/chain/info.js +1 -0
  293. package/types/yield/info/chain/target.d.ts +37 -0
  294. package/types/yield/info/chain/target.js +1 -0
  295. package/types/yield/info/index.d.ts +4 -0
  296. package/types/yield/info/index.js +7 -0
  297. package/types/yield/info/pallet.d.ts +143 -0
  298. package/types/yield/info/pallet.js +9 -0
  299. package/utils/fetchStaticData.js +2 -1
  300. package/utils/index.d.ts +5 -0
  301. package/utils/index.js +53 -1
  302. package/utils/number.d.ts +1 -1
  303. package/utils/number.js +1 -1
  304. package/utils/object.d.ts +1 -0
  305. package/utils/object.js +6 -0
@@ -105,7 +105,9 @@ const toBNString = (input, decimal) => {
105
105
  return raw.multipliedBy(BN_TEN.pow(decimal)).toFixed();
106
106
  };
107
107
  exports.toBNString = toBNString;
108
- const formatNumber = (input, decimal, formatter, metadata) => {
108
+ const formatNumber = function (input, decimal) {
109
+ let formatter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : balanceFormatter;
110
+ let metadata = arguments.length > 3 ? arguments[3] : undefined;
109
111
  const raw = new _bignumber.default(input).dividedBy(BN_TEN.pow(decimal)).toFixed();
110
112
  return formatter(raw, metadata);
111
113
  };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isEmptyObject = isEmptyObject;
7
+ // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
8
+ // SPDX-License-Identifier: Apache-2.0
9
+
10
+ function isEmptyObject(input) {
11
+ return Object.keys(input).length === 0;
12
+ }
@@ -1,3 +1,5 @@
1
+ export declare const BASE_SECOND_INTERVAL = 1000;
2
+ export declare const BASE_MINUTE_INTERVAL: number;
1
3
  export declare const CRON_REFRESH_PRICE_INTERVAL = 30000;
2
4
  export declare const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
3
5
  export declare const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
@@ -6,7 +8,7 @@ export declare const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
6
8
  export declare const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
7
9
  export declare const CRON_REFRESH_NFT_INTERVAL = 7200000;
8
10
  export declare const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
9
- export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 300000;
11
+ export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 90000;
10
12
  export declare const CRON_REFRESH_HISTORY_INTERVAL = 900000;
11
13
  export declare const CRON_GET_API_MAP_STATUS = 10000;
12
14
  export declare const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
@@ -14,6 +16,7 @@ export declare const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
14
16
  export declare const CRON_RECOVER_HISTORY_INTERVAL = 30000;
15
17
  export declare const CRON_SYNC_MANTA_PAY = 300000;
16
18
  export declare const MANTA_PAY_BALANCE_INTERVAL = 30000;
19
+ export declare const CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL: number;
17
20
  export declare const ALL_ACCOUNT_KEY = "ALL";
18
21
  export declare const ALL_NETWORK_KEY = "all";
19
22
  export declare const ALL_GENESIS_HASH: null;
@@ -22,5 +25,7 @@ export declare const IGNORE_QR_SIGNER: string[];
22
25
  export declare const XCM_MIN_AMOUNT_RATIO = 1.2;
23
26
  export declare const GAS_PRICE_RATIO: number;
24
27
  export declare const NETWORK_MULTI_GAS_FEE: string[];
28
+ export declare const ORDINAL_COLLECTION = "__Ordinal__";
29
+ export declare const ORDINAL_METHODS: string[];
25
30
  export * from './staking';
26
31
  export * from './storage';
@@ -1,6 +1,8 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ export const BASE_SECOND_INTERVAL = 1000;
5
+ export const BASE_MINUTE_INTERVAL = 60 * BASE_SECOND_INTERVAL;
4
6
  export const CRON_REFRESH_PRICE_INTERVAL = 30000;
5
7
  export const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
6
8
  export const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
@@ -9,7 +11,7 @@ export const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
9
11
  export const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
10
12
  export const CRON_REFRESH_NFT_INTERVAL = 7200000;
11
13
  export const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
12
- export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 300000;
14
+ export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 90000;
13
15
  export const CRON_REFRESH_HISTORY_INTERVAL = 900000;
14
16
  export const CRON_GET_API_MAP_STATUS = 10000;
15
17
  export const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
@@ -17,6 +19,7 @@ export const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
17
19
  export const CRON_RECOVER_HISTORY_INTERVAL = 30000;
18
20
  export const CRON_SYNC_MANTA_PAY = 300000;
19
21
  export const MANTA_PAY_BALANCE_INTERVAL = 30000;
22
+ export const CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = 15 * BASE_MINUTE_INTERVAL;
20
23
  export const ALL_ACCOUNT_KEY = 'ALL';
21
24
  export const ALL_NETWORK_KEY = 'all';
22
25
  export const ALL_GENESIS_HASH = null;
@@ -25,5 +28,7 @@ export const IGNORE_QR_SIGNER = [];
25
28
  export const XCM_MIN_AMOUNT_RATIO = 1.2;
26
29
  export const GAS_PRICE_RATIO = 1 + 2 / 100;
27
30
  export const NETWORK_MULTI_GAS_FEE = ['*'];
31
+ export const ORDINAL_COLLECTION = '__Ordinal__';
32
+ export const ORDINAL_METHODS = ['drc-20', 'pol-20'];
28
33
  export * from "./staking.js";
29
34
  export * from "./storage.js";
@@ -15,7 +15,11 @@ export const CLOUDFLARE_PINATA_SERVER = 'https://cloudflare-ipfs.com/ipfs/';
15
15
  export const BIT_COUNTRY_IPFS_SERVER = 'https://ipfs-cdn.bit.country/';
16
16
  export const BIT_COUNTRY_LAND_ESTATE_METADATA_API = 'https://pioneer-api.bit.country/metadata/landTokenUriPioneer';
17
17
  export const BIT_COUNTRY_THUMBNAIL_RESOLVER = 'https://res.cloudinary.com/ddftctzph/image/upload/c_scale,q_100,w_250/production-ipfs/asset/';
18
+
19
+ // XOrigin
18
20
  export const CF_IPFS_GATEWAY = 'https://cf-ipfs.com/ipfs/';
21
+
22
+ // XOrigin
19
23
  export const PINATA_IPFS_GATEWAY = 'https://gateway.pinata.cloud/ipfs/';
20
24
  export const UNIQUE_SCAN_ENDPOINT = 'https://explorer-api.unique.network/v1/graphql';
21
25
  export const QUARTZ_SCAN_ENDPOINT = 'https://hasura-quartz.unique.network/v1/graphql';
@@ -24,10 +28,18 @@ export const VARA_SCAN_ENDPOINT = 'https://nft-explorer.vara-network.io/graphql'
24
28
  // GATEWAY
25
29
 
26
30
  export const UNIQUE_IPFS_GATEWAY = 'https://ipfs.unique.network/ipfs/';
31
+
32
+ // XOrigin
27
33
  export const NFT_STORAGE_GATEWAY = 'https://nftstorage.link/ipfs/';
28
34
  export const IPFS_W3S_LINK = 'https://w3s.link/ipfs/';
35
+
36
+ // XOrigin
29
37
  export const GATEWAY_IPFS_IO = 'https://gateway.ipfs.io/ipfs/';
38
+
39
+ // XOrigin
30
40
  export const IPFS_IO = 'https://ipfs.io/ipfs/';
41
+
42
+ // XOrigin
31
43
  export const DWEB_LINK = 'https://dweb.link/ipfs/';
32
44
  export const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
33
45
  export const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
@@ -83,26 +95,8 @@ export let SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME;
83
95
  SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME["pioneer"] = "pioneer";
84
96
  })(SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME || (SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = {}));
85
97
  const RANDOM_IPFS_GATEWAY_SETTING = [{
86
- provider: CF_IPFS_GATEWAY,
87
- weight: 4
88
- }, {
89
98
  provider: CLOUDFLARE_PINATA_SERVER,
90
99
  weight: 10
91
- }, {
92
- provider: PINATA_IPFS_GATEWAY,
93
- weight: 1 // Rate limit too low
94
- }, {
95
- provider: DWEB_LINK,
96
- weight: 5
97
- }, {
98
- provider: GATEWAY_IPFS_IO,
99
- weight: 5
100
- }, {
101
- provider: IPFS_IO,
102
- weight: 5
103
- }, {
104
- provider: NFT_STORAGE_GATEWAY,
105
- weight: 50
106
100
  }];
107
101
  if (isFirefox) {
108
102
  RANDOM_IPFS_GATEWAY_SETTING.push({
@@ -110,18 +104,34 @@ if (isFirefox) {
110
104
  weight: 5000
111
105
  });
112
106
  }
113
- if (!RuntimeInfo.protocol || RuntimeInfo.protocol && !RuntimeInfo.protocol.startsWith('http')) {
107
+ if (!RuntimeInfo.protocol || !RuntimeInfo.protocol.startsWith('http') || RuntimeInfo.protocol.startsWith('https')) {
114
108
  RANDOM_IPFS_GATEWAY_SETTING.push({
115
109
  provider: IPFS_FLEEK,
116
110
  weight: 4
117
- });
118
- RANDOM_IPFS_GATEWAY_SETTING.push({
111
+ }, {
119
112
  provider: IPFS_GATEWAY_4EVERLAND,
120
113
  weight: 2
121
- });
122
- RANDOM_IPFS_GATEWAY_SETTING.push({
114
+ }, {
123
115
  provider: IPFS_W3S_LINK,
124
116
  weight: 1
117
+ }, {
118
+ provider: CF_IPFS_GATEWAY,
119
+ weight: 4
120
+ }, {
121
+ provider: PINATA_IPFS_GATEWAY,
122
+ weight: 1 // Rate limit too low
123
+ }, {
124
+ provider: NFT_STORAGE_GATEWAY,
125
+ weight: 50
126
+ }, {
127
+ provider: GATEWAY_IPFS_IO,
128
+ weight: 5
129
+ }, {
130
+ provider: DWEB_LINK,
131
+ weight: 5
132
+ }, {
133
+ provider: IPFS_IO,
134
+ weight: 5
125
135
  });
126
136
  }
127
137
  const RANDOM_IPFS_GATEWAY_TOTAL_WEIGHT = RANDOM_IPFS_GATEWAY_SETTING.reduce((value, item) => value + item.weight, 0);
@@ -5,13 +5,14 @@ import { AcalaNftApi } from '@subwallet/extension-base/koni/api/nft/acala_nft';
5
5
  import { BitCountryNftApi } from '@subwallet/extension-base/koni/api/nft/bit.country';
6
6
  import { EvmNftApi } from '@subwallet/extension-base/koni/api/nft/evm_nft';
7
7
  import { KaruraNftApi } from '@subwallet/extension-base/koni/api/nft/karura_nft';
8
+ import OrdinalNftApi from '@subwallet/extension-base/koni/api/nft/ordinal_nft';
8
9
  import { RmrkNftApi } from '@subwallet/extension-base/koni/api/nft/rmrk_nft';
9
10
  import StatemineNftApi from '@subwallet/extension-base/koni/api/nft/statemine_nft';
10
11
  import UniqueNftApi from '@subwallet/extension-base/koni/api/nft/unique_nft';
11
12
  import { VaraNftApi } from '@subwallet/extension-base/koni/api/nft/vara_nft';
12
13
  import { WasmNftApi } from '@subwallet/extension-base/koni/api/nft/wasm_nft';
13
14
  import { _NFT_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
14
- import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils';
15
+ import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft, _isSupportOrdinal } from '@subwallet/extension-base/services/chain-service/utils';
15
16
  import { categoryAddresses } from '@subwallet/extension-base/utils';
16
17
  import StatemintNftApi from "./statemint_nft/index.js";
17
18
  function createSubstrateNftApi(chain, substrateApi, addresses) {
@@ -43,6 +44,9 @@ function createWeb3NftApi(chain, evmApi, addresses) {
43
44
  const [, evmAddresses] = categoryAddresses(addresses);
44
45
  return new EvmNftApi(evmApi, evmAddresses, chain);
45
46
  }
47
+ const createOrdinalApi = (chain, subscanChain, addresses) => {
48
+ return new OrdinalNftApi(addresses, chain, subscanChain);
49
+ };
46
50
  export class NftHandler {
47
51
  // General settings
48
52
  chainInfoMap = {};
@@ -122,6 +126,16 @@ export class NftHandler {
122
126
  }
123
127
  }
124
128
  }
129
+ if (_isSupportOrdinal(chain)) {
130
+ var _chainInfo$extraInfo;
131
+ const subscanChain = (_chainInfo$extraInfo = chainInfo.extraInfo) === null || _chainInfo$extraInfo === void 0 ? void 0 : _chainInfo$extraInfo.subscanSlug;
132
+ if (subscanChain) {
133
+ const handler = createOrdinalApi(chain, subscanChain, substrateAddresses);
134
+ if (handler && !this.handlers.includes(handler)) {
135
+ this.handlers.push(handler);
136
+ }
137
+ }
138
+ }
125
139
  });
126
140
  this.needSetupApi = false;
127
141
  }
@@ -1,8 +1,7 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { getRandomIpfsGateway } from '@subwallet/extension-base/koni/api/nft/config';
5
- import { isUrl } from '@subwallet/extension-base/utils';
4
+ import { baseParseIPFSUrl } from '@subwallet/extension-base/utils';
6
5
  export class BaseNftApi {
7
6
  chain = '';
8
7
  substrateApi = null;
@@ -65,27 +64,7 @@ export class BaseNftApi {
65
64
  return tokenId;
66
65
  }
67
66
  parseUrl(input) {
68
- if (!input || input.length === 0) {
69
- return undefined;
70
- }
71
- if (isUrl(input)) {
72
- return input;
73
- }
74
- if (isUrl(input) || input.includes('https://') || input.includes('http')) {
75
- return input;
76
- }
77
- if (input.startsWith('/ipfs/')) {
78
- return getRandomIpfsGateway() + input.split('/ipfs/')[1];
79
- }
80
- if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
81
- // just the IPFS hash
82
- return getRandomIpfsGateway() + input;
83
- }
84
- if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
85
- // starts with ipfs://
86
- return getRandomIpfsGateway() + input.split('ipfs://')[1];
87
- }
88
- return getRandomIpfsGateway() + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
67
+ return baseParseIPFSUrl(input);
89
68
  }
90
69
 
91
70
  // Subclass implements this function to parse data into prop result
@@ -0,0 +1,9 @@
1
+ export declare const GET_EVENT_LIST_API = "https://{{chain}}.api.subscan.io/api/v2/scan/events";
2
+ export declare const GET_EXTRINSIC_PARAMS_API = "https://{{chain}}.api.subscan.io/api/scan/extrinsic/params";
3
+ export declare const BASE_FETCH_ORDINAL_EVENT_DATA: {
4
+ event_id: string;
5
+ module: string;
6
+ order: string;
7
+ success: boolean;
8
+ row: number;
9
+ };
@@ -0,0 +1,12 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export const GET_EVENT_LIST_API = 'https://{{chain}}.api.subscan.io/api/v2/scan/events';
5
+ export const GET_EXTRINSIC_PARAMS_API = 'https://{{chain}}.api.subscan.io/api/scan/extrinsic/params';
6
+ export const BASE_FETCH_ORDINAL_EVENT_DATA = {
7
+ event_id: 'Remarked',
8
+ module: 'system',
9
+ order: 'desc',
10
+ success: true,
11
+ row: 100
12
+ };
@@ -0,0 +1,8 @@
1
+ import { BaseNftApi, HandleNftParams } from '@subwallet/extension-base/koni/api/nft/nft';
2
+ export default class OrdinalNftApi extends BaseNftApi {
3
+ subscanChain: string;
4
+ constructor(addresses: string[], chain: string, subscanChain: string);
5
+ handleNft(address: string, handleNftParams: HandleNftParams): Promise<void>;
6
+ handleNfts(params: HandleNftParams): Promise<void>;
7
+ fetchNfts(params: HandleNftParams): Promise<number>;
8
+ }
@@ -0,0 +1,114 @@
1
+ // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ORDINAL_COLLECTION } from '@subwallet/extension-base/constants';
5
+ import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
6
+ import { fetchExtrinsicParams, fetchRemarkEvent } from '@subwallet/extension-base/koni/api/nft/ordinal_nft/utils';
7
+ import { state } from '@subwallet/extension-base/koni/background/handlers';
8
+ const parseParamData = (param, event, chain, address) => {
9
+ const ordinalData = JSON.parse(param.value);
10
+ if ('p' in ordinalData) {
11
+ const properties = {};
12
+ for (const [key, value] of Object.entries(ordinalData)) {
13
+ const _name = key.charAt(0).toUpperCase() + key.slice(1);
14
+ properties[_name] = {
15
+ value: value
16
+ };
17
+ }
18
+ properties['Block number'] = {
19
+ value: event.extrinsic_index.split('-')[0]
20
+ };
21
+ properties.Timestamp = {
22
+ value: event.block_timestamp
23
+ };
24
+ const op = ordinalData.op.charAt(0).toUpperCase() + ordinalData.op.slice(1);
25
+ const nameParams = [op];
26
+ if (ordinalData.amt !== undefined) {
27
+ nameParams.push(ordinalData.amt);
28
+ }
29
+ nameParams.push(ordinalData.tick);
30
+ const name = nameParams.join(' ');
31
+ return {
32
+ chain: chain,
33
+ collectionId: ORDINAL_COLLECTION,
34
+ id: event.extrinsic_hash,
35
+ description: JSON.stringify(ordinalData),
36
+ name,
37
+ owner: address,
38
+ properties: properties
39
+ };
40
+ }
41
+ return undefined;
42
+ };
43
+ export default class OrdinalNftApi extends BaseNftApi {
44
+ constructor(addresses, chain, subscanChain) {
45
+ super(chain, undefined, addresses);
46
+ this.subscanChain = subscanChain;
47
+ }
48
+ async handleNft(address, handleNftParams) {
49
+ const events = await state.subscanService.addRequest(async () => {
50
+ return await fetchRemarkEvent(this.subscanChain, address);
51
+ });
52
+ if (events && events.length) {
53
+ const extrinsicIds = events.map(data => data.extrinsic_index);
54
+ const extrinsicParams = await state.subscanService.addRequest(async () => {
55
+ return await fetchExtrinsicParams(this.subscanChain, extrinsicIds);
56
+ });
57
+ const items = [];
58
+ for (const data of extrinsicParams) {
59
+ const {
60
+ extrinsic_index: extrinsicIndex,
61
+ params
62
+ } = data;
63
+ const event = events.find(item => item.extrinsic_index === extrinsicIndex);
64
+ if (params.length === 1 && event) {
65
+ const [param] = params;
66
+ if (param.name === 'remark') {
67
+ const childParam = {
68
+ name: param.name,
69
+ type: param.type,
70
+ value: param.value
71
+ };
72
+ const item = parseParamData(childParam, event, this.chain, address);
73
+ if (item) {
74
+ items.push(item);
75
+ }
76
+ } else if (param.name === 'calls') {
77
+ const children = param.value;
78
+ for (const child of children) {
79
+ if (child.call_module === 'System' && child.call_name === 'remark_with_event') {
80
+ for (const childParam of child.params) {
81
+ const item = parseParamData(childParam, event, this.chain, address);
82
+ if (item) {
83
+ items.push(item);
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+ if (items.length) {
92
+ // handleNftParams.updateCollection(this.chain, {
93
+ // chain: this.chain,
94
+ // collectionId: ORDINAL_COLLECTION
95
+ // });
96
+
97
+ for (const item of items) {
98
+ handleNftParams.updateItem(this.chain, item, address);
99
+ }
100
+ }
101
+ }
102
+ }
103
+ async handleNfts(params) {
104
+ await Promise.all(this.addresses.map(address => this.handleNft(address, params)));
105
+ }
106
+ async fetchNfts(params) {
107
+ try {
108
+ await this.handleNfts(params);
109
+ } catch (e) {
110
+ return 0;
111
+ }
112
+ return 1;
113
+ }
114
+ }
@@ -0,0 +1,2 @@
1
+ export declare const fetchRemarkEvent: (chain: string, address: string) => Promise<import("@subwallet/extension-base/types").SubscanEventBaseItemData[]>;
2
+ export declare const fetchExtrinsicParams: (chain: string, extrinsicIndexes: string[]) => Promise<import("@subwallet/extension-base/types").SubscanExtrinsicParam[]>;
@@ -0,0 +1,33 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { BASE_FETCH_ORDINAL_EVENT_DATA, GET_EVENT_LIST_API, GET_EXTRINSIC_PARAMS_API } from "./constants.js";
5
+ export const fetchRemarkEvent = async (chain, address) => {
6
+ const params = {
7
+ ...BASE_FETCH_ORDINAL_EVENT_DATA,
8
+ address
9
+ };
10
+ const response = await fetch(GET_EVENT_LIST_API.replace('{{chain}}', chain), {
11
+ method: 'POST',
12
+ headers: {
13
+ 'Content-Type': 'application/json'
14
+ },
15
+ body: JSON.stringify(params)
16
+ });
17
+ const data = await response.json();
18
+ return data.data.events;
19
+ };
20
+ export const fetchExtrinsicParams = async (chain, extrinsicIndexes) => {
21
+ const params = {
22
+ extrinsic_index: extrinsicIndexes
23
+ };
24
+ const response = await fetch(GET_EXTRINSIC_PARAMS_API.replace('{{chain}}', chain), {
25
+ method: 'POST',
26
+ headers: {
27
+ 'Content-Type': 'application/json'
28
+ },
29
+ body: JSON.stringify(params)
30
+ });
31
+ const data = await response.json();
32
+ return data.data;
33
+ };
@@ -1,9 +1,11 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { StakingStatus, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
5
- import { getBondedValidators, getStakingStatusByNominations, isUnstakeAll, parseIdentity } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
4
+ import { StakingType } from '@subwallet/extension-base/background/KoniTypes';
5
+ import { getBondedValidators, getEarningStatusByNominations, isUnstakeAll } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
6
6
  import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
7
+ import { parseIdentity } from '@subwallet/extension-base/services/earning-service/utils';
8
+ import { EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
7
9
  import { parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
8
10
  import { BN, BN_ZERO } from '@polkadot/util';
9
11
  import { isEthereumAddress } from '@polkadot/util-crypto';
@@ -64,9 +66,9 @@ export async function subscribeAmplitudeNominatorMetadata(chainInfo, address, su
64
66
  const [identity] = await parseIdentity(substrateApi, delegatorState.owner);
65
67
  activeStake = delegatorState.amount.toString();
66
68
  const bnActiveStake = new BN(activeStake);
67
- let delegationStatus = StakingStatus.NOT_EARNING;
69
+ let delegationStatus = EarningStatus.NOT_EARNING;
68
70
  if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegatorStake))) {
69
- delegationStatus = StakingStatus.EARNING_REWARD;
71
+ delegationStatus = EarningStatus.EARNING_REWARD;
70
72
  }
71
73
  nominationList.push({
72
74
  status: delegationStatus,
@@ -99,7 +101,7 @@ export async function subscribeAmplitudeNominatorMetadata(chainInfo, address, su
99
101
  validatorAddress: (delegatorState === null || delegatorState === void 0 ? void 0 : delegatorState.owner) || undefined
100
102
  });
101
103
  }
102
- const stakingStatus = getStakingStatusByNominations(new BN(activeStake), nominationList);
104
+ const stakingStatus = getEarningStatusByNominations(new BN(activeStake), nominationList);
103
105
  return {
104
106
  chain: chainInfo.slug,
105
107
  type: StakingType.NOMINATED,
@@ -131,7 +133,7 @@ export async function getAmplitudeNominatorMetadata(chainInfo, address, substrat
131
133
  chain: chainInfo.slug,
132
134
  type: StakingType.NOMINATED,
133
135
  address,
134
- status: StakingStatus.NOT_STAKING,
136
+ status: EarningStatus.NOT_STAKING,
135
137
  activeStake: '0',
136
138
  nominations: [],
137
139
  unstakings: []
@@ -143,9 +145,9 @@ export async function getAmplitudeNominatorMetadata(chainInfo, address, substrat
143
145
  const [identity] = await parseIdentity(substrateApi, delegatorState.owner);
144
146
  activeStake = delegatorState.amount.toString();
145
147
  const bnActiveStake = new BN(activeStake);
146
- let delegationStatus = StakingStatus.NOT_EARNING;
148
+ let delegationStatus = EarningStatus.NOT_EARNING;
147
149
  if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegatorStake))) {
148
- delegationStatus = StakingStatus.EARNING_REWARD;
150
+ delegationStatus = EarningStatus.EARNING_REWARD;
149
151
  }
150
152
  nominationList.push({
151
153
  status: delegationStatus,
@@ -181,7 +183,7 @@ export async function getAmplitudeNominatorMetadata(chainInfo, address, substrat
181
183
  if (nominationList.length === 0 && unstakingList.length === 0) {
182
184
  return;
183
185
  }
184
- const stakingStatus = getStakingStatusByNominations(new BN(activeStake), nominationList);
186
+ const stakingStatus = getEarningStatusByNominations(new BN(activeStake), nominationList);
185
187
  return {
186
188
  chain,
187
189
  type: StakingType.NOMINATED,
@@ -1,9 +1,10 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { StakingStatus, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
5
- import { getStakingStatusByNominations } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
4
+ import { StakingType } from '@subwallet/extension-base/background/KoniTypes';
5
+ import { getEarningStatusByNominations } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
6
6
  import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
7
+ import { EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
7
8
  import { isUrl, parseRawNumber } from '@subwallet/extension-base/utils';
8
9
  import fetch from 'cross-fetch';
9
10
  import { BN, BN_ZERO } from '@polkadot/util';
@@ -99,7 +100,7 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
99
100
  const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
100
101
  const bnCurrentStake = new BN(currentStake);
101
102
  if (bnCurrentStake.gt(BN_ZERO)) {
102
- const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ? StakingStatus.EARNING_REWARD : StakingStatus.NOT_EARNING;
103
+ const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ? EarningStatus.EARNING_REWARD : EarningStatus.NOT_EARNING;
103
104
  bnTotalActiveStake = bnTotalActiveStake.add(bnCurrentStake);
104
105
  const dappInfo = dAppInfoMap[dappAddress];
105
106
  nominationList.push({
@@ -134,13 +135,13 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
134
135
  chain: chainInfo.slug,
135
136
  type: StakingType.NOMINATED,
136
137
  address,
137
- status: StakingStatus.NOT_STAKING,
138
+ status: EarningStatus.NOT_STAKING,
138
139
  activeStake: '0',
139
140
  nominations: [],
140
141
  unstakings: []
141
142
  };
142
143
  }
143
- const stakingStatus = getStakingStatusByNominations(bnTotalActiveStake, nominationList);
144
+ const stakingStatus = getEarningStatusByNominations(bnTotalActiveStake, nominationList);
144
145
  return {
145
146
  chain: chainInfo.slug,
146
147
  type: StakingType.NOMINATED,
@@ -185,7 +186,7 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
185
186
  const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
186
187
  const bnCurrentStake = new BN(currentStake);
187
188
  if (bnCurrentStake.gt(BN_ZERO)) {
188
- const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ? StakingStatus.EARNING_REWARD : StakingStatus.NOT_EARNING;
189
+ const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ? EarningStatus.EARNING_REWARD : EarningStatus.NOT_EARNING;
189
190
  bnTotalActiveStake = bnTotalActiveStake.add(bnCurrentStake);
190
191
  const dappInfo = dAppInfoMap[dappAddress];
191
192
  nominationList.push({
@@ -220,13 +221,13 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
220
221
  chain: chainInfo.slug,
221
222
  type: StakingType.NOMINATED,
222
223
  address,
223
- status: StakingStatus.NOT_STAKING,
224
+ status: EarningStatus.NOT_STAKING,
224
225
  activeStake: '0',
225
226
  nominations: [],
226
227
  unstakings: []
227
228
  };
228
229
  }
229
- const stakingStatus = getStakingStatusByNominations(bnTotalActiveStake, nominationList);
230
+ const stakingStatus = getEarningStatusByNominations(bnTotalActiveStake, nominationList);
230
231
  return {
231
232
  chain,
232
233
  type: StakingType.NOMINATED,
@@ -10,7 +10,7 @@ export declare function getChainStakingMetadata(chainInfo: _ChainInfo, substrate
10
10
  * */
11
11
  export declare function getNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi): Promise<NominatorMetadata | undefined>;
12
12
  export declare function getValidatorsInfo(networkKey: string, substrateApi: _SubstrateApi, decimals: number, chainStakingMetadata: ChainStakingMetadata): Promise<ValidatorInfo[]>;
13
- export declare function getNominationPoolsInfo(chain: string, substrateApi: _SubstrateApi): Promise<import("@subwallet/extension-base/background/KoniTypes").NominationPoolInfo[]>;
13
+ export declare function getNominationPoolsInfo(chain: string, substrateApi: _SubstrateApi): Promise<import("../../../../types").NominationPoolInfo[]>;
14
14
  export declare function getBondingExtrinsic(chainInfo: _ChainInfo, amount: string, selectedValidators: ValidatorInfo[], substrateApi: _SubstrateApi, address: string, nominatorMetadata?: NominatorMetadata): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
15
15
  export declare function getUnbondingExtrinsic(nominatorMetadata: NominatorMetadata, amount: string, chain: string, substrateApi: _SubstrateApi, selectedValidator?: string): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
16
16
  export declare function getWithdrawalExtrinsic(substrateApi: _SubstrateApi, chain: string, nominatorMetadata: NominatorMetadata, validatorAddress?: string): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
@@ -6,10 +6,14 @@ import { getAmplitudeBondingExtrinsic, getAmplitudeClaimRewardExtrinsic, getAmpl
6
6
  import { getAstarBondingExtrinsic, getAstarClaimRewardExtrinsic, getAstarDappsInfo, getAstarNominatorMetadata, getAstarStakingMetadata, getAstarUnbondingExtrinsic, getAstarWithdrawalExtrinsic, subscribeAstarStakingMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/astar';
7
7
  import { getParaBondingExtrinsic, getParaCancelWithdrawalExtrinsic, getParachainCollatorsInfo, getParaChainNominatorMetadata, getParaChainStakingMetadata, getParaUnbondingExtrinsic, getParaWithdrawalExtrinsic, subscribeParaChainStakingMetadata, validateParaChainBondingCondition, validateParaChainUnbondingCondition } from '@subwallet/extension-base/koni/api/staking/bonding/paraChain';
8
8
  import { getPoolingClaimRewardExtrinsic, getPoolingWithdrawalExtrinsic, getRelayBondingExtrinsic, getRelayCancelWithdrawalExtrinsic, getRelayChainNominatorMetadata, getRelayChainStakingMetadata, getRelayPoolsInfo, getRelayUnbondingExtrinsic, getRelayValidatorsInfo, getRelayWithdrawalExtrinsic, subscribeRelayChainStakingMetadata, validateRelayBondingCondition, validateRelayUnbondingCondition } from '@subwallet/extension-base/koni/api/staking/bonding/relayChain';
9
- import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
9
+ import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
10
+
10
11
  // all addresses must be converted to its chain format
11
12
 
12
13
  export function validateUnbondingCondition(nominatorMetadata, amount, chain, chainStakingMetadata, selectedValidator) {
14
+ if (nominatorMetadata.type === StakingType.LIQUID_STAKING) {
15
+ return [];
16
+ }
13
17
  if (_STAKING_CHAIN_GROUP.relay.includes(chain)) {
14
18
  return validateRelayUnbondingCondition(amount, chainStakingMetadata, nominatorMetadata);
15
19
  }