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

implement ip info and send supabase #46

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion client/src/ui/actions/Start.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,37 @@ export const Start: React.FC<StartProps> = ({ mode, handleGameMode }) => {
proof_verify_hint,
beta,
} = await fetchVrfData();

//send to supabase
if (import.meta.env.VITE_SEND_TO_SUPABASE) {
try {
const responseIp = await fetch(
`https://ipinfo.io/json?token=${import.meta.env.VITE_IPINFO_KEY}`,
);
const { country } = await responseIp.json();
const accountAddress = account?.address;
Cheelax marked this conversation as resolved.
Show resolved Hide resolved
const response = await fetch(
"https://rjzlpqqdiwqkglbzeaxa.supabase.co/functions/v1/zkube-payment",
{
method: "POST",
headers: {
Authorization: `Bearer ${import.meta.env.VITE_SUPABASE_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
wallet: accountAddress,
country: country,
timestamp: new Date().toISOString(),
}),
},
);

if (!response.ok) {
console.error("Failed to send data to Supabase");
}
Cheelax marked this conversation as resolved.
Show resolved Hide resolved
} catch (error) {
console.error("Error sending data to Supabase:", error);
}
}
Cheelax marked this conversation as resolved.
Show resolved Hide resolved
await start({
account: account as Account,
mode: new Mode(mode).into(),
Expand Down
Loading