From d766a9ec0805925230603e090fa85bbf0047ffdf Mon Sep 17 00:00:00 2001 From: janmichek Date: Thu, 1 Aug 2024 16:38:21 +0200 Subject: [PATCH 01/40] add basic listing --- src/components/ContractDetailsPanel.vue | 384 ++++++++++++------------ src/components/DexTradesPanel.vue | 1 + src/components/DexTradesTable.vue | 6 + src/components/PriceLabel.vue | 6 +- src/components/TheNavigation.vue | 167 ++++++----- src/pages/dex/index.vue | 22 ++ src/pages/tokens/[id].vue | 6 +- src/stores/dexTrades.js | 5 + src/utils/adapters.js | 71 +++++ 9 files changed, 388 insertions(+), 280 deletions(-) create mode 100644 src/pages/dex/index.vue diff --git a/src/components/ContractDetailsPanel.vue b/src/components/ContractDetailsPanel.vue index 2b9e3fdbc..5b25febf7 100644 --- a/src/components/ContractDetailsPanel.vue +++ b/src/components/ContractDetailsPanel.vue @@ -4,215 +4,215 @@ class="contract-details-panel"> - - - - + + + + - - - - + + + + - - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + +
- - {{ contractsHints.contractId }} - - Smart Contract ID - -
- -
-
- -
-
+ + {{ contractsHints.contractId }} + + Smart Contract ID + +
+ +
+
+ +
+
- - {{ contractsHints.type }} - - Type - - - {{ contractDetails.contractType }} - -
+ + {{ contractsHints.type }} + + Type + + + {{ contractDetails.contractType }} + +
- - {{ contractsHints.token }} - - Token - -
- - - {{ contractDetails.tokenDetails.symbol }} - - - - {{ contractDetails.tokenDetails.name }} - -
-
- - {{ contractsHints.contractTxHash }} - - Create Transaction - - +
+ + {{ contractsHints.token }} + + Token + +
+ + + {{ contractDetails.tokenDetails.name }} + +
+
+ + {{ contractsHints.contractTxHash }} + + Create Transaction + + {{ contractDetails.createTransactionHash }} - + {{ formatEllipseHash(contractDetails.createTransactionHash) }} - -
- - {{ contractsHints.contractCreatedHeight }} - - Created Height - - - {{ contractDetails.creationHeight }} - -
- - {{ contractsHints.contractCreated }} - - Created - - -
- - {{ contractsHints.contractCreator }} - - Created By - - + +
+ + {{ contractsHints.contractCreatedHeight }} + + Created Height + + + {{ contractDetails.creationHeight }} + +
+ + {{ contractsHints.contractCreated }} + + Created + + +
+ + {{ contractsHints.contractCreator }} + + Created By + + {{ contractDetails.createdBy }} - + {{ formatEllipseHash(contractDetails.createdBy) }} - -
- - {{ contractsHints.bytecode }} - - Bytecode - - -
- - {{ contractsHints.contractsAccount }} - - Smart Contract’s Account - - + +
+ + {{ contractsHints.bytecode }} + + Bytecode + + +
+ + {{ contractsHints.contractsAccount }} + + Smart Contract’s Account + + {{ contractDetails.contractAccount }} - + {{ formatEllipseHash(contractDetails.contractAccount) }} - -
- - {{ contractsHints.contractsAccountBalance }} - - Smart Contract's Account Balance - - -
- - {{ contractsHints.contractCalls }} - - Smart Contract Calls - - {{ contractDetails.callsCount }} -
- - {{ contractsHints.apiLinks }} - - API Links - - - - Node - - - - Middleware - -
+ + {{ contractsHints.contractsAccountBalance }} + + Smart Contract's Account Balance + + +
+ + {{ contractsHints.contractCalls }} + + Smart Contract Calls + + {{ contractDetails.callsCount }} +
+ + {{ contractsHints.apiLinks }} + + API Links + + + + Node + + + + Middleware + +
diff --git a/src/components/DexTradesPanel.vue b/src/components/DexTradesPanel.vue index 8d66c8d78..f8ebf501b 100644 --- a/src/components/DexTradesPanel.vue +++ b/src/components/DexTradesPanel.vue @@ -15,6 +15,7 @@ diff --git a/src/pages/tokens/[id].vue b/src/pages/tokens/[id].vue index f93f74b95..98fa25a0c 100644 --- a/src/pages/tokens/[id].vue +++ b/src/pages/tokens/[id].vue @@ -13,7 +13,7 @@ From 538c21a5bdeace9029cf566f1f5353d2c4608ff3 Mon Sep 17 00:00:00 2001 From: janmichek Date: Mon, 5 Aug 2024 12:34:01 +0200 Subject: [PATCH 05/40] change url --- src/components/TheNavigation.vue | 2 +- src/pages/dex-trades/index.vue | 1 + src/pages/dex/index.vue | 23 ----------------------- 3 files changed, 2 insertions(+), 24 deletions(-) delete mode 100644 src/pages/dex/index.vue diff --git a/src/components/TheNavigation.vue b/src/components/TheNavigation.vue index 5e09e7fdc..0cc321085 100644 --- a/src/components/TheNavigation.vue +++ b/src/components/TheNavigation.vue @@ -79,7 +79,7 @@ const menuOptions = ref([ }, { name: 'DEX Trades', - path: '/dex-trades', + path: '/dex-trades', }, ], }, diff --git a/src/pages/dex-trades/index.vue b/src/pages/dex-trades/index.vue index 2cb202cba..686c99b79 100644 --- a/src/pages/dex-trades/index.vue +++ b/src/pages/dex-trades/index.vue @@ -2,6 +2,7 @@ Dex Tracker + Dex Trades diff --git a/src/pages/dex/index.vue b/src/pages/dex/index.vue deleted file mode 100644 index 00e7da0ce..000000000 --- a/src/pages/dex/index.vue +++ /dev/null @@ -1,23 +0,0 @@ - - - From 3cd62c778ec0ad541d023d09b777725e7be14a97 Mon Sep 17 00:00:00 2001 From: janmichek Date: Mon, 5 Aug 2024 13:19:14 +0200 Subject: [PATCH 06/40] add hints --- src/components/DexTradesTable.vue | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/components/DexTradesTable.vue b/src/components/DexTradesTable.vue index 1ea36b87a..241517f70 100644 --- a/src/components/DexTradesTable.vue +++ b/src/components/DexTradesTable.vue @@ -55,19 +55,16 @@ :link-to="`/transactions/${trade.txHash}`" :hash="trade.txHash"/> - - {{ trade.action }} - - - - Date: Mon, 5 Aug 2024 13:51:49 +0200 Subject: [PATCH 07/40] add hint --- src/pages/dex-trades/index.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/dex-trades/index.vue b/src/pages/dex-trades/index.vue index 686c99b79..2cb202cba 100644 --- a/src/pages/dex-trades/index.vue +++ b/src/pages/dex-trades/index.vue @@ -2,7 +2,6 @@ Dex Tracker - Dex Trades From 2dab287d3394a98a716f105a7313a7763b22ff52 Mon Sep 17 00:00:00 2001 From: janmichek Date: Mon, 5 Aug 2024 14:05:45 +0200 Subject: [PATCH 08/40] revert unwanted changes --- src/components/ContractDetailsPanel.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ContractDetailsPanel.vue b/src/components/ContractDetailsPanel.vue index 5b25febf7..287d84394 100644 --- a/src/components/ContractDetailsPanel.vue +++ b/src/components/ContractDetailsPanel.vue @@ -50,7 +50,7 @@
- + From e13a2a60d3802bff0556357236a7210792ce8cfd Mon Sep 17 00:00:00 2001 From: janmichek Date: Tue, 20 Aug 2024 16:03:20 +0200 Subject: [PATCH 09/40] reuse action from response --- src/stores/dexTrades.js | 3 +-- src/utils/adapters.js | 37 ++++++++++++++++++------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/stores/dexTrades.js b/src/stores/dexTrades.js index 9648d3d13..404ee33a9 100644 --- a/src/stores/dexTrades.js +++ b/src/stores/dexTrades.js @@ -19,14 +19,13 @@ export const useDexTradesStore = defineStore('dexTrades', () => { : null, ) - async function fetchDexTrades({ queryParameters, limit } = {}) { rawTrades.value = null const defaultParameters = `/v3/dex/swaps?limit=${limit ?? 10}` const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`) rawTrades.value = data - } + } return { fetchDexTrades, diff --git a/src/utils/adapters.js b/src/utils/adapters.js index 26cbb4d89..b0663aa49 100644 --- a/src/utils/adapters.js +++ b/src/utils/adapters.js @@ -769,30 +769,29 @@ export function adaptWriteEntrypoints(aci) { export function adaptTrades(trades, price) { - const formattedData = trades.data - .map(trade => { - const fromAmount = trade.fromAmount / 10 ** trade.fromDecimals - const toAmount = trade.toAmount / 10 ** trade.toDecimals - return { - fromAmount, - toAmount, + const formattedData = trades.data.map(trade => { + const fromAmount = trade.fromAmount / 10 ** trade.fromDecimals + const toAmount = trade.toAmount / 10 ** trade.toDecimals + return { + fromAmount, + toAmount, - txHash: trade.txHash, - fromToken: trade.fromToken, - toToken: trade.toToken, + txHash: trade.txHash, + fromToken: trade.fromToken, + toToken: trade.toToken, - fromContract: trade.fromContract, - toContract: trade.toContract, + fromContract: trade.fromContract, + toContract: trade.toContract, - height: trade.height, - timestamp: DateTime.fromMillis(trade.microtime), + height: trade.height, + timestamp: DateTime.fromMillis(trade.microtime), - rate: formatTradeRate(fromAmount, toAmount, trade.fromContract, trade.toContract), - action: formatTradeAction(trade.fromContract, trade.toContract), + rate: formatTradeRate(trade.action, fromAmount, toAmount), + action: trade.action, - value: formatNumber(formatTradeValue(fromAmount, toAmount, trade.fromContract, trade.toContract, price)), - } - }) + value: formatNumber(formatTradeValue(trade.action, fromAmount, toAmount, price)), + } + }) return { next: trades.next, data: formattedData, From aa7ea2a88b88970b316244aa7102d5fb777a97f4 Mon Sep 17 00:00:00 2001 From: janmichek Date: Wed, 21 Aug 2024 09:47:12 +0200 Subject: [PATCH 10/40] revert unused code --- src/components/ContractDetailsPanel.vue | 384 ++++++++++++------------ src/utils/adapters.js | 11 +- src/utils/format.js | 2 - 3 files changed, 194 insertions(+), 203 deletions(-) diff --git a/src/components/ContractDetailsPanel.vue b/src/components/ContractDetailsPanel.vue index 287d84394..2b9e3fdbc 100644 --- a/src/components/ContractDetailsPanel.vue +++ b/src/components/ContractDetailsPanel.vue @@ -4,215 +4,215 @@ class="contract-details-panel"> - - - - + + + + - - - - + + + + - - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + +
- - {{ contractsHints.contractId }} - - Smart Contract ID - -
- -
-
- -
-
+ + {{ contractsHints.contractId }} + + Smart Contract ID + +
+ +
+
+ +
+
- - {{ contractsHints.type }} - - Type - - - {{ contractDetails.contractType }} - -
+ + {{ contractsHints.type }} + + Type + + + {{ contractDetails.contractType }} + +
- - {{ contractsHints.token }} - - Token - -
- - - {{ contractDetails.tokenDetails.symbol }} - - - - {{ contractDetails.tokenDetails.name }} - -
-
- - {{ contractsHints.contractTxHash }} - - Create Transaction - - +
+ + {{ contractsHints.token }} + + Token + +
+ + + {{ contractDetails.tokenDetails.symbol }} + + + + {{ contractDetails.tokenDetails.name }} + +
+
+ + {{ contractsHints.contractTxHash }} + + Create Transaction + + {{ contractDetails.createTransactionHash }} - + {{ formatEllipseHash(contractDetails.createTransactionHash) }} - -
- - {{ contractsHints.contractCreatedHeight }} - - Created Height - - - {{ contractDetails.creationHeight }} - -
- - {{ contractsHints.contractCreated }} - - Created - - -
- - {{ contractsHints.contractCreator }} - - Created By - - + +
+ + {{ contractsHints.contractCreatedHeight }} + + Created Height + + + {{ contractDetails.creationHeight }} + +
+ + {{ contractsHints.contractCreated }} + + Created + + +
+ + {{ contractsHints.contractCreator }} + + Created By + + {{ contractDetails.createdBy }} - + {{ formatEllipseHash(contractDetails.createdBy) }} - -
- - {{ contractsHints.bytecode }} - - Bytecode - - -
- - {{ contractsHints.contractsAccount }} - - Smart Contract’s Account - - + +
+ + {{ contractsHints.bytecode }} + + Bytecode + + +
+ + {{ contractsHints.contractsAccount }} + + Smart Contract’s Account + + {{ contractDetails.contractAccount }} - + {{ formatEllipseHash(contractDetails.contractAccount) }} - -
- - {{ contractsHints.contractsAccountBalance }} - - Smart Contract's Account Balance - - -
- - {{ contractsHints.contractCalls }} - - Smart Contract Calls - - {{ contractDetails.callsCount }} -
- - {{ contractsHints.apiLinks }} - - API Links - - - - Node - - - - Middleware - -
+ + {{ contractsHints.contractsAccountBalance }} + + Smart Contract's Account Balance + + +
+ + {{ contractsHints.contractCalls }} + + Smart Contract Calls + + {{ contractDetails.callsCount }} +
+ + {{ contractsHints.apiLinks }} + + API Links + + + + Node + + + + Middleware + +
diff --git a/src/utils/adapters.js b/src/utils/adapters.js index b0663aa49..107f69561 100644 --- a/src/utils/adapters.js +++ b/src/utils/adapters.js @@ -775,21 +775,16 @@ export function adaptTrades(trades, price) { return { fromAmount, toAmount, - txHash: trade.txHash, fromToken: trade.fromToken, toToken: trade.toToken, - fromContract: trade.fromContract, toContract: trade.toContract, - + action: trade.action, height: trade.height, timestamp: DateTime.fromMillis(trade.microtime), - rate: formatTradeRate(trade.action, fromAmount, toAmount), - action: trade.action, - - value: formatNumber(formatTradeValue(trade.action, fromAmount, toAmount, price)), + value: formatTradeValue(trade.action, fromAmount, toAmount, price), } }) return { @@ -798,5 +793,3 @@ export function adaptTrades(trades, price) { prev: trades.prev, } } - - diff --git a/src/utils/format.js b/src/utils/format.js index e4699df3b..b43a5bc13 100644 --- a/src/utils/format.js +++ b/src/utils/format.js @@ -7,7 +7,6 @@ import { NUMBER_FRACTION_THRESHOLD, REVOKED_PERIOD, } from '@/utils/constants' -import { useRuntimeConfig } from "nuxt/app"; export function formatEllipseHash(hash) { @@ -206,7 +205,6 @@ export function formatTradeValue(action, fromAmount, toAmount, price) { if (action === 'SELL') { return formatNumber(toAmount * price) } - return null } From 7028fa8f387712d8d7015e15d35fea3f90f16098 Mon Sep 17 00:00:00 2001 From: janmichek Date: Wed, 21 Aug 2024 09:48:28 +0200 Subject: [PATCH 11/40] reformat code --- src/components/TheNavigation.vue | 67 ++++++++++++++++---------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/components/TheNavigation.vue b/src/components/TheNavigation.vue index 0cc321085..c0dcb2c82 100644 --- a/src/components/TheNavigation.vue +++ b/src/components/TheNavigation.vue @@ -17,50 +17,49 @@ diff --git a/src/components/DexTradesTable.vue b/src/components/DexTradesTable.vue index 241517f70..c232b89cc 100644 --- a/src/components/DexTradesTable.vue +++ b/src/components/DexTradesTable.vue @@ -55,6 +55,7 @@ :link-to="`/transactions/${trade.txHash}`" :hash="trade.txHash"/> + a + + Dex Tracker + + + + Dex Tracker + + + + + + + diff --git a/src/stores/dexTrades.js b/src/stores/dexTrades.js index 404ee33a9..587a51583 100644 --- a/src/stores/dexTrades.js +++ b/src/stores/dexTrades.js @@ -8,6 +8,7 @@ import { adaptTrades } from "@/utils/adapters"; import { useMarketStatsStore } from "@/stores/marketStats"; export const useDexTradesStore = defineStore('dexTrades', () => { + const { MIDDLEWARE_URL } = useRuntimeConfig().public const axios = useAxios() const { MIDDLEWARE_URL } = useRuntimeConfig().public const { price } = storeToRefs(useMarketStatsStore()) @@ -22,6 +23,7 @@ export const useDexTradesStore = defineStore('dexTrades', () => { async function fetchDexTrades({ queryParameters, limit } = {}) { rawTrades.value = null const defaultParameters = `/v3/dex/swaps?limit=${limit ?? 10}` + const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`) rawTrades.value = data From 47c11a83e057f5c4fa4148f3ebdcdf50bed5f110 Mon Sep 17 00:00:00 2001 From: janmichek Date: Thu, 13 Jun 2024 14:28:44 +0200 Subject: [PATCH 13/40] fix code style --- src/pages/dex/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/dex/index.vue b/src/pages/dex/index.vue index b98ccffdd..7ecf5180e 100644 --- a/src/pages/dex/index.vue +++ b/src/pages/dex/index.vue @@ -17,5 +17,5 @@ import PageHeader from '@/components/PageHeader' import { tokensHints } from '@/utils/hints/tokensHints' -const { isLoading } = useLoading() +// todo const { isLoading } = useLoading() From 337355fc819b16e1758cc12e5a8847080d400700 Mon Sep 17 00:00:00 2001 From: janmichek Date: Thu, 13 Jun 2024 14:32:20 +0200 Subject: [PATCH 14/40] merge stores --- src/components/TimeToggleButton.vue | 6 +++--- src/components/TimestampLabel.vue | 4 ++-- src/stores/app.js | 12 ------------ src/stores/ui.js | 8 ++++++++ 4 files changed, 13 insertions(+), 17 deletions(-) delete mode 100644 src/stores/app.js diff --git a/src/components/TimeToggleButton.vue b/src/components/TimeToggleButton.vue index a297ffa8e..89adad0d2 100644 --- a/src/components/TimeToggleButton.vue +++ b/src/components/TimeToggleButton.vue @@ -9,10 +9,10 @@ From a850eadff89e7b9ee4bc8962782dc8a90e70dc73 Mon Sep 17 00:00:00 2001 From: janmichek Date: Tue, 18 Jun 2024 16:52:27 +0200 Subject: [PATCH 18/40] refactor naming --- src/pages/dex/index.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/dex/index.vue b/src/pages/dex/index.vue index 00e7da0ce..0f4321648 100644 --- a/src/pages/dex/index.vue +++ b/src/pages/dex/index.vue @@ -11,13 +11,13 @@ - - + + From a7923176875030a59b30476054dfe8c8e238e7d1 Mon Sep 17 00:00:00 2001 From: janmichek Date: Tue, 6 Aug 2024 12:56:37 +0200 Subject: [PATCH 19/40] add basic UI --- src/components/TokenTradesPanel.vue | 159 ++++++++++++++++++++++++++ src/pages/tokens/[id].vue | 5 +- src/stores/tokenDetails.js | 168 ++++++++++++++-------------- src/utils/adapters.js | 3 + 4 files changed, 252 insertions(+), 83 deletions(-) create mode 100644 src/components/TokenTradesPanel.vue diff --git a/src/components/TokenTradesPanel.vue b/src/components/TokenTradesPanel.vue new file mode 100644 index 000000000..700af7c9e --- /dev/null +++ b/src/components/TokenTradesPanel.vue @@ -0,0 +1,159 @@ + + + + + diff --git a/src/pages/tokens/[id].vue b/src/pages/tokens/[id].vue index 15ab5cf74..73e28de00 100644 --- a/src/pages/tokens/[id].vue +++ b/src/pages/tokens/[id].vue @@ -23,6 +23,9 @@ + + + @@ -43,7 +46,7 @@ const { tokenDetails } = storeToRefs(tokenDetailsStore) const { fetchTokenDetails } = tokenDetailsStore const { isLoading } = useLoading() -const TAB_KEYS = ['holders', 'events'] +const TAB_KEYS = ['holders', 'events', 'trades'] const activeTabIndex = computed({ get() { diff --git a/src/stores/tokenDetails.js b/src/stores/tokenDetails.js index 7e2e41109..0553c1204 100644 --- a/src/stores/tokenDetails.js +++ b/src/stores/tokenDetails.js @@ -8,106 +8,110 @@ import { useWalletStore } from '@/stores/wallet' import { useDexStore } from '@/stores/dex' export const useTokenDetailsStore = defineStore('tokenDetails', () => { - const { MIDDLEWARE_URL } = useRuntimeConfig().public - const axios = useAxios() + const { MIDDLEWARE_URL } = useRuntimeConfig().public + const axios = useAxios() const { aeSdk } = storeToRefs(useWalletStore()) - const { fetchPrice } = useDexStore() + const { fetchPrice } = useDexStore() - const tokenId = ref(null) - const price = ref(null) - const rawTokenEvents = ref(null) - const tokenEventsCount = ref(null) + const tokenId = ref(null) + const price = ref(null) + const rawTokenEvents = ref(null) + const tokenEventsCount = ref(null) - const rawToken = ref(null) - const rawTotalSupply = ref(null) - const rawTokenHolders = ref(null) + const rawToken = ref(null) + const rawTotalSupply = ref(null) + const rawTokenHolders = ref(null) const tokenHoldersCount = ref(null) + const rawTokenTrades = ref(null) - const tokenDetails = computed(() => rawToken.value - ? adaptTokenDetails( - rawToken.value, - rawTotalSupply.value, - price.value, - ) - : null, - ) - - const tokenHolders = computed(() => - tokenDetails.value && rawTokenHolders.value - ? adaptTokenHolders( - rawTokenHolders.value, - tokenDetails.value, + const tokenDetails = computed(() => rawToken.value + ? adaptTokenDetails( + rawToken.value, + rawTotalSupply.value, + price.value, ) : null, - ) + ) + + const tokenHolders = computed(() => + tokenDetails.value && rawTokenHolders.value + ? adaptTokenHolders( + rawTokenHolders.value, + tokenDetails.value, + ) + : null, + ) + + const tokenEvents = computed(() => { + return rawTokenEvents.value + ? adaptTokenEvents(rawTokenEvents.value) + : null + }) - const tokenEvents = computed(() => { - return rawTokenEvents.value - ? adaptTokenEvents(rawTokenEvents.value) - : null - }) + function fetchTokenDetails(id) { + tokenId.value = id - function fetchTokenDetails(id) { - tokenId.value = id + const tokenPromise = fetchToken() - const tokenPromise = fetchToken() + return Promise.all([ + tokenPromise, + fetchTotalSupply(), + tokenPromise.then(() => fetchTokenPrice()), + ]) + } - return Promise.all([ - tokenPromise, - fetchTotalSupply(), - tokenPromise.then(() => fetchTokenPrice()), - ]) - } + // todo fix indent + // todo shorten naming + const trades = computed(() => rawTokenTrades.value && price.value + ? adaptTrades(rawTokenTrades.value, price.value) + : null, + ) - async function fetchTokenPrice() { - price.value = await fetchPrice(tokenId.value, rawToken.value.decimals) - } + async function fetchTokenPrice() { + price.value = await fetchPrice(tokenId.value, rawToken.value.decimals) + } - async function fetchToken() { - const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/aex9/${tokenId.value}`) - rawToken.value = data + async function fetchToken() { + const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/aex9/${tokenId.value}`) + rawToken.value = data tokenEventsCount.value = data.logsCount - } + } - async function fetchTotalSupply() { + async function fetchTotalSupply() { const contract = await Contract.initialize({ ...aeSdk.value.getContext(), - aci: TOKEN_SUPPLY_ACI, - address: tokenId.value, - }) + aci: TOKEN_SUPPLY_ACI, + address: tokenId.value, + }) const contractCallResult = await contract.total_supply() - rawTotalSupply.value = contractCallResult?.decodedResult - } - - async function fetchTokenEvents({ queryParameters, limit, contractId } = {}) { - rawTokenEvents.value = null - const defaultParameters = `/v3/contracts/logs?contract=${contractId}&aexn-args=true&limit=${limit ?? 10}` - const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`) - rawTokenEvents.value = data - } - - async function fetchTokenHolders({ queryParameters, limit } = {}) { - rawTokenHolders.value = null + rawTotalSupply.value = contractCallResult?.decodedResult + } + + async function fetchTokenEvents({ queryParameters, limit, contractId } = {}) { + rawTokenEvents.value = null + const defaultParameters = `/v3/contracts/logs?contract=${contractId}&aexn-args=true&limit=${limit ?? 10}` + const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`) + rawTokenEvents.value = data + } + + async function fetchTokenHolders({ queryParameters, limit } = {}) { + rawTokenHolders.value = null const defaultParameters = `/v2/aex9/${tokenId.value}/balances?by=amount&limit=${limit ?? 10}` - const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`) - rawTokenHolders.value = data - } - - async function fetchTokenHoldersCount() { - tokenHoldersCount.value = null - const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/aex9/${tokenId.value}`) - tokenHoldersCount.value = data.holders - } - - return { - fetchTokenDetails, - fetchTokenHolders, + const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`) + rawTokenHolders.value = data + } + + return { + fetchTokenDetails, + fetchTokenHolders, tokenHoldersCount, - fetchTokenEvents, - fetchTokenHoldersCount, - tokenDetails, - tokenHolders, - tokenEvents, - tokenEventsCount, - } + fetchTokenEvents, + fetchTokenHoldersCount, + fetchTokenTrades, + tokenDetails, + tokenHolders, + tokenEvents, + tokenEventsCount, + trades + } }) diff --git a/src/utils/adapters.js b/src/utils/adapters.js index 9f8a5e88e..b44c60772 100644 --- a/src/utils/adapters.js +++ b/src/utils/adapters.js @@ -21,6 +21,9 @@ import { formatTradeRate, formatTradeAction, formatTradeRate, + formatTradeAction, + formatTradeRate, + formatTradeValue, } from '@/utils/format' import { MINUTES_PER_BLOCK, SPECIAL_POINTERS_PRESET_KEYS } from '@/utils/constants' From 4953cbb82bfffdd9f85566586b9df23aa6a31d00 Mon Sep 17 00:00:00 2001 From: janmichek Date: Wed, 7 Aug 2024 09:44:02 +0200 Subject: [PATCH 20/40] add mobile view --- src/components/TokenTradesPanel.vue | 167 ++++------------------------ 1 file changed, 24 insertions(+), 143 deletions(-) diff --git a/src/components/TokenTradesPanel.vue b/src/components/TokenTradesPanel.vue index 700af7c9e..6edd4ace0 100644 --- a/src/components/TokenTradesPanel.vue +++ b/src/components/TokenTradesPanel.vue @@ -1,159 +1,40 @@ - - - From a2ad18c9926dd2c7964ca1c830fd182ecb3b0af9 Mon Sep 17 00:00:00 2001 From: janmichek Date: Wed, 7 Aug 2024 10:15:37 +0200 Subject: [PATCH 21/40] add mobile view --- src/utils/adapters.js | 5 +---- src/utils/format.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/utils/adapters.js b/src/utils/adapters.js index b44c60772..ff797e351 100644 --- a/src/utils/adapters.js +++ b/src/utils/adapters.js @@ -3,13 +3,9 @@ import { useRuntimeConfig } from 'nuxt/app' import { BigNumber } from 'bignumber.js' import { decode, Encoding, isAddressValid } from '@aeternity/aepp-sdk' import { - formatAeContractArgumentIndex, - formatAeContractIndex, formatAettosToAe, formatBlockDiffAsDatetime, formatDecodeBase64, - formatDexActionName, - formatInAmountIndex, formatIsAuction, formatIsStatefulEntrypoint, formatNameState, @@ -700,6 +696,7 @@ export function adaptMarketStatsCoinW(stats) { } } + export function adaptTopAccounts(topAccounts, distribution) { return topAccounts .slice(0, 100) diff --git a/src/utils/format.js b/src/utils/format.js index b43a5bc13..3e511afc3 100644 --- a/src/utils/format.js +++ b/src/utils/format.js @@ -193,7 +193,7 @@ export function formatTradeRate(action, fromAmount, toAmount) { if (action === 'SELL') { return `${formatNumber((toAmount / fromAmount), 4)} WAE` - } +} return null } From 22460228289b15097ba741adf550f32872d11305 Mon Sep 17 00:00:00 2001 From: janmichek Date: Wed, 7 Aug 2024 10:18:20 +0200 Subject: [PATCH 22/40] add test --- cypress/e2e/app/tokenDetail.cy.js | 3 +++ src/components/TokenTradesPanel.vue | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/app/tokenDetail.cy.js b/cypress/e2e/app/tokenDetail.cy.js index 767db74d1..faa601629 100644 --- a/cypress/e2e/app/tokenDetail.cy.js +++ b/cypress/e2e/app/tokenDetail.cy.js @@ -7,6 +7,9 @@ describe('token detail', () => { cy.contains('.tabs__item', 'Events').click() cy.get('.token-events-panel .paginated-content').should('be.visible') + + cy.contains('.tabs__item', 'Events').click() + cy.get('.token-trades-panel .paginated-content').should('be.visible') }) it('should display token not found', () => { diff --git a/src/components/TokenTradesPanel.vue b/src/components/TokenTradesPanel.vue index 6edd4ace0..c98eae052 100644 --- a/src/components/TokenTradesPanel.vue +++ b/src/components/TokenTradesPanel.vue @@ -1,5 +1,5 @@ From bec22fb790520e1df93bbad7b5c81122786bec6d Mon Sep 17 00:00:00 2001 From: janmichek Date: Thu, 21 Nov 2024 07:41:38 +0100 Subject: [PATCH 34/40] revert missing code --- src/stores/tokenDetails.js | 6 ++++++ src/utils/adapters.js | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/stores/tokenDetails.js b/src/stores/tokenDetails.js index 9997e9342..49b2a55e0 100644 --- a/src/stores/tokenDetails.js +++ b/src/stores/tokenDetails.js @@ -100,6 +100,12 @@ export const useTokenDetailsStore = defineStore('tokenDetails', () => { rawTokenHolders.value = data } + async function fetchTokenHoldersCount() { + tokenHoldersCount.value = null + const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/aex9/${tokenId.value}`) + tokenHoldersCount.value = data.holders + } + return { fetchTokenDetails, fetchTokenHolders, diff --git a/src/utils/adapters.js b/src/utils/adapters.js index 6a50115f1..7ae3a0dec 100644 --- a/src/utils/adapters.js +++ b/src/utils/adapters.js @@ -439,8 +439,6 @@ export function adaptTokenEvents(events) { } export function adaptTokenHolders(tokenHolders, tokenDetails) { - console.log('tokenDetails', tokenDetails) - console.log('tokenHolders', tokenHolders) const formattedData = tokenHolders.data .map(holder => { const percentage = (new BigNumber(holder.amount) From 86def226db9a8ea9baa9895bb99a22f3bcbf15fc Mon Sep 17 00:00:00 2001 From: janmichek Date: Thu, 21 Nov 2024 13:31:15 +0100 Subject: [PATCH 35/40] chenge dex link --- src/stores/dex.js | 3 +-- src/stores/tokenDetails.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/stores/dex.js b/src/stores/dex.js index 88200ce0c..c456aeff3 100644 --- a/src/stores/dex.js +++ b/src/stores/dex.js @@ -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}`) if (data.length === 0) { return false } diff --git a/src/stores/tokenDetails.js b/src/stores/tokenDetails.js index 49b2a55e0..46ae0a9aa 100644 --- a/src/stores/tokenDetails.js +++ b/src/stores/tokenDetails.js @@ -55,8 +55,10 @@ export const useTokenDetailsStore = defineStore('tokenDetails', () => { return Promise.all([ tokenPromise, - fetchTotalSupply(), - tokenPromise.then(() => fetchTokenPrice()), + Promise.allSettled([ + fetchTotalSupply(), + tokenPromise.then(() => fetchTokenPrice()), + ]), ]) } @@ -106,6 +108,15 @@ 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`) + console.log('data', data) + rawTokenTrades.value = data + + console.log('price.value', price.value) + } + return { fetchTokenDetails, fetchTokenHolders, From 92246408f35fbcac9db4873817dfac2bb3e389e5 Mon Sep 17 00:00:00 2001 From: janmichek Date: Thu, 21 Nov 2024 13:33:44 +0100 Subject: [PATCH 36/40] change dex link --- src/components/TokenTradesPanel.vue | 12 ++++++------ src/stores/tokenDetails.js | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/TokenTradesPanel.vue b/src/components/TokenTradesPanel.vue index 0d7b63a90..1c0f372c5 100644 --- a/src/components/TokenTradesPanel.vue +++ b/src/components/TokenTradesPanel.vue @@ -1,15 +1,15 @@