Skip to content

Points update#8

Merged
luu-alex merged 25 commits intoprodfrom
points-update
Mar 26, 2026
Merged

Points update#8
luu-alex merged 25 commits intoprodfrom
points-update

Conversation

@luu-alex
Copy link
Copy Markdown

No description provided.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 26, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
hyperterminal 9e59576 Mar 26 2026, 01:54 PM

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates a comprehensive 'Hypermiles' points system into the application, designed to enhance user engagement and growth. It introduces a new modal for displaying user points and managing referrals, accessible directly from the main navigation. The system includes logic for capturing referral codes from URLs and automatically registering users, streamlining the onboarding process for referred users. Configuration for the new points API and Turnstile has also been updated, alongside necessary localization string additions.

Highlights

  • New Points System Integration: Implemented a new 'Hypermiles' points system, allowing users to earn points through trading and referring friends.
  • Referral Program: Introduced a referral mechanism that captures referral codes from URLs and automatically registers users with the points system.
  • User Interface Updates: Added a new 'Points' button with a trophy icon to the top navigation bar, which opens a dedicated points modal.
  • Configuration Updates: Updated environment variables to include the new Hypermiles API URL and adjusted the Turnstile site key.
  • Localization Support: Added new localization strings across multiple languages (Arabic, English, Spanish, French, Hindi, Chinese) to support the new points feature.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new 'Hypermiles' points system, including a dedicated PointsModal for displaying user points, rank, and referral information, along with signup functionality. A 'Points' button has been added to the top navigation, which replaces the Faucet button on mainnet. The changes also include new referral capture and auto-registration hooks, updates to the global modal store, and environment variable configurations. Review comments suggest improvements for error logging in catch blocks and proper dependency management for useEffect hooks using useCallback in the new points modal and referral hooks.

Comment on lines +126 to +129
.catch(() => {
setError("Unable to connect to points service");
setView("error");
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For better observability and easier debugging, it's a good practice to log caught errors to the console. This applies here and in the catch block of the handleSignup function (line 182).

			.catch((error) => {
				console.error("Failed to fetch points:", error);
				setError("Unable to connect to points service");
				setView("error");
			});

Comment on lines +132 to +136
// biome-ignore lint/correctness/useExhaustiveDependencies: fetchPoints is intentionally excluded to avoid re-creating on every render
useEffect(() => {
if (!open || !address) return;
fetchPoints();
}, [open, address]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This useEffect is ignoring the exhaustive-deps lint rule. To fix this properly, you should wrap the fetchPoints function in a useCallback hook. This will give fetchPoints a stable identity and allow you to include it in the dependency array, satisfying the lint rule and making the data flow more explicit.

Example for fetchPoints:

const fetchPoints = useCallback(() => {
  // ... function body
}, [address]);

Then you can add fetchPoints to this useEffect's dependency array.

Comment on lines +182 to +183
} catch (err) {
setError(err instanceof Error ? err.message : "Signup failed");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

It's a good practice to log caught errors for easier debugging. The actual error object err is available here but is not being logged to the console.

Suggested change
} catch (err) {
setError(err instanceof Error ? err.message : "Signup failed");
} catch (err) {
console.error("Signup failed:", err);
setError(err instanceof Error ? err.message : "Signup failed");

Comment on lines +68 to +70
.catch(() => {
registeredRef.current = false;
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This catch block resets the registeredRef, but it swallows the error. Logging the error here would be very helpful for debugging issues with the auto-registration flow.

			.catch((error) => {
				console.error("Auto-register referral failed:", error);
				registeredRef.current = false;
			});

@luu-alex
Copy link
Copy Markdown
Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements a new referral system. It introduces useReferralCapture to extract referral codes from the URL and store them, and useAutoRegisterReferral to automatically register users with these codes upon wallet connection. The points modal has been updated to use stored referral codes, improve error logging, and display a full referral link. A suggestion was made to refactor the useAutoRegisterReferral hook's useEffect logic to use async/await for improved readability and more explicit error handling, as the current promise chain might inadvertently swallow errors.

Comment on lines +39 to +71
useEffect(() => {
if (!isConnected || !address || registeredRef.current) return;

registeredRef.current = true;

fetch(`${API_URL}/user_points?user_address=${address}`)
.then((res) => {
if (res.ok) {
clearStoredReferral();
return;
}
if (res.status === 404) {
const referral = getStoredReferral();
const body: Record<string, string> = { walletAddress: address };
if (referral) {
body.referralCode = referral;
}
if (user?.id) {
body.privyUserId = user.id;
}
return fetch(`${API_URL}/users`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
}).then(() => {
clearStoredReferral();
});
}
})
.catch(() => {
registeredRef.current = false;
});
}, [isConnected, address, user?.id]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The logic inside this useEffect can be simplified and made more readable by using async/await. This also provides an opportunity to handle errors more explicitly by logging them in a catch block. The current implementation swallows errors, which can make debugging difficult.

useEffect(() => {
	const autoRegister = async () => {
		if (!isConnected || !address || registeredRef.current) return;

		registeredRef.current = true;

		try {
			const res = await fetch(`${API_URL}/user_points?user_address=${address}`);
			if (res.ok) {
				clearStoredReferral();
				return;
			}

			if (res.status === 404) {
				const referral = getStoredReferral();
				const body: Record<string, string> = { walletAddress: address };
				if (referral) {
					body.referralCode = referral;
				}
				if (user?.id) {
					body.privyUserId = user.id;
				}
				await fetch(`${API_URL}/users`, {
					method: "POST",
					headers: { "Content-Type": "application/json" },
					body: JSON.stringify(body),
				});
				clearStoredReferral();
			}
		} catch (error) {
			console.error("Auto-registration failed:", error);
			registeredRef.current = false;
		}
	};

	autoRegister();
}, [isConnected, address, user?.id]);

@luu-alex luu-alex merged commit 57087ae into prod Mar 26, 2026
3 of 4 checks passed
@priom priom deleted the points-update branch March 31, 2026 01:58
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.

1 participant