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: Improve protection logic #1732

Merged
merged 16 commits into from
Jan 21, 2025
Merged

Conversation

0xonramp
Copy link
Collaborator

@0xonramp 0xonramp commented Jan 13, 2025

Updates the protection provider to leverage the new API endpoint to check for restricted countries/VPN usage, and adds new messaging for VPN users.

Copy link

vercel bot commented Jan 13, 2025

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

Name Status Preview Comments Updated (UTC)
index-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 6:11pm

Comment on lines +14 to +21
'ic-ip-address':
req.headers.get('cf-connecting-ip') ??
req.headers.get('x-forwarded-for') ??
undefined,
'ic-ip-country':
req.headers.get('cf-ipcountry') ??
req.headers.get('x-vercel-ip-country') ??
undefined,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fallbacks are there so the code works on preview deployments (i.e. not passing through the cloudflare proxy)

Copy link
Collaborator

@janndriessen janndriessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm. 🔒

@@ -97,10 +103,22 @@ export function SmartTradeButton(props: SmartTradeButtonProps) {
const [warnings, setWarnings] = useState<WarningType[]>([])

useEffect(() => {
if (!isTradablePair && !hiddenWarnings?.includes(WarningType.restricted)) {
if (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im thinking there is no effect here, so instead of an effect and a state you could just use useMemo, and return the result

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tokdaniel good call, updated to useMemo 👍

Copy link
Collaborator

@tokdaniel tokdaniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smol comment, otherwise lgtm

@0xonramp 0xonramp merged commit 48c9a28 into master Jan 21, 2025
3 checks passed
@0xonramp 0xonramp deleted the feat/improved-protection-logic branch January 21, 2025 14:40
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.

3 participants