Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Server handlers 3 #991

Open
wants to merge 42 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
15cb98b
move stats to api
janmichek Oct 24, 2024
14061e5
move transactions to api
janmichek Oct 24, 2024
f01d3b7
pass parameters to transactions
janmichek Oct 24, 2024
e834c9f
move transactions count to api
janmichek Oct 24, 2024
a4e2634
add comments
janmichek Oct 24, 2024
d8dae79
move oracles to api
janmichek Oct 24, 2024
06600fc
adapt transactions
janmichek Oct 25, 2024
eda1334
adapt oracles
janmichek Oct 25, 2024
35d3167
move oracle count
janmichek Oct 25, 2024
0be74c4
move top accounts
janmichek Oct 25, 2024
9334d54
move account transactions to api
janmichek Oct 25, 2024
d6783bd
move account details to api
janmichek Oct 25, 2024
86f641d
move oracle details to api
janmichek Oct 25, 2024
0b01054
move oracle events to api
janmichek Oct 28, 2024
d745226
move search to api
janmichek Oct 28, 2024
170295e
move nfts to api
janmichek Oct 31, 2024
bf6766f
move nfts count to api
janmichek Nov 1, 2024
d09b272
move microblocks to api
janmichek Nov 1, 2024
9bd6306
move microblocks transactions to api
janmichek Nov 1, 2024
6ea3f70
move token events to api
janmichek Nov 1, 2024
8c1f176
move token holders count to api
janmichek Nov 1, 2024
5667f63
move dex prices to api
janmichek Nov 1, 2024
84d5fcd
move dex trades to api
janmichek Nov 1, 2024
350973c
move status to api
janmichek Nov 1, 2024
35cc40b
move keyblocks to api
janmichek Nov 1, 2024
8a23386
move keyblock stats to api
janmichek Nov 4, 2024
ebc5ce7
move keyblocks chart to api
janmichek Nov 4, 2024
c8b5a57
move difficulty chart to api
janmichek Nov 4, 2024
238014e
move names chart to api
janmichek Nov 4, 2024
5363029
move names contracts.js to api
janmichek Nov 4, 2024
1cce20c
move charts to api
janmichek Nov 4, 2024
2401ce0
move token counter to api
janmichek Nov 4, 2024
3c0bef5
move dasboard stats to api
janmichek Nov 12, 2024
228ecf8
move state channels to api
janmichek Nov 13, 2024
75913f9
refactor markets proxy
janmichek Jan 2, 2025
7295b21
refactor markets proxy
janmichek Jan 2, 2025
1120761
refactor keyblock detail
janmichek Jan 3, 2025
f885dcb
refactor account names
janmichek Jan 6, 2025
b83d042
refactor account details
janmichek Jan 7, 2025
de41068
refactor account activities
janmichek Jan 7, 2025
7d3be31
refactor account transactions
janmichek Jan 7, 2025
128c8a0
refactor account names
janmichek Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cypress/e2e/app/oracles.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('oracles', () => {
cy.get('.oracles-table__data').first()
.invoke('text')
.should(hash2 => {
console.log('hash2', hash2)
expect(hash1).not.to.eq(hash2)
})
})
Expand All @@ -37,7 +36,6 @@ describe('oracles', () => {
cy.get('.oracles-table__data').first()
.invoke('text')
.should(hash2 => {
console.log('hash2', hash2)
expect(hash1).to.eq(hash2)
})
})
Expand Down
3 changes: 0 additions & 3 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ export default defineNuxtConfig({
routeRules: {
'/proxy/avatar/**': { proxy: 'https://avatars.z52da5wt.xyz/**', cors: true },
'/proxy/nodes': { proxy: 'http://138.68.22.27:3113/v2/debug/network', cors: true },
'/proxy/gate': { proxy: 'https://api.gateio.ws/api/v4/spot/tickers?currency_pair=AE_USDT', cors: true },
'/proxy/mexc': { proxy: 'https://api.mexc.com/api/v3/ticker/24hr?symbol=AEUSDT', cors: true },
'/proxy/coinw': { proxy: 'https://api.coinw.com/api/v1/public?command=returnTicker', cors: true },
},
},
modules: [
Expand Down
6 changes: 5 additions & 1 deletion src/components/AccountDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
Transactions
</th>
<td>
{{ formatNumber(accountDetails.totalTransactionsCount) }}
{{ formatNumber(totalAccountTransactionsCount) }}
</td>
</tr>
<tr
Expand Down Expand Up @@ -158,6 +158,10 @@ const props = defineProps({
type: Object,
required: true,
},
totalAccountTransactionsCount: {
type: String,
required: true,
},
})

const accountNodeUrl = computed(() =>
Expand Down
10 changes: 10 additions & 0 deletions src/components/AccountNamesPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,23 @@ const accountStore = useAccountStore()
const { fetchAccountNames } = accountStore
const { accountNames } = storeToRefs(accountStore)

// const route = useRoute()

async function loadPrevAccountNames() {
await fetchAccountNames({ queryParameters: accountNames.value.prev })
}

async function loadNextAccountNames() {
await fetchAccountNames({ queryParameters: accountNames.value.next })
}

// if (process.client) {
// // todo pass params
// const limit = computed(() => isDesktop() ? 10 : 3)
// fetchAccountNames({ accountId: route.params.id, limit })
// // fetchOracleEvents(`/v3/oracles/${route.params.id}/responses?limit=${limit.value}`)
// }

</script>

<style scoped>
Expand Down
26 changes: 11 additions & 15 deletions src/components/AeCoinMarketsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<template v-else>
<ae-coin-markets-table
class="u-hidden-mobile"
:gate="gate"
:mexc="mexc"
:hot-coin="hotCoin"
:coin-store="coinStore"
:coin-w="coinW"/>
:gate="coinMarkets.gate"
:mexc="coinMarkets.mexc"
:hot-coin="coinMarkets.hotcoin"
:coin-store="coinMarkets.coinstore"
:coin-w="coinMarkets.coinw"/>
<ae-coin-markets-table-condensed
class="u-hidden-desktop"
:gate="gate"
:mexc="mexc"
:hot-coin="hotCoin"
:coin-store="coinStore"
:coin-w="coinW"/>
:gate="coinMarkets.gate"
:mexc="coinMarkets.mexc"
:hot-coin="coinMarkets.hotcoin"
:coin-store="coinMarkets.coinstore"
:coin-w="coinMarkets.coinw"/>
</template>
</app-panel>
</template>
Expand All @@ -27,12 +27,8 @@ import { useAeCoinStore } from '@/stores/aeCoin'
const aeCoinStore = useAeCoinStore()
const { fetchMarketStats } = aeCoinStore
const {
gate,
mexc,
hotCoin,
coinStore,
coinW,
isLoading,
coinMarkets,
} = storeToRefs(aeCoinStore)

await useAsyncData(async() => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/DashboardStateChannelsTable.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<template>
aaa
{{ stateChannels }}
<table>
<thead>
<tr>
Expand Down
1 change: 1 addition & 0 deletions src/components/KeyblockMicroblocksPanel.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<app-panel class="keyblock-microblock-panel">
microblocks > {{ microblocks }}
<paginated-content
v-model:page-index="pageIndex"
pagination-style="history"
Expand Down
11 changes: 8 additions & 3 deletions src/components/OracleEventsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ const route = useRoute()
const pageIndex = ref(1)

function loadPrevEvents() {
fetchOracleEvents(oracleEvents.value.prev)

fetchOracleEvents(route.params.id)
// fetchOracleEvents(oracleEvents.value.prev)
}

function loadNextEvents() {
fetchOracleEvents(oracleEvents.value.next)
fetchOracleEvents(route.params.id)
// fetchOracleEvents(oracleEvents.value.next)
}

if (process.client) {
// todo pass params
const limit = computed(() => isDesktop() ? 10 : 3)
fetchOracleEvents(`/v3/oracles/${route.params.id}/responses?limit=${limit.value}`)
fetchOracleEvents(route.params.id)
// fetchOracleEvents(`/v3/oracles/${route.params.id}/responses?limit=${limit.value}`)
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/components/TheNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const menuOptions = ref([{
submenu: [
{
name: 'AE Coin',
path: '/tokens/AE',
path: '/tokens/ae',
},
{
name: 'AEX9 Tokens',
Expand Down
7 changes: 4 additions & 3 deletions src/components/TimestampLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const relativeUpdated = ref(null)
const intervalRef = ref(null)

const absolute = computed(() => {
return props.timestamp.toLocaleString(DateTime.DATETIME_SHORT)
return props.timestamp
})

const labelTime = computed(() => {
Expand All @@ -62,7 +62,8 @@ const dynamicInterval = computed(() => {
})

const expirationDuration = computed(() => {
return props.timestamp.diffNow().shiftTo(...DATETIME_UNITS)
// todo moc velky kejkle idelne passnout object
return DateTime.fromFormat(props.timestamp, 'f').diffNow().shiftTo(...DATETIME_UNITS)
})

const highestUnit = computed(() => {
Expand All @@ -88,7 +89,7 @@ onBeforeUnmount(() => {

function update() {
if (isPast.value) {
relativeUpdated.value = props.timestamp.setLocale('en-US').toRelative()
relativeUpdated.value = DateTime.fromFormat(props.timestamp, 'f').setLocale('en-US').toRelative()
} else if (isNow.value) {
relativeUpdated.value = 'now'
} else {
Expand Down
7 changes: 4 additions & 3 deletions src/pages/accounts/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<template v-if="!isLoading">
<account-details-panel
class="account__account-details-panel"
:total-account-transactions-count="totalAccountTransactionsCount"
:account-details="accountDetails"/>

<client-only>
Expand Down Expand Up @@ -52,7 +53,7 @@ const { isLoading } = useLoading()
const { push, replace } = useRouter()

const accountStore = useAccountStore()
const { accountDetails, accountTokens } = storeToRefs(accountStore)
const { accountDetails, accountTokens, totalAccountTransactionsCount } = storeToRefs(accountStore)
const { fetchAccount } = accountStore
const route = useRoute()

Expand All @@ -61,11 +62,11 @@ const isAccountExistent = computed(() => {
})

const isTabsVisible = computed(() => process.client &&
(isAccountExistent.value || !!accountTokens.value?.data.length),
(isAccountExistent.value || !!accountTokens.value?.data.length),
)

const isTokensTabPreselected = computed(() => process.client &&
!isAccountExistent.value && !!accountTokens.value?.data.length,
!isAccountExistent.value && !!accountTokens.value?.data.length,
)

const activeTabIndex = computed({
Expand Down
5 changes: 2 additions & 3 deletions src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ const {
fetchDeltaStats,
} = useRecentBlocksStore()
const {
fetchTotalStats,
fetchMaxTps,
fetchTotalTransactionsCount,
fetchBlockchainStats,
} = useBlockchainStatsStore()
const { fetchStateChannels } = useDashboardStateChannelsStore()
const { fetchInAuctionNames, fetchRecentlyActivatedNames } = useNamesStore()
Expand All @@ -110,6 +108,7 @@ definePageMeta({
const isLoading = ref(true)

await useAsyncData(() => Promise.all([
fetchBlockchainStats(),
fetchStateChannels(),
fetchInAuctionNames(),
fetchRecentlyActivatedNames(),
Expand Down
118 changes: 118 additions & 0 deletions src/pages/tokens/ae.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<template>
<Head>
<Title>AE Coin</Title>
</Head>

<page-header>
AE Coin
<template #tooltip>
{{ aeCoinHints.aeCoin }}
</template>

<template #end>
<app-dropdown class="ae-coin__dropdown">
<app-button class="ae-coin__button">
Trade
</app-button>
<template #menu>
<markets-list/>
</template>
</app-dropdown>
</template>
</page-header>

<template v-if="!isLoading">
<ae-coin-panel
class="ae-coin__panel"
:price="price"
:price-change="priceChange"
:total-token-supply="totalTokenSupply"/>

<app-tabs v-model="activeTabIndex">
<app-tab title="Transactions">
<ae-coin-transactions-panel/>
</app-tab>
<app-tab title="Markets">
<ae-coin-markets-panel/>
</app-tab>
</app-tabs>
</template>
<loader-panel v-else/>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import { aeCoinHints } from '@/utils/hints/aeCoinHints'
import { useMarketStatsStore } from '@/stores/marketStats'
import { useBlockchainStatsStore } from '@/stores/blockchainStats'

const route = useRoute()
const { push, replace } = useRouter()

const { price, priceChange } = storeToRefs(useMarketStatsStore())
const { fetchMarketStats } = useMarketStatsStore()

const { totalTokenSupply } = storeToRefs(useBlockchainStatsStore())
const { fetchTotalStats } = useBlockchainStatsStore()

const { isLoading } = useLoading()
const TAB_KEYS = ['transactions', 'markets']

const activeTabIndex = computed({
get() {
const { type: activeTabName } = route.query

if (activeTabName === undefined) {
return 0
}

return TAB_KEYS.indexOf(activeTabName)
},
set(index) {
const newRoute = {
query: {
type: TAB_KEYS[index],
},
}

if (activeTabIndex.value === index) {
// if navigating back
return replace(newRoute)
}

return push(newRoute)
},
})

await useAsyncData(() => Promise.allSettled([
fetchTotalStats(),
fetchMarketStats(),
]))
</script>

<style scoped>
.ae-coin {
&__panel {
margin-bottom: var(--space-4);

@media (--desktop) {
margin-bottom: var(--space-6);
}
}

&__button {
height: 32px;
margin-left: var(--space-1);
}

&__dropdown {
display: flex;
align-items: center;
margin-bottom: var(--space-5);

@media (--desktop) {
margin-bottom: 0;
}
}
}
</style>
38 changes: 38 additions & 0 deletions src/server/api/account/activities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { DateTime } from 'luxon'
import useAxios from '~/composables/useAxios'
// todo rename component
const { MIDDLEWARE_URL } = useRuntimeConfig().public
const axios = useAxios()

export default defineEventHandler(async event => {
const query = getQuery(event)
const defaultParameters = `/v3/accounts/${query.accountId}/activities?limit=${query.limit || 10}`

const url = new URL(`${MIDDLEWARE_URL}${query.queryParameters || defaultParameters}`)
const { data } = await axios.get(url)
return adaptAccountActivities(data)
})

function adaptAccountActivities(activities) {
const formattedData = activities.data.map(activity => {
return {
hash: activity.payload?.hash || activity.payload?.txHash ||
activity.payload?.refTxHash || activity.payload?.callTxHash,
type: activity.type,
time: DateTime.fromMillis(activity.payload?.microTime || activity.blockTime)
.toLocaleString(DateTime.DATETIME_SHORT),
height: activity.payload?.blockHeight || activity.height,
payload: activity.payload,
hintKey:
activity.payload?.tx
? activity.payload.tx.type.charAt(0).toLowerCase() + activity.payload.tx.type.slice(1)
: null,
}
})

return {
next: activities.next,
data: formattedData,
prev: activities.prev,
}
}
Loading