Skip to content
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: Registration Discount codes #1084

Merged
merged 22 commits into from
Oct 21, 2024
Merged

Feat: Registration Discount codes #1084

merged 22 commits into from
Oct 21, 2024

Conversation

kirkas
Copy link
Collaborator

@kirkas kirkas commented Oct 15, 2024

Introducing Discount Codes for Basenames.

This PR is addresses two body of works.

1. Promo Code

Get the code from the url ?code=...

See searchParams?.code in apps/web/app/(basenames)/names/page.tsx.

Pass the code to the attestations hooks

Introducing useDiscountCodeAttestations, fetch data from a new endpoint: /api/proofs/discountCode. This endpoints compare, validate & sign the code.

From here the existing attestations logic handles the discount automatically.

2. RegisterName refactor

We've had issues with the register flow for Smart Wallet, which led to a small refactor.

This flow is the first one we built, and we've since introduced helpful hooks like useWriteContractsWithLogs and useWriteContractWithReceipt for better, safer tracking of web3 transactions.

Changes to RegistrationContext

To avoid rendering race condition and other state / logic mishaps, we moved all the shared logic and state to the Context. This includes useRegisterNameCallback, setYears, price, etc..

Changes to RegistrationForm

Since the context holds the logic and state, this greatly simplify this components.

Changes to useRegisterNameCallback

This hook holds all the logic regarding initiating & tracking transactions, including error and analytics. This simplifies and consolidate Basename registration contract logic into one place.

Changes to RegistrationProfileForm

Fix which name you are editing.

Copy link

vercel bot commented Oct 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
base-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 18, 2024 8:01pm
web-base-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 18, 2024 8:01pm

@cb-heimdall
Copy link
Collaborator

cb-heimdall commented Oct 15, 2024

✅ Heimdall Review Status

Requirement Status More Info
Reviews 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

ricardoMogg
ricardoMogg previously approved these changes Oct 15, 2024
@cb-heimdall cb-heimdall dismissed ricardoMogg’s stale review October 16, 2024 13:52

Approved review 2370486781 from ricardoMogg is now dismissed due to new commit. Re-request for approval.

@JFrankfurt
Copy link
Contributor

JFrankfurt commented Oct 17, 2024

lgtm but we do need that mainnet address uncommented before merge right?

zencephalon
zencephalon previously approved these changes Oct 17, 2024
@cb-heimdall cb-heimdall dismissed zencephalon’s stale review October 17, 2024 17:27

Approved review 2375576845 from zencephalon is now dismissed due to new commit. Re-request for approval.

@kirkas
Copy link
Collaborator Author

kirkas commented Oct 17, 2024

@JFrankfurt yes waiting for contract on mainnet before mergin this. I'll also do a sepolia/codeflow test deploy first

@cb-heimdall
Copy link
Collaborator

Review Error for JFrankfurt @ 2024-10-18 20:26:44 UTC
User failed mfa authentication, see go/mfa-help

@kirkas kirkas merged commit 7dcd856 into master Oct 21, 2024
8 checks passed
@kirkas kirkas deleted the feat/discount-codes branch October 21, 2024 13:50
kirkas added a commit that referenced this pull request Oct 21, 2024
* discount code temp

* comments

* BE: Proof of concept

* mark/increment code as consumed

* bad code

* bad code

* dry it up

* remove test code

* cleanup and fix

* suspense

* undo change

* refactor: use internal transaction/capacities hooks for registration flow

* refetch basename

* fix: wrong name being used when reverseRecord is false

* prefetch

* ssr code instead of search params

* add banner & code
kirkas added a commit that referenced this pull request Oct 21, 2024
* discount code temp

* comments

* BE: Proof of concept

* mark/increment code as consumed

* bad code

* bad code

* dry it up

* remove test code

* cleanup and fix

* suspense

* undo change

* refactor: use internal transaction/capacities hooks for registration flow

* refetch basename

* fix: wrong name being used when reverseRecord is false

* prefetch

* ssr code instead of search params

* add banner & code
kirkas added a commit that referenced this pull request Oct 21, 2024
* discount code temp

* comments

* BE: Proof of concept

* mark/increment code as consumed

* bad code

* bad code

* dry it up

* remove test code

* cleanup and fix

* suspense

* undo change

* refactor: use internal transaction/capacities hooks for registration flow

* refetch basename

* fix: wrong name being used when reverseRecord is false

* prefetch

* ssr code instead of search params

* add banner & code
kirkas added a commit that referenced this pull request Oct 21, 2024
* [Tutorial] Apply custom theme to Swap component (#1098)

* add theme gif

* add styled swap component image

* add swap component before custom theme

* add tutorial for custom themes in OCK

* Feat: Registration Discount codes (#1084)

* discount code temp

* comments

* BE: Proof of concept

* mark/increment code as consumed

* bad code

* bad code

* dry it up

* remove test code

* cleanup and fix

* suspense

* undo change

* refactor: use internal transaction/capacities hooks for registration flow

* refetch basename

* fix: wrong name being used when reverseRecord is false

* prefetch

* ssr code instead of search params

* add banner & code

* Fix: Use correct chain for discoutn code (#1107)

* use correct chain

* use dynamic chain

* Revert "[Tutorial] Apply custom theme to Swap component (#1098)" (#1111)

This reverts commit c38fcab.

---------

Co-authored-by: Pat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants