-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move the Dune data fetching functions to their own files
- Loading branch information
1 parent
d9e4992
commit 94f9f29
Showing
8 changed files
with
69 additions
and
60 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { DUNE_API_KEY } from '@/config/constants' | ||
import { duneQueryUrlBuilder } from '@/lib/duneQueryUrlBuilder' | ||
|
||
const QUERY_ID_MONTHLY_ACTIVE_USERS = 4151164 | ||
|
||
export const fetchMonthlyActiveUsers = async (): Promise<number | null> => { | ||
return fetch(duneQueryUrlBuilder(QUERY_ID_MONTHLY_ACTIVE_USERS, DUNE_API_KEY)) | ||
.then((res) => { | ||
if (!res.ok) { | ||
throw new Error(res.statusText) | ||
} | ||
|
||
return res.json() | ||
}) | ||
.then((data) => data.result.rows[data.result.rows.length - 1].active_users) | ||
.catch((err) => console.error(`Error fetching monthly active users: ${err.message}`)) | ||
} |
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,12 @@ | ||
const QUERY_ID_TOTAL_ASSETS_BY_CHAIN = 3609251 | ||
|
||
export const fetchTotalBalanceUsd = async (): Promise<number | null> => { | ||
// TODO: Uncomment this code after agreeing with the narrative team on the data source | ||
return null | ||
// return fetch(duneQueryUrlBuilder(QUERY_ID_TOTAL_ASSETS_BY_CHAIN, DUNE_API_KEY)) | ||
// .then((res) => res.json()) | ||
// .then((data) => { | ||
// return data.result.rows[0].total_balance_usd | ||
// }) | ||
// .catch(() => null) | ||
} |
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,17 @@ | ||
import { DUNE_API_KEY } from '@/config/constants' | ||
import { duneQueryUrlBuilder } from '@/lib/duneQueryUrlBuilder' | ||
|
||
const QUERY_ID_TOTAL_SAFES_DEPLOYED = 2459401 | ||
|
||
export const fetchTotalSafesDeployed = async (): Promise<number | null> => { | ||
return fetch(duneQueryUrlBuilder(QUERY_ID_TOTAL_SAFES_DEPLOYED, DUNE_API_KEY)) | ||
.then((res) => { | ||
if (!res.ok) { | ||
throw new Error(res.statusText) | ||
} | ||
|
||
return res.json() | ||
}) | ||
.then((data) => data.result.rows[0].num_safes) | ||
.catch((err) => console.error(`Error fetching total safes deployed: ${err.message}`)) | ||
} |
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,17 @@ | ||
import { DUNE_API_KEY } from '@/config/constants' | ||
import { duneQueryUrlBuilder } from '@/lib/duneQueryUrlBuilder' | ||
|
||
const QUERY_ID_TOTAL_TRANSACTIONS = 2093960 | ||
|
||
export const fetchTotalTransactions = async (): Promise<number | null> => { | ||
return fetch(duneQueryUrlBuilder(QUERY_ID_TOTAL_TRANSACTIONS, DUNE_API_KEY)) | ||
.then((res) => { | ||
if (!res.ok) { | ||
throw new Error(res.statusText) | ||
} | ||
|
||
return res.json() | ||
}) | ||
.then((data) => data.result.rows[0].num_txs) | ||
.catch((err) => console.error(`Error fetching total number of transactions: ${err.message}`)) | ||
} |
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