liquidity.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <script setup lang="ts">
  2. /* Import modules. */
  3. import BCHJS from '@psf/bch-js'
  4. // REST API servers.
  5. const BCHN_MAINNET = 'https://bchn.fullstack.cash/v5/'
  6. // const runtimeConfig = useRuntimeConfig()
  7. // const jwtAuthToken = runtimeConfig.public.PSF_JWT_AUTH_TOKEN
  8. const balances = ref(null)
  9. const cashAddress = ref(null)
  10. const utxos = ref(null)
  11. // Instantiate bch-js based on the network.
  12. const bchjs = new BCHJS({
  13. restURL: BCHN_MAINNET,
  14. // apiToken: jwtAuthToken,
  15. })
  16. // console.log('bchjs', bchjs)
  17. definePageMeta({
  18. layout: 'admin',
  19. })
  20. useHead({
  21. title: `Liquidity Provider — Hush Your Money`,
  22. meta: [
  23. { name: 'description', content: `Provide additional liquidity & anonymity to the Hush Your Money community.` }
  24. ],
  25. })
  26. /* Initialize stores. */
  27. import { useSystemStore } from '@/stores/system'
  28. import { useWalletStore } from '@/stores/wallet'
  29. const System = useSystemStore()
  30. const Wallet = useWalletStore()
  31. const init = async () => {
  32. /* Initialize locals. */
  33. let childNode
  34. let masterHdnode
  35. let response
  36. let rootSeed
  37. // utxos.value = []
  38. if (typeof Wallet.mnemonic === 'undefined' || Wallet.mnemonic === null) {
  39. throw new Error('NO mnemonic available to create wallet.')
  40. }
  41. /* Set root seed. */
  42. rootSeed = await bchjs.Mnemonic.toSeed(Wallet.mnemonic)
  43. // console.log('rootSeed', rootSeed)
  44. /* Set HD master node. */
  45. masterHdnode = bchjs.HDNode.fromSeed(rootSeed)
  46. // console.log('masterHdnode', masterHdnode);
  47. /* Set child node. */
  48. childNode = masterHdnode.derivePath(`m/44'/145'/0'/0/0`)
  49. // console.log('childNode', childNode)
  50. /* Set Bitcoin Cash address. */
  51. cashAddress.value = bchjs.HDNode.toCashAddress(childNode)
  52. console.log('cashAddress', cashAddress.value)
  53. // response = await bchjs.Electrumx.utxo(cashAddress.value)
  54. // console.log('RESPONSE', response)
  55. /* Set UTXOs. */
  56. // utxos.value = response.utxos
  57. // utxos.value = response.utxos.filter(_utxo => {
  58. // return _utxo.value >= 10000 // NOTE: Protocol DUST limit (100 bits).
  59. // })
  60. // console.log('UTXOS', JSON.stringify(utxos.value, null, 2))
  61. /* Request balances. */
  62. // response = await bchjs.Electrumx.balance(cashAddress.value)
  63. /* Validate response. */
  64. // if (response.success) {
  65. // /* Set balances. */
  66. // balances.value = response.balance
  67. // console.log('BALANCES', balances.value)
  68. // }
  69. }
  70. onMounted(() => {
  71. init()
  72. })
  73. // onBeforeUnmount(() => {
  74. // console.log('Before Unmount!')
  75. // // Now is the time to perform all cleanup operations.
  76. // })
  77. </script>
  78. <template>
  79. <main class="max-w-5xl mx-auto py-5 flex flex-col gap-4">
  80. <h1 class="text-5xl font-medium">
  81. Liquidity Provider
  82. </h1>
  83. <section class="mt-5 w-full lg:w-2/3 flex flex-col gap-4">
  84. <h2 class="text-fuchsia-500 text-4xl font-light italic tracking-tight">
  85. What does an LP do?
  86. </h2>
  87. <p class="text-fuchsia-800 text-2xl font-light leading-8 italic">
  88. If this was a playground, LPs would be the ones turning the double dutch ropes for everyone else to enjoy a great time!
  89. </p>
  90. <p class="text-gray-600 text-lg font-light leading-7">
  91. Liquidity is spread across ALL <NuxtLink to="/help/tiers" class="text-blue-500 font-normal hover:underline">Tiers</NuxtLink> to maximize its utility to the greatest number of active <NuxtLink to="/help/guests" class="text-blue-500 font-normal hover:underline">Club Guests</NuxtLink>.
  92. The Hush Protocol, powered by a community of independently operated Hush Your Money (HYM) Clubs, is engineered <em>(i.e. financially incentivized)</em> to offer sub 15-seconds <NuxtLink to="/help/coinjoin" class="text-blue-500 font-normal hover:underline">CoinJoins</NuxtLink>, consistently!
  93. </p>
  94. </section>
  95. <section class="w-full w-3/4 py-10 flex justify-center">
  96. <Loading v-if="Wallet.isLoading" />
  97. <WalletSetup v-else-if="!Wallet.isReady" />
  98. <WalletWelcome v-else
  99. :balances="balances"
  100. :cashAddress="cashAddress"
  101. :utxos="utxos"
  102. />
  103. </section>
  104. </main>
  105. </template>