Skip to content

Commit

Permalink
refactor: joins history endpoint fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodressel authored and mmpetarpeshev committed Jun 25, 2024
1 parent 8d1c3e6 commit 88a3aa1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
13 changes: 2 additions & 11 deletions src/store/modules/dexBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,11 @@ export default {
return pairs;
},

async fetchHistoryByPair({ dispatch }, options) {
const queryString = new URLSearchParams({
limit: 100,
offset: 0,
...options,
}).toString();
return dispatch('safeFetch', { url: `history?${queryString}` });
},

async fetchHistoryByToken({ dispatch }, options) {
async fetchHistory({ dispatch }, options) {
// fetch the full history with all pages
let history = [];
let offset = 0;
const limit = 100;
const limit = 9999999;
let page;
do {
const queryString = new URLSearchParams({
Expand Down
6 changes: 3 additions & 3 deletions src/views/PoolDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
:link="`${activeNetwork.explorerUrl}/contracts/${pairId}`"
/>
<InfoElement
:title="`${pair.token0.symbol} Address`"
:title="`${pair?.token0.symbol} Address`"
:value="shortenAddress(pair?.token0?.address)"
:link="`${activeNetwork.explorerUrl}/contracts/${pair?.token0?.address}`"
/>
<InfoElement
:title="`${pair.token1.symbol} Address`"
:title="`${pair?.token1.symbol} Address`"
:value="shortenAddress(pair?.token1?.address)"
:link="`${activeNetwork.explorerUrl}/contracts/${pair?.token1?.address}`"
/>
Expand Down Expand Up @@ -230,7 +230,7 @@ export default defineComponent({
});
// Fetch pair price history
this.history = await this.$store.dispatch('backend/fetchHistoryByPair', {
this.history = await this.$store.dispatch('backend/fetchHistory', {
pairAddress: this.pairId,
});
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/TokenDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export default defineComponent({
]);
// Fetch token price history
this.history = await this.$store.dispatch('backend/fetchHistoryByToken', {
this.history = await this.$store.dispatch('backend/fetchHistory', {
tokenAddress: this.tokenId,
});
Expand Down

0 comments on commit 88a3aa1

Please sign in to comment.