Skip to content

Commit

Permalink
add simple supply view
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Apr 6, 2024
1 parent b354dae commit 1c3ff88
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { apiReady, apiUrl, apiUrlNote } from '../store'
import type { EventObj, ViewObj } from './payloads/types'

// const DEBUG_URL: string = 'https://rpc.openlibra.space:8080/v1/'
const DEBUG_URL: string = 'http://99.145.200.98:8080/v1/'
const DEBUG_URL: string = 'http://138.197.32.103:8080/v1/'

export let api

Expand Down
1 change: 1 addition & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export const TESTNET_SEED_NODES =
'https://raw.githubusercontent.com/0LNetworkCommunity/seed-peers/main/fullnode_seed_playlist_testnet.json'

export const COIN_SCALING = 1_000_000
export const FINAL_SUPPLY = 100_000_000_000
19 changes: 12 additions & 7 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
import { onMount } from 'svelte'
import { initApi, setApi } from '../api'
import { apiUrl, apiUrlNote } from '../store'
import { apiUrl, apiUrlNote, selectedAccount } from '../store'
import { refresh } from '../store/get_system_info'
import Supply from '../ui/Supply.svelte'
import AccountView from '../ui/AccountView.svelte'
import SystemInfo from '../ui/SystemInfo.svelte'
import BoundaryStatus from '../ui/BoundaryStatus.svelte'
import GovEvents from '../ui/GovEvents.svelte'
import Validators from '../ui/Validators.svelte'
onMount(async () => {
await initApi() // ONLY DO THIS ONCE ON LOAD
Expand Down Expand Up @@ -37,22 +42,22 @@
{/if}
</div>
</div>
<Supply />
<Supply />

<!-- <div class="uk-flex">
<div class="uk-flex">
{#if $selectedAccount && $selectedAccount.address}
<AccountView />
{:else}
<SystemInfo />
<BoundaryStatus />
<GovEvents/>
<GovEvents />
{/if}
</div>
<div class="uk-flex">
<Validators />
</div>
<div class="uk-flex">
<!-- <div class="uk-flex">
<TransactionTable />
</div>
</div> -->
</div> -->
</div>
</main>
31 changes: 30 additions & 1 deletion src/store/get_supply.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
import { supplyStore } from '.'
import { postViewFunc } from '../api'
import { COIN_SCALING } from '../constants'
import { COIN_SCALING, FINAL_SUPPLY } from '../constants'
import type { SupplyData } from '../types'

export const supplySimple = async (): Promise<SupplyData> => {
const supply_query = await postViewFunc({
function: '0x1::supply::get_stats',
arguments: [],
type_arguments: [],
});
console.log(supply_query);

const total = supply_query[0] / COIN_SCALING
const burn = (FINAL_SUPPLY - total)
const infra = supply_query[3] / COIN_SCALING
const comm = supply_query[2] / COIN_SCALING
const slow = supply_query[1] / COIN_SCALING
const circulating = supply_query[4] / COIN_SCALING
const user = (slow + circulating)
const s = {
final: FINAL_SUPPLY,
total,
burn,
infra,
comm,
slow,
user,
circulating,
}
supplyStore.set(s)
return s
}

export const populateSupply = async (): Promise<SupplyData> => {
const supply_type: SupplyData = {
final: 10_000_000_000,
Expand Down
5 changes: 3 additions & 2 deletions src/store/get_system_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as commonPayloads from '../api/payloads/common'
import { govEvents } from '../api/payloads/events'
import { fetchTransactions } from './transactions.js'
import { govStore, indexDataStore, systemInfo, valDataStore } from '.'
import { populateSupply } from './get_supply'
import { populateSupply, supplySimple } from './get_supply'

export const getIndexData = async () => {
try {
Expand Down Expand Up @@ -123,7 +123,8 @@ export const refresh = async () => {
try {

getIndexData()
populateSupply()
// populateSupply()
supplySimple()
getSystemInfo()
getValidators()
fetchTransactions()
Expand Down
1 change: 0 additions & 1 deletion src/ui/Supply.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import Card from './Card.svelte'
import { supplyStore } from '../store'
import { onMount } from 'svelte'
</script>

Expand Down

0 comments on commit 1c3ff88

Please sign in to comment.