This repository was archived by the owner on Jun 10, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Addresses TODOs in TokenGate component. #138
Open
kayvee-x
wants to merge
2
commits into
quiknode-labs:main
Choose a base branch
from
kayvee-x:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,4 +1,4 @@ | ||
| import { useEffect, useState } from 'react'; | ||
|
Check warning on line 1 in packages/libs/ui/token-gate/src/lib/TokenVerify.tsx
|
||
| import VerificationModal from './VerificationModal'; | ||
| import VerifyButton from './VerifyButton'; | ||
| import { createGlobalState } from 'react-hooks-global-state'; | ||
|
|
@@ -10,12 +10,10 @@ | |
| appElement: string; | ||
| quicknodeUrl: string; | ||
| nftContractAddress: string; | ||
| verificationMessage?: string; | ||
| } | ||
|
|
||
| // Using this global state to persist the verification state between page navigation | ||
| // TODO: Can we do this with a localstorage or a cookie in a secure way? | ||
| // that can't be faked by non-nft holders with an expiration? | ||
| // TODO: Can we use redux here? | ||
| const initialState = { fullyVerified: false, isModalOpen: false }; | ||
| const { useGlobalState } = createGlobalState<{ | ||
| fullyVerified: boolean; | ||
|
|
@@ -27,6 +25,7 @@ | |
| appElement, | ||
| nftContractAddress, | ||
| quicknodeUrl, | ||
| verificationMessage = 'This message is used to verify your wallet ownership.\n\nSigning this message will not make any transactions.', | ||
| }: TokenGateProps) { | ||
| const browserProvider = new ethers.BrowserProvider((window as any).ethereum); | ||
| const qnProvider = new JsonRpcProvider(quicknodeUrl); | ||
|
|
@@ -82,12 +81,7 @@ | |
|
|
||
| async function validateWallet() { | ||
| const signer = await browserProvider.getSigner(); | ||
| // TODO: make message customizable | ||
| const message = | ||
| 'This message is used to verify your wallet ownership.\n\nSigning this message will not make any transactions.'; | ||
| await signer.signMessage(message); | ||
| // TODO: Store the hashed message, and re-verify hash instead of having to ask wallet to sign each time | ||
| // https://github.com/ethers-io/ethers.js/issues/447 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kayvee-x does this address this TODO? |
||
| await signer.signMessage(verificationMessage); | ||
| setOwnershipStatus(OWNERSHIP_STATUS.SIGNED); | ||
| } | ||
|
|
||
|
|
@@ -103,8 +97,7 @@ | |
| } | ||
| } catch (e) { | ||
| console.error(e); | ||
| // TODO: make an error handler status | ||
| setOwnershipStatus(OWNERSHIP_STATUS.DENIED); | ||
| setOwnershipStatus(OWNERSHIP_STATUS.ERROR); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
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.
@kayvee-x are these TODOs addressed by these changes?