-
Notifications
You must be signed in to change notification settings - Fork 3
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: Dex Trades per Token #876
Open
janmichek
wants to merge
40
commits into
develop
Choose a base branch
from
dex-trades-token
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+180
−121
Open
Changes from 38 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
d766a9e
add basic listing
janmichek cbddcd9
fix formatting values
janmichek 6ba863b
move formatting functions
janmichek 9a1f257
add loading
janmichek 538c21a
change url
janmichek 3cd62c7
add hints
janmichek d9d231a
add hint
janmichek 2dab287
revert unwanted changes
janmichek e13a2a6
reuse action from response
janmichek aa7ea2a
revert unused code
janmichek 7028fa8
reformat code
janmichek 821e5e1
add basic UI
janmichek 47c11a8
fix code style
janmichek 337355f
merge stores
janmichek a8e99e6
display swap time
janmichek deb712c
print formatted values
janmichek 9dd0be6
fix loading and fetching
janmichek a850ead
refactor naming
janmichek a792317
add basic UI
janmichek 4953cbb
add mobile view
janmichek a2ad18c
add mobile view
janmichek 2246022
add test
janmichek 4cd67c5
fix test selector
janmichek 8cc6291
fixes after rebase
janmichek e92c838
fix renamed attribute
janmichek 9f5dff5
fix indent
janmichek d592341
add missing counter
janmichek 5488339
add commnet
janmichek fe6a8ad
fixes after rebase
janmichek 345edcd
fixes after rebase
janmichek 1be2388
fixes after rebase
janmichek c2c628e
fixes after rebase
janmichek 53fdf0a
fix markup
janmichek bec22fb
revert missing code
janmichek 86def22
chenge dex link
janmichek 9224640
change dex link
janmichek 5dd1ec4
cleanup code
janmichek 7ee1d60
fix price condition
janmichek cdf954f
fix pagination
janmichek 596729d
increase test timeout
janmichek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template> | ||
<app-panel class="token-trades-panel"> | ||
<paginated-content | ||
:entities="tokenTrades" | ||
pagination-style="history" | ||
@prev-clicked="loadPrevEvents" | ||
@next-clicked="loadNextEvents"> | ||
<dex-trades-table | ||
:trades="tokenTrades" | ||
class="u-hidden-mobile"/> | ||
<dex-trades-table-condensed | ||
:trades="tokenTrades" | ||
class="u-hidden-desktop"/> | ||
</paginated-content> | ||
</app-panel> | ||
</template> | ||
<script setup> | ||
|
||
const tokenDetailsStore = useTokenDetailsStore() | ||
const { tokenTrades } = storeToRefs(tokenDetailsStore) | ||
const { fetchTokenTrades } = tokenDetailsStore | ||
const route = useRoute() | ||
|
||
function loadPrevEvents() { | ||
fetchTokenTrades({ queryParameters: tokenTrades.value.prev }) | ||
} | ||
|
||
function loadNextEvents() { | ||
fetchTokenTrades({ queryParameters: tokenTrades.value.next }) | ||
} | ||
|
||
if (process.client) { | ||
const limit = computed(() => isDesktop() ? 10 : 3) | ||
await fetchTokenTrades({ | ||
contractId: route.params.id, | ||
limit: limit.value, | ||
}) | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,7 @@ export const useDexStore = defineStore('dex', () => { | |
return 1 | ||
} | ||
|
||
const { data } = await axios.get(`${DEX_BACKEND_URL}/pairs/swap-routes/${tokenId}/${AE_TOKEN_ID}`) | ||
|
||
const { data } = await axios.get(`${DEX_BACKEND_URL}/swap-routes/${tokenId}/${AE_TOKEN_ID}`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dex changed link just today |
||
if (data.length === 0) { | ||
return false | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import { defineStore, storeToRefs } from 'pinia' | |
import { useRuntimeConfig } from 'nuxt/app' | ||
import { Contract } from '@aeternity/aepp-sdk' | ||
import useAxios from '@/composables/useAxios' | ||
import { adaptTokenDetails, adaptTokenEvents, adaptTokenHolders } from '@/utils/adapters' | ||
import { adaptTokenDetails, adaptTokenEvents, adaptTokenHolders, adaptTrades } from '@/utils/adapters' | ||
import { TOKEN_SUPPLY_ACI } from '@/utils/constants' | ||
import { useWalletStore } from '@/stores/wallet' | ||
import { useDexStore } from '@/stores/dex' | ||
|
@@ -22,6 +22,7 @@ export const useTokenDetailsStore = defineStore('tokenDetails', () => { | |
const rawTotalSupply = ref(null) | ||
const rawTokenHolders = ref(null) | ||
const tokenHoldersCount = ref(null) | ||
const rawTokenTrades = ref(null) | ||
|
||
const tokenDetails = computed(() => rawToken.value | ||
? adaptTokenDetails( | ||
|
@@ -41,11 +42,16 @@ export const useTokenDetailsStore = defineStore('tokenDetails', () => { | |
: null, | ||
) | ||
|
||
const tokenEvents = computed(() => { | ||
return rawTokenEvents.value | ||
const tokenEvents = computed(() => | ||
rawTokenEvents.value | ||
? adaptTokenEvents(rawTokenEvents.value) | ||
: null | ||
}) | ||
: null, | ||
) | ||
|
||
const tokenTrades = computed(() => rawTokenTrades.value | ||
? adaptTrades(rawTokenTrades.value, price.value) | ||
: null, | ||
) | ||
|
||
function fetchTokenDetails(id) { | ||
tokenId.value = id | ||
|
@@ -54,8 +60,10 @@ export const useTokenDetailsStore = defineStore('tokenDetails', () => { | |
|
||
return Promise.all([ | ||
tokenPromise, | ||
fetchTotalSupply(), | ||
tokenPromise.then(() => fetchTokenPrice()), | ||
Promise.allSettled([ | ||
fetchTotalSupply(), | ||
tokenPromise.then(() => fetchTokenPrice()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't |
||
]), | ||
]) | ||
} | ||
|
||
|
@@ -99,15 +107,23 @@ export const useTokenDetailsStore = defineStore('tokenDetails', () => { | |
tokenHoldersCount.value = data.holders | ||
} | ||
|
||
async function fetchTokenTrades() { | ||
rawTokenTrades.value = null | ||
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/dex/${tokenId.value}/swaps`) | ||
rawTokenTrades.value = data | ||
} | ||
|
||
return { | ||
fetchTokenDetails, | ||
fetchTokenHolders, | ||
tokenHoldersCount, | ||
fetchTokenEvents, | ||
fetchTokenHoldersCount, | ||
fetchTokenTrades, | ||
tokenDetails, | ||
tokenHolders, | ||
tokenEvents, | ||
tokenEventsCount, | ||
tokenTrades, | ||
} | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not related to the feature, renamed confusing store name. App is too general