Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
41 changes: 41 additions & 0 deletions examples/invitation-link-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions examples/invitation-link-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
16 changes: 16 additions & 0 deletions examples/invitation-link-example/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
});

const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"),
];

export default eslintConfig;
7 changes: 7 additions & 0 deletions examples/invitation-link-example/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
};

export default nextConfig;
34 changes: 34 additions & 0 deletions examples/invitation-link-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "invitation-link-example",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@metamask/delegation-toolkit": "^0.11.0",
"@tanstack/react-query": "^5.76.1",
"@web3auth/modal": "^10.0.0",
"next": "15.2.1",
"permissionless": "^0.2.46",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"viem": "^2.29.2",
"wagmi": "^2.15.3"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.3.5",
"tailwindcss": "^4",
"typescript": "^5"
},
"packageManager": "[email protected]"
}
5 changes: 5 additions & 0 deletions examples/invitation-link-example/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
plugins: ["@tailwindcss/postcss"],
};

export default config;
1 change: 1 addition & 0 deletions examples/invitation-link-example/public/file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/invitation-link-example/public/globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/invitation-link-example/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/invitation-link-example/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/invitation-link-example/public/window.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
5 changes: 5 additions & 0 deletions examples/invitation-link-example/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "tailwindcss";

nextjs-portal {
display: none;
}
35 changes: 35 additions & 0 deletions examples/invitation-link-example/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { AppProvider } from "@/providers/AppProvider";

const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});

const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});

export const metadata: Metadata = {
title: "Delegation Toolkit Starter App",
description: "Generated by create next app",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en" className="dark:text-white">
<body
className={`${geistSans.variable} ${geistMono.variable} bg-white dark:bg-black text-black dark:text-white font-geist-sans antialiased max-w-full overflow-x-hidden`}
>
<AppProvider>{children}</AppProvider>
</body>
</html>
);
}
36 changes: 36 additions & 0 deletions examples/invitation-link-example/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use client";
import Steps from "@/components/Steps";
import Footer from "@/components/Footer";
import { useAccount, useDisconnect } from "wagmi";

export default function Home() {
const { address } = useAccount();
const { disconnect } = useDisconnect();

return (
<div className="grid items-center justify-items-center min-h-screen p-8 gap-4 font-geist-sans">
{address && (
<header className="absolute top-4 right-4">
<button
onClick={() => disconnect()}
className="text-gray-400 hover:text-white text-sm transition-colors"
>
Disconnect
</button>
</header>
)}
<main className="flex flex-col gap-6 row-start-2">
<div className="text-center">
<h1 className="text-3xl font-bold text-white mb-2">
Invitation Links
</h1>
<p className="text-white/70">
Create and share invitation links for rewards
</p>
</div>
<Steps />
</main>
<Footer />
</div>
);
}
30 changes: 30 additions & 0 deletions examples/invitation-link-example/src/components/AccountCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import useDelegatorSmartAccount from "@/hooks/useDelegatorSmartAccount";
import { formatEther } from "viem";
import { useBalance } from "wagmi";

export default function AccountCard() {
const { smartAccount } = useDelegatorSmartAccount();
const { data: balance } = useBalance({
address: smartAccount?.address,
});

return (
<div className="bg-gray-800 border border-gray-700 p-3 rounded">
<div className="flex justify-between items-center space-x-8">
<div>
<p className="text-gray-300 text-sm font-mono">
{smartAccount?.address.slice(0, 6)}...
{smartAccount?.address.slice(-4)}
</p>
</div>
<div className="text-right">
<p className="text-gray-300 text-sm font-mono">
{balance
? `${formatEther(BigInt(balance.value))} ${balance.symbol}`
: "0.0000"}
</p>
</div>
</div>
</div>
);
}
20 changes: 20 additions & 0 deletions examples/invitation-link-example/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ButtonHTMLAttributes, ReactNode } from "react";

interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
children: ReactNode;
}

export default function Button({
children,
className = "",
...props
}: ButtonProps) {
const baseClasses =
'w-fit px-4 py-2 text-sm font-semibold text-white bg-gradient-to-br from-indigo-500 to-blue-500 hover:from-indigo-600 hover:to-blue-600 rounded-lg cursor-pointer transition-all duration-200 ease-in-out shadow-md hover:scale-102 active:scale-95 min-h-4 inline-flex items-center justify-center border-none disabled:opacity-50 disabled:cursor-not-allowed';

return (
<button className={`${baseClasses} ${className}`} {...props}>
{children}
</button>
);
}
Loading
Loading