-
Notifications
You must be signed in to change notification settings - Fork 3
feat: onboarding flow! #84
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9c8ce87
feat: onboarding basics
antoncoding 523f44d
chore: onboarding input done
antoncoding c47284f
chore: onboarding flow done
antoncoding b3d47fa
chore: lint
antoncoding 4f860a7
chore: lint
antoncoding 164f4e8
chore: revert changes
antoncoding 5911372
chore: styling
antoncoding c4e7dd8
chore: lint
antoncoding 4d7bd44
chore: lint fix
antoncoding 6e8a855
fix: homepage fonts
antoncoding f2fab54
chore: better types
antoncoding 313ee64
chore: execution error
antoncoding cb9ea17
chore: fmt
antoncoding 0c236b1
chore: review feedbacks
antoncoding 20b2131
chore: complete workflow
antoncoding 180e9f7
chore: lint and review fixes
antoncoding 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 hidden or 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,3 +1,6 @@ | ||
| NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=GA_TEST_1234567890 | ||
| NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=TEST_1234567890 | ||
| ENVIRONMENT=localhost | ||
| ENVIRONMENT=localhost | ||
|
|
||
| # | ||
| ALCHEMY_API_KEY=test |
This file contains hidden or 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,76 @@ | ||
| import { NextRequest, NextResponse } from 'next/server'; | ||
|
|
||
| const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY; | ||
| const ALCHEMY_URLS = { | ||
| '1': `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, | ||
| '8453': `https://base-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, | ||
| }; | ||
|
|
||
| type TokenBalance = { | ||
| contractAddress: string; | ||
| tokenBalance: string; | ||
| }; | ||
|
|
||
| export async function GET(req: NextRequest) { | ||
| const searchParams = req.nextUrl.searchParams; | ||
| const address = searchParams.get('address'); | ||
| const chainId = searchParams.get('chainId'); | ||
|
|
||
| if (!address || !chainId) { | ||
| return NextResponse.json({ error: 'Missing address or chainId' }, { status: 400 }); | ||
| } | ||
antoncoding marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| try { | ||
| const alchemyUrl = ALCHEMY_URLS[chainId as keyof typeof ALCHEMY_URLS]; | ||
| if (!alchemyUrl) { | ||
| throw new Error(`Chain ${chainId} not supported`); | ||
| } | ||
|
|
||
| // Get token balances | ||
| const balancesResponse = await fetch(alchemyUrl, { | ||
| method: 'POST', | ||
| headers: { | ||
| accept: 'application/json', | ||
| 'content-type': 'application/json', | ||
| }, | ||
| body: JSON.stringify({ | ||
| id: 1, | ||
| jsonrpc: '2.0', | ||
| method: 'alchemy_getTokenBalances', | ||
| params: [address], | ||
| }), | ||
| }); | ||
|
|
||
| if (!balancesResponse.ok) { | ||
| throw new Error(`HTTP error! status: ${balancesResponse.status}`); | ||
| } | ||
|
|
||
| const balancesData = (await balancesResponse.json()) as { | ||
| id: number; | ||
| jsonrpc: string; | ||
| result: { | ||
| tokenBalances: TokenBalance[]; | ||
| }; | ||
| }; | ||
|
|
||
| const nonZeroBalances: TokenBalance[] = balancesData.result.tokenBalances.filter( | ||
| (token: TokenBalance) => | ||
| token.tokenBalance !== '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
| ); | ||
|
|
||
| // Filter out failed metadata requests | ||
| const tokens = nonZeroBalances | ||
| .filter((token) => token !== null) | ||
| .map((token) => ({ | ||
| address: token.contractAddress.toLowerCase(), | ||
| balance: BigInt(token.tokenBalance).toString(10), | ||
| })); | ||
antoncoding marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return NextResponse.json({ | ||
| tokens, | ||
| }); | ||
| } catch (error) { | ||
| console.error('Failed to fetch balances:', error); | ||
| return NextResponse.json({ error: 'Failed to fetch balances' }, { status: 500 }); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.