-
-
Notifications
You must be signed in to change notification settings - Fork 252
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(unlock-app): Support ENS in checkout builder for Referrer field #14834
base: master
Are you sure you want to change the base?
feat(unlock-app): Support ENS in checkout builder for Referrer field #14834
Conversation
* Added a new hook useGetReferrer * Added new util func shouldReferrerResolveForENS to check if a lock config has ENS * use shouldReferrerResolveForENS in getReferrers to resolve for ENS
lockAddress | ||
) | ||
if (isReferrerAddressEns) { | ||
if (isReferrerAddressEns && paywallConfig && paywallConfig.referrer) { |
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.
The reason to change this to be here is that if the referrer is an ENS it will be the same for all. There is no reason to call this for all recipients since that will unnecessarily make quite a few ENS calls.
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.
This codepath will be executed for any existing ENS addresses on config before this change goes live. since it will be formatted to address from here on out.
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.
I am not sure the referrer should ever be an ENS. You are resolving the ENS in the settings UI and the config only receives the actual address, which, IMO is good!
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.
Additionally, if the config does use an ENS, instead of having an address, the paywall UI should be able to "resolve" that ENS and use the resolved address when sending transactions.
The issue states to handle this scenario, hence I added it. Let me know if my assumption here is wrong. If we don't have to resolve an ENS from config all we need is small change of using <AddressInput>
@julien51 Up for review |
@@ -113,6 +113,7 @@ | |||
"deploy-fleek": "./scripts/deploy-fleek.sh", | |||
"start": "yarn build && NODE_ENV=production next start", | |||
"test": "UNLOCK_ENV=test vitest run --coverage --environment=jsdom", | |||
"test:watch": "UNLOCK_ENV=test vitest --coverage --environment=jsdom -w", |
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.
Added for convenience, Let me know if this has to be reverted
|
||
import { getReferrers } from '~/utils/checkoutLockUtils' | ||
|
||
export const useGetReferrers = ( |
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.
I don't understand why we need a hook for this and we could not call getReferrers
when we need ?
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.
(you actually do that in several places and that's correct!)
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.
since getReferrers
is not sync and it does make rpc calls, I am using hook. react query caches it based on the inputs to avoid making extra calls on re-renders causing issues.
error={errors.referrer?.message} | ||
value={referrer} | ||
onChange={(value: any) => { | ||
setValue('referrer', value) |
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.
👍
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.
Please, remove the hook and let's assume the paywall config's referrer
value is always an address. If we ever want to add support for ENS, then we should do it upstream.
Description
Issues
Fixes # #14102
Refs #
Checklist:
Release Note Draft Snippet