Skip to content

Commit 931943d

Browse files
committed
Merge branch 'preview'
2 parents 63b54cf + b863878 commit 931943d

File tree

4 files changed

+44
-47
lines changed

4 files changed

+44
-47
lines changed

app/verify/page.tsx

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { Suspense, useCallback, useState } from "react";
3+
import { Suspense, useState } from "react";
44
import { Header } from "@/components/header/header";
55
import {
66
Button,
@@ -15,22 +15,21 @@ import { LoginWidget } from "@mochi-web3/login-widget";
1515
import { useSearchParams } from "next/navigation";
1616
import { WretchError } from "wretch";
1717
import { API } from "@/constants/api";
18+
import { CheckCircleHalfColoredLine } from "@mochi-ui/icons";
1819

1920
const Verify = () => {
2021
const { isOpen, onOpenChange } = useDisclosure();
2122
const searchParams = useSearchParams();
2223
const [loading, setLoading] = useState(false);
2324
const [verified, setVerified] = useState(false);
24-
const [error, _setError] = useState("");
25-
const setError = useCallback(
26-
(e: WretchError) => {
27-
_setError(e.json?.msg ?? "Something went wrong");
28-
},
29-
[_setError]
30-
);
25+
const [error, setError] = useState("");
3126

3227
const code = searchParams.get("code");
3328
const guild_id = searchParams.get("guild_id");
29+
const channel_id = searchParams.get("channel_id");
30+
const author_id = searchParams.get("author_id");
31+
const request_platform = searchParams.get("platform");
32+
const request_application = searchParams.get("application");
3433

3534
if (error) {
3635
return (
@@ -47,13 +46,16 @@ const Verify = () => {
4746

4847
if (verified) {
4948
return (
50-
<div className="py-8 px-8 mx-auto md:px-16 md:max-w-2xl min-h-[calc(100vh-56px)] flex flex-col items-center justify-center">
51-
<div className="text-2xl font-black text-center md:text-3xl">
52-
<span className="uppercase text-tono-gradient">
53-
Your wallet is verified! You can close this window
54-
</span>{" "}
55-
49+
<div className="w-full min-h-[calc(100vh-56px)] flex flex-col items-center justify-center text-center px-4 space-y-6">
50+
<div className="rounded-full bg-success-plain-active w-24 h-24 flex items-center justify-center border-[16px] border-success-soft">
51+
<CheckCircleHalfColoredLine className="w-10 h-10 text-success-solid" />
5652
</div>
53+
<p className="text-2xl sm:text-3.5xl sm:leading-9 font-semibold text-text-primary">
54+
You have connected your wallet.
55+
</p>
56+
<p className="text-base sm:text-lg text-text-primary">
57+
Please close this window and go back to your Discord server.
58+
</p>
5759
</div>
5860
);
5961
}
@@ -91,8 +93,13 @@ const Verify = () => {
9193
if (!code || loading) return;
9294
setLoading(true);
9395
const payload = {
94-
wallet_address: address,
9596
code,
97+
guild_id,
98+
channel_id,
99+
author_id,
100+
request_platform,
101+
request_application,
102+
wallet_address: address,
96103
signature,
97104
message:
98105
"Please sign this message to prove wallet ownership",
@@ -105,31 +112,15 @@ const Verify = () => {
105112
""
106113
)}`
107114
)
108-
.badRequest(setError)
109-
.json(async (r) => {
110-
const user_discord_id = r.associated_accounts.find(
111-
(aa: any) => aa.platform === "discord"
112-
)?.platform_identifier;
113-
if (!guild_id) {
114-
setVerified(true);
115-
} else if (user_discord_id) {
116-
await API.MOCHI.post(
117-
{
118-
user_discord_id,
119-
guild_id,
120-
},
121-
`/verify/assign-role`
122-
)
123-
.badRequest(setError)
124-
.res(() => {
125-
setVerified(true);
126-
})
127-
.catch(setError)
128-
.finally(() => {
129-
setLoading(false);
130-
onOpenChange(false);
131-
});
132-
}
115+
.res(() => {
116+
setVerified(true);
117+
})
118+
.catch((e: WretchError) => {
119+
setError(e.json?.msg ?? "Something went wrong");
120+
})
121+
.finally(() => {
122+
setLoading(false);
123+
onOpenChange(false);
133124
});
134125
}}
135126
/>

components/token-image.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import useSWR from "swr";
2+
import wretch from "wretch";
23
import Image from "next/image";
34

45
interface Props {
@@ -10,7 +11,10 @@ export const TokenImage = (props: Props) => {
1011
const { symbol = "", size = 20 } = props;
1112
const { data } = useSWR(
1213
`https://api-preview.mochi.console.so/api/v1/product-metadata/emoji?codes=${symbol}`,
13-
(url) => fetch(url).then((res) => res.json()),
14+
(url) =>
15+
wretch(url)
16+
.get()
17+
.json((res) => res.data),
1418
{
1519
revalidateIfStale: false,
1620
revalidateOnFocus: false,
@@ -21,7 +25,7 @@ export const TokenImage = (props: Props) => {
2125
return (
2226
<Image
2327
src={
24-
data?.data[0]?.emoji_url ||
28+
data?.[0]?.emoji_url ||
2529
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk8AEAAFIATgDK/mEAAAAASUVORK5CYII="
2630
}
2731
alt={symbol}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stake-token",
3-
"version": "1.2.0",
3+
"version": "1.3.0-rc.1",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",

store/token-staking.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { create } from "zustand";
2+
import wretch from "wretch";
23

34
export interface Chain {
45
id?: number;
@@ -52,10 +53,11 @@ const initialState: State = {
5253
export const useTokenStaking = create<State & Action>((set, get) => ({
5354
...initialState,
5455
fetchStakingPools: async () => {
55-
const response = await fetch(
56+
const res = await wretch(
5657
"https://api-preview.tono.console.so/api/v1/guilds/462663954813157376/community/token/staking"
57-
);
58-
const json = await response.json();
59-
set({ stakingPools: json?.data?.data || [] });
58+
)
59+
.get()
60+
.json((res) => res?.data?.data);
61+
set({ stakingPools: res || [] });
6062
},
6163
}));

0 commit comments

Comments
 (0)