-
Notifications
You must be signed in to change notification settings - Fork 18
Addresses TODOs in TokenGate component. #138
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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?