-
Notifications
You must be signed in to change notification settings - Fork 511
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: add a heatmap #1022
Merged
Merged
feat: add a heatmap #1022
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
97807ec
add a heatmap
JFrankfurt ab97416
styling and public env vars
JFrankfurt 1b48577
heatmap polish
JFrankfurt c495b14
add support for sepolia deployments, add styling input
JFrankfurt 8bbf594
update icon
JFrankfurt 37f7af9
responsive heatmap
JFrankfurt f1c4546
Merge branch 'master' into heatmap
JFrankfurt 1fd31a1
improve url security
JFrankfurt eedb675
heatmap-color-update (#1030)
JFrankfurt 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
import { isAddress } from 'viem'; | ||
|
||
// Make sure the environment variables are properly set | ||
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY; | ||
const BASESCAN_API_KEY = process.env.BASESCAN_API_KEY; | ||
const TALENT_PROTOCOL_API_KEY = process.env.TALENT_PROTOCOL_API_KEY; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
const { query, method } = req; | ||
const address = query.address as string; | ||
const apiType = query.apiType as string; | ||
const body = req.body as Record<string, unknown>; // Explicitly type the body | ||
|
||
if (!address || !isAddress(address)) { | ||
return res.status(400).json({ error: 'Missing or invalid address parameter' }); | ||
} | ||
|
||
let apiUrl: string; | ||
|
||
try { | ||
switch (apiType) { | ||
case 'etherscan': | ||
apiUrl = `https://api.etherscan.io/api?address=${address}&apikey=${ETHERSCAN_API_KEY}&module=account&action=txlist`; | ||
break; | ||
case 'base-sepolia': | ||
apiUrl = `https://api-sepolia.basescan.org/api?address=${address}&apikey=${BASESCAN_API_KEY}&module=account&action=txlistinternal`; | ||
break; | ||
case 'basescan': | ||
apiUrl = `https://api.basescan.org/api?address=${address}&apikey=${BASESCAN_API_KEY}&module=account&action=txlist`; | ||
break; | ||
case 'basescan-internal': | ||
apiUrl = `https://api.basescan.org/api?address=${address}&apikey=${BASESCAN_API_KEY}&module=account&action=txlistinternal`; | ||
break; | ||
case 'talent': | ||
apiUrl = `https://api.talentprotocol.com/api/v2/passports/${address}`; | ||
break; | ||
default: | ||
return res.status(400).json({ error: 'Invalid apiType parameter' }); | ||
} | ||
|
||
// Fetch from the external API using the constructed URL | ||
const externalResponse = await fetch(apiUrl, { | ||
method, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-API-KEY': TALENT_PROTOCOL_API_KEY ?? '', | ||
}, | ||
body: method !== 'GET' ? JSON.stringify(body) : undefined, | ||
}); | ||
|
||
|
||
// Handle the content type of the response | ||
const contentType = externalResponse.headers.get('content-type'); | ||
let responseData; | ||
if (contentType?.includes('application/json')) { | ||
responseData = await externalResponse.json(); | ||
} else { | ||
responseData = await externalResponse.text(); | ||
} | ||
|
||
if (externalResponse.ok) { | ||
return res.status(200).json({ data: responseData }); | ||
} else { | ||
return res.status(externalResponse.status).json({ error: responseData }); | ||
} | ||
} catch (error) { | ||
console.error('Error in API proxy:', error); | ||
return res.status(500).json({ error: 'Internal server error' }); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
23 changes: 23 additions & 0 deletions
23
apps/web/src/components/Basenames/UsernameProfileSectionHeatmap/cal.css
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,23 @@ | ||
.react-calendar-heatmap { | ||
min-width: 780px; | ||
height: auto; | ||
width: 100%; | ||
} | ||
|
||
.react-calendar-heatmap text { | ||
font-size: 10px; | ||
fill: #aaa; | ||
} | ||
|
||
.react-calendar-heatmap .react-calendar-heatmap-small-text { | ||
font-size: 5px; | ||
} | ||
|
||
.react-calendar-heatmap rect:hover { | ||
stroke-width: 1; | ||
stroke: #fff; | ||
} | ||
.react-calendar-heatmap rect { | ||
stroke-width: 1; | ||
stroke: #fff; | ||
} |
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.
Do these keys need to be added to config service or are they already in there?
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.
these still need to be added via codeflow 👍
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.
changes proposed