Skip to content

Commit 4d964aa

Browse files
feature: add faucet with Clerk authentication (#84)
* chore: update react and react-dom to version 19.2.0 * chore: remove .env file containing sensitive configuration * feat: add example environment configuration file * feat: integrate Clerk for authentication and add faucet functionality * feat: update Navbar and Faucet components for improved user experience * fix: ensure signOut is called only when user is signed in * fix: add missing semicolons for consistency in useLoginLogout hook * feat: integrate useWatchAsset hook to add asset in wallet manager * fix: update import path for useWatchAsset hook to ensure correct functionality * feat: enhance Faucet component with dynamic block explorer URL and improved success message styling * feat: add nrlcToRlc utility function and update success message in FaucetRoute * fix: reorder import statements for consistency in FaucetRoute component * fix: update FAUCET_API_URL to use environment variable and add faucet api URL in .env.example * chore: add comment header for development environment in .env.example * feat: update faucet success explorer link Co-authored-by: Robin Le Caignec <[email protected]> * fix: clarify fund request message to specify RLC for Arbitrum Sepolia --------- Co-authored-by: Robin Le Caignec <[email protected]>
1 parent 2bf7683 commit 4d964aa

File tree

11 files changed

+435
-22
lines changed

11 files changed

+435
-22
lines changed
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# dev
2+
13
VITE_POCO_SUBGRAPH_URL="https://thegraph.iex.ec/subgraphs/name/bellecour/poco-v5"
24
VITE_DATAPROTECTOR_SUBGRAPH_URL="https://thegraph.iex.ec/subgraphs/name/bellecour/dataprotector-v2"
3-
VITE_REOWN_PROJECT_ID=b89f75687c01fa0df9e68c903283012d
5+
VITE_REOWN_PROJECT_ID=
6+
VITE_CLERK_PUBLISHABLE_KEY=
7+
VITE_FAUCET_API_URL = 'https://dev-rlc-faucet.iex.ec'
8+
9+
# prod
10+
11+
VITE_FAUCET_API_URL = 'https://rlc-faucet.iex.ec'

package-lock.json

Lines changed: 117 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"watch:codegen:poco": "graphql-codegen --config codegenPoco.ts --watch"
1919
},
2020
"dependencies": {
21+
"@clerk/clerk-react": "^5.51.0",
2122
"@fontsource-variable/anybody": "^5.2.6",
2223
"@fontsource-variable/mulish": "^5.2.6",
2324
"@fontsource/space-mono": "^5.2.8",
@@ -48,8 +49,8 @@
4849
"iexec": "^8.18.0",
4950
"lucide-react": "^0.536.0",
5051
"prettier-plugin-tailwindcss": "^0.6.14",
51-
"react": "^19.1.1",
52-
"react-dom": "^19.1.1",
52+
"react": "^19.2.0",
53+
"react-dom": "^19.2.0",
5354
"react-hook-form": "^7.62.0",
5455
"rollbar": "^2.26.4",
5556
"tailwind-merge": "^3.3.1",

src/components/navbar/NavBar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ export function Navbar() {
2424
<span className="hidden lg:block">iExec Explorer</span>
2525
</ChainLink>
2626
<div className="mr-8 flex items-center gap-4 md:mr-0">
27+
<Button variant="link" asChild className="text-foreground -mr-4">
28+
<ChainLink to="/faucet">Faucet</ChainLink>
29+
</Button>
2730
{isConnected && (
28-
<div className="hidden md:flex">
31+
<div className="-mr-4 hidden md:flex">
2932
<Button variant="link" asChild className="text-foreground">
3033
<ChainLink to={`/address/${userAddress}?from=my_activity`}>
3134
My activity
@@ -34,9 +37,9 @@ export function Navbar() {
3437
<Button variant="link" asChild className="text-foreground">
3538
<ChainLink to="/account">iExec Account</ChainLink>
3639
</Button>
37-
<span className="border-secondary border-l" />
3840
</div>
3941
)}
42+
<span className="border-secondary h-9 border-l" />
4043
<div className="content hidden gap-4 md:flex">
4144
<ModeToggle />
4245
<ChainSelector />

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const TABLE_REFETCH_INTERVAL = 10_000;
1212

1313
export const IPFS_GATEWAY_URL = 'https://ipfs.iex.ec';
1414
export const API_COINGECKO_URL = 'https://api.coingecko.com/api/v3/simple/';
15+
export const FAUCET_API_URL = import.meta.env.VITE_FAUCET_API_URL;
1516

1617
export const SUPPORTED_CHAINS = [
1718
{

src/hooks/useLoginLogout.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
import { useAuth } from '@clerk/clerk-react';
12
import { useAppKit } from '@reown/appkit/react';
23
import { useDisconnect } from 'wagmi';
34

45
export function useLoginLogout() {
56
const { open } = useAppKit();
67
const { disconnectAsync } = useDisconnect();
8+
const { signOut, isSignedIn } = useAuth();
79

810
const logout = async () => {
11+
if (isSignedIn) {
12+
signOut();
13+
}
914
try {
1015
await disconnectAsync();
1116
} catch (err) {

src/main.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ClerkProvider } from '@clerk/clerk-react';
12
import '@fontsource-variable/anybody/wdth.css';
23
import '@fontsource-variable/mulish/index.css';
34
import {
@@ -24,8 +25,12 @@ const { rollbar, rollbarConfig } = initRollbarAlerting();
2425
const queryClient = initQueryClient({ rollbar });
2526

2627
const router = initRouter(queryClient);
27-
2828
const rootElement = document.getElementById('root')!;
29+
const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY;
30+
31+
if (!PUBLISHABLE_KEY) {
32+
throw new Error('Add your Clerk Publishable Key to the .env file');
33+
}
2934
if (!rootElement.innerHTML) {
3035
const root = createRoot(rootElement);
3136
root.render(
@@ -37,7 +42,9 @@ if (!rootElement.innerHTML) {
3742
>
3843
<RollbarErrorBoundary>
3944
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
40-
<RouterProvider router={router} />
45+
<ClerkProvider publishableKey={PUBLISHABLE_KEY}>
46+
<RouterProvider router={router} />
47+
</ClerkProvider>
4148
</ThemeProvider>
4249
</RollbarErrorBoundary>
4350
</RollbarProvider>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { ChainLink } from '@/components/ChainLink';
2+
import {
3+
Breadcrumb,
4+
BreadcrumbItem,
5+
BreadcrumbLink,
6+
BreadcrumbList,
7+
BreadcrumbPage,
8+
BreadcrumbSeparator,
9+
} from '@/components/ui/breadcrumb';
10+
11+
export function FaucetBreadcrumbs() {
12+
return (
13+
<Breadcrumb>
14+
<BreadcrumbList>
15+
<BreadcrumbItem>
16+
<BreadcrumbLink asChild>
17+
<ChainLink to="/">Homepage</ChainLink>
18+
</BreadcrumbLink>
19+
</BreadcrumbItem>
20+
<BreadcrumbSeparator />
21+
<BreadcrumbItem>
22+
<BreadcrumbPage>Faucets</BreadcrumbPage>
23+
</BreadcrumbItem>
24+
</BreadcrumbList>
25+
</Breadcrumb>
26+
);
27+
}

0 commit comments

Comments
 (0)