-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prettier formatting following the same configuration as in dune.com repo. Fixes https://linear.app/dune/issue/DX-689/create-standard-hard-linting-rules-for-pr-approvals The PR: • Installs prettier and adds prettier config • Runs prettier on the entire repo
- Loading branch information
Showing
12 changed files
with
254 additions
and
184 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: React Hooks for Dune Echo | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: "npm" | ||
|
||
- name: Install dependencies | ||
run: npm install --no-audit --no-fund | ||
|
||
- name: "Test: prettier" | ||
run: npm run test:prettier |
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 @@ | ||
{} |
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react", | ||
"@babel/preset-typescript" | ||
] | ||
} | ||
|
||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react", | ||
"@babel/preset-typescript" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,65 +1,82 @@ | ||
|
||
import {BalanceData, TokenBalancesParams, TransactionData, TransactionsParams} from "./types"; | ||
import { | ||
BalanceData, | ||
TokenBalancesParams, | ||
TransactionData, | ||
TransactionsParams, | ||
} from "./types"; | ||
|
||
const BALANCE_API_BASE_URL = "https://api.dune.com/api/echo/v1/balances/evm/"; | ||
const TRANSACTIONS_API_BASE_URL = "https://api.dune.com/api/echo/v1/transactions/evm/"; | ||
|
||
const getBalanceQueryParams = (params: TokenBalancesParams): URLSearchParams => { | ||
const queryParams = new URLSearchParams(); | ||
if (params.allChains) queryParams.append("all_chains", "true"); | ||
if (params.chainIds) queryParams.append("chain_ids", params.chainIds); | ||
if (params.excludeSpamTokens) queryParams.append("exclude_spam_tokens", "true"); | ||
if (params.filters) queryParams.append("filters", params.filters); | ||
if (params.offset) queryParams.append("offset", params.offset.toString()); | ||
if (params.limit) queryParams.append("limit", params.limit.toString()); | ||
if (params.metadata) queryParams.append("metadata", "logo,url"); | ||
return queryParams; | ||
}; | ||
const TRANSACTIONS_API_BASE_URL = | ||
"https://api.dune.com/api/echo/v1/transactions/evm/"; | ||
|
||
const getTransactionsQueryParams = (params: TransactionsParams): URLSearchParams => { | ||
const queryParams = new URLSearchParams(); | ||
if (params.chainIds) queryParams.append("chain_ids", params.chainIds); | ||
if (params.offset) queryParams.append("offset", params.offset.toString()); | ||
if (params.limit) queryParams.append("limit", params.limit.toString()); | ||
if (params.method_id) queryParams.append("method_id", params.method_id); | ||
if (params.to) queryParams.append("to", params.to); | ||
if (params.decode) queryParams.append("decode", params.decode.toString()); | ||
return queryParams; | ||
}; | ||
const getBalanceQueryParams = ( | ||
params: TokenBalancesParams | ||
): URLSearchParams => { | ||
const queryParams = new URLSearchParams(); | ||
if (params.allChains) queryParams.append("all_chains", "true"); | ||
if (params.chainIds) queryParams.append("chain_ids", params.chainIds); | ||
if (params.excludeSpamTokens) | ||
queryParams.append("exclude_spam_tokens", "true"); | ||
if (params.filters) queryParams.append("filters", params.filters); | ||
if (params.offset) queryParams.append("offset", params.offset.toString()); | ||
if (params.limit) queryParams.append("limit", params.limit.toString()); | ||
if (params.metadata) queryParams.append("metadata", "logo,url"); | ||
return queryParams; | ||
}; | ||
|
||
const getTransactionsQueryParams = ( | ||
params: TransactionsParams | ||
): URLSearchParams => { | ||
const queryParams = new URLSearchParams(); | ||
if (params.chainIds) queryParams.append("chain_ids", params.chainIds); | ||
if (params.offset) queryParams.append("offset", params.offset.toString()); | ||
if (params.limit) queryParams.append("limit", params.limit.toString()); | ||
if (params.method_id) queryParams.append("method_id", params.method_id); | ||
if (params.to) queryParams.append("to", params.to); | ||
if (params.decode) queryParams.append("decode", params.decode.toString()); | ||
return queryParams; | ||
}; | ||
|
||
export async function fetchBalances(walletAddress: string, params: TokenBalancesParams, duneApiKey: string): Promise<BalanceData> { | ||
const queryParams = getBalanceQueryParams(params) | ||
const apiUrl = `${BALANCE_API_BASE_URL}/${walletAddress}?${queryParams.toString()}`; | ||
export async function fetchBalances( | ||
walletAddress: string, | ||
params: TokenBalancesParams, | ||
duneApiKey: string | ||
): Promise<BalanceData> { | ||
const queryParams = getBalanceQueryParams(params); | ||
const apiUrl = `${BALANCE_API_BASE_URL}/${walletAddress}?${queryParams.toString()}`; | ||
|
||
const response = await fetch(apiUrl, { | ||
method: 'GET', | ||
headers: { | ||
"x-dune-api-key": duneApiKey | ||
method: "GET", | ||
headers: { | ||
"x-dune-api-key": duneApiKey, | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
|
||
return response.json(); | ||
} | ||
|
||
export async function fetchTransactions(walletAddress: string, params: TransactionsParams, duneApiKey: string): Promise<TransactionData> { | ||
const queryParams = getTransactionsQueryParams(params) | ||
const apiUrl = `${TRANSACTIONS_API_BASE_URL}/${walletAddress}?${queryParams.toString()}`; | ||
export async function fetchTransactions( | ||
walletAddress: string, | ||
params: TransactionsParams, | ||
duneApiKey: string | ||
): Promise<TransactionData> { | ||
const queryParams = getTransactionsQueryParams(params); | ||
const apiUrl = `${TRANSACTIONS_API_BASE_URL}/${walletAddress}?${queryParams.toString()}`; | ||
|
||
const response = await fetch(apiUrl, { | ||
method: 'GET', | ||
headers: { | ||
"x-dune-api-key": duneApiKey | ||
method: "GET", | ||
headers: { | ||
"x-dune-api-key": duneApiKey, | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
|
||
return response.json(); | ||
} | ||
} |
Oops, something went wrong.