@subwallet/extension-base 1.1.33-beta.3 → 1.1.35-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 (310) 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 +16 -1
  28. package/cjs/services/chain-service/index.js +2 -5
  29. package/cjs/services/chain-service/utils.js +1 -7
  30. package/cjs/services/event-service/index.js +0 -5
  31. package/cjs/services/keyring-service/index.js +2 -14
  32. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  33. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  34. package/cjs/services/migration-service/scripts/index.js +1 -6
  35. package/cjs/services/notification-service/NotificationService.js +1 -1
  36. package/cjs/services/storage-service/DatabaseService.js +0 -63
  37. package/cjs/services/storage-service/databases/index.js +0 -4
  38. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  39. package/cjs/services/subscan-service/index.js +0 -16
  40. package/cjs/services/transaction-service/event-parser/index.js +0 -58
  41. package/cjs/services/transaction-service/helpers/index.js +1 -3
  42. package/cjs/services/transaction-service/index.js +75 -249
  43. package/cjs/services/transaction-service/utils.js +0 -1
  44. package/cjs/types/index.js +0 -44
  45. package/cjs/utils/fetchStaticData.js +1 -2
  46. package/cjs/utils/index.js +1 -89
  47. package/cjs/utils/number.js +2 -6
  48. package/constants/index.d.ts +1 -6
  49. package/constants/index.js +1 -6
  50. package/koni/api/nft/config.js +23 -33
  51. package/koni/api/nft/index.js +1 -15
  52. package/koni/api/nft/nft.js +23 -2
  53. package/koni/api/staking/bonding/amplitude.js +10 -13
  54. package/koni/api/staking/bonding/astar.js +8 -9
  55. package/koni/api/staking/bonding/index.d.ts +1 -1
  56. package/koni/api/staking/bonding/index.js +1 -5
  57. package/koni/api/staking/bonding/paraChain.js +10 -12
  58. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  59. package/koni/api/staking/bonding/relayChain.js +30 -33
  60. package/koni/api/staking/bonding/utils.d.ts +38 -15
  61. package/koni/api/staking/bonding/utils.js +69 -85
  62. package/koni/api/staking/index.js +1 -2
  63. package/koni/api/staking/paraChain.js +18 -11
  64. package/koni/api/staking/relayChain.js +3 -4
  65. package/koni/background/cron.d.ts +4 -0
  66. package/koni/background/cron.js +22 -4
  67. package/koni/background/handlers/Extension.d.ts +1 -17
  68. package/koni/background/handlers/Extension.js +30 -327
  69. package/koni/background/handlers/State.d.ts +1 -6
  70. package/koni/background/handlers/State.js +12 -17
  71. package/koni/background/handlers/index.js +2 -4
  72. package/koni/background/subscription.d.ts +6 -1
  73. package/koni/background/subscription.js +104 -8
  74. package/package.json +7 -320
  75. package/packageInfo.js +1 -1
  76. package/services/balance-service/helpers/subscribe/substrate/index.js +2 -4
  77. package/services/campaign-service/index.js +6 -9
  78. package/services/chain-service/constants.d.ts +12 -0
  79. package/services/chain-service/constants.js +14 -0
  80. package/services/chain-service/index.js +2 -5
  81. package/services/chain-service/utils.d.ts +0 -1
  82. package/services/chain-service/utils.js +1 -5
  83. package/services/event-service/index.d.ts +0 -2
  84. package/services/event-service/index.js +0 -5
  85. package/services/event-service/types.d.ts +0 -9
  86. package/services/keyring-service/index.d.ts +1 -2
  87. package/services/keyring-service/index.js +2 -14
  88. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  89. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  90. package/services/migration-service/scripts/index.js +1 -6
  91. package/services/notification-service/NotificationService.js +1 -1
  92. package/services/storage-service/DatabaseService.d.ts +1 -22
  93. package/services/storage-service/DatabaseService.js +0 -63
  94. package/services/storage-service/databases/index.d.ts +1 -3
  95. package/services/storage-service/databases/index.js +0 -4
  96. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  97. package/services/subscan-service/index.d.ts +2 -3
  98. package/services/subscan-service/index.js +0 -15
  99. package/services/subscan-service/types.d.ts +0 -20
  100. package/services/transaction-service/event-parser/index.d.ts +1 -3
  101. package/services/transaction-service/event-parser/index.js +1 -57
  102. package/services/transaction-service/helpers/index.js +1 -3
  103. package/services/transaction-service/index.d.ts +13 -6
  104. package/services/transaction-service/index.js +73 -247
  105. package/services/transaction-service/types.d.ts +0 -2
  106. package/services/transaction-service/utils.js +0 -1
  107. package/types/index.d.ts +0 -5
  108. package/types/index.js +1 -5
  109. package/utils/fetchStaticData.js +1 -2
  110. package/utils/index.d.ts +0 -5
  111. package/utils/index.js +0 -52
  112. package/utils/number.d.ts +1 -2
  113. package/utils/number.js +1 -2
  114. package/cjs/koni/api/dotsama/balance.js +0 -464
  115. package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
  116. package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
  117. package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
  118. package/cjs/koni/api/yield/helper/utils.js +0 -46
  119. package/cjs/services/earning-service/constants/chains.js +0 -30
  120. package/cjs/services/earning-service/constants/index.js +0 -27
  121. package/cjs/services/earning-service/constants/step.js +0 -18
  122. package/cjs/services/earning-service/handlers/base.js +0 -262
  123. package/cjs/services/earning-service/handlers/index.js +0 -60
  124. package/cjs/services/earning-service/handlers/lending/base.js +0 -81
  125. package/cjs/services/earning-service/handlers/lending/index.js +0 -13
  126. package/cjs/services/earning-service/handlers/lending/interlay.js +0 -192
  127. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -240
  128. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -97
  129. package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -140
  130. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -298
  131. package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
  132. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -227
  133. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -404
  134. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -434
  135. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -466
  136. package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
  137. package/cjs/services/earning-service/handlers/native-staking/base.js +0 -161
  138. package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
  139. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -390
  140. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -567
  141. package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -566
  142. package/cjs/services/earning-service/handlers/special.js +0 -493
  143. package/cjs/services/earning-service/service.js +0 -740
  144. package/cjs/services/earning-service/utils/index.js +0 -128
  145. package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
  146. package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
  147. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
  148. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
  149. package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
  150. package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
  151. package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
  152. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
  153. package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
  154. package/cjs/services/mint-campaign-service/constants.js +0 -11
  155. package/cjs/services/mint-campaign-service/index.js +0 -18
  156. package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
  157. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -71
  158. package/cjs/services/storage-service/index.js +0 -241
  159. package/cjs/types/campaigns/index.js +0 -16
  160. package/cjs/types/campaigns/unlock-dot.js +0 -1
  161. package/cjs/types/ordinal.js +0 -1
  162. package/cjs/types/transaction.js +0 -1
  163. package/cjs/types/yield/actions/index.js +0 -27
  164. package/cjs/types/yield/actions/join/index.js +0 -38
  165. package/cjs/types/yield/actions/join/step.js +0 -47
  166. package/cjs/types/yield/actions/join/submit.js +0 -1
  167. package/cjs/types/yield/actions/join/validate.js +0 -16
  168. package/cjs/types/yield/actions/others.js +0 -1
  169. package/cjs/types/yield/index.js +0 -27
  170. package/cjs/types/yield/info/account/index.js +0 -49
  171. package/cjs/types/yield/info/account/info.js +0 -1
  172. package/cjs/types/yield/info/account/reward.js +0 -1
  173. package/cjs/types/yield/info/account/target.js +0 -32
  174. package/cjs/types/yield/info/account/unstake.js +0 -27
  175. package/cjs/types/yield/info/base.js +0 -41
  176. package/cjs/types/yield/info/chain/index.js +0 -27
  177. package/cjs/types/yield/info/chain/info.js +0 -1
  178. package/cjs/types/yield/info/chain/target.js +0 -1
  179. package/cjs/types/yield/info/index.js +0 -49
  180. package/cjs/types/yield/info/pallet.js +0 -15
  181. package/cjs/types.js +0 -1
  182. package/cjs/utils/address.js +0 -34
  183. package/cjs/utils/keyring.js +0 -57
  184. package/cjs/utils/object.js +0 -12
  185. package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
  186. package/koni/api/nft/ordinal_nft/constants.js +0 -12
  187. package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
  188. package/koni/api/nft/ordinal_nft/index.js +0 -114
  189. package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
  190. package/koni/api/nft/ordinal_nft/utils.js +0 -33
  191. package/koni/api/yield/helper/utils.d.ts +0 -10
  192. package/koni/api/yield/helper/utils.js +0 -32
  193. package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
  194. package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
  195. package/services/earning-service/constants/chains.d.ts +0 -15
  196. package/services/earning-service/constants/chains.js +0 -22
  197. package/services/earning-service/constants/index.d.ts +0 -2
  198. package/services/earning-service/constants/index.js +0 -5
  199. package/services/earning-service/constants/step.d.ts +0 -3
  200. package/services/earning-service/constants/step.js +0 -10
  201. package/services/earning-service/handlers/base.d.ts +0 -113
  202. package/services/earning-service/handlers/base.js +0 -256
  203. package/services/earning-service/handlers/index.d.ts +0 -5
  204. package/services/earning-service/handlers/index.js +0 -8
  205. package/services/earning-service/handlers/lending/base.d.ts +0 -8
  206. package/services/earning-service/handlers/lending/base.js +0 -73
  207. package/services/earning-service/handlers/lending/index.d.ts +0 -1
  208. package/services/earning-service/handlers/lending/index.js +0 -4
  209. package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
  210. package/services/earning-service/handlers/lending/interlay.js +0 -184
  211. package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
  212. package/services/earning-service/handlers/liquid-staking/acala.js +0 -232
  213. package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -11
  214. package/services/earning-service/handlers/liquid-staking/base.js +0 -89
  215. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
  216. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -287
  217. package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
  218. package/services/earning-service/handlers/liquid-staking/index.js +0 -7
  219. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
  220. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -219
  221. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
  222. package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -394
  223. package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
  224. package/services/earning-service/handlers/native-staking/amplitude.js +0 -425
  225. package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
  226. package/services/earning-service/handlers/native-staking/astar.js +0 -456
  227. package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
  228. package/services/earning-service/handlers/native-staking/base-para.js +0 -138
  229. package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
  230. package/services/earning-service/handlers/native-staking/base.js +0 -152
  231. package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
  232. package/services/earning-service/handlers/native-staking/index.js +0 -7
  233. package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
  234. package/services/earning-service/handlers/native-staking/para-chain.js +0 -382
  235. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
  236. package/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
  237. package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
  238. package/services/earning-service/handlers/nomination-pool/index.js +0 -556
  239. package/services/earning-service/handlers/special.d.ts +0 -64
  240. package/services/earning-service/handlers/special.js +0 -485
  241. package/services/earning-service/service.d.ts +0 -94
  242. package/services/earning-service/service.js +0 -729
  243. package/services/earning-service/utils/index.d.ts +0 -18
  244. package/services/earning-service/utils/index.js +0 -112
  245. package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
  246. package/services/migration-service/scripts/DeleteEarningData.js +0 -13
  247. package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
  248. package/services/migration-service/scripts/EnableEarningChains.js +0 -13
  249. package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
  250. package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
  251. package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
  252. package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
  253. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
  254. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
  255. package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
  256. package/services/mint-campaign-service/campaigns/index.js +0 -4
  257. package/services/mint-campaign-service/constants.d.ts +0 -1
  258. package/services/mint-campaign-service/constants.js +0 -4
  259. package/services/mint-campaign-service/index.d.ts +0 -7
  260. package/services/mint-campaign-service/index.js +0 -11
  261. package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
  262. package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
  263. package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -11
  264. package/services/storage-service/db-stores/YieldPositionStore.js +0 -63
  265. package/types/campaigns/index.d.ts +0 -1
  266. package/types/campaigns/index.js +0 -4
  267. package/types/campaigns/unlock-dot.d.ts +0 -71
  268. package/types/campaigns/unlock-dot.js +0 -1
  269. package/types/ordinal.d.ts +0 -69
  270. package/types/ordinal.js +0 -1
  271. package/types/transaction.d.ts +0 -3
  272. package/types/transaction.js +0 -1
  273. package/types/yield/actions/index.d.ts +0 -2
  274. package/types/yield/actions/index.js +0 -5
  275. package/types/yield/actions/join/index.d.ts +0 -3
  276. package/types/yield/actions/join/index.js +0 -6
  277. package/types/yield/actions/join/step.d.ts +0 -95
  278. package/types/yield/actions/join/step.js +0 -46
  279. package/types/yield/actions/join/submit.d.ts +0 -58
  280. package/types/yield/actions/join/submit.js +0 -1
  281. package/types/yield/actions/join/validate.d.ts +0 -18
  282. package/types/yield/actions/join/validate.js +0 -10
  283. package/types/yield/actions/others.d.ts +0 -85
  284. package/types/yield/actions/others.js +0 -1
  285. package/types/yield/index.d.ts +0 -2
  286. package/types/yield/index.js +0 -5
  287. package/types/yield/info/account/index.d.ts +0 -4
  288. package/types/yield/info/account/index.js +0 -7
  289. package/types/yield/info/account/info.d.ts +0 -92
  290. package/types/yield/info/account/info.js +0 -1
  291. package/types/yield/info/account/reward.d.ts +0 -47
  292. package/types/yield/info/account/reward.js +0 -1
  293. package/types/yield/info/account/target.d.ts +0 -43
  294. package/types/yield/info/account/target.js +0 -27
  295. package/types/yield/info/account/unstake.d.ts +0 -31
  296. package/types/yield/info/account/unstake.js +0 -22
  297. package/types/yield/info/base.d.ts +0 -45
  298. package/types/yield/info/base.js +0 -36
  299. package/types/yield/info/chain/index.d.ts +0 -2
  300. package/types/yield/info/chain/index.js +0 -5
  301. package/types/yield/info/chain/info.d.ts +0 -252
  302. package/types/yield/info/chain/info.js +0 -1
  303. package/types/yield/info/chain/target.d.ts +0 -37
  304. package/types/yield/info/chain/target.js +0 -1
  305. package/types/yield/info/index.d.ts +0 -4
  306. package/types/yield/info/index.js +0 -7
  307. package/types/yield/info/pallet.d.ts +0 -143
  308. package/types/yield/info/pallet.js +0 -9
  309. package/utils/object.d.ts +0 -1
  310. package/utils/object.js +0 -6
@@ -1,18 +0,0 @@
1
- import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
2
- import { LendingYieldPoolInfo, LiquidYieldPoolInfo, NativeYieldPoolInfo, NominationYieldPoolInfo, YieldAssetExpectedEarning, YieldCompoundingPeriod, YieldPoolInfo, YieldPoolType } from '@subwallet/extension-base/types';
3
- export declare function calculateReward(apr: number, amount?: number, compoundingPeriod?: YieldCompoundingPeriod, isApy?: boolean): YieldAssetExpectedEarning;
4
- /**
5
- * @returns
6
- * <p>
7
- * [0] - identity
8
- * </p>
9
- * <p>
10
- * [1] - isReasonable (isVerified)
11
- * </p>
12
- * */
13
- export declare function parseIdentity(substrateApi: _SubstrateApi, address: string, children?: string): Promise<[string | undefined, boolean]>;
14
- export declare function isActionFromValidator(stakingType: YieldPoolType, chain: string): boolean;
15
- export declare const isNominationPool: (pool: YieldPoolInfo) => pool is NominationYieldPoolInfo;
16
- export declare const isNativeStakingPool: (pool: YieldPoolInfo) => pool is NativeYieldPoolInfo;
17
- export declare const isLiquidPool: (pool: YieldPoolInfo) => pool is LiquidYieldPoolInfo;
18
- export declare const isLendingPool: (pool: YieldPoolInfo) => pool is LendingYieldPoolInfo;
@@ -1,112 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-base
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
5
- import { YieldCompoundingPeriod, YieldPoolType } from '@subwallet/extension-base/types';
6
- import { hexToString, isHex } from '@polkadot/util';
7
- export function calculateReward(apr, amount = 0, compoundingPeriod = YieldCompoundingPeriod.YEARLY, isApy = false) {
8
- if (!apr) {
9
- return {};
10
- }
11
- if (!isApy) {
12
- const periodApr = apr / 365 * compoundingPeriod; // APR is always annually
13
- const earningRatio = periodApr / 100 / compoundingPeriod;
14
- const periodApy = (1 + earningRatio) ** compoundingPeriod - 1;
15
- const reward = periodApy * amount;
16
- return {
17
- apy: periodApy * 100,
18
- rewardInToken: reward
19
- };
20
- } else {
21
- const reward = apr / 100 * amount;
22
- return {
23
- apy: apr,
24
- rewardInToken: reward * (compoundingPeriod / YieldCompoundingPeriod.YEARLY)
25
- };
26
- }
27
- }
28
-
29
- /**
30
- * @returns
31
- * <p>
32
- * [0] - identity
33
- * </p>
34
- * <p>
35
- * [1] - isReasonable (isVerified)
36
- * </p>
37
- * */
38
- export async function parseIdentity(substrateApi, address, children) {
39
- const compactResult = rs => {
40
- const result = [];
41
- if (rs) {
42
- result.push(rs);
43
- }
44
- if (children) {
45
- result.push(children);
46
- }
47
- if (result.length > 0) {
48
- return result.join('/');
49
- } else {
50
- return undefined;
51
- }
52
- };
53
- if (substrateApi.api.query.identity) {
54
- let identity;
55
- const _parent = await substrateApi.api.query.identity.superOf(address);
56
- const parentInfo = _parent.toHuman();
57
- if (parentInfo) {
58
- const [parentAddress, {
59
- Raw: data
60
- }] = parentInfo;
61
- const child = isHex(data) ? hexToString(data) : data;
62
-
63
- // TODO: Re-check
64
- if (address !== parentAddress) {
65
- const [rs, isReasonable] = await parseIdentity(substrateApi, parentAddress, child);
66
- return [compactResult(rs), isReasonable];
67
- }
68
- }
69
- const _identity = await substrateApi.api.query.identity.identityOf(address);
70
- const identityInfo = _identity.toHuman();
71
- if (identityInfo) {
72
- var _identityInfo$info, _identityInfo$info$di, _identityInfo$info2, _identityInfo$info2$w, _identityInfo$info3, _identityInfo$info3$r, _identityInfo$info4, _identityInfo$info4$t;
73
- const displayName = (_identityInfo$info = identityInfo.info) === null || _identityInfo$info === void 0 ? void 0 : (_identityInfo$info$di = _identityInfo$info.display) === null || _identityInfo$info$di === void 0 ? void 0 : _identityInfo$info$di.Raw;
74
- const web = (_identityInfo$info2 = identityInfo.info) === null || _identityInfo$info2 === void 0 ? void 0 : (_identityInfo$info2$w = _identityInfo$info2.web) === null || _identityInfo$info2$w === void 0 ? void 0 : _identityInfo$info2$w.Raw;
75
- const riot = (_identityInfo$info3 = identityInfo.info) === null || _identityInfo$info3 === void 0 ? void 0 : (_identityInfo$info3$r = _identityInfo$info3.riot) === null || _identityInfo$info3$r === void 0 ? void 0 : _identityInfo$info3$r.Raw;
76
- const twitter = (_identityInfo$info4 = identityInfo.info) === null || _identityInfo$info4 === void 0 ? void 0 : (_identityInfo$info4$t = _identityInfo$info4.twitter) === null || _identityInfo$info4$t === void 0 ? void 0 : _identityInfo$info4$t.Raw;
77
- const isReasonable = identityInfo.judgements.length > 0;
78
- if (displayName) {
79
- identity = isHex(displayName) ? hexToString(displayName) : displayName;
80
- } else {
81
- identity = twitter || web || riot;
82
- }
83
- return [compactResult(identity), isReasonable];
84
- }
85
- }
86
- return [undefined, false];
87
- }
88
- export function isActionFromValidator(stakingType, chain) {
89
- if (stakingType === YieldPoolType.NOMINATION_POOL || stakingType === YieldPoolType.LIQUID_STAKING || stakingType === YieldPoolType.LENDING) {
90
- return false;
91
- }
92
- if (_STAKING_CHAIN_GROUP.astar.includes(chain)) {
93
- return true;
94
- } else if (_STAKING_CHAIN_GROUP.amplitude.includes(chain)) {
95
- return true;
96
- } else if (_STAKING_CHAIN_GROUP.para.includes(chain)) {
97
- return true;
98
- }
99
- return false;
100
- }
101
- export const isNominationPool = pool => {
102
- return pool.type === YieldPoolType.NOMINATION_POOL;
103
- };
104
- export const isNativeStakingPool = pool => {
105
- return pool.type === YieldPoolType.NATIVE_STAKING;
106
- };
107
- export const isLiquidPool = pool => {
108
- return pool.type === YieldPoolType.LIQUID_STAKING;
109
- };
110
- export const isLendingPool = pool => {
111
- return pool.type === YieldPoolType.LENDING;
112
- };
@@ -1,4 +0,0 @@
1
- import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
2
- export default class DeleteEarningData extends BaseMigrationJob {
3
- run(): Promise<void>;
4
- }
@@ -1,13 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
5
- export default class DeleteEarningData extends BaseMigrationJob {
6
- async run() {
7
- try {
8
- await this.state.dbService.deleteYieldPoolInfo(['LcDOT___acala_euphrates_liquid_staking', 'xcDOT___moonwell_lending']);
9
- } catch (e) {
10
- console.error(e);
11
- }
12
- }
13
- }
@@ -1,4 +0,0 @@
1
- import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
2
- export default class EnableEarningChains extends BaseMigrationJob {
3
- run(): Promise<void>;
4
- }
@@ -1,13 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
5
- export default class EnableEarningChains extends BaseMigrationJob {
6
- async run() {
7
- try {
8
- await this.state.chainService.enableChains(['moonbeam', 'acala', 'bifrost_dot', 'interlay', 'parallel']);
9
- } catch (e) {
10
- console.error(e);
11
- }
12
- }
13
- }
@@ -1,4 +0,0 @@
1
- import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
2
- export default class MigrateEarningHistory extends BaseMigrationJob {
3
- run(): Promise<void>;
4
- }
@@ -1,13 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
5
- export default class MigrateEarningHistory extends BaseMigrationJob {
6
- async run() {
7
- try {
8
- await this.state.dbService.removeOldEarningData();
9
- } catch (e) {
10
- console.error(e);
11
- }
12
- }
13
- }
@@ -1,4 +0,0 @@
1
- import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
2
- export default class MigrateEarningVersion extends BaseMigrationJob {
3
- run(): Promise<void>;
4
- }
@@ -1,13 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
5
- export default class MigrateEarningVersion extends BaseMigrationJob {
6
- async run() {
7
- try {
8
- await this.state.dbService.removeOldEarningData();
9
- } catch (e) {
10
- console.error(e);
11
- }
12
- }
13
- }
@@ -1,13 +0,0 @@
1
- import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
2
- import { UnlockDotSubmitMintData, UnlockDotTransactionNft } from '@subwallet/extension-base/types';
3
- export default class UnlockDotCampaign {
4
- #private;
5
- constructor(state: KoniState);
6
- mintNft({ address, extrinsicHash, network, slug, transactionId }: UnlockDotSubmitMintData): Promise<void>;
7
- private checkMint;
8
- private submitNft;
9
- private getMinted;
10
- canMint(address: string, slug: string, network: string): Promise<boolean>;
11
- subscribeMintedNft(transactionId: string, cb: (data: UnlockDotTransactionNft) => void): import("rxjs").Subscription;
12
- getMintedNft(transactionId: string): UnlockDotTransactionNft;
13
- }
@@ -1,139 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { isSameAddress } from '@subwallet/extension-base/utils';
5
- import axios from 'axios';
6
- import { BehaviorSubject } from 'rxjs';
7
- import { MINT_HOST } from "../constants.js";
8
- export default class UnlockDotCampaign {
9
- #host = MINT_HOST;
10
- #campaignId = 4;
11
- #state;
12
- #transactionNftSubject = new BehaviorSubject({});
13
- #transactionNftState = {};
14
- constructor(state) {
15
- this.#state = state;
16
- }
17
- async mintNft({
18
- address,
19
- extrinsicHash,
20
- network,
21
- slug,
22
- transactionId
23
- }) {
24
- var _result;
25
- this.#transactionNftState[transactionId] = undefined;
26
- this.#transactionNftSubject.next(this.#transactionNftState);
27
- const requestId = await this.checkMint({
28
- address,
29
- extrinsicHash,
30
- network,
31
- slug
32
- });
33
- let result;
34
- if (requestId) {
35
- result = await this.submitNft(address, requestId);
36
- await this.#state.reloadNft();
37
- // } else {
38
- // result = await this.getMinted(address, slug);
39
- }
40
-
41
- this.#transactionNftState[transactionId] = (_result = result) !== null && _result !== void 0 ? _result : {
42
- nftImage: ''
43
- };
44
- this.#transactionNftSubject.next(this.#transactionNftState);
45
- }
46
- async checkMint({
47
- address,
48
- extrinsicHash,
49
- network,
50
- slug
51
- }) {
52
- const data = {
53
- address,
54
- campaignId: this.#campaignId,
55
- category: slug,
56
- additionalData: {
57
- slug,
58
- extrinsicHash,
59
- network
60
- }
61
- };
62
- const response = await axios.request({
63
- baseURL: this.#host,
64
- url: '/api/mint/check',
65
- method: 'POST',
66
- data
67
- });
68
- const respData = response.data;
69
- if (respData.inMintingTime && respData.hasBalance && respData.validCampaign && respData.validCategory && respData.validUser && respData.notDuplicated && respData.requestId && respData.requestId > 1) {
70
- return respData.requestId;
71
- }
72
- return null;
73
- }
74
- async submitNft(address, id) {
75
- const data = {
76
- requestId: id,
77
- recipient: address
78
- };
79
- const response = await axios.request({
80
- baseURL: this.#host,
81
- url: '/api/mint/submit',
82
- method: 'POST',
83
- data
84
- });
85
- return response.data;
86
- }
87
-
88
- // @ts-ignore
89
- async getMinted(address, slug) {
90
- const params = {
91
- address
92
- };
93
- const response = await axios.request({
94
- baseURL: this.#host,
95
- url: '/api/mint/fetch',
96
- method: 'GET',
97
- params: params
98
- });
99
- const data = response.data;
100
- for (const item of data) {
101
- if (isSameAddress(item.address, address) && slug === item.mintCategory && item.status === 'success' && item.campaignId === this.#campaignId) {
102
- return item;
103
- }
104
- }
105
- return undefined;
106
- }
107
- async canMint(address, slug, network) {
108
- const data = {
109
- address,
110
- campaignId: this.#campaignId,
111
- category: slug,
112
- additionalData: {
113
- slug,
114
- network
115
- }
116
- };
117
- const response = await axios.request({
118
- baseURL: this.#host,
119
- url: '/api/mint/check',
120
- method: 'POST',
121
- data
122
- });
123
- const respData = response.data;
124
- if (respData.inMintingTime && respData.validCampaign && respData.validCategory && respData.validUser && respData.notDuplicated) {
125
- return true;
126
- }
127
- return false;
128
- }
129
- subscribeMintedNft(transactionId, cb) {
130
- return this.#transactionNftSubject.subscribe({
131
- next: map => {
132
- cb(map[transactionId]);
133
- }
134
- });
135
- }
136
- getMintedNft(transactionId) {
137
- return this.#transactionNftSubject.value[transactionId];
138
- }
139
- }
@@ -1 +0,0 @@
1
- export { default as UnlockDotCampaign } from './UnlockDotCampaign';
@@ -1,4 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export { default as UnlockDotCampaign } from "./UnlockDotCampaign.js";
@@ -1 +0,0 @@
1
- export declare const MINT_HOST: string;
@@ -1,4 +0,0 @@
1
- // Copyright 2019-2022 @polkadot/extension-base authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export const MINT_HOST = process.env.NFT_MINTING_HOST || '';
@@ -1,7 +0,0 @@
1
- import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
2
- import { UnlockDotCampaign } from './campaigns';
3
- export default class MintCampaignService {
4
- #private;
5
- readonly unlockDotCampaign: UnlockDotCampaign;
6
- constructor(state: KoniState);
7
- }
@@ -1,11 +0,0 @@
1
- // Copyright 2019-2022 @polkadot/extension-base authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { UnlockDotCampaign } from "./campaigns/index.js";
5
- export default class MintCampaignService {
6
- #state;
7
- constructor(state) {
8
- this.#state = state;
9
- this.unlockDotCampaign = new UnlockDotCampaign(this.#state);
10
- }
11
- }
@@ -1,10 +0,0 @@
1
- import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
2
- import { YieldPoolInfo, YieldPoolType } from '@subwallet/extension-base/types';
3
- export default class YieldPoolStore extends BaseStore<YieldPoolInfo> {
4
- getAll(): Promise<YieldPoolInfo[]>;
5
- getByChains(chains: string[]): Promise<YieldPoolInfo[]>;
6
- getByChainAndType(chain: string, poolType: YieldPoolType): Promise<YieldPoolInfo | undefined>;
7
- bulkDelete(slugs: string[]): Promise<void>;
8
- getBySlug(slug: string): Promise<YieldPoolInfo | undefined>;
9
- subscribeYieldPoolInfo(chains: string[]): import("dexie").Observable<YieldPoolInfo[]>;
10
- }
@@ -1,28 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
5
- import { liveQuery } from 'dexie';
6
- export default class YieldPoolStore extends BaseStore {
7
- async getAll() {
8
- return this.table.toArray();
9
- }
10
- async getByChains(chains) {
11
- if (chains.length === 0) {
12
- return this.getAll();
13
- }
14
- return this.table.where('chain').anyOfIgnoreCase(chains).toArray();
15
- }
16
- async getByChainAndType(chain, poolType) {
17
- return this.table.where('chain').equals(chain).and(item => item.type === poolType).first();
18
- }
19
- async bulkDelete(slugs) {
20
- return this.table.bulkDelete(slugs);
21
- }
22
- async getBySlug(slug) {
23
- return this.table.get(slug);
24
- }
25
- subscribeYieldPoolInfo(chains) {
26
- return liveQuery(() => this.getByChains(chains));
27
- }
28
- }
@@ -1,11 +0,0 @@
1
- import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
2
- import { YieldPositionInfo } from '@subwallet/extension-base/types';
3
- export default class YieldPositionStore extends BaseStore<YieldPositionInfo> {
4
- getAll(): Promise<YieldPositionInfo[]>;
5
- getByAddress(addresses: string[]): Promise<YieldPositionInfo[]>;
6
- removeByAddresses(addresses: string[]): import("dexie").PromiseExtended<number>;
7
- removeByChains(chains: string[]): import("dexie").PromiseExtended<number>;
8
- getByAddressAndChains(addresses: string[], chains: string[]): Promise<YieldPositionInfo[]>;
9
- getByAddressAndSlug(address: string, slug: string): import("dexie").PromiseExtended<YieldPositionInfo | undefined>;
10
- subscribeYieldPositions(addresses: string[]): import("dexie").Observable<YieldPositionInfo[]>;
11
- }
@@ -1,63 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
5
- import { liveQuery } from 'dexie';
6
- export default class YieldPositionStore extends BaseStore {
7
- async getAll() {
8
- return this.table
9
- // .filter((item) => {
10
- // let isValidLiquidStaking = false;
11
- //
12
- // if (item.type === YieldPoolType.LIQUID_STAKING) {
13
- // const nominatorMetadata = item.metadata as NominatorMetadata;
14
- //
15
- // if (nominatorMetadata.unstakings.length > 0) {
16
- // console.log('true', item);
17
- // isValidLiquidStaking = true;
18
- // }
19
- // }
20
- //
21
- // return parseInt(item.balance[0].activeBalance) > 0 || isValidLiquidStaking;
22
- // })
23
- .toArray();
24
- }
25
- async getByAddress(addresses) {
26
- if (addresses.length === 0) {
27
- return this.getAll();
28
- }
29
- return this.table.where('address').anyOfIgnoreCase(addresses)
30
- // .filter((item) => {
31
- // let isValidLiquidStaking = false;
32
- //
33
- // if (item.type === YieldPoolType.LIQUID_STAKING) {
34
- // const nominatorMetadata = item.metadata as NominatorMetadata;
35
- //
36
- // if (nominatorMetadata && nominatorMetadata?.unstakings?.length > 0) {
37
- // isValidLiquidStaking = true;
38
- // }
39
- // }
40
- //
41
- // return parseInt(item.balance[0].activeBalance) > 0 || isValidLiquidStaking;
42
- // })
43
- .toArray();
44
- }
45
- removeByAddresses(addresses) {
46
- return this.table.where('address').anyOf(addresses).delete();
47
- }
48
- removeByChains(chains) {
49
- return this.table.where('chain').anyOf(chains).delete();
50
- }
51
- async getByAddressAndChains(addresses, chains) {
52
- return this.table.where('address').anyOfIgnoreCase(addresses).filter(item => chains.includes(item.chain)).toArray();
53
- }
54
- getByAddressAndSlug(address, slug) {
55
- return this.table.get({
56
- address,
57
- slug
58
- });
59
- }
60
- subscribeYieldPositions(addresses) {
61
- return liveQuery(() => this.getByAddress(addresses));
62
- }
63
- }
@@ -1 +0,0 @@
1
- export * from './unlock-dot';
@@ -1,4 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export * from "./unlock-dot.js";
@@ -1,71 +0,0 @@
1
- export interface UnlockDotAdditionalData {
2
- slug: string;
3
- network: string;
4
- extrinsicHash?: string;
5
- }
6
- export interface UnlockDotCheckMintRequest {
7
- address: string;
8
- additionalData: UnlockDotAdditionalData;
9
- category: string;
10
- campaignId: number;
11
- }
12
- export interface UnlockDotCheckMintResponse {
13
- requestId: number | null;
14
- userId: number;
15
- validUser: boolean;
16
- validCampaign: boolean;
17
- validCategory: boolean;
18
- isWhiteList: boolean;
19
- isOwner: boolean;
20
- hasBalance: boolean;
21
- notDuplicated: boolean;
22
- inMintingTime: boolean;
23
- }
24
- export interface UnlockDotMintedData {
25
- id: number;
26
- campaignId: number;
27
- collectionId: number;
28
- userId: number;
29
- address: string;
30
- status: string;
31
- extrinsicHash: string;
32
- mintCategory: string;
33
- mintDate: null;
34
- rmrkNftId: string;
35
- nftName: string;
36
- nftImage: string;
37
- recipient: string;
38
- blockNumber: number;
39
- additionalData: string;
40
- }
41
- export declare type UnlockDotTransactionNft = UnlockDotMintedData | undefined | Pick<UnlockDotMintedData, 'nftImage'>;
42
- export interface UnlockDotFetchMintedRequest {
43
- address: string;
44
- }
45
- export declare type UnlockDotFetchMintedResponse = UnlockDotMintedData[];
46
- export interface UnlockDotMintSubmitRequest {
47
- recipient: string;
48
- requestId: number;
49
- }
50
- export declare type UnlockDotMintSubmitResponse = UnlockDotMintedData;
51
- export interface UnlockDotCheckMintData {
52
- address: string;
53
- slug: string;
54
- network: string;
55
- extrinsicHash?: string;
56
- }
57
- export interface UnlockDotSubmitMintData {
58
- transactionId: string;
59
- address: string;
60
- slug: string;
61
- network: string;
62
- extrinsicHash: string;
63
- }
64
- export interface RequestUnlockDotCheckCanMint {
65
- address: string;
66
- slug: string;
67
- network: string;
68
- }
69
- export interface RequestUnlockDotSubscribeMintedData {
70
- transactionId: string;
71
- }
@@ -1 +0,0 @@
1
- export {};