-
Notifications
You must be signed in to change notification settings - Fork 16
Using NormalizedAddress in referral program logic
#1938
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
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@namehash/ens-referrals": patch | ||
|
Goader marked this conversation as resolved.
|
||
| --- | ||
|
|
||
| Tighten referral program types to use `NormalizedAddress` instead of `Address` in internal leaderboard map keys (pie-split, shared `sliceReferrers`) and related JSDoc. No runtime behavior change. | ||
|
Goader marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -158,7 +158,7 @@ The package also includes helpers for building referral links. | |||||
|
|
||||||
| ```typescript | ||||||
| import { buildEnsReferralUrl } from "@namehash/ens-referrals"; | ||||||
| import type { Address } from "viem"; | ||||||
| import type { Address } from "enssdk"; | ||||||
|
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.
The example now imports
Suggested change
|
||||||
|
|
||||||
| const referrerAddress: Address = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||
| import type { NormalizedAddress } from "enssdk"; | ||||||
| import { isNormalizedAddress } from "enssdk"; | ||||||
|
|
||||||
| export const validateAddress = (address: NormalizedAddress): void => { | ||||||
| export const validateNormalizedAddress = (address: NormalizedAddress): void => { | ||||||
|
Member
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. Feel free to have a look at
Suggested change
Member
Author
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. Thank you for the tip! In this case validation functions work more like runtime assertions and guards rather than a way to handle unvalidated objects. From what I see in the |
||||||
| if (!isNormalizedAddress(address)) { | ||||||
| throw new Error(`Invalid address: '${address}'. Address must be a lowercase EVM Address.`); | ||||||
|
Goader marked this conversation as resolved.
|
||||||
| } | ||||||
|
Goader marked this conversation as resolved.
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.