diff --git a/Makefile b/Makefile index e76afa2..64d2045 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,5 @@ generate-env-files: @cp backend/.env.example backend/.env @cp frontend/.env.local.example frontend/.env.local @echo "Environment files copied..." - @echo "Update backend/.env and frontend/.env.local" setup: install generate-env-files db \ No newline at end of file diff --git a/README.md b/README.md index 87aa7a5..0da3fdf 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ cd get-started make setup ``` -4. Add environment variables to `./backend/.env` +4. Add environment variables to `./backend/.env` and `./frontend/.env.local` 5. Execute development commands: diff --git a/backend/src/constants/missions.ts b/backend/src/constants/missions.ts index 26fadf9..437e7ae 100644 --- a/backend/src/constants/missions.ts +++ b/backend/src/constants/missions.ts @@ -1,8 +1,8 @@ export default [ { - id: "test_mission", + id: "Reward User", description: - "Complete two test actions to complete the Test Mission", + "Press Reward User on the App page twice to complete this Quest.", tokens: [ { address: process.env.XP_TOKEN_ID, diff --git a/backend/src/routes/api/v1/auth.ts b/backend/src/routes/api/v1/auth.ts index d9ba770..eb38dfd 100644 --- a/backend/src/routes/api/v1/auth.ts +++ b/backend/src/routes/api/v1/auth.ts @@ -36,8 +36,6 @@ auth.post("/verify", async (c) => { }, }); - console.log({ result }); - const originalChallenge = result ? result.challenge : null; if (!originalChallenge) { @@ -88,6 +86,7 @@ auth.post("/verify", async (c) => { status: Status.SUCCESS, access_token: accessToken, refresh_token: refreshToken, + address: eth_address, }); } else { return c.json( @@ -143,6 +142,7 @@ auth.post("/refresh-token", async (c) => { return c.json({ status: Status.SUCCESS, refresh_token, + address: tokenRecord.user.eth_address, access_token: newAccessToken, }); }); diff --git a/bun.lockb b/bun.lockb index 018685a..670ec03 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/frontend/.env.local.example b/frontend/.env.local.example index acc918d..53c151a 100644 --- a/frontend/.env.local.example +++ b/frontend/.env.local.example @@ -1 +1,14 @@ +# The APPLICATION_ID, XP_TOKEN_ID, and REWARD_TOKEN_ID are accessible by +# selecting "View Application Keys" on the Manage Application page in the OPENFORMAT App. + +# This ID links your application with the OPENFORMAT platform. +NEXT_PUBLIC_APPLICATION_ID= + +# Identifier for the Reward Token used in your application. +NEXT_PUBLIC_REWARD_TOKEN_ID= + +# Wallet address of application owner. When a user spends a Reward Token, it will be sent to this address. +# This will generally be the same address you created the Application with in the OPENFORMAT App. +NEXT_PUBLIC_APPLICATION_OWNER_ADDRESS= + NEXT_PUBLIC_API_HOSTNAME=http://localhost:8080/api/v1 \ No newline at end of file diff --git a/frontend/components/Footer.tsx b/frontend/components/Footer.tsx index f02aa49..8b567e4 100644 --- a/frontend/components/Footer.tsx +++ b/frontend/components/Footer.tsx @@ -2,12 +2,14 @@ export default function Footer() { return ( ); } diff --git a/frontend/components/Header.tsx b/frontend/components/Header.tsx index dbaf48a..6c825cf 100644 --- a/frontend/components/Header.tsx +++ b/frontend/components/Header.tsx @@ -18,6 +18,7 @@ export default function Header() { }; const handleAuth = async () => { + if (!address) return; try { const challengeResponse = await apiClient.post( "auth/challenge", @@ -41,9 +42,10 @@ export default function Header() { }; useEffect(() => { - const tokenExists = localStorage.getItem("tokens"); + const tokens = localStorage.getItem("tokens"); + const parsedTokens = JSON.parse(tokens); - if (address && !tokenExists) { + if ((address && !tokens) || address !== parsedTokens?.address) { handleAuth(); } }, [address]); @@ -63,7 +65,7 @@ export default function Header() {