-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit e765138.
- Loading branch information
1 parent
e765138
commit 241adbc
Showing
10 changed files
with
986 additions
and
4 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
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.