Compare commits
153
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8abf3cc777 | ||
|
|
f10fbc8383 | ||
|
|
38627d352b | ||
|
|
ad8cc9a1d2 | ||
|
|
4e935392fa | ||
|
|
f44d6ba282 | ||
|
|
3678054931 | ||
|
|
196cb54ae9 | ||
|
|
ed2d64197d | ||
|
|
e141e11ff3 | ||
|
|
6ae54ddd98 | ||
|
|
8245c06b3e | ||
|
|
1c11f84481 | ||
|
|
b84db126d7 | ||
|
|
a4406214c6 | ||
|
|
02627631b6 | ||
|
|
913b243147 | ||
|
|
3edbe2898c | ||
|
|
926dad4556 | ||
|
|
0639d0d9ea | ||
|
|
4fed9f4593 | ||
|
|
f2e8b9ecab | ||
|
|
523412437b | ||
|
|
ac4ade6262 | ||
|
|
819ce86c61 | ||
|
|
86fd445276 | ||
|
|
55fba51dab | ||
|
|
7c95211b98 | ||
|
|
3bb1fe0e1f | ||
|
|
a1aba2989e | ||
|
|
deeca886a4 | ||
|
|
31c4bb22fc | ||
|
|
3b1e16c8b7 | ||
|
|
1f42ad2a2d | ||
|
|
0299034fc1 | ||
|
|
861e623a1b | ||
|
|
6a335bfa77 | ||
|
|
cb994dcb8f | ||
|
|
4d38a7e8fe | ||
|
|
89e6af6baf | ||
|
|
b345cc115e | ||
|
|
3d3c6f3d45 | ||
|
|
ff3a79c884 | ||
|
|
16482cfa6a | ||
|
|
e8a25d70b9 | ||
|
|
44a7460c83 | ||
|
|
0731831169 | ||
|
|
91750eddc6 | ||
|
|
2fc083f1f2 | ||
|
|
75ae536e61 | ||
|
|
41e59a9c20 | ||
|
|
fd97406fa2 | ||
|
|
c336de3bfb | ||
|
|
c420099dc3 | ||
|
|
dcb412fc27 | ||
|
|
4705a599a2 | ||
|
|
f7331f15a2 | ||
|
|
a5d6e769db | ||
|
|
97b8926024 | ||
|
|
655df037dd | ||
|
|
cbde32e974 | ||
|
|
8ed5ef3f81 | ||
|
|
e14a1349e1 | ||
|
|
acd8b9e535 | ||
|
|
52d451ff70 | ||
|
|
c03616666b | ||
|
|
bb7a8988ef | ||
|
|
8d0ffedd41 | ||
|
|
5edfb81ec5 | ||
|
|
f115b4d2db | ||
|
|
0e4390b2c7 | ||
|
|
aec8d88af2 | ||
|
|
80207ae240 | ||
|
|
ec7bc2bb1e | ||
|
|
12475027d1 | ||
|
|
9479d252b4 | ||
|
|
5139857db9 | ||
|
|
ad4341a7ad | ||
|
|
ebd58f49b6 | ||
|
|
3862bc7a94 | ||
|
|
5277eddb70 | ||
|
|
6c180b5c8a | ||
|
|
3489ecec98 | ||
|
|
f9b34ff2f1 | ||
|
|
f3abea3276 | ||
|
|
adc738e536 | ||
|
|
dd2fb1b13d | ||
|
|
69fdef07f5 | ||
|
|
362c086bf6 | ||
|
|
f9b609e7a2 | ||
|
|
916ecf494c | ||
|
|
d1ca9af2f4 | ||
|
|
317211a48e | ||
|
|
6cd64e7368 | ||
|
|
005acce714 | ||
|
|
cde2dd941f | ||
|
|
7130f9a929 | ||
|
|
1e0b1422f3 | ||
|
|
70a519ada4 | ||
|
|
678c00e322 | ||
|
|
5ab59ff400 | ||
|
|
73629e9f0e | ||
|
|
23029db9ef | ||
|
|
526b6b54cf | ||
|
|
f31116ea5a | ||
|
|
c1f7aaadc1 | ||
|
|
1ad109f3bc | ||
|
|
376bdb23d2 | ||
|
|
dcd6b99e67 | ||
|
|
88533d9113 | ||
|
|
6c3a8d36a7 | ||
|
|
a31ac0c065 | ||
|
|
7b72e88611 | ||
|
|
4b9a506fdf | ||
|
|
77da352366 | ||
|
|
72cc27a69a | ||
|
|
46d1dab11e | ||
|
|
a1c432ca17 | ||
|
|
243c661929 | ||
|
|
b64ffe369a | ||
|
|
30fafd16db | ||
|
|
99901dcfd7 | ||
|
|
f5072d882e | ||
|
|
e7f7a32dd4 | ||
|
|
d2098ad0bf | ||
|
|
d6239785cf | ||
|
|
20fdd5b6d7 | ||
|
|
438c019f01 | ||
|
|
61044013c8 | ||
|
|
e6213db8af | ||
|
|
c46b2597be | ||
|
|
9ff97688ce | ||
|
|
b4f5cc7b5a | ||
|
|
256850d1c6 | ||
|
|
acb2b9f85f | ||
|
|
6ac62ffe96 | ||
|
|
80f4bd4e53 | ||
|
|
a3072c4335 | ||
|
|
3277cf6e8e | ||
|
|
77938c4d5c | ||
|
|
3080a9baba | ||
|
|
6cf92c6b11 | ||
|
|
89ccc80d9c | ||
|
|
713ebe0a2d | ||
|
|
bfdac10dcc | ||
|
|
64964da22e | ||
|
|
260c2fd370 | ||
|
|
c61e258ec3 | ||
|
|
fdd344184b | ||
|
|
0c853e8709 | ||
|
|
7d47b4cde0 | ||
|
|
feae304da2 | ||
|
|
8f605d989c |
@@ -89,7 +89,7 @@ jobs:
|
|||||||
- run: pnpm test
|
- run: pnpm test
|
||||||
|
|
||||||
- name: Code Coverage
|
- name: Code Coverage
|
||||||
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
|
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
|
||||||
with:
|
with:
|
||||||
directory: packages/
|
directory: packages/
|
||||||
flags: packages
|
flags: packages
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ jobs:
|
|||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
|
uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
@@ -59,7 +59,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
|
uses: github/codeql-action/autobuild@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||||
@@ -72,4 +72,4 @@ jobs:
|
|||||||
# ./location_of_script_within_repo/buildscript.sh
|
# ./location_of_script_within_repo/buildscript.sh
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
|
uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Create release Pull Request or publish to NPM
|
- name: Create release Pull Request or publish to NPM
|
||||||
id: changesets
|
id: changesets
|
||||||
uses: changesets/action@746c25e23caa47dceb6a48ee85b4cbc5a9f5f293 #v1.4.0
|
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba #v1.4.0
|
||||||
with:
|
with:
|
||||||
publish: pnpm release
|
publish: pnpm release
|
||||||
version: pnpm version-packages
|
version: pnpm version-packages
|
||||||
|
|||||||
+3
-1
@@ -16,6 +16,7 @@ yalc.lock
|
|||||||
./build/
|
./build/
|
||||||
playwright-report/
|
playwright-report/
|
||||||
.env/
|
.env/
|
||||||
|
.pnpm-store/
|
||||||
|
|
||||||
# codecov binary
|
# codecov binary
|
||||||
codecov
|
codecov
|
||||||
@@ -31,4 +32,5 @@ storybook-static
|
|||||||
.aider*
|
.aider*
|
||||||
|
|
||||||
tsconfig.tsbuildinfo
|
tsconfig.tsbuildinfo
|
||||||
.cursor
|
.cursor
|
||||||
|
apps/dashboard/node-compile-cache
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
🤖 Codex Agent Guidelines for thirdweb-dev/js
|
||||||
|
|
||||||
|
Welcome, AI copilots! This guide captures the coding standards, architectural decisions, and workflow conventions that every automated agent (and human contributor!) must follow. Unless a rule explicitly targets a sub‑project, it applies repo‑wide.
|
||||||
|
|
||||||
|
⸻
|
||||||
|
|
||||||
|
1. GitHub Workflow & Etiquette
|
||||||
|
|
||||||
|
- Pull‑request titles must start with the affected workspace in brackets (e.g. [SDK], [Dashboard], [Portal], [Playground]).
|
||||||
|
- Begin the PR description with a one‑sentence summary, then add a checklist of changes and reference issues with Fixes #123.
|
||||||
|
- Keep commits small and topical – one logical change per commit.
|
||||||
|
- Branch names should follow area/brief-topic (e.g. sdk/fix-gas-estimate). Avoid personal names.
|
||||||
|
- Request at least one core maintainer review. Do not self‑merge unless you are the sole owner of that package.
|
||||||
|
- All CI checks (type‑check, Biome, tests) must pass before merging.
|
||||||
|
|
||||||
|
⸻
|
||||||
|
|
||||||
|
2. Formatting & Linting
|
||||||
|
|
||||||
|
- Biome governs formatting and linting; its rules live in biome.json.
|
||||||
|
- Run pnpm biome check --apply before committing.
|
||||||
|
- Avoid editor‑specific configs; rely on the shared settings.
|
||||||
|
|
||||||
|
⸻
|
||||||
|
|
||||||
|
3. TypeScript Style Guide
|
||||||
|
|
||||||
|
- Write idiomatic TypeScript: explicit function declarations and return types.
|
||||||
|
- Limit each file to one stateless, single‑responsibility function for clarity and testability.
|
||||||
|
- Re‑use shared types from @/types or local types.ts barrels.
|
||||||
|
- Prefer type aliases over interface except for nominal shapes.
|
||||||
|
- Avoid any and unknown unless unavoidable; narrow generics whenever possible.
|
||||||
|
- Choose composition over inheritance; leverage utility types (Partial, Pick, etc.).
|
||||||
|
|
||||||
|
⸻
|
||||||
|
|
||||||
|
4. Testing Strategy
|
||||||
|
|
||||||
|
- Co‑locate tests: foo.ts ↔ foo.test.ts.
|
||||||
|
- Use real function invocations with stub data; avoid brittle mocks.
|
||||||
|
- For network interactions, use Mock Service Worker (MSW) to intercept fetch/HTTP calls, mocking only scenarios that are hard to reproduce.
|
||||||
|
- Keep tests deterministic and side‑effect free; Jest is pre‑configured.
|
||||||
|
|
||||||
|
⸻
|
||||||
|
|
||||||
|
5. packages/thirdweb
|
||||||
|
|
||||||
|
5.1 Public API Surface
|
||||||
|
|
||||||
|
- Export everything via the exports/ directory, grouped by feature.
|
||||||
|
- Every public symbol must have comprehensive TSDoc:
|
||||||
|
- Include at least one @example block that compiles.
|
||||||
|
- Tag with one custom annotation (@beta, @internal, @experimental, etc.).
|
||||||
|
- Comment only ambiguous logic; avoid restating TypeScript in prose.
|
||||||
|
|
||||||
|
5.2 Performance
|
||||||
|
|
||||||
|
- Lazy‑load heavy dependencies inside async paths to keep the initial bundle lean:
|
||||||
|
|
||||||
|
`const { jsPDF } = await import("jspdf");`
|
||||||
|
|
||||||
|
⸻
|
||||||
|
|
||||||
|
6. apps/dashboard & apps/playground
|
||||||
|
|
||||||
|
6.1 Core UI Toolkit
|
||||||
|
|
||||||
|
- Import primitives from @/components/ui/\_ (e.g. Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator).
|
||||||
|
- Use NavLink for internal navigation so active states are handled automatically.
|
||||||
|
- Group feature‑specific components under feature/components/\_ and expose a barrel index.ts when necessary.
|
||||||
|
|
||||||
|
6.2 Styling Conventions
|
||||||
|
|
||||||
|
- Tailwind CSS is the styling system – no inline styles or CSS modules.
|
||||||
|
- Merge class names with cn() from @/lib/utils to keep conditional logic readable.
|
||||||
|
- Stick to design tokens: backgrounds (bg-card), borders (border-border), muted text (text-muted-foreground), etc.
|
||||||
|
- Expose a className prop on the root element of every component for overrides.
|
||||||
|
|
||||||
|
6.3 Component Patterns
|
||||||
|
|
||||||
|
- Server Components (run on the Node edge):
|
||||||
|
-- Read cookies/headers with next/headers.
|
||||||
|
-- Access server‑only environment variables or secrets.
|
||||||
|
-- Perform heavy data fetching that should not ship to the client.
|
||||||
|
-- Implement redirect logic with redirect() from next/navigation.
|
||||||
|
-- Start files with import "server-only"; to prevent client bundling.
|
||||||
|
- Client Components (run in the browser):
|
||||||
|
-- Begin files with 'use client'; before imports.
|
||||||
|
-- Handle interactive UI relying on React hooks (useState, useEffect, React Query, wallet hooks).
|
||||||
|
-- Access browser APIs (localStorage, window, IntersectionObserver, etc.).
|
||||||
|
-- Support fast transitions where data is prefetched on the client.
|
||||||
|
|
||||||
|
6.4 Data Fetching Guidelines
|
||||||
|
|
||||||
|
- Server Side
|
||||||
|
-- Always call getAuthToken() to retrieve the JWT from cookies.
|
||||||
|
-- Inject the token as an Authorization: Bearer header – never embed it in the URL.
|
||||||
|
-- Return typed results (Project[], User[], …) – avoid any.
|
||||||
|
- Client Side
|
||||||
|
-- Wrap calls in React Query (@tanstack/react-query).
|
||||||
|
-- Use descriptive, stable queryKeys for cache hits.
|
||||||
|
-- Configure staleTime / cacheTime based on freshness requirements (default ≥ 60 s).
|
||||||
|
-- Keep tokens secret by calling internal API routes or server actions.
|
||||||
|
|
||||||
|
⸻
|
||||||
|
|
||||||
|
7. Performance & Bundle Size
|
||||||
|
|
||||||
|
- Track bundle budgets via package.json#size-limit.
|
||||||
|
- Lazy‑import optional features; avoid top‑level side‑effects.
|
||||||
|
- De‑duplicate dependencies across packages through pnpm workspace hoisting.
|
||||||
|
|
||||||
|
⸻
|
||||||
|
|
||||||
|
8. Documentation & Developer Experience
|
||||||
|
|
||||||
|
- Each change in packages/\* should contain a changeset for the appropriate package, with the appropriate version bump
|
||||||
|
|
||||||
|
- patch for changes that don't impact the public API
|
||||||
|
- minor for any new/modified public API
|
||||||
|
|
||||||
|
- Surface breaking changes prominently in PR descriptions.
|
||||||
|
- For new UI components, add Storybook stories (\*.stories.tsx) alongside the code.
|
||||||
@@ -27,10 +27,7 @@ module.exports = [
|
|||||||
// -- engine
|
// -- engine
|
||||||
"/engine",
|
"/engine",
|
||||||
// -- solutions pages --
|
// -- solutions pages --
|
||||||
"/solutions/gaming",
|
"/solutions/:solution_slug",
|
||||||
"/solutions/consumer-apps",
|
|
||||||
"/solutions/defi",
|
|
||||||
"/solutions/ecosystem",
|
|
||||||
// -- campaigns --
|
// -- campaigns --
|
||||||
// "/unlimited-wallets", -- OFF for now
|
// "/unlimited-wallets", -- OFF for now
|
||||||
// -- TPP --
|
// -- TPP --
|
||||||
|
|||||||
+22
-22
@@ -40,8 +40,8 @@
|
|||||||
"@radix-ui/react-popover": "^1.1.10",
|
"@radix-ui/react-popover": "^1.1.10",
|
||||||
"@radix-ui/react-progress": "^1.1.4",
|
"@radix-ui/react-progress": "^1.1.4",
|
||||||
"@radix-ui/react-radio-group": "^1.3.3",
|
"@radix-ui/react-radio-group": "^1.3.3",
|
||||||
"@radix-ui/react-select": "^2.2.2",
|
"@radix-ui/react-select": "^2.2.5",
|
||||||
"@radix-ui/react-separator": "^1.1.4",
|
"@radix-ui/react-separator": "^1.1.7",
|
||||||
"@radix-ui/react-slot": "^1.2.0",
|
"@radix-ui/react-slot": "^1.2.0",
|
||||||
"@radix-ui/react-switch": "^1.2.2",
|
"@radix-ui/react-switch": "^1.2.2",
|
||||||
"@radix-ui/react-tooltip": "1.2.3",
|
"@radix-ui/react-tooltip": "1.2.3",
|
||||||
@@ -71,13 +71,13 @@
|
|||||||
"ioredis": "^5.6.1",
|
"ioredis": "^5.6.1",
|
||||||
"ipaddr.js": "^2.2.0",
|
"ipaddr.js": "^2.2.0",
|
||||||
"lucide-react": "0.503.0",
|
"lucide-react": "0.503.0",
|
||||||
"next": "15.3.1",
|
"next": "15.3.2",
|
||||||
"next-plausible": "^3.12.4",
|
"next-plausible": "^3.12.4",
|
||||||
"next-themes": "^0.4.6",
|
"next-themes": "^0.4.6",
|
||||||
"nextjs-toploader": "^1.6.12",
|
"nextjs-toploader": "^1.6.12",
|
||||||
"nuqs": "^2.4.3",
|
"nuqs": "^2.4.3",
|
||||||
"p-limit": "^6.2.0",
|
"p-limit": "^6.2.0",
|
||||||
"papaparse": "^5.5.2",
|
"papaparse": "^5.5.3",
|
||||||
"pluralize": "^8.0.0",
|
"pluralize": "^8.0.0",
|
||||||
"posthog-js": "1.67.1",
|
"posthog-js": "1.67.1",
|
||||||
"prettier": "3.5.3",
|
"prettier": "3.5.3",
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
"react-dropzone": "^14.3.8",
|
"react-dropzone": "^14.3.8",
|
||||||
"react-error-boundary": "^5.0.0",
|
"react-error-boundary": "^5.0.0",
|
||||||
"react-hook-form": "7.55.0",
|
"react-hook-form": "7.55.0",
|
||||||
"react-markdown": "^9.0.1",
|
"react-markdown": "10.1.0",
|
||||||
"react-table": "^7.8.0",
|
"react-table": "^7.8.0",
|
||||||
"recharts": "2.15.3",
|
"recharts": "2.15.3",
|
||||||
"remark-gfm": "4.0.1",
|
"remark-gfm": "4.0.1",
|
||||||
@@ -105,30 +105,30 @@
|
|||||||
"thirdweb": "workspace:*",
|
"thirdweb": "workspace:*",
|
||||||
"tiny-invariant": "^1.3.3",
|
"tiny-invariant": "^1.3.3",
|
||||||
"use-debounce": "^10.0.4",
|
"use-debounce": "^10.0.4",
|
||||||
"zod": "3.24.3"
|
"zod": "3.25.24"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@chakra-ui/cli": "^2.4.1",
|
"@chakra-ui/cli": "^2.4.1",
|
||||||
"@chromatic-com/storybook": "3.2.6",
|
"@chromatic-com/storybook": "3.2.6",
|
||||||
"@next/bundle-analyzer": "15.3.1",
|
"@next/bundle-analyzer": "15.3.2",
|
||||||
"@next/eslint-plugin-next": "15.3.1",
|
"@next/eslint-plugin-next": "15.3.2",
|
||||||
"@playwright/test": "1.52.0",
|
"@playwright/test": "1.52.0",
|
||||||
"@storybook/addon-essentials": "8.6.12",
|
"@storybook/addon-essentials": "8.6.14",
|
||||||
"@storybook/addon-interactions": "8.6.12",
|
"@storybook/addon-interactions": "8.6.14",
|
||||||
"@storybook/addon-links": "8.6.12",
|
"@storybook/addon-links": "8.6.14",
|
||||||
"@storybook/addon-onboarding": "8.6.12",
|
"@storybook/addon-onboarding": "8.6.14",
|
||||||
"@storybook/addon-viewport": "8.6.12",
|
"@storybook/addon-viewport": "8.6.14",
|
||||||
"@storybook/blocks": "8.6.12",
|
"@storybook/blocks": "8.6.14",
|
||||||
"@storybook/nextjs": "8.6.12",
|
"@storybook/nextjs": "8.6.14",
|
||||||
"@storybook/react": "8.6.12",
|
"@storybook/react": "8.6.14",
|
||||||
"@storybook/test": "8.6.12",
|
"@storybook/test": "8.6.14",
|
||||||
"@types/color": "4.2.0",
|
"@types/color": "4.2.0",
|
||||||
"@types/node": "22.14.1",
|
"@types/node": "22.14.1",
|
||||||
"@types/papaparse": "^5.3.15",
|
"@types/papaparse": "^5.3.16",
|
||||||
"@types/pluralize": "^0.0.33",
|
"@types/pluralize": "^0.0.33",
|
||||||
"@types/qrcode": "^1.5.5",
|
"@types/qrcode": "^1.5.5",
|
||||||
"@types/react": "19.1.2",
|
"@types/react": "19.1.4",
|
||||||
"@types/react-dom": "19.1.2",
|
"@types/react-dom": "19.1.5",
|
||||||
"@types/react-table": "^7.7.20",
|
"@types/react-table": "^7.7.20",
|
||||||
"@types/spdx-correct": "^3.1.3",
|
"@types/spdx-correct": "^3.1.3",
|
||||||
"@types/swagger-ui-react": "^5.18.0",
|
"@types/swagger-ui-react": "^5.18.0",
|
||||||
@@ -140,10 +140,10 @@
|
|||||||
"eslint-config-biome": "1.9.4",
|
"eslint-config-biome": "1.9.4",
|
||||||
"eslint-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
|
"eslint-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
|
||||||
"eslint-plugin-storybook": "0.12.0",
|
"eslint-plugin-storybook": "0.12.0",
|
||||||
"knip": "5.50.5",
|
"knip": "5.56.0",
|
||||||
"next-sitemap": "^4.2.3",
|
"next-sitemap": "^4.2.3",
|
||||||
"postcss": "8.5.3",
|
"postcss": "8.5.3",
|
||||||
"storybook": "8.6.12",
|
"storybook": "8.6.14",
|
||||||
"tailwindcss": "3.4.17",
|
"tailwindcss": "3.4.17",
|
||||||
"typescript": "5.8.3"
|
"typescript": "5.8.3"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import type { WalletNFT } from "lib/wallet/nfts/types";
|
|||||||
import { getVercelEnv } from "../../lib/vercel-utils";
|
import { getVercelEnv } from "../../lib/vercel-utils";
|
||||||
import { isAlchemySupported } from "../../lib/wallet/nfts/isAlchemySupported";
|
import { isAlchemySupported } from "../../lib/wallet/nfts/isAlchemySupported";
|
||||||
import { isMoralisSupported } from "../../lib/wallet/nfts/isMoralisSupported";
|
import { isMoralisSupported } from "../../lib/wallet/nfts/isMoralisSupported";
|
||||||
import { NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID } from "../constants/public-envs";
|
import { NEXT_PUBLIC_DASHBOARD_CLIENT_ID } from "../constants/public-envs";
|
||||||
import { MORALIS_API_KEY } from "../constants/server-envs";
|
import { MORALIS_API_KEY } from "../constants/server-envs";
|
||||||
|
|
||||||
type WalletNFTApiReturn =
|
type WalletNFTApiReturn =
|
||||||
@@ -149,7 +149,7 @@ async function getWalletNFTsFromInsight(params: {
|
|||||||
|
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
headers: {
|
headers: {
|
||||||
"x-client-id": NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
"x-client-id": NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { revalidatePath } from "next/cache";
|
||||||
|
|
||||||
|
export async function revalidatePathAction(
|
||||||
|
path: string,
|
||||||
|
type: "page" | "layout",
|
||||||
|
) {
|
||||||
|
revalidatePath(path, type);
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import "server-only";
|
|||||||
import type {
|
import type {
|
||||||
AnalyticsQueryParams,
|
AnalyticsQueryParams,
|
||||||
EcosystemWalletStats,
|
EcosystemWalletStats,
|
||||||
|
EngineCloudStats,
|
||||||
InAppWalletStats,
|
InAppWalletStats,
|
||||||
RpcMethodStats,
|
RpcMethodStats,
|
||||||
TransactionStats,
|
TransactionStats,
|
||||||
@@ -425,9 +426,30 @@ export async function getUniversalBridgeWalletUsage(args: {
|
|||||||
console.error(
|
console.error(
|
||||||
`Failed to fetch universal bridge wallet stats: ${res?.status} - ${res.statusText} - ${reason}`,
|
`Failed to fetch universal bridge wallet stats: ${res?.status} - ${res.statusText} - ${reason}`,
|
||||||
);
|
);
|
||||||
return null;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
return json.data as UniversalBridgeWalletStats[];
|
return json.data as UniversalBridgeWalletStats[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getEngineCloudMethodUsage(
|
||||||
|
params: AnalyticsQueryParams,
|
||||||
|
): Promise<EngineCloudStats[]> {
|
||||||
|
const searchParams = buildSearchParams(params);
|
||||||
|
const res = await fetchAnalytics(
|
||||||
|
`v2/engine-cloud/requests?${searchParams.toString()}`,
|
||||||
|
{
|
||||||
|
method: "GET",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (res?.status !== 200) {
|
||||||
|
console.error("Failed to fetch Engine Cloud method usage");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = await res.json();
|
||||||
|
return json.data as EngineCloudStats[];
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,239 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
"use server";
|
||||||
|
|
||||||
|
import { getAuthToken } from "app/(app)/api/lib/getAuthToken";
|
||||||
|
import { THIRDWEB_INSIGHT_API_DOMAIN } from "constants/urls";
|
||||||
|
|
||||||
|
export interface WebhookResponse {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
team_id: string;
|
||||||
|
project_id: string;
|
||||||
|
webhook_url: string;
|
||||||
|
webhook_secret: string;
|
||||||
|
filters: WebhookFilters;
|
||||||
|
suspended_at: string | null;
|
||||||
|
suspended_reason: string | null;
|
||||||
|
disabled: boolean;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WebhookFilters {
|
||||||
|
"v1.events"?: {
|
||||||
|
chain_ids?: string[];
|
||||||
|
addresses?: string[];
|
||||||
|
signatures?: Array<{
|
||||||
|
sig_hash: string;
|
||||||
|
abi?: string;
|
||||||
|
params?: Record<string, unknown>;
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
"v1.transactions"?: {
|
||||||
|
chain_ids?: string[];
|
||||||
|
from_addresses?: string[];
|
||||||
|
to_addresses?: string[];
|
||||||
|
signatures?: Array<{
|
||||||
|
sig_hash: string;
|
||||||
|
abi?: string;
|
||||||
|
params?: Record<string, unknown>;
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CreateWebhookPayload {
|
||||||
|
name: string;
|
||||||
|
webhook_url: string;
|
||||||
|
filters: WebhookFilters;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface WebhooksListResponse {
|
||||||
|
data: WebhookResponse[];
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface WebhookSingleResponse {
|
||||||
|
data: WebhookResponse | null;
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestWebhookPayload {
|
||||||
|
webhook_url: string;
|
||||||
|
type?: "event" | "transaction";
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestWebhookResponse {
|
||||||
|
success: boolean;
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type SupportedWebhookChainsResponse =
|
||||||
|
| { chains: Array<number> }
|
||||||
|
| { error: string };
|
||||||
|
|
||||||
|
export async function createWebhook(
|
||||||
|
payload: CreateWebhookPayload,
|
||||||
|
clientId: string,
|
||||||
|
): Promise<WebhookSingleResponse> {
|
||||||
|
try {
|
||||||
|
const authToken = await getAuthToken();
|
||||||
|
const response = await fetch(
|
||||||
|
`https://${THIRDWEB_INSIGHT_API_DOMAIN}/v1/webhooks`,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"x-client-id": clientId,
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorText = await response.text();
|
||||||
|
return {
|
||||||
|
data: null,
|
||||||
|
error: `Failed to create webhook: ${errorText}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return (await response.json()) as WebhookSingleResponse;
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
data: null,
|
||||||
|
error: `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getWebhooks(
|
||||||
|
clientId: string,
|
||||||
|
): Promise<WebhooksListResponse> {
|
||||||
|
try {
|
||||||
|
const authToken = await getAuthToken();
|
||||||
|
const response = await fetch(
|
||||||
|
`https://${THIRDWEB_INSIGHT_API_DOMAIN}/v1/webhooks`,
|
||||||
|
{
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"x-client-id": clientId,
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorText = await response.text();
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
error: `Failed to get webhooks: ${errorText}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return (await response.json()) as WebhooksListResponse;
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
error: `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteWebhook(
|
||||||
|
webhookId: string,
|
||||||
|
clientId: string,
|
||||||
|
): Promise<WebhookSingleResponse> {
|
||||||
|
try {
|
||||||
|
const authToken = await getAuthToken();
|
||||||
|
const response = await fetch(
|
||||||
|
`https://${THIRDWEB_INSIGHT_API_DOMAIN}/v1/webhooks/${encodeURIComponent(webhookId)}`,
|
||||||
|
{
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
"x-client-id": clientId,
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorText = await response.text();
|
||||||
|
return {
|
||||||
|
data: null,
|
||||||
|
error: `Failed to delete webhook: ${errorText}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return (await response.json()) as WebhookSingleResponse;
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
data: null,
|
||||||
|
error: `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function testWebhook(
|
||||||
|
payload: TestWebhookPayload,
|
||||||
|
clientId: string,
|
||||||
|
): Promise<TestWebhookResponse> {
|
||||||
|
try {
|
||||||
|
const authToken = await getAuthToken();
|
||||||
|
const response = await fetch(
|
||||||
|
`https://${THIRDWEB_INSIGHT_API_DOMAIN}/v1/webhooks/test`,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"x-client-id": clientId,
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorText = await response.text();
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: `Failed to test webhook: ${errorText}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return (await response.json()) as TestWebhookResponse;
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getSupportedWebhookChains(): Promise<SupportedWebhookChainsResponse> {
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`https://${THIRDWEB_INSIGHT_API_DOMAIN}/service/chains`,
|
||||||
|
{
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"x-service-api-key": process.env.INSIGHT_SERVICE_API_KEY || "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorText = await response.json();
|
||||||
|
return { error: `Failed to fetch supported chains: ${errorText.error}` };
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
if (Array.isArray(data.data)) {
|
||||||
|
return { chains: data.data };
|
||||||
|
}
|
||||||
|
return { error: "Unexpected response format" };
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching supported chains:", error);
|
||||||
|
return { error: `Failed to fetch supported chains: ${error}` };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,7 +84,7 @@ export async function getDefaultTeam() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getLastVisitedTeamOrDefaultTeam() {
|
export async function getLastVisitedTeam() {
|
||||||
const token = await getAuthToken();
|
const token = await getAuthToken();
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return null;
|
return null;
|
||||||
@@ -100,5 +100,5 @@ export async function getLastVisitedTeamOrDefaultTeam() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getDefaultTeam();
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import "server-only";
|
||||||
|
|
||||||
|
import { DASHBOARD_THIRDWEB_SECRET_KEY } from "@/constants/server-envs";
|
||||||
|
import { UB_BASE_URL } from "./constants";
|
||||||
|
|
||||||
|
type PaymentLink = {
|
||||||
|
clientId: string;
|
||||||
|
title?: string;
|
||||||
|
imageUrl?: string;
|
||||||
|
receiver: string;
|
||||||
|
destinationToken: {
|
||||||
|
address: string;
|
||||||
|
symbol: string;
|
||||||
|
decimals: number;
|
||||||
|
chainId: number;
|
||||||
|
};
|
||||||
|
amount: bigint | undefined;
|
||||||
|
purchaseData: Record<string, unknown> | undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function getPaymentLink(props: {
|
||||||
|
paymentId: string;
|
||||||
|
}) {
|
||||||
|
const res = await fetch(`${UB_BASE_URL}/v1/links/${props.paymentId}`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"x-secret-key": DASHBOARD_THIRDWEB_SECRET_KEY,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
const text = await res.text();
|
||||||
|
throw new Error(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await res.json();
|
||||||
|
return {
|
||||||
|
clientId: data.clientId,
|
||||||
|
title: data.title,
|
||||||
|
imageUrl: data.imageUrl,
|
||||||
|
receiver: data.receiver,
|
||||||
|
destinationToken: data.destinationToken,
|
||||||
|
amount: data.amount ? BigInt(data.amount) : undefined,
|
||||||
|
purchaseData: data.purchaseData,
|
||||||
|
} as PaymentLink;
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
"use server";
|
"use server";
|
||||||
import { DASHBOARD_THIRDWEB_SECRET_KEY } from "@/constants/server-envs";
|
import { DASHBOARD_THIRDWEB_SECRET_KEY } from "@/constants/server-envs";
|
||||||
|
import type { ProjectResponse } from "@thirdweb-dev/service-utils";
|
||||||
|
import { getAuthToken } from "app/(app)/api/lib/getAuthToken";
|
||||||
import { UB_BASE_URL } from "./constants";
|
import { UB_BASE_URL } from "./constants";
|
||||||
|
|
||||||
export type TokenMetadata = {
|
export type TokenMetadata = {
|
||||||
@@ -37,3 +39,33 @@ export async function getUniversalBridgeTokens(props: {
|
|||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
return json.data as Array<TokenMetadata>;
|
return json.data as Array<TokenMetadata>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function addUniversalBridgeTokenRoute(props: {
|
||||||
|
chainId: number;
|
||||||
|
tokenAddress: string;
|
||||||
|
project: ProjectResponse;
|
||||||
|
}) {
|
||||||
|
const authToken = await getAuthToken();
|
||||||
|
const url = new URL(`${UB_BASE_URL}/v1/tokens`);
|
||||||
|
|
||||||
|
const res = await fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
"x-client-id": props.project.publishableKey,
|
||||||
|
} as Record<string, string>,
|
||||||
|
body: JSON.stringify({
|
||||||
|
chainId: props.chainId,
|
||||||
|
tokenAddress: props.tokenAddress,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
const text = await res.text();
|
||||||
|
throw new Error(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = await res.json();
|
||||||
|
return json.data as Array<TokenMetadata>;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
import { MultiSelect } from "@/components/blocks/multi-select";
|
import { MultiSelect } from "@/components/blocks/multi-select";
|
||||||
import { SelectWithSearch } from "@/components/blocks/select-with-search";
|
import { SelectWithSearch } from "@/components/blocks/select-with-search";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { ChainIconClient } from "components/icons/ChainIcon";
|
||||||
|
import { useAllChainsData } from "hooks/chains/allChains";
|
||||||
import { useCallback, useMemo } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
import type { ThirdwebClient } from "thirdweb";
|
import type { ThirdwebClient } from "thirdweb";
|
||||||
import { ChainIconClient } from "../../../components/icons/ChainIcon";
|
|
||||||
import { useAllChainsData } from "../../../hooks/chains/allChains";
|
|
||||||
|
|
||||||
function cleanChainName(chainName: string) {
|
function cleanChainName(chainName: string) {
|
||||||
return chainName.replace("Mainnet", "");
|
return chainName.replace("Mainnet", "");
|
||||||
@@ -27,8 +27,15 @@ export function MultiNetworkSelector(props: {
|
|||||||
side?: "left" | "right" | "top" | "bottom";
|
side?: "left" | "right" | "top" | "bottom";
|
||||||
showSelectedValuesInModal?: boolean;
|
showSelectedValuesInModal?: boolean;
|
||||||
client: ThirdwebClient;
|
client: ThirdwebClient;
|
||||||
|
chainIds?: number[];
|
||||||
}) {
|
}) {
|
||||||
const { allChains, idToChain } = useAllChainsData();
|
let { allChains, idToChain } = useAllChainsData();
|
||||||
|
|
||||||
|
if (props.chainIds && props.chainIds.length > 0) {
|
||||||
|
allChains = allChains.filter((chain) =>
|
||||||
|
props.chainIds?.includes(chain.chainId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
let sortedChains = allChains;
|
let sortedChains = allChains;
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import { Spinner } from "@/components/ui/Spinner/Spinner";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import type React from "react";
|
||||||
|
|
||||||
|
export function RouteDiscoveryCard(
|
||||||
|
props: React.PropsWithChildren<{
|
||||||
|
bottomText: React.ReactNode;
|
||||||
|
header?: {
|
||||||
|
description: string | undefined;
|
||||||
|
title: string;
|
||||||
|
};
|
||||||
|
errorText: string | undefined;
|
||||||
|
noPermissionText: string | undefined;
|
||||||
|
saveButton?: {
|
||||||
|
onClick?: () => void;
|
||||||
|
disabled: boolean;
|
||||||
|
isPending: boolean;
|
||||||
|
type?: "submit";
|
||||||
|
variant?:
|
||||||
|
| "ghost"
|
||||||
|
| "default"
|
||||||
|
| "primary"
|
||||||
|
| "destructive"
|
||||||
|
| "outline"
|
||||||
|
| "secondary";
|
||||||
|
className?: string;
|
||||||
|
label?: string;
|
||||||
|
};
|
||||||
|
}>,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<div className="relative rounded-lg border border-border bg-card">
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"relative border-border border-b px-4 py-6 lg:px-6",
|
||||||
|
props.noPermissionText && "cursor-not-allowed",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{props.header && (
|
||||||
|
<>
|
||||||
|
<h3 className="font-semibold text-xl tracking-tight">
|
||||||
|
{props.header.title}
|
||||||
|
</h3>
|
||||||
|
{props.header.description && (
|
||||||
|
<p className="mt-1.5 mb-4 text-foreground text-sm">
|
||||||
|
{props.header.description}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex min-h-[60px] items-center justify-between gap-2 px-4 py-3 lg:px-6">
|
||||||
|
{props.noPermissionText ? (
|
||||||
|
<p className="text-muted-foreground text-sm">
|
||||||
|
{props.noPermissionText}
|
||||||
|
</p>
|
||||||
|
) : props.errorText ? (
|
||||||
|
<p className="text-destructive-text text-sm">{props.errorText}</p>
|
||||||
|
) : (
|
||||||
|
<p className="text-muted-foreground text-sm">{props.bottomText}</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{props.saveButton && !props.noPermissionText && (
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
className={cn("gap-2", props.saveButton.className)}
|
||||||
|
onClick={props.saveButton.onClick}
|
||||||
|
disabled={props.saveButton.disabled || props.saveButton.isPending}
|
||||||
|
variant={props.saveButton.variant || "outline"}
|
||||||
|
type={props.saveButton.type}
|
||||||
|
>
|
||||||
|
{props.saveButton.isPending && <Spinner className="size-3" />}
|
||||||
|
{props.saveButton.label ||
|
||||||
|
(props.saveButton.isPending ? "Submit" : "Submit Token")}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -35,14 +35,28 @@ function Variant(props: {
|
|||||||
label: string;
|
label: string;
|
||||||
selectedChainId?: number;
|
selectedChainId?: number;
|
||||||
}) {
|
}) {
|
||||||
const [tokenAddress, setTokenAddress] = useState<string>("");
|
const [token, setToken] = useState<
|
||||||
|
| {
|
||||||
|
address: string;
|
||||||
|
chainId: number;
|
||||||
|
}
|
||||||
|
| undefined
|
||||||
|
>(undefined);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BadgeContainer label={props.label}>
|
<BadgeContainer label={props.label}>
|
||||||
<TokenSelector
|
<TokenSelector
|
||||||
tokenAddress={tokenAddress}
|
addNativeTokenIfMissing={false}
|
||||||
|
showCheck={false}
|
||||||
|
selectedToken={token}
|
||||||
chainId={props.selectedChainId}
|
chainId={props.selectedChainId}
|
||||||
client={storybookThirdwebClient}
|
client={storybookThirdwebClient}
|
||||||
onChange={setTokenAddress}
|
onChange={(v) => {
|
||||||
|
setToken({
|
||||||
|
address: v.address,
|
||||||
|
chainId: v.chainId,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</BadgeContainer>
|
</BadgeContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
|
import { useAllChainsData } from "hooks/chains/allChains";
|
||||||
|
import { useTokensData } from "hooks/tokens/tokens";
|
||||||
import { useCallback, useMemo } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
import type { ThirdwebClient } from "thirdweb";
|
import {
|
||||||
|
NATIVE_TOKEN_ADDRESS,
|
||||||
|
type ThirdwebClient,
|
||||||
|
getAddress,
|
||||||
|
} from "thirdweb";
|
||||||
import { shortenAddress } from "thirdweb/utils";
|
import { shortenAddress } from "thirdweb/utils";
|
||||||
import { useTokensData } from "../../../hooks/tokens/tokens";
|
|
||||||
import { replaceIpfsUrl } from "../../../lib/sdk";
|
import { replaceIpfsUrl } from "../../../lib/sdk";
|
||||||
import { fallbackChainIcon } from "../../../utils/chain-icons";
|
import { fallbackChainIcon } from "../../../utils/chain-icons";
|
||||||
|
import type { TokenMetadata } from "../../api/universal-bridge/tokens";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
import { Badge } from "../ui/badge";
|
import { Badge } from "../ui/badge";
|
||||||
import { Img } from "./Img";
|
import { Img } from "./Img";
|
||||||
@@ -11,37 +17,87 @@ import { SelectWithSearch } from "./select-with-search";
|
|||||||
|
|
||||||
type Option = { label: string; value: string };
|
type Option = { label: string; value: string };
|
||||||
|
|
||||||
|
const checksummedNativeTokenAddress = getAddress(NATIVE_TOKEN_ADDRESS);
|
||||||
|
|
||||||
export function TokenSelector(props: {
|
export function TokenSelector(props: {
|
||||||
tokenAddress: string | undefined;
|
selectedToken: { chainId: number; address: string } | undefined;
|
||||||
onChange: (tokenAddress: string) => void;
|
onChange: (token: TokenMetadata) => void;
|
||||||
className?: string;
|
className?: string;
|
||||||
popoverContentClassName?: string;
|
popoverContentClassName?: string;
|
||||||
chainId?: number;
|
chainId?: number;
|
||||||
side?: "left" | "right" | "top" | "bottom";
|
side?: "left" | "right" | "top" | "bottom";
|
||||||
disableChainId?: boolean;
|
disableAddress?: boolean;
|
||||||
align?: "center" | "start" | "end";
|
align?: "center" | "start" | "end";
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
client: ThirdwebClient;
|
client: ThirdwebClient;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
|
showCheck: boolean;
|
||||||
|
addNativeTokenIfMissing: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { tokens, isFetching } = useTokensData({
|
const tokensQuery = useTokensData({
|
||||||
chainId: props.chainId,
|
chainId: props.chainId,
|
||||||
enabled: props.enabled,
|
enabled: props.enabled,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { idToChain } = useAllChainsData();
|
||||||
|
|
||||||
|
const tokens = useMemo(() => {
|
||||||
|
if (!tokensQuery.data) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.addNativeTokenIfMissing) {
|
||||||
|
const hasNativeToken = tokensQuery.data.some(
|
||||||
|
(token) => token.address === checksummedNativeTokenAddress,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!hasNativeToken && props.chainId) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name:
|
||||||
|
idToChain.get(props.chainId)?.nativeCurrency.name ??
|
||||||
|
"Native Token",
|
||||||
|
symbol:
|
||||||
|
idToChain.get(props.chainId)?.nativeCurrency.symbol ?? "ETH",
|
||||||
|
decimals: 18,
|
||||||
|
chainId: props.chainId,
|
||||||
|
address: checksummedNativeTokenAddress,
|
||||||
|
} satisfies TokenMetadata,
|
||||||
|
...tokensQuery.data,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tokensQuery.data;
|
||||||
|
}, [
|
||||||
|
tokensQuery.data,
|
||||||
|
props.chainId,
|
||||||
|
props.addNativeTokenIfMissing,
|
||||||
|
idToChain,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const addressChainToToken = useMemo(() => {
|
||||||
|
const value = new Map<string, TokenMetadata>();
|
||||||
|
for (const token of tokens) {
|
||||||
|
value.set(`${token.chainId}:${token.address}`, token);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}, [tokens]);
|
||||||
|
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
return tokens.allTokens.map((token) => {
|
return (
|
||||||
return {
|
tokens.map((token) => {
|
||||||
label: token.symbol,
|
return {
|
||||||
value: `${token.chainId}:${token.address}`,
|
label: token.symbol,
|
||||||
};
|
value: `${token.chainId}:${token.address}`,
|
||||||
});
|
};
|
||||||
}, [tokens.allTokens]);
|
}) || []
|
||||||
|
);
|
||||||
|
}, [tokens]);
|
||||||
|
|
||||||
const searchFn = useCallback(
|
const searchFn = useCallback(
|
||||||
(option: Option, searchValue: string) => {
|
(option: Option, searchValue: string) => {
|
||||||
const token = tokens.addressChainToToken.get(option.value);
|
const token = addressChainToToken.get(option.value);
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -55,12 +111,12 @@ export function TokenSelector(props: {
|
|||||||
token.address.toLowerCase().includes(searchValue.toLowerCase())
|
token.address.toLowerCase().includes(searchValue.toLowerCase())
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[tokens],
|
[addressChainToToken],
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderOption = useCallback(
|
const renderOption = useCallback(
|
||||||
(option: Option) => {
|
(option: Option) => {
|
||||||
const token = tokens.addressChainToToken.get(option.value);
|
const token = addressChainToToken.get(option.value);
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return option.label;
|
return option.label;
|
||||||
}
|
}
|
||||||
@@ -87,8 +143,8 @@ export function TokenSelector(props: {
|
|||||||
{token.symbol}
|
{token.symbol}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{!props.disableChainId && (
|
{!props.disableAddress && (
|
||||||
<Badge variant="outline" className="gap-2 max-sm:hidden">
|
<Badge variant="outline" className="gap-2 py-1 max-sm:hidden">
|
||||||
<span className="text-muted-foreground">Address</span>
|
<span className="text-muted-foreground">Address</span>
|
||||||
{shortenAddress(token.address, 4)}
|
{shortenAddress(token.address, 4)}
|
||||||
</Badge>
|
</Badge>
|
||||||
@@ -96,27 +152,37 @@ export function TokenSelector(props: {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[tokens, props.disableChainId, props.client],
|
[addressChainToToken, props.disableAddress, props.client],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const selectedValue = props.selectedToken
|
||||||
|
? `${props.selectedToken.chainId}:${props.selectedToken.address}`
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SelectWithSearch
|
<SelectWithSearch
|
||||||
searchPlaceholder="Search by name or symbol"
|
searchPlaceholder="Search by name or symbol"
|
||||||
value={props.tokenAddress}
|
value={selectedValue}
|
||||||
options={options}
|
options={options}
|
||||||
onValueChange={(tokenAddress) => {
|
onValueChange={(tokenAddress) => {
|
||||||
props.onChange(tokenAddress);
|
const token = addressChainToToken.get(tokenAddress);
|
||||||
|
if (!token) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
props.onChange(token);
|
||||||
}}
|
}}
|
||||||
closeOnSelect={true}
|
closeOnSelect={true}
|
||||||
showCheck={false}
|
showCheck={props.showCheck}
|
||||||
placeholder={
|
placeholder={
|
||||||
isFetching ? "Loading Tokens..." : props.placeholder || "Select Token"
|
tokensQuery.isPending
|
||||||
|
? "Loading Tokens..."
|
||||||
|
: props.placeholder || "Select Token"
|
||||||
}
|
}
|
||||||
overrideSearchFn={searchFn}
|
overrideSearchFn={searchFn}
|
||||||
renderOption={renderOption}
|
renderOption={renderOption}
|
||||||
className={props.className}
|
className={props.className}
|
||||||
popoverContentClassName={props.popoverContentClassName}
|
popoverContentClassName={props.popoverContentClassName}
|
||||||
disabled={isFetching || props.disabled}
|
disabled={tokensQuery.isPending || props.disabled}
|
||||||
side={props.side}
|
side={props.side}
|
||||||
align={props.align}
|
align={props.align}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import type { Meta, StoryObj } from "@storybook/react";
|
||||||
|
import { ArrowRightIcon, RocketIcon, StarIcon } from "lucide-react";
|
||||||
|
import { BadgeContainer } from "../../../stories/utils";
|
||||||
|
import { UpsellBannerCard } from "./UpsellBannerCard";
|
||||||
|
|
||||||
|
function Story() {
|
||||||
|
return (
|
||||||
|
<div className="container flex max-w-4xl flex-col gap-8 py-10">
|
||||||
|
<BadgeContainer label="Green with icon (default)">
|
||||||
|
<UpsellBannerCard
|
||||||
|
title="Unlock more with thirdweb"
|
||||||
|
description="Upgrade to increase limits and access advanced features."
|
||||||
|
cta={{
|
||||||
|
text: "View plans",
|
||||||
|
icon: <ArrowRightIcon className="size-4" />,
|
||||||
|
link: "#",
|
||||||
|
}}
|
||||||
|
trackingCategory="storybook"
|
||||||
|
trackingLabel="green"
|
||||||
|
icon={<RocketIcon className="size-5" />}
|
||||||
|
accentColor="green"
|
||||||
|
/>
|
||||||
|
</BadgeContainer>
|
||||||
|
|
||||||
|
<BadgeContainer label="Blue accent">
|
||||||
|
<UpsellBannerCard
|
||||||
|
title="Need more storage?"
|
||||||
|
description="Add additional space to your account."
|
||||||
|
cta={{
|
||||||
|
text: "Upgrade storage",
|
||||||
|
icon: <ArrowRightIcon className="size-4" />,
|
||||||
|
link: "#",
|
||||||
|
}}
|
||||||
|
trackingCategory="storybook"
|
||||||
|
trackingLabel="blue"
|
||||||
|
icon={<StarIcon className="size-5" />}
|
||||||
|
accentColor="blue"
|
||||||
|
/>
|
||||||
|
</BadgeContainer>
|
||||||
|
|
||||||
|
<BadgeContainer label="Purple without leading icon">
|
||||||
|
<UpsellBannerCard
|
||||||
|
title="Join the beta"
|
||||||
|
description="Get early access to experimental features."
|
||||||
|
cta={{
|
||||||
|
text: "Request access",
|
||||||
|
icon: <ArrowRightIcon className="size-4" />,
|
||||||
|
link: "#",
|
||||||
|
}}
|
||||||
|
trackingCategory="storybook"
|
||||||
|
trackingLabel="purple"
|
||||||
|
accentColor="purple"
|
||||||
|
/>
|
||||||
|
</BadgeContainer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
title: "blocks/Banners/UpsellBannerCard",
|
||||||
|
component: Story,
|
||||||
|
parameters: {
|
||||||
|
nextjs: {
|
||||||
|
appDirectory: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} satisfies Meta<typeof Story>;
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof meta>;
|
||||||
|
|
||||||
|
export const Variants: Story = {
|
||||||
|
args: {},
|
||||||
|
};
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { TrackedLinkTW } from "@/components/ui/tracked-link";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import type React from "react";
|
||||||
|
|
||||||
|
const ACCENT = {
|
||||||
|
green: {
|
||||||
|
border: "border-green-600 dark:border-green-700",
|
||||||
|
bgFrom: "from-green-50 dark:from-green-900/20",
|
||||||
|
blur: "bg-green-600",
|
||||||
|
title: "text-green-900 dark:text-green-200",
|
||||||
|
desc: "text-green-800 dark:text-green-300",
|
||||||
|
iconBg: "bg-green-600 text-white",
|
||||||
|
btn: "bg-green-600 text-white hover:bg-green-700",
|
||||||
|
},
|
||||||
|
blue: {
|
||||||
|
border: "border-blue-600 dark:border-blue-700",
|
||||||
|
bgFrom: "from-blue-50 dark:from-blue-900/20",
|
||||||
|
blur: "bg-blue-600",
|
||||||
|
title: "text-blue-900 dark:text-blue-200",
|
||||||
|
desc: "text-blue-800 dark:text-blue-300",
|
||||||
|
iconBg: "bg-blue-600 text-white",
|
||||||
|
btn: "bg-blue-600 text-white hover:bg-blue-700",
|
||||||
|
},
|
||||||
|
purple: {
|
||||||
|
border: "border-purple-600 dark:border-purple-700",
|
||||||
|
bgFrom: "from-purple-50 dark:from-purple-900/20",
|
||||||
|
blur: "bg-purple-600",
|
||||||
|
title: "text-purple-900 dark:text-purple-200",
|
||||||
|
desc: "text-purple-800 dark:text-purple-300",
|
||||||
|
iconBg: "bg-purple-600 text-white",
|
||||||
|
btn: "bg-purple-600 text-white hover:bg-purple-700",
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
type UpsellBannerCardProps = {
|
||||||
|
title: React.ReactNode;
|
||||||
|
description: React.ReactNode;
|
||||||
|
cta: {
|
||||||
|
text: React.ReactNode;
|
||||||
|
icon?: React.ReactNode;
|
||||||
|
target?: "_blank";
|
||||||
|
link: string;
|
||||||
|
};
|
||||||
|
trackingCategory: string;
|
||||||
|
trackingLabel: string;
|
||||||
|
accentColor?: keyof typeof ACCENT;
|
||||||
|
icon?: React.ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function UpsellBannerCard(props: UpsellBannerCardProps) {
|
||||||
|
const color = ACCENT[props.accentColor || "green"];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"relative overflow-hidden rounded-lg border bg-gradient-to-r p-4 lg:p-6",
|
||||||
|
color.border,
|
||||||
|
color.bgFrom,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{/* Decorative blur */}
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"-right-10 -top-10 pointer-events-none absolute size-28 rounded-full opacity-20 blur-2xl",
|
||||||
|
color.blur,
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="relative flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||||
|
<div className="flex items-start gap-3">
|
||||||
|
{props.icon ? (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"mt-0.5 hidden h-9 w-9 shrink-0 items-center justify-center rounded-full lg:flex",
|
||||||
|
color.iconBg,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{props.icon}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3
|
||||||
|
className={cn(
|
||||||
|
"font-semibold text-lg tracking-tight",
|
||||||
|
color.title,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{props.title}
|
||||||
|
</h3>
|
||||||
|
<p className={cn("text-sm", color.desc)}>{props.description}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
asChild
|
||||||
|
size="sm"
|
||||||
|
className={cn(
|
||||||
|
"mt-2 gap-2 hover:translate-y-0 hover:shadow-inner sm:mt-0",
|
||||||
|
color.btn,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<TrackedLinkTW
|
||||||
|
href={props.cta.link}
|
||||||
|
category={props.trackingCategory}
|
||||||
|
label={props.trackingLabel}
|
||||||
|
target={props.cta.target}
|
||||||
|
>
|
||||||
|
{props.cta.text}
|
||||||
|
{props.cta.icon && <span className="ml-2">{props.cta.icon}</span>}
|
||||||
|
</TrackedLinkTW>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -15,14 +15,14 @@ import {
|
|||||||
ChartTooltip,
|
ChartTooltip,
|
||||||
ChartTooltipContent,
|
ChartTooltipContent,
|
||||||
} from "@/components/ui/chart";
|
} from "@/components/ui/chart";
|
||||||
import { formatDate } from "date-fns";
|
import { cn } from "@/lib/utils";
|
||||||
import { useMemo } from "react";
|
|
||||||
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts";
|
|
||||||
import {
|
import {
|
||||||
EmptyChartState,
|
EmptyChartState,
|
||||||
LoadingChartState,
|
LoadingChartState,
|
||||||
} from "../../../../components/analytics/empty-chart-state";
|
} from "components/analytics/empty-chart-state";
|
||||||
import { cn } from "../../../lib/utils";
|
import { formatDate } from "date-fns";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts";
|
||||||
|
|
||||||
type ThirdwebAreaChartProps<TConfig extends ChartConfig> = {
|
type ThirdwebAreaChartProps<TConfig extends ChartConfig> = {
|
||||||
header?: {
|
header?: {
|
||||||
@@ -46,8 +46,12 @@ type ThirdwebAreaChartProps<TConfig extends ChartConfig> = {
|
|||||||
// chart className
|
// chart className
|
||||||
chartClassName?: string;
|
chartClassName?: string;
|
||||||
isPending: boolean;
|
isPending: boolean;
|
||||||
|
className?: string;
|
||||||
|
cardContentClassName?: string;
|
||||||
hideLabel?: boolean;
|
hideLabel?: boolean;
|
||||||
toolTipLabelFormatter?: (label: string, payload: unknown) => React.ReactNode;
|
toolTipLabelFormatter?: (label: string, payload: unknown) => React.ReactNode;
|
||||||
|
toolTipValueFormatter?: (value: unknown) => React.ReactNode;
|
||||||
|
emptyChartState?: React.ReactElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ThirdwebAreaChart<TConfig extends ChartConfig>(
|
export function ThirdwebAreaChart<TConfig extends ChartConfig>(
|
||||||
@@ -56,7 +60,7 @@ export function ThirdwebAreaChart<TConfig extends ChartConfig>(
|
|||||||
const configKeys = useMemo(() => Object.keys(props.config), [props.config]);
|
const configKeys = useMemo(() => Object.keys(props.config), [props.config]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card className={props.className}>
|
||||||
{props.header && (
|
{props.header && (
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className={cn("mb-2", props.header.titleClassName)}>
|
<CardTitle className={cn("mb-2", props.header.titleClassName)}>
|
||||||
@@ -70,12 +74,16 @@ export function ThirdwebAreaChart<TConfig extends ChartConfig>(
|
|||||||
|
|
||||||
{props.customHeader && props.customHeader}
|
{props.customHeader && props.customHeader}
|
||||||
|
|
||||||
<CardContent className={cn(!props.header && "pt-6")}>
|
<CardContent
|
||||||
|
className={cn(!props.header && "pt-6", props.cardContentClassName)}
|
||||||
|
>
|
||||||
<ChartContainer config={props.config} className={props.chartClassName}>
|
<ChartContainer config={props.config} className={props.chartClassName}>
|
||||||
{props.isPending ? (
|
{props.isPending ? (
|
||||||
<LoadingChartState />
|
<LoadingChartState />
|
||||||
) : props.data.length === 0 ? (
|
) : props.data.length === 0 ? (
|
||||||
<EmptyChartState />
|
<EmptyChartState type="area">
|
||||||
|
{props.emptyChartState}
|
||||||
|
</EmptyChartState>
|
||||||
) : (
|
) : (
|
||||||
<AreaChart accessibilityLayer data={props.data}>
|
<AreaChart accessibilityLayer data={props.data}>
|
||||||
<CartesianGrid vertical={false} />
|
<CartesianGrid vertical={false} />
|
||||||
@@ -100,6 +108,7 @@ export function ThirdwebAreaChart<TConfig extends ChartConfig>(
|
|||||||
props.hideLabel !== undefined ? props.hideLabel : true
|
props.hideLabel !== undefined ? props.hideLabel : true
|
||||||
}
|
}
|
||||||
labelFormatter={props.toolTipLabelFormatter}
|
labelFormatter={props.toolTipLabelFormatter}
|
||||||
|
valueFormatter={props.toolTipValueFormatter}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ import {
|
|||||||
ChartTooltip,
|
ChartTooltip,
|
||||||
ChartTooltipContent,
|
ChartTooltipContent,
|
||||||
} from "@/components/ui/chart";
|
} from "@/components/ui/chart";
|
||||||
import { formatDate } from "date-fns";
|
import { cn } from "@/lib/utils";
|
||||||
import { useMemo } from "react";
|
|
||||||
import {
|
import {
|
||||||
EmptyChartState,
|
EmptyChartState,
|
||||||
LoadingChartState,
|
LoadingChartState,
|
||||||
} from "../../../../components/analytics/empty-chart-state";
|
} from "components/analytics/empty-chart-state";
|
||||||
import { cn } from "../../../lib/utils";
|
import { formatDate } from "date-fns";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
|
||||||
type ThirdwebBarChartProps<TConfig extends ChartConfig> = {
|
type ThirdwebBarChartProps<TConfig extends ChartConfig> = {
|
||||||
// metadata
|
// metadata
|
||||||
@@ -75,7 +75,9 @@ export function ThirdwebBarChart<TConfig extends ChartConfig>(
|
|||||||
{props.isPending ? (
|
{props.isPending ? (
|
||||||
<LoadingChartState />
|
<LoadingChartState />
|
||||||
) : props.data.length === 0 ? (
|
) : props.data.length === 0 ? (
|
||||||
<EmptyChartState>{props.emptyChartState}</EmptyChartState>
|
<EmptyChartState type="bar">
|
||||||
|
{props.emptyChartState}
|
||||||
|
</EmptyChartState>
|
||||||
) : (
|
) : (
|
||||||
<BarChart accessibilityLayer data={props.data}>
|
<BarChart accessibilityLayer data={props.data}>
|
||||||
<CartesianGrid vertical={false} />
|
<CartesianGrid vertical={false} />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useLocalStorage } from "hooks/useLocalStorage";
|
||||||
import { XIcon } from "lucide-react";
|
import { XIcon } from "lucide-react";
|
||||||
import { useLocalStorage } from "../../../hooks/useLocalStorage";
|
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
|
||||||
export function DismissibleAlert(props: {
|
export function DismissibleAlert(props: {
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
export type Segment = {
|
||||||
|
label: string;
|
||||||
|
percent: number;
|
||||||
|
color: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type DistributionBarChartProps = {
|
||||||
|
segments: Segment[];
|
||||||
|
title: string;
|
||||||
|
};
|
||||||
|
export function DistributionBarChart(props: DistributionBarChartProps) {
|
||||||
|
const totalPercentage = props.segments.reduce(
|
||||||
|
(sum, segment) => sum + segment.percent,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
|
const invalidTotalPercentage = totalPercentage !== 100;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="mb-2 flex items-center justify-between">
|
||||||
|
<h3 className="font-medium text-sm">{props.title}</h3>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"font-medium text-muted-foreground text-sm",
|
||||||
|
invalidTotalPercentage && "text-red-500",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
Total: {totalPercentage}%
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Bar */}
|
||||||
|
<div className="flex h-3 overflow-hidden rounded-lg">
|
||||||
|
{props.segments.map((segment) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={segment.label}
|
||||||
|
className="flex h-full items-center justify-center transition-all duration-200"
|
||||||
|
style={{
|
||||||
|
width: `${segment.percent}%`,
|
||||||
|
backgroundColor: segment.color,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Legends */}
|
||||||
|
<div className="mt-3 flex flex-col gap-1 lg:flex-row lg:gap-6">
|
||||||
|
{props.segments.map((segment) => {
|
||||||
|
return (
|
||||||
|
<div key={segment.label} className="flex items-center gap-1.5">
|
||||||
|
<div
|
||||||
|
className="size-3 rounded-full"
|
||||||
|
style={{
|
||||||
|
backgroundColor: segment.color,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<p className="text-sm">
|
||||||
|
{segment.label}: {segment.percent}%
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
+66
@@ -0,0 +1,66 @@
|
|||||||
|
import type { Meta, StoryObj } from "@storybook/react";
|
||||||
|
import { MultiStepStatus } from "./multi-step-status";
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
title: "Blocks/MultiStepStatus",
|
||||||
|
component: MultiStepStatus,
|
||||||
|
decorators: [
|
||||||
|
(Story) => (
|
||||||
|
<div className="container w-full max-w-md py-10">
|
||||||
|
<Story />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
],
|
||||||
|
} satisfies Meta<typeof MultiStepStatus>;
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
type Story = StoryObj<typeof meta>;
|
||||||
|
|
||||||
|
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
|
||||||
|
export const AllStates: Story = {
|
||||||
|
args: {
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
status: "completed",
|
||||||
|
label: "Connect Wallet",
|
||||||
|
retryLabel: "Failed to connect wallet",
|
||||||
|
execute: async () => {
|
||||||
|
await sleep(1000);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: "pending",
|
||||||
|
label: "Sign Message",
|
||||||
|
retryLabel: "Failed to sign message",
|
||||||
|
execute: async () => {
|
||||||
|
await sleep(1000);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: "error",
|
||||||
|
label: "Approve Transaction",
|
||||||
|
retryLabel: "Transaction approval failed",
|
||||||
|
execute: async () => {
|
||||||
|
await sleep(1000);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: "idle",
|
||||||
|
label: "Confirm Transaction",
|
||||||
|
retryLabel: "Transaction confirmation failed",
|
||||||
|
execute: async () => {
|
||||||
|
await sleep(1000);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: "idle",
|
||||||
|
label: "Finalize",
|
||||||
|
retryLabel: "Finalization failed",
|
||||||
|
execute: async () => {
|
||||||
|
await sleep(1000);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
AlertCircleIcon,
|
||||||
|
CircleCheckIcon,
|
||||||
|
CircleIcon,
|
||||||
|
RefreshCwIcon,
|
||||||
|
} from "lucide-react";
|
||||||
|
import { DynamicHeight } from "../../ui/DynamicHeight";
|
||||||
|
import { Spinner } from "../../ui/Spinner/Spinner";
|
||||||
|
|
||||||
|
export type MultiStepState = {
|
||||||
|
status: "idle" | "pending" | "completed" | "error";
|
||||||
|
retryLabel: string;
|
||||||
|
label: string;
|
||||||
|
execute: () => Promise<void>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function MultiStepStatus(props: {
|
||||||
|
steps: MultiStepState[];
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<DynamicHeight>
|
||||||
|
<div className="space-y-4">
|
||||||
|
{props.steps.map((step) => (
|
||||||
|
<div key={step.label} className="flex items-start space-x-3 ">
|
||||||
|
{step.status === "completed" ? (
|
||||||
|
<CircleCheckIcon className="mt-0.5 size-5 flex-shrink-0 text-green-500" />
|
||||||
|
) : step.status === "pending" ? (
|
||||||
|
<Spinner className="mt-0.5 size-5 flex-shrink-0 text-foreground" />
|
||||||
|
) : step.status === "error" ? (
|
||||||
|
<AlertCircleIcon className="mt-0.5 size-5 flex-shrink-0 text-red-500" />
|
||||||
|
) : (
|
||||||
|
<CircleIcon className="mt-0.5 size-5 flex-shrink-0 text-muted-foreground/70" />
|
||||||
|
)}
|
||||||
|
<div className="flex-1">
|
||||||
|
<p
|
||||||
|
className={`font-medium ${
|
||||||
|
step.status === "pending"
|
||||||
|
? "text-foreground"
|
||||||
|
: step.status === "completed"
|
||||||
|
? "text-green-500"
|
||||||
|
: step.status === "error"
|
||||||
|
? "text-red-500"
|
||||||
|
: "text-muted-foreground/70"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{step.label}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{step.status === "error" && (
|
||||||
|
<div className="mt-1 space-y-2">
|
||||||
|
<p className="mb-1 text-red-500 text-sm">{step.retryLabel}</p>
|
||||||
|
<Button
|
||||||
|
variant="destructive"
|
||||||
|
size="sm"
|
||||||
|
className="gap-2"
|
||||||
|
onClick={() => step.execute()}
|
||||||
|
>
|
||||||
|
<RefreshCwIcon className="size-4" />
|
||||||
|
Retry
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</DynamicHeight>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,13 +4,13 @@ import { Badge } from "@/components/ui/badge";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { ToolTipLabel } from "@/components/ui/tooltip";
|
import { ToolTipLabel } from "@/components/ui/tooltip";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { CheckIcon, CircleDollarSignIcon } from "lucide-react";
|
import { RenewSubscriptionButton } from "components/settings/Account/Billing/renew-subscription/renew-subscription-button";
|
||||||
|
import { useTrack } from "hooks/analytics/useTrack";
|
||||||
|
import { CheckIcon, DollarSignIcon } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import type React from "react";
|
import type React from "react";
|
||||||
|
import { remainingDays } from "utils/date-utils";
|
||||||
import { TEAM_PLANS } from "utils/pricing";
|
import { TEAM_PLANS } from "utils/pricing";
|
||||||
import { RenewSubscriptionButton } from "../../../components/settings/Account/Billing/renew-subscription/renew-subscription-button";
|
|
||||||
import { useTrack } from "../../../hooks/analytics/useTrack";
|
|
||||||
import { remainingDays } from "../../../utils/date-utils";
|
|
||||||
import type { ProductSKU } from "../../lib/billing";
|
import type { ProductSKU } from "../../lib/billing";
|
||||||
import { CheckoutButton } from "../billing";
|
import { CheckoutButton } from "../billing";
|
||||||
|
|
||||||
@@ -105,9 +105,12 @@ export const PricingCard: React.FC<PricingCardProps> = ({
|
|||||||
|
|
||||||
{/* Price */}
|
{/* Price */}
|
||||||
<div className="flex flex-col gap-0.5">
|
<div className="flex flex-col gap-0.5">
|
||||||
|
{plan.isStartingPriceOnly && (
|
||||||
|
<span className="text-muted-foreground text-xs">Starting at</span>
|
||||||
|
)}
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="font-semibold text-2xl text-foreground tracking-tight">
|
<span className="font-semibold text-2xl text-foreground tracking-tight">
|
||||||
${plan.price}
|
${plan.price.toLocaleString()}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{!isCustomPrice && (
|
{!isCustomPrice && (
|
||||||
@@ -183,10 +186,10 @@ const billingPlanToSkuMap: Record<Team["billingPlan"], ProductSKU | undefined> =
|
|||||||
{
|
{
|
||||||
starter: "plan:starter",
|
starter: "plan:starter",
|
||||||
growth: "plan:growth",
|
growth: "plan:growth",
|
||||||
accelerate: "plan:accelerate",
|
|
||||||
scale: "plan:scale",
|
scale: "plan:scale",
|
||||||
|
pro: "plan:pro",
|
||||||
// we can't render checkout buttons for these plans:
|
// we can't render checkout buttons for these plans:
|
||||||
pro: undefined,
|
accelerate: undefined,
|
||||||
free: undefined,
|
free: undefined,
|
||||||
growth_legacy: undefined,
|
growth_legacy: undefined,
|
||||||
starter_legacy: undefined,
|
starter_legacy: undefined,
|
||||||
@@ -201,16 +204,19 @@ function FeatureItem({ text }: FeatureItemProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2 text-sm">
|
<div className="flex items-center gap-2 text-sm">
|
||||||
<CheckIcon className="size-4 shrink-0 text-green-500" />
|
{Array.isArray(text) ? (
|
||||||
|
<ToolTipLabel label={text[1]}>
|
||||||
|
<DollarSignIcon className="size-4 shrink-0 text-green-500" />
|
||||||
|
</ToolTipLabel>
|
||||||
|
) : (
|
||||||
|
<CheckIcon className="size-4 shrink-0 text-green-500" />
|
||||||
|
)}
|
||||||
{Array.isArray(text) ? (
|
{Array.isArray(text) ? (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
{titleStr}{" "}
|
{titleStr}{" "}
|
||||||
<span className="text-muted-foreground md:hidden">{text[1]}</span>
|
<span className="text-muted-foreground md:hidden">{text[1]}</span>
|
||||||
</p>
|
</p>
|
||||||
<ToolTipLabel label={text[1]}>
|
|
||||||
<CircleDollarSignIcon className="hidden size-4 text-muted-foreground md:block" />
|
|
||||||
</ToolTipLabel>
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-muted-foreground">{titleStr}</p>
|
<p className="text-muted-foreground">{titleStr}</p>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
HoverCardContent,
|
HoverCardContent,
|
||||||
HoverCardTrigger,
|
HoverCardTrigger,
|
||||||
} from "@/components/ui/hover-card";
|
} from "@/components/ui/hover-card";
|
||||||
import { useThirdwebClient } from "@/constants/thirdweb.client";
|
|
||||||
import { resolveSchemeWithErrorHandler } from "@/lib/resolveSchemeWithErrorHandler";
|
import { resolveSchemeWithErrorHandler } from "@/lib/resolveSchemeWithErrorHandler";
|
||||||
import { useClipboard } from "hooks/useClipboard";
|
import { useClipboard } from "hooks/useClipboard";
|
||||||
import { CheckIcon, CopyIcon, XIcon } from "lucide-react";
|
import { CheckIcon, CopyIcon, XIcon } from "lucide-react";
|
||||||
@@ -24,8 +23,8 @@ export function WalletAddress(props: {
|
|||||||
shortenAddress?: boolean;
|
shortenAddress?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
iconClassName?: string;
|
iconClassName?: string;
|
||||||
|
client: ThirdwebClient;
|
||||||
}) {
|
}) {
|
||||||
const thirdwebClient = useThirdwebClient();
|
|
||||||
// default back to zero address if no address provided
|
// default back to zero address if no address provided
|
||||||
const address = useMemo(() => props.address || ZERO_ADDRESS, [props.address]);
|
const address = useMemo(() => props.address || ZERO_ADDRESS, [props.address]);
|
||||||
|
|
||||||
@@ -40,7 +39,7 @@ export function WalletAddress(props: {
|
|||||||
|
|
||||||
const profiles = useSocialProfiles({
|
const profiles = useSocialProfiles({
|
||||||
address: address,
|
address: address,
|
||||||
client: thirdwebClient,
|
client: props.client,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { onCopy, hasCopied } = useClipboard(address, 2000);
|
const { onCopy, hasCopied } = useClipboard(address, 2000);
|
||||||
@@ -78,7 +77,7 @@ export function WalletAddress(props: {
|
|||||||
<WalletAvatar
|
<WalletAvatar
|
||||||
address={address}
|
address={address}
|
||||||
profiles={profiles.data || []}
|
profiles={profiles.data || []}
|
||||||
thirdwebClient={thirdwebClient}
|
thirdwebClient={props.client}
|
||||||
iconClassName={props.iconClassName}
|
iconClassName={props.iconClassName}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -122,7 +121,7 @@ export function WalletAddress(props: {
|
|||||||
) : (
|
) : (
|
||||||
profiles.data?.map((profile) => {
|
profiles.data?.map((profile) => {
|
||||||
const walletAvatarLink = resolveSchemeWithErrorHandler({
|
const walletAvatarLink = resolveSchemeWithErrorHandler({
|
||||||
client: thirdwebClient,
|
client: props.client,
|
||||||
uri: profile.avatar,
|
uri: profile.avatar,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export function CopyTextButton(props: {
|
|||||||
variant={props.variant || "outline"}
|
variant={props.variant || "outline"}
|
||||||
aria-label={props.tooltip}
|
aria-label={props.tooltip}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex h-auto w-auto gap-2 rounded-lg px-2.5 py-1.5 font-normal text-foreground",
|
"flex h-auto w-auto gap-2 rounded-lg px-1.5 py-0.5 font-normal text-foreground",
|
||||||
props.className,
|
props.className,
|
||||||
)}
|
)}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
export function LoadingDots() {
|
||||||
|
return (
|
||||||
|
<div className="fade-in-0 flex animate-in gap-2 duration-300">
|
||||||
|
<span className="sr-only">Loading...</span>
|
||||||
|
<div className="size-4 animate-bounce rounded-full bg-foreground [animation-delay:-0.3s]" />
|
||||||
|
<div className="size-4 animate-bounce rounded-full bg-foreground [animation-delay:-0.15s]" />
|
||||||
|
<div className="size-4 animate-bounce rounded-full bg-foreground" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { useTrack } from "hooks/analytics/useTrack";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { useTrack } from "../../../hooks/analytics/useTrack";
|
|
||||||
|
|
||||||
export type NavButtonProps = {
|
export type NavButtonProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
|||||||
@@ -6,13 +6,17 @@ export type CodeProps = {
|
|||||||
code: string;
|
code: string;
|
||||||
lang: BundledLanguage;
|
lang: BundledLanguage;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
ignoreFormattingErrors?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CodeServer: React.FC<CodeProps> = async ({
|
export const CodeServer: React.FC<CodeProps> = async ({
|
||||||
code,
|
code,
|
||||||
lang,
|
lang,
|
||||||
className,
|
className,
|
||||||
|
ignoreFormattingErrors,
|
||||||
}) => {
|
}) => {
|
||||||
const { html, formattedCode } = await getCodeHtml(code, lang);
|
const { html, formattedCode } = await getCodeHtml(code, lang, {
|
||||||
|
ignoreFormattingErrors,
|
||||||
|
});
|
||||||
return <RenderCode code={formattedCode} html={html} className={className} />;
|
return <RenderCode code={formattedCode} html={html} className={className} />;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { Input } from "./input";
|
||||||
|
export function DecimalInput(props: {
|
||||||
|
value: string;
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
maxValue?: number;
|
||||||
|
id?: string;
|
||||||
|
className?: string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
id={props.id}
|
||||||
|
type="text"
|
||||||
|
value={props.value}
|
||||||
|
className={props.className}
|
||||||
|
inputMode="decimal"
|
||||||
|
onChange={(e) => {
|
||||||
|
const number = Number(e.target.value);
|
||||||
|
// ignore if string becomes invalid number
|
||||||
|
if (Number.isNaN(number)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (props.maxValue && number > props.maxValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// replace leading multiple zeros with single zero
|
||||||
|
let cleanedValue = e.target.value.replace(/^0+/, "0");
|
||||||
|
// replace leading zero before decimal point
|
||||||
|
if (!cleanedValue.includes(".")) {
|
||||||
|
cleanedValue = cleanedValue.replace(/^0+/, "");
|
||||||
|
}
|
||||||
|
props.onChange(cleanedValue || "0");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
export const NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID =
|
export const NEXT_PUBLIC_DASHBOARD_CLIENT_ID =
|
||||||
process.env.NEXT_PUBLIC_DASHBOARD_CLIENT_ID || "";
|
process.env.NEXT_PUBLIC_DASHBOARD_CLIENT_ID || "";
|
||||||
|
|
||||||
export const NEXT_PUBLIC_NEBULA_APP_CLIENT_ID =
|
export const NEXT_PUBLIC_NEBULA_APP_CLIENT_ID =
|
||||||
|
|||||||
@@ -36,14 +36,6 @@ if (API_SERVER_SECRET) {
|
|||||||
|
|
||||||
export const THIRDWEB_ENGINE_URL = process.env.THIRDWEB_ENGINE_URL || "";
|
export const THIRDWEB_ENGINE_URL = process.env.THIRDWEB_ENGINE_URL || "";
|
||||||
|
|
||||||
if (THIRDWEB_ENGINE_URL) {
|
|
||||||
experimental_taintUniqueValue(
|
|
||||||
"Do not pass THIRDWEB_ENGINE_URL to the client",
|
|
||||||
process,
|
|
||||||
THIRDWEB_ENGINE_URL,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const THIRDWEB_ACCESS_TOKEN = process.env.THIRDWEB_ACCESS_TOKEN || "";
|
export const THIRDWEB_ACCESS_TOKEN = process.env.THIRDWEB_ACCESS_TOKEN || "";
|
||||||
|
|
||||||
if (THIRDWEB_ACCESS_TOKEN) {
|
if (THIRDWEB_ACCESS_TOKEN) {
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useMemo } from "react";
|
|
||||||
import { useActiveAccount } from "thirdweb/react";
|
|
||||||
import type { GetAuthTokenResponse } from "../../app/(app)/api/auth/get-auth-token/route";
|
|
||||||
import { LAST_USED_TEAM_ID } from "../../constants/cookies";
|
|
||||||
import { getCookie } from "../../lib/cookie";
|
|
||||||
import { getClientThirdwebClient } from "./thirdweb-client.client";
|
|
||||||
|
|
||||||
// returns a thirdweb client with optional JWT passed i
|
|
||||||
|
|
||||||
export function useThirdwebClient(jwt?: string) {
|
|
||||||
const account = useActiveAccount();
|
|
||||||
const lastUsedTeamId = getCookie(LAST_USED_TEAM_ID);
|
|
||||||
|
|
||||||
const query = useQuery({
|
|
||||||
queryKey: ["jwt", account?.address],
|
|
||||||
// only enable the query if there is an account and no JWT is passed in directly
|
|
||||||
enabled: !!account && !jwt,
|
|
||||||
retry: false,
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!account) {
|
|
||||||
throw new Error("No account");
|
|
||||||
}
|
|
||||||
const res = await fetch(
|
|
||||||
`/api/auth/get-auth-token?address=${account.address}`,
|
|
||||||
);
|
|
||||||
if (!res.ok) {
|
|
||||||
throw new Error("Failed to get auth token");
|
|
||||||
}
|
|
||||||
const json = (await res.json()) as GetAuthTokenResponse;
|
|
||||||
if (!json.jwt) {
|
|
||||||
throw new Error("No JWT in response");
|
|
||||||
}
|
|
||||||
return json.jwt;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return useMemo(
|
|
||||||
// prefer jwt from props over the one from the token query if it exists
|
|
||||||
() =>
|
|
||||||
getClientThirdwebClient({
|
|
||||||
jwt: jwt || query.data,
|
|
||||||
teamId: lastUsedTeamId,
|
|
||||||
}),
|
|
||||||
[jwt, query.data, lastUsedTeamId],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DO NOT ADD ANYTHING TO THIS FILE IF YOU ARE NOT ABSOLUTELY SURE IT IS OK
|
|
||||||
*/
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||||
NEXT_PUBLIC_IPFS_GATEWAY_URL,
|
NEXT_PUBLIC_IPFS_GATEWAY_URL,
|
||||||
} from "@/constants/public-envs";
|
} from "@/constants/public-envs";
|
||||||
import {
|
import {
|
||||||
|
THIRDWEB_BRIDGE_URL,
|
||||||
THIRDWEB_BUNDLER_DOMAIN,
|
THIRDWEB_BUNDLER_DOMAIN,
|
||||||
THIRDWEB_INAPP_WALLET_DOMAIN,
|
THIRDWEB_INAPP_WALLET_DOMAIN,
|
||||||
THIRDWEB_INSIGHT_API_DOMAIN,
|
THIRDWEB_INSIGHT_API_DOMAIN,
|
||||||
@@ -35,6 +36,7 @@ export function getConfiguredThirdwebClient(options: {
|
|||||||
social: THIRDWEB_SOCIAL_API_DOMAIN,
|
social: THIRDWEB_SOCIAL_API_DOMAIN,
|
||||||
bundler: THIRDWEB_BUNDLER_DOMAIN,
|
bundler: THIRDWEB_BUNDLER_DOMAIN,
|
||||||
insight: THIRDWEB_INSIGHT_API_DOMAIN,
|
insight: THIRDWEB_INSIGHT_API_DOMAIN,
|
||||||
|
bridge: THIRDWEB_BRIDGE_URL,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ export function getConfiguredThirdwebClient(options: {
|
|||||||
return createThirdwebClient({
|
return createThirdwebClient({
|
||||||
teamId: options.teamId,
|
teamId: options.teamId,
|
||||||
secretKey: options.secretKey,
|
secretKey: options.secretKey,
|
||||||
clientId: NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
clientId: NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||||
config: {
|
config: {
|
||||||
storage: {
|
storage: {
|
||||||
gatewayUrl: NEXT_PUBLIC_IPFS_GATEWAY_URL,
|
gatewayUrl: NEXT_PUBLIC_IPFS_GATEWAY_URL,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export type ProductSKU =
|
|||||||
| "plan:custom"
|
| "plan:custom"
|
||||||
| "plan:accelerate"
|
| "plan:accelerate"
|
||||||
| "plan:scale"
|
| "plan:scale"
|
||||||
|
| "plan:pro"
|
||||||
| "product:ecosystem_wallets"
|
| "product:ecosystem_wallets"
|
||||||
| "product:engine_standard"
|
| "product:engine_standard"
|
||||||
| "product:engine_premium"
|
| "product:engine_premium"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { differenceInCalendarDays } from "date-fns";
|
|
||||||
import {
|
import {
|
||||||
type DurationId,
|
type DurationId,
|
||||||
type Range,
|
type Range,
|
||||||
getLastNDaysRange,
|
getLastNDaysRange,
|
||||||
} from "../../components/analytics/date-range-selector";
|
} from "components/analytics/date-range-selector";
|
||||||
|
import { differenceInCalendarDays } from "date-fns";
|
||||||
|
|
||||||
export function normalizeTime(date: Date) {
|
export function normalizeTime(date: Date) {
|
||||||
const newDate = new Date(date);
|
const newDate = new Date(date);
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useThirdwebClient } from "@/constants/thirdweb.client";
|
|
||||||
import { useStore } from "@/lib/reactive";
|
import { useStore } from "@/lib/reactive";
|
||||||
import { getSDKTheme } from "app/(app)/components/sdk-component-theme";
|
import { getSDKTheme } from "app/(app)/components/sdk-component-theme";
|
||||||
|
import { LazyConfigureNetworkModal } from "components/configure-networks/LazyConfigureNetworkModal";
|
||||||
import { CustomChainRenderer } from "components/selects/CustomChainRenderer";
|
import { CustomChainRenderer } from "components/selects/CustomChainRenderer";
|
||||||
import { mapV4ChainToV5Chain } from "contexts/map-chains";
|
import { mapV4ChainToV5Chain } from "contexts/map-chains";
|
||||||
import { useTrack } from "hooks/analytics/useTrack";
|
import { useTrack } from "hooks/analytics/useTrack";
|
||||||
|
import { useAllChainsData } from "hooks/chains/allChains";
|
||||||
import { useTheme } from "next-themes";
|
import { useTheme } from "next-themes";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
import type { Chain } from "thirdweb";
|
import type { Chain, ThirdwebClient } from "thirdweb";
|
||||||
import {
|
import {
|
||||||
ConnectButton,
|
ConnectButton,
|
||||||
type NetworkSelectorProps,
|
type NetworkSelectorProps,
|
||||||
@@ -21,8 +22,6 @@ import {
|
|||||||
} from "thirdweb/react";
|
} from "thirdweb/react";
|
||||||
import { useFavoriteChainIds } from "../../../../app/(app)/(dashboard)/(chain)/components/client/star-button";
|
import { useFavoriteChainIds } from "../../../../app/(app)/(dashboard)/(chain)/components/client/star-button";
|
||||||
import { doLogout } from "../../../../app/(app)/login/auth-actions";
|
import { doLogout } from "../../../../app/(app)/login/auth-actions";
|
||||||
import { LazyConfigureNetworkModal } from "../../../../components/configure-networks/LazyConfigureNetworkModal";
|
|
||||||
import { useAllChainsData } from "../../../../hooks/chains/allChains";
|
|
||||||
import {
|
import {
|
||||||
type StoredChain,
|
type StoredChain,
|
||||||
addRecentlyUsedChainId,
|
addRecentlyUsedChainId,
|
||||||
@@ -36,9 +35,11 @@ export const CustomConnectWallet = (props: {
|
|||||||
signInLinkButtonClassName?: string;
|
signInLinkButtonClassName?: string;
|
||||||
detailsButtonClassName?: string;
|
detailsButtonClassName?: string;
|
||||||
chain?: Chain;
|
chain?: Chain;
|
||||||
|
client: ThirdwebClient;
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const thirdwebClient = useThirdwebClient();
|
const client = props.client;
|
||||||
|
|
||||||
const loginRequired =
|
const loginRequired =
|
||||||
props.loginRequired === undefined ? true : props.loginRequired;
|
props.loginRequired === undefined ? true : props.loginRequired;
|
||||||
|
|
||||||
@@ -140,7 +141,7 @@ export const CustomConnectWallet = (props: {
|
|||||||
<>
|
<>
|
||||||
<ConnectButton
|
<ConnectButton
|
||||||
theme={getSDKTheme(t)}
|
theme={getSDKTheme(t)}
|
||||||
client={thirdwebClient}
|
client={client}
|
||||||
connectModal={{
|
connectModal={{
|
||||||
privacyPolicyUrl: "/privacy-policy",
|
privacyPolicyUrl: "/privacy-policy",
|
||||||
termsOfServiceUrl: "/terms",
|
termsOfServiceUrl: "/terms",
|
||||||
@@ -175,7 +176,7 @@ export const CustomConnectWallet = (props: {
|
|||||||
renderChain(props) {
|
renderChain(props) {
|
||||||
return (
|
return (
|
||||||
<CustomChainRenderer
|
<CustomChainRenderer
|
||||||
client={thirdwebClient}
|
client={client}
|
||||||
{...props}
|
{...props}
|
||||||
openEditChainModal={(c) => {
|
openEditChainModal={(c) => {
|
||||||
setIsNetworkConfigModalOpen(true);
|
setIsNetworkConfigModalOpen(true);
|
||||||
@@ -197,6 +198,7 @@ export const CustomConnectWallet = (props: {
|
|||||||
open={isNetworkConfigModalOpen}
|
open={isNetworkConfigModalOpen}
|
||||||
onOpenChange={setIsNetworkConfigModalOpen}
|
onOpenChange={setIsNetworkConfigModalOpen}
|
||||||
editChain={editChain}
|
editChain={editChain}
|
||||||
|
client={client}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -276,12 +278,11 @@ function ConnectWalletWelcomeScreen(props: {
|
|||||||
export function useCustomConnectModal() {
|
export function useCustomConnectModal() {
|
||||||
const { connect } = useConnectModal();
|
const { connect } = useConnectModal();
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
const thirdwebClient = useThirdwebClient();
|
|
||||||
|
|
||||||
return useCallback(
|
return useCallback(
|
||||||
(options?: { chain?: Chain }) => {
|
(options: { chain?: Chain; client: ThirdwebClient }) => {
|
||||||
return connect({
|
return connect({
|
||||||
client: thirdwebClient,
|
client: options.client,
|
||||||
appMetadata: {
|
appMetadata: {
|
||||||
name: "thirdweb",
|
name: "thirdweb",
|
||||||
logoUrl: "https://thirdweb.com/favicon.ico",
|
logoUrl: "https://thirdweb.com/favicon.ico",
|
||||||
@@ -299,7 +300,7 @@ export function useCustomConnectModal() {
|
|||||||
theme: getSDKTheme(theme === "light" ? "light" : "dark"),
|
theme: getSDKTheme(theme === "light" ? "light" : "dark"),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[connect, theme, thirdwebClient],
|
[connect, theme],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { apiServerProxy } from "@/actions/proxies";
|
import { apiServerProxy } from "@/actions/proxies";
|
||||||
import type { Project } from "@/api/projects";
|
import type { Project } from "@/api/projects";
|
||||||
import type { Team } from "@/api/team";
|
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useActiveAccount } from "thirdweb/react";
|
import { useActiveAccount } from "thirdweb/react";
|
||||||
import { accountKeys, authorizedWallets } from "../cache-keys";
|
import { accountKeys, authorizedWallets } from "../cache-keys";
|
||||||
@@ -32,7 +31,6 @@ export type Account = {
|
|||||||
image?: string | null;
|
image?: string | null;
|
||||||
name?: string;
|
name?: string;
|
||||||
email?: string;
|
email?: string;
|
||||||
advancedEnabled: boolean;
|
|
||||||
emailConfirmedAt?: string;
|
emailConfirmedAt?: string;
|
||||||
unconfirmedEmail?: string;
|
unconfirmedEmail?: string;
|
||||||
emailConfirmationWalletAddress?: string;
|
emailConfirmationWalletAddress?: string;
|
||||||
@@ -41,7 +39,6 @@ export type Account = {
|
|||||||
billing: "email" | "none";
|
billing: "email" | "none";
|
||||||
updates: "email" | "none";
|
updates: "email" | "none";
|
||||||
};
|
};
|
||||||
// TODO - add image URL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
interface UpdateAccountNotificationsInput {
|
interface UpdateAccountNotificationsInput {
|
||||||
@@ -53,27 +50,6 @@ interface ConfirmEmailInput {
|
|||||||
confirmationToken: string;
|
confirmationToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UsageStorage {
|
|
||||||
sumFileSizeBytes: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UsageBillableByService {
|
|
||||||
usage: {
|
|
||||||
storage: UsageStorage;
|
|
||||||
};
|
|
||||||
limits: {
|
|
||||||
storage: number;
|
|
||||||
};
|
|
||||||
rateLimits: {
|
|
||||||
storage: number;
|
|
||||||
rpc: number;
|
|
||||||
};
|
|
||||||
rateLimitedAt: {
|
|
||||||
storage?: string;
|
|
||||||
rpc?: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BillingProduct {
|
interface BillingProduct {
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
@@ -211,7 +187,7 @@ export function useUpdateNotifications() {
|
|||||||
export const verifyEmailClient = async (input: ConfirmEmailInput) => {
|
export const verifyEmailClient = async (input: ConfirmEmailInput) => {
|
||||||
type Result = {
|
type Result = {
|
||||||
error?: { message: string };
|
error?: { message: string };
|
||||||
data: { team: Team; account: Account };
|
data: { account: Account };
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = await apiServerProxy<Result>({
|
const res = await apiServerProxy<Result>({
|
||||||
@@ -345,13 +321,14 @@ export type RotateSecretKeyAPIReturnType = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function rotateSecretKeyClient(projectId: string) {
|
export async function rotateSecretKeyClient(params: {
|
||||||
|
teamId: string;
|
||||||
|
projectId: string;
|
||||||
|
}) {
|
||||||
const res = await apiServerProxy<RotateSecretKeyAPIReturnType>({
|
const res = await apiServerProxy<RotateSecretKeyAPIReturnType>({
|
||||||
pathname: "/v2/keys/rotate-secret-key",
|
pathname: `/v1/teams/${params.teamId}/projects/${params.projectId}/rotate-secret-key`,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({}),
|
||||||
projectId,
|
|
||||||
}),
|
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import { useThirdwebClient } from "@/constants/thirdweb.client";
|
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
import type { ThirdwebClient } from "thirdweb";
|
||||||
import { upload } from "thirdweb/storage";
|
import { upload } from "thirdweb/storage";
|
||||||
|
|
||||||
type DashboardUploadOptions = {
|
type DashboardUploadOptions = {
|
||||||
uploadWithoutDirectory?: boolean;
|
uploadWithoutDirectory?: boolean;
|
||||||
metadata?: Record<string, string>;
|
metadata?: Record<string, string>;
|
||||||
|
client: ThirdwebClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useDashboardStorageUpload(options?: DashboardUploadOptions) {
|
export function useDashboardStorageUpload(options: DashboardUploadOptions) {
|
||||||
const thirdwebClient = useThirdwebClient();
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (files: Array<File | string>): Promise<string[]> => {
|
mutationFn: async (files: Array<File | string>): Promise<string[]> => {
|
||||||
const uris = await upload({
|
const uris = await upload({
|
||||||
client: thirdwebClient,
|
|
||||||
files,
|
files,
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import type { EngineBackendWalletType } from "lib/engine";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useActiveAccount } from "thirdweb/react";
|
import { useActiveAccount } from "thirdweb/react";
|
||||||
import invariant from "tiny-invariant";
|
import invariant from "tiny-invariant";
|
||||||
import type { ResultItem } from "../../../app/(app)/team/[team_slug]/[project_slug]/engine/dedicated/(instance)/[engineId]/metrics/components/StatusCodes";
|
import type { ResultItem } from "../../../app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/dedicated/(instance)/[engineId]/metrics/components/StatusCodes";
|
||||||
import type { EngineStatus } from "../../../app/(app)/team/[team_slug]/[project_slug]/engine/dedicated/(instance)/[engineId]/overview/components/transactions-table";
|
import type { EngineStatus } from "../../../app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/dedicated/(instance)/[engineId]/overview/components/transactions-table";
|
||||||
import { engineKeys } from "../cache-keys";
|
import { engineKeys } from "../cache-keys";
|
||||||
|
|
||||||
// Engine instances
|
// Engine instances
|
||||||
|
|||||||
-29
@@ -1,29 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { getSDKTheme } from "app/(app)/components/sdk-component-theme";
|
|
||||||
import { useV5DashboardChain } from "lib/v5-adapter";
|
|
||||||
import { useTheme } from "next-themes";
|
|
||||||
import type { ThirdwebClient } from "thirdweb";
|
|
||||||
import { PayEmbed } from "thirdweb/react";
|
|
||||||
|
|
||||||
export function UniversalBridgeEmbed({
|
|
||||||
chainId,
|
|
||||||
client,
|
|
||||||
}: { chainId?: number; client: ThirdwebClient }) {
|
|
||||||
const { theme } = useTheme();
|
|
||||||
const chain = useV5DashboardChain(chainId || 1);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PayEmbed
|
|
||||||
client={client}
|
|
||||||
payOptions={{
|
|
||||||
mode: "fund_wallet",
|
|
||||||
prefillBuy: {
|
|
||||||
chain,
|
|
||||||
amount: "0.01",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
theme={getSDKTheme(theme === "light" ? "light" : "dark")}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
import type { Metadata } from "next";
|
|
||||||
import { getClientThirdwebClient } from "../../../../../@/constants/thirdweb-client.client";
|
|
||||||
import { UniversalBridgeEmbed } from "./components/client/UniversalBridgeEmbed";
|
|
||||||
|
|
||||||
const title = "Universal Bridge: Swap, Bridge, and On-Ramp";
|
|
||||||
const description =
|
|
||||||
"Swap, bridge, and on-ramp to any EVM chain with thirdweb's Universal Bridge.";
|
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
|
||||||
title,
|
|
||||||
description,
|
|
||||||
openGraph: {
|
|
||||||
title,
|
|
||||||
description,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default async function RoutesPage({
|
|
||||||
searchParams,
|
|
||||||
}: { searchParams: Record<string, string | string[]> }) {
|
|
||||||
const { chainId } = searchParams;
|
|
||||||
const client = getClientThirdwebClient(undefined);
|
|
||||||
return (
|
|
||||||
<div className="relative mx-auto flex h-screen w-full flex-col items-center justify-center overflow-hidden border py-10">
|
|
||||||
<main className="container z-10 flex justify-center">
|
|
||||||
<UniversalBridgeEmbed
|
|
||||||
chainId={chainId ? Number(chainId) : undefined}
|
|
||||||
client={client}
|
|
||||||
/>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
||||||
<img
|
|
||||||
alt=""
|
|
||||||
src="/assets/login/background.svg"
|
|
||||||
className="-bottom-12 -right-12 pointer-events-none absolute lg:right-0 lg:bottom-0"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { TeamHeader } from "../../team/components/TeamHeader/team-header";
|
||||||
|
|
||||||
|
export default function Layout({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="flex grow flex-col">
|
||||||
|
<div className="border-border border-b bg-card">
|
||||||
|
<TeamHeader />
|
||||||
|
</div>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 536 KiB |
+1
-1
@@ -47,7 +47,7 @@ export const SearchInput: React.FC = () => {
|
|||||||
<div className="group relative w-full">
|
<div className="group relative w-full">
|
||||||
<SearchIcon className="-translate-y-1/2 absolute top-[50%] left-3 size-4 text-muted-foreground" />
|
<SearchIcon className="-translate-y-1/2 absolute top-[50%] left-3 size-4 text-muted-foreground" />
|
||||||
<Input
|
<Input
|
||||||
placeholder="Search with anything!"
|
placeholder="Search by token name or symbol"
|
||||||
className="h-10 rounded-lg bg-card py-2 pl-9 lg:min-w-[300px]"
|
className="h-10 rounded-lg bg-card py-2 pl-9 lg:min-w-[300px]"
|
||||||
defaultValue={searchParams?.get("query") || ""}
|
defaultValue={searchParams?.get("query") || ""}
|
||||||
onChange={(e) => handleSearch(e.target.value)}
|
onChange={(e) => handleSearch(e.target.value)}
|
||||||
|
|||||||
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||||
|
import { serverThirdwebClient } from "@/constants/thirdweb-client.server";
|
||||||
import { resolveSchemeWithErrorHandler } from "@/lib/resolveSchemeWithErrorHandler";
|
import { resolveSchemeWithErrorHandler } from "@/lib/resolveSchemeWithErrorHandler";
|
||||||
import { defineChain } from "thirdweb";
|
import { defineChain } from "thirdweb";
|
||||||
import { getChainMetadata } from "thirdweb/chains";
|
import { getChainMetadata } from "thirdweb/chains";
|
||||||
import { serverThirdwebClient } from "../../../../../../../@/constants/thirdweb-client.server";
|
|
||||||
|
|
||||||
type RouteListCardProps = {
|
type RouteListCardProps = {
|
||||||
originChainId: number;
|
originChainId: number;
|
||||||
|
|||||||
+15
-15
@@ -52,20 +52,20 @@ export async function RouteListRow({
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow linkBox className="hover:bg-accent/50">
|
<TableRow linkBox className="group transition-colors hover:bg-accent/50">
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<div className="flex flex-row items-center gap-4">
|
<div className="flex flex-row items-center gap-3">
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-2">
|
||||||
{resolvedOriginTokenIconUri ? (
|
{resolvedOriginTokenIconUri ? (
|
||||||
// For now we're using a normal img tag because the domain for these images is unknown
|
// For now we're using a normal img tag because the domain for these images is unknown
|
||||||
// eslint-disable-next-line @next/next/no-img-element
|
// eslint-disable-next-line @next/next/no-img-element
|
||||||
<img
|
<img
|
||||||
src={resolvedOriginTokenIconUri}
|
src={resolvedOriginTokenIconUri}
|
||||||
alt={originTokenAddress}
|
alt={originTokenAddress}
|
||||||
className="size-6 rounded-full border border-muted-foreground"
|
className="size-7 rounded-full border border-border/50 shadow-sm transition-transform group-hover:scale-105"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="size-6 rounded-full bg-muted-foreground" />
|
<div className="size-7 rounded-full bg-muted-foreground/20" />
|
||||||
)}
|
)}
|
||||||
{originTokenSymbol && (
|
{originTokenSymbol && (
|
||||||
<CopyTextButton
|
<CopyTextButton
|
||||||
@@ -76,7 +76,7 @@ export async function RouteListRow({
|
|||||||
: originTokenSymbol
|
: originTokenSymbol
|
||||||
}
|
}
|
||||||
tooltip="Copy Token Address"
|
tooltip="Copy Token Address"
|
||||||
className="relative z-10 text-base"
|
className="relative z-10 font-medium text-base"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
copyIconPosition="right"
|
copyIconPosition="right"
|
||||||
/>
|
/>
|
||||||
@@ -85,22 +85,22 @@ export async function RouteListRow({
|
|||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell className="text-muted-foreground">
|
<TableCell className="text-muted-foreground/90">
|
||||||
{originChain.name}
|
<span className="font-medium">{originChain.name}</span>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<div className="flex flex-row items-center gap-4">
|
<div className="flex flex-row items-center gap-3">
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-2">
|
||||||
{resolvedDestinationTokenIconUri ? (
|
{resolvedDestinationTokenIconUri ? (
|
||||||
// eslint-disable-next-line @next/next/no-img-element
|
// eslint-disable-next-line @next/next/no-img-element
|
||||||
<img
|
<img
|
||||||
src={resolvedDestinationTokenIconUri}
|
src={resolvedDestinationTokenIconUri}
|
||||||
alt={destinationTokenAddress}
|
alt={destinationTokenAddress}
|
||||||
className="size-6 rounded-full border border-muted-foreground"
|
className="size-7 rounded-full border border-border/50 shadow-sm transition-transform group-hover:scale-105"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="size-6 rounded-full bg-muted-foreground" />
|
<div className="size-7 rounded-full bg-muted-foreground/20" />
|
||||||
)}
|
)}
|
||||||
{destinationTokenSymbol && (
|
{destinationTokenSymbol && (
|
||||||
<CopyTextButton
|
<CopyTextButton
|
||||||
@@ -111,7 +111,7 @@ export async function RouteListRow({
|
|||||||
: destinationTokenSymbol
|
: destinationTokenSymbol
|
||||||
}
|
}
|
||||||
tooltip="Copy Token Address"
|
tooltip="Copy Token Address"
|
||||||
className="relative z-10 text-base"
|
className="relative z-10 font-medium text-base"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
copyIconPosition="right"
|
copyIconPosition="right"
|
||||||
/>
|
/>
|
||||||
@@ -120,8 +120,8 @@ export async function RouteListRow({
|
|||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell className="text-muted-foreground">
|
<TableCell className="text-muted-foreground/90">
|
||||||
{destinationChain.name}
|
<span className="font-medium">{destinationChain.name}</span>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
|
|||||||
+36
-85
@@ -7,7 +7,6 @@ import {
|
|||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from "@/components/ui/table";
|
||||||
import type { Address } from "thirdweb";
|
import type { Address } from "thirdweb";
|
||||||
import { checksumAddress } from "thirdweb/utils";
|
|
||||||
import { getRoutes } from "../../../utils";
|
import { getRoutes } from "../../../utils";
|
||||||
import { ChainlistPagination } from "../client/pagination";
|
import { ChainlistPagination } from "../client/pagination";
|
||||||
import { RouteListCard } from "./routelist-card";
|
import { RouteListCard } from "./routelist-card";
|
||||||
@@ -25,18 +24,15 @@ export type SearchParams = Partial<{
|
|||||||
|
|
||||||
// 120 is divisible by 2, 3, and 4 so card layout looks nice
|
// 120 is divisible by 2, 3, and 4 so card layout looks nice
|
||||||
const DEFAULT_PAGE_SIZE = 120;
|
const DEFAULT_PAGE_SIZE = 120;
|
||||||
const DEFAULT_PAGE = 1;
|
|
||||||
|
|
||||||
async function getRoutesToRender(params: SearchParams) {
|
async function getRoutesToRender(params: SearchParams) {
|
||||||
const filters: Partial<{
|
const filters: Partial<{
|
||||||
limit: number;
|
originQuery?: string;
|
||||||
offset: number;
|
destinationQuery?: string;
|
||||||
originChainId?: number;
|
originChainId?: number;
|
||||||
originTokenAddress?: Address;
|
originTokenAddress?: Address;
|
||||||
destinationChainId?: number;
|
destinationChainId?: number;
|
||||||
destinationTokenAddress?: Address;
|
destinationTokenAddress?: Address;
|
||||||
originTextQuery?: string;
|
|
||||||
destinationTextQuery?: string;
|
|
||||||
}> = {};
|
}> = {};
|
||||||
|
|
||||||
if (params.type === "origin" || typeof params.type === "undefined") {
|
if (params.type === "origin" || typeof params.type === "undefined") {
|
||||||
@@ -45,7 +41,7 @@ async function getRoutesToRender(params: SearchParams) {
|
|||||||
} else if (Number.isInteger(Number(params.query))) {
|
} else if (Number.isInteger(Number(params.query))) {
|
||||||
filters.originChainId = Number(params.query);
|
filters.originChainId = Number(params.query);
|
||||||
} else if (params.query) {
|
} else if (params.query) {
|
||||||
filters.originTextQuery = params.query;
|
filters.originQuery = params.query;
|
||||||
}
|
}
|
||||||
} else if (params.type === "destination") {
|
} else if (params.type === "destination") {
|
||||||
if (params.query?.startsWith("0x")) {
|
if (params.query?.startsWith("0x")) {
|
||||||
@@ -53,69 +49,20 @@ async function getRoutesToRender(params: SearchParams) {
|
|||||||
} else if (Number.isInteger(Number(params.query))) {
|
} else if (Number.isInteger(Number(params.query))) {
|
||||||
filters.destinationChainId = Number(params.query);
|
filters.destinationChainId = Number(params.query);
|
||||||
} else if (params.query) {
|
} else if (params.query) {
|
||||||
filters.destinationTextQuery = params.query;
|
filters.destinationQuery = params.query;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Temporary, will update this after the /routes endpoint
|
const routes = await getRoutes({
|
||||||
let routes = await getRoutes({ limit: 100_000 });
|
limit: DEFAULT_PAGE_SIZE,
|
||||||
|
offset: DEFAULT_PAGE_SIZE * ((params.page || 1) - 1),
|
||||||
const totalCount = routes.length;
|
originQuery: filters.originQuery,
|
||||||
|
destinationQuery: filters.destinationQuery,
|
||||||
if (filters.originChainId) {
|
});
|
||||||
routes = routes.filter(
|
|
||||||
(route) => route.originToken.chainId === filters.originChainId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (filters.originTokenAddress) {
|
|
||||||
const originTokenAddress = filters.originTokenAddress;
|
|
||||||
routes = routes.filter(
|
|
||||||
(route) =>
|
|
||||||
checksumAddress(route.originToken.address) ===
|
|
||||||
checksumAddress(originTokenAddress),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (filters.destinationChainId) {
|
|
||||||
routes = routes.filter(
|
|
||||||
(route) => route.destinationToken.chainId === filters.destinationChainId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (filters.destinationTokenAddress) {
|
|
||||||
const destinationTokenAddress = filters.destinationTokenAddress;
|
|
||||||
routes = routes.filter(
|
|
||||||
(route) =>
|
|
||||||
checksumAddress(route.destinationToken.address) ===
|
|
||||||
checksumAddress(destinationTokenAddress),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filters.originTextQuery) {
|
|
||||||
const originTextQuery = filters.originTextQuery.toLowerCase();
|
|
||||||
routes = routes.filter((route) => {
|
|
||||||
return (
|
|
||||||
route.originToken.name.toLowerCase().includes(originTextQuery) ||
|
|
||||||
route.originToken.symbol.toLowerCase().includes(originTextQuery)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filters.destinationTextQuery) {
|
|
||||||
const destinationTextQuery = filters.destinationTextQuery.toLowerCase();
|
|
||||||
routes = routes.filter((route) => {
|
|
||||||
return (
|
|
||||||
route.destinationToken.name
|
|
||||||
.toLowerCase()
|
|
||||||
.includes(destinationTextQuery) ||
|
|
||||||
route.destinationToken.symbol
|
|
||||||
.toLowerCase()
|
|
||||||
.includes(destinationTextQuery)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
routesToRender: routes,
|
routesToRender: routes.data,
|
||||||
totalCount,
|
totalCount: routes.meta.totalCount,
|
||||||
filteredCount: routes.length,
|
filteredCount: routes.meta.filteredCount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,36 +75,37 @@ export async function RoutesData(props: {
|
|||||||
props.searchParams,
|
props.searchParams,
|
||||||
);
|
);
|
||||||
|
|
||||||
// pagination
|
const totalPages = Math.ceil(filteredCount / DEFAULT_PAGE_SIZE);
|
||||||
const totalPages = Math.ceil(routesToRender.length / DEFAULT_PAGE_SIZE);
|
|
||||||
|
|
||||||
const activePage = Number(props.searchParams.page || DEFAULT_PAGE);
|
|
||||||
const pageSize = DEFAULT_PAGE_SIZE;
|
|
||||||
const startIndex = (activePage - 1) * pageSize;
|
|
||||||
const endIndex = startIndex + pageSize;
|
|
||||||
const paginatedRoutes = routesToRender.slice(startIndex, endIndex);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<main>
|
<main>
|
||||||
{/* empty state */}
|
{/* empty state */}
|
||||||
{paginatedRoutes.length === 0 ? (
|
{routesToRender.length === 0 ? (
|
||||||
<div className="flex h-[300px] items-center justify-center rounded-lg border p-8 lg:h-[500px]">
|
<div className="flex h-[300px] items-center justify-center rounded-lg border p-8 lg:h-[500px]">
|
||||||
<p className="text-2xl">No Results found</p>
|
<p className="text-2xl">No Results found</p>
|
||||||
</div>
|
</div>
|
||||||
) : props.activeView === "table" ? (
|
) : props.activeView === "table" ? (
|
||||||
<TableContainer>
|
<TableContainer className="overflow-hidden rounded-xl border border-border/50 bg-card/50 shadow-sm transition-all">
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader className="z-0">
|
<TableHeader className="z-0">
|
||||||
<TableRow>
|
<TableRow className="border-border/50 border-b bg-muted/50">
|
||||||
<TableHead>Origin Token</TableHead>
|
<TableHead className="py-4 font-medium text-muted-foreground/80 text-xs uppercase tracking-wider">
|
||||||
<TableHead>Origin Chain</TableHead>
|
Origin Token
|
||||||
<TableHead>Destination Token</TableHead>
|
</TableHead>
|
||||||
<TableHead>Destination Chain</TableHead>
|
<TableHead className="py-4 font-medium text-muted-foreground/80 text-xs uppercase tracking-wider">
|
||||||
|
Origin Chain
|
||||||
|
</TableHead>
|
||||||
|
<TableHead className="py-4 font-medium text-muted-foreground/80 text-xs uppercase tracking-wider">
|
||||||
|
Destination Token
|
||||||
|
</TableHead>
|
||||||
|
<TableHead className="py-4 font-medium text-muted-foreground/80 text-xs uppercase tracking-wider">
|
||||||
|
Destination Chain
|
||||||
|
</TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{paginatedRoutes.map((route) => (
|
{routesToRender.map((route) => (
|
||||||
<RouteListRow
|
<RouteListRow
|
||||||
key={`${route.originToken.chainId}:${route.originToken.address}-${route.destinationToken.chainId}:${route.destinationToken.address}`}
|
key={`${route.originToken.chainId}:${route.originToken.address}-${route.destinationToken.chainId}:${route.destinationToken.address}`}
|
||||||
originChainId={route.originToken.chainId}
|
originChainId={route.originToken.chainId}
|
||||||
@@ -177,7 +125,7 @@ export async function RoutesData(props: {
|
|||||||
</TableContainer>
|
</TableContainer>
|
||||||
) : (
|
) : (
|
||||||
<ul className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
<ul className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||||
{paginatedRoutes.map((route) => (
|
{routesToRender.map((route) => (
|
||||||
<li
|
<li
|
||||||
key={`${route.originToken.chainId}:${route.originToken.address}-${route.destinationToken.chainId}:${route.destinationToken.address}`}
|
key={`${route.originToken.chainId}:${route.originToken.address}-${route.destinationToken.chainId}:${route.destinationToken.address}`}
|
||||||
className="h-full"
|
className="h-full"
|
||||||
@@ -201,12 +149,15 @@ export async function RoutesData(props: {
|
|||||||
</main>
|
</main>
|
||||||
<div className="h-10" />
|
<div className="h-10" />
|
||||||
{totalPages > 1 && (
|
{totalPages > 1 && (
|
||||||
<ChainlistPagination totalPages={totalPages} activePage={activePage} />
|
<ChainlistPagination
|
||||||
|
totalPages={totalPages}
|
||||||
|
activePage={Number(props.searchParams.page) || 1}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="h-4" />
|
<div className="h-4" />
|
||||||
<p className="text-balance text-center text-muted-foreground text-sm">
|
<p className="text-balance text-center text-muted-foreground text-sm">
|
||||||
Showing{" "}
|
Showing{" "}
|
||||||
<span className="text-accent-foreground">{paginatedRoutes.length}</span>{" "}
|
<span className="text-accent-foreground">{routesToRender.length}</span>{" "}
|
||||||
out of{" "}
|
out of{" "}
|
||||||
{filteredCount !== totalCount ? (
|
{filteredCount !== totalCount ? (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ArrowUpRightIcon } from "lucide-react";
|
||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import { getAuthToken } from "../../../api/lib/getAuthToken";
|
import { getAuthToken } from "../../../api/lib/getAuthToken";
|
||||||
@@ -9,7 +10,7 @@ import {
|
|||||||
type SearchParams,
|
type SearchParams,
|
||||||
} from "./components/server/routes-table";
|
} from "./components/server/routes-table";
|
||||||
|
|
||||||
const title = "Routes: Swap, Bridge, and On-Ramp";
|
const title = "Universal Bridge Routes: Swap, Bridge, and Onramp";
|
||||||
const description =
|
const description =
|
||||||
"A list of token routes for swapping, bridging, and on-ramping between EVM chains with thirdweb.";
|
"A list of token routes for swapping, bridging, and on-ramping between EVM chains with thirdweb.";
|
||||||
|
|
||||||
@@ -43,15 +44,15 @@ export default async function RoutesPage(props: {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="container mx-auto flex h-full flex-col px-4 py-10">
|
<section className="container mx-auto flex h-full flex-col px-4 py-10">
|
||||||
<header className="flex flex-col gap-4">
|
<header className="flex flex-col gap-6">
|
||||||
<div className="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
|
<div className="flex flex-col gap-6 lg:flex-row lg:items-center lg:justify-between">
|
||||||
<div className="flex flex-row items-center justify-between gap-4 lg:flex-col lg:justify-start">
|
<div className="flex flex-col gap-2">
|
||||||
<h1 className="font-semibold text-4xl tracking-tighter lg:text-5xl">
|
<h1 className="font-semibold text-4xl tracking-tighter lg:text-5xl">
|
||||||
Routes
|
Routes
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row items-end gap-4 lg:flex-col ">
|
<div className="flex flex-row items-end gap-4 lg:flex-col">
|
||||||
<div className="flex w-full flex-row gap-4">
|
<div className="flex w-full flex-row items-center gap-4">
|
||||||
<SearchInput />
|
<SearchInput />
|
||||||
<QueryType activeType={activeType} />
|
<QueryType activeType={activeType} />
|
||||||
<RouteListView activeView={activeView} />
|
<RouteListView activeView={activeView} />
|
||||||
@@ -60,6 +61,29 @@ export default async function RoutesPage(props: {
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div className="h-10" />
|
<div className="h-10" />
|
||||||
|
<div className="relative overflow-hidden rounded-lg border-2 border-green-500/20 bg-gradient-to-br from-card/80 to-card/50 p-4 shadow-[inset_0_1px_2px_0_rgba(0,0,0,0.02)]">
|
||||||
|
<div className="absolute inset-0 bg-gradient-to-br from-green-500/5 to-transparent" />
|
||||||
|
<div className="relative flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<h3 className="font-medium text-lg">
|
||||||
|
Get Started with Universal Bridge
|
||||||
|
</h3>
|
||||||
|
<p className="text-muted-foreground text-sm">
|
||||||
|
Simple, instant, and secure payments across any token and chain.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<a
|
||||||
|
href="https://portal.thirdweb.com/pay"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="inline-flex items-center gap-2 rounded-md bg-green-600 px-4 py-2 font-medium text-sm text-white transition-all hover:bg-green-600/90 hover:shadow-sm"
|
||||||
|
>
|
||||||
|
Learn More
|
||||||
|
<ArrowUpRightIcon className="size-4" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="h-10" />
|
||||||
<RoutesData
|
<RoutesData
|
||||||
searchParams={searchParams}
|
searchParams={searchParams}
|
||||||
activeView={activeView}
|
activeView={activeView}
|
||||||
|
|||||||
@@ -2,35 +2,69 @@ import "server-only";
|
|||||||
|
|
||||||
import { NEXT_PUBLIC_THIRDWEB_BRIDGE_HOST } from "@/constants/public-envs";
|
import { NEXT_PUBLIC_THIRDWEB_BRIDGE_HOST } from "@/constants/public-envs";
|
||||||
import { DASHBOARD_THIRDWEB_SECRET_KEY } from "@/constants/server-envs";
|
import { DASHBOARD_THIRDWEB_SECRET_KEY } from "@/constants/server-envs";
|
||||||
import { getAuthToken } from "app/(app)/api/lib/getAuthToken";
|
import type { Address } from "thirdweb";
|
||||||
import type { Route } from "./types/route";
|
import type { Route } from "./types/route";
|
||||||
|
|
||||||
export async function getRoutes({
|
export async function getRoutes({
|
||||||
limit,
|
limit,
|
||||||
|
offset,
|
||||||
|
originQuery,
|
||||||
|
destinationQuery,
|
||||||
|
originChainId,
|
||||||
|
destinationChainId,
|
||||||
|
originTokenAddress,
|
||||||
|
destinationTokenAddress,
|
||||||
}: {
|
}: {
|
||||||
limit?: number;
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
originQuery?: string;
|
||||||
|
destinationQuery?: string;
|
||||||
|
originChainId?: number;
|
||||||
|
destinationChainId?: number;
|
||||||
|
originTokenAddress?: Address;
|
||||||
|
destinationTokenAddress?: Address;
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const url = new URL(`${NEXT_PUBLIC_THIRDWEB_BRIDGE_HOST}/v1/routes`);
|
const url = new URL(`${NEXT_PUBLIC_THIRDWEB_BRIDGE_HOST}/v1/routes`);
|
||||||
if (limit) {
|
if (limit) {
|
||||||
url.searchParams.set("limit", limit.toString());
|
url.searchParams.set("limit", limit.toString());
|
||||||
}
|
}
|
||||||
|
if (offset) {
|
||||||
|
url.searchParams.set("offset", offset.toString());
|
||||||
|
}
|
||||||
|
if (originQuery) {
|
||||||
|
url.searchParams.set("originQuery", originQuery);
|
||||||
|
}
|
||||||
|
if (destinationQuery) {
|
||||||
|
url.searchParams.set("destinationQuery", destinationQuery);
|
||||||
|
}
|
||||||
|
if (originChainId) {
|
||||||
|
url.searchParams.set("originChainId", originChainId.toString());
|
||||||
|
}
|
||||||
|
if (destinationChainId) {
|
||||||
|
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
||||||
|
}
|
||||||
|
if (originTokenAddress) {
|
||||||
|
url.searchParams.set("originTokenAddress", originTokenAddress);
|
||||||
|
}
|
||||||
|
if (destinationTokenAddress) {
|
||||||
|
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
||||||
|
}
|
||||||
|
url.searchParams.set("sortBy", "popularity");
|
||||||
// It's faster to filter client side, doesn't seem to be a big performance boost to paginate/filter server side
|
// It's faster to filter client side, doesn't seem to be a big performance boost to paginate/filter server side
|
||||||
const token = await getAuthToken();
|
|
||||||
const routesResponse = await fetch(url, {
|
const routesResponse = await fetch(url, {
|
||||||
headers: token
|
headers: {
|
||||||
? {
|
"x-secret-key": DASHBOARD_THIRDWEB_SECRET_KEY,
|
||||||
authorization: `Bearer ${token}`,
|
},
|
||||||
}
|
|
||||||
: {
|
|
||||||
"x-secret-key": DASHBOARD_THIRDWEB_SECRET_KEY,
|
|
||||||
},
|
|
||||||
next: { revalidate: 60 * 60 },
|
next: { revalidate: 60 * 60 },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!routesResponse.ok) {
|
if (!routesResponse.ok) {
|
||||||
throw new Error("Failed to fetch routes");
|
throw new Error("Failed to fetch routes");
|
||||||
}
|
}
|
||||||
const routes: { data: Route[] } = await routesResponse.json();
|
const routes: {
|
||||||
|
data: Route[];
|
||||||
|
meta: { totalCount: number; filteredCount: number };
|
||||||
|
} = await routesResponse.json();
|
||||||
|
|
||||||
return routes.data;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -23,7 +23,6 @@ import {
|
|||||||
NEXT_PUBLIC_THIRDWEB_ENGINE_FAUCET_WALLET,
|
NEXT_PUBLIC_THIRDWEB_ENGINE_FAUCET_WALLET,
|
||||||
NEXT_PUBLIC_TURNSTILE_SITE_KEY,
|
NEXT_PUBLIC_TURNSTILE_SITE_KEY,
|
||||||
} from "@/constants/public-envs";
|
} from "@/constants/public-envs";
|
||||||
import { useThirdwebClient } from "@/constants/thirdweb.client";
|
|
||||||
import { CustomConnectWallet } from "@3rdweb-sdk/react/components/connect-wallet";
|
import { CustomConnectWallet } from "@3rdweb-sdk/react/components/connect-wallet";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { Turnstile } from "@marsidev/react-turnstile";
|
import { Turnstile } from "@marsidev/react-turnstile";
|
||||||
@@ -77,13 +76,14 @@ export function FaucetButton({
|
|||||||
chain,
|
chain,
|
||||||
amount,
|
amount,
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
|
client,
|
||||||
}: {
|
}: {
|
||||||
chain: ChainMetadata;
|
chain: ChainMetadata;
|
||||||
amount: number;
|
amount: number;
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
|
client: ThirdwebClient;
|
||||||
}) {
|
}) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const client = useThirdwebClient();
|
|
||||||
const address = useActiveAccount()?.address;
|
const address = useActiveAccount()?.address;
|
||||||
const chainId = chain.chainId;
|
const chainId = chain.chainId;
|
||||||
// do not include local overrides for chain pages
|
// do not include local overrides for chain pages
|
||||||
@@ -407,6 +407,7 @@ function SendFundsToFaucetModalContent(props: {
|
|||||||
isLoggedIn={props.isLoggedIn}
|
isLoggedIn={props.isLoggedIn}
|
||||||
connectButtonClassName="!w-full"
|
connectButtonClassName="!w-full"
|
||||||
detailsButtonClassName="!w-full"
|
detailsButtonClassName="!w-full"
|
||||||
|
client={props.client}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
+7
-4
@@ -1,16 +1,19 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
|
||||||
import { useThirdwebClient } from "@/constants/thirdweb.client";
|
|
||||||
import { useTrack } from "hooks/analytics/useTrack";
|
import { useTrack } from "hooks/analytics/useTrack";
|
||||||
import { defineDashboardChain } from "lib/defineDashboardChain";
|
import { defineDashboardChain } from "lib/defineDashboardChain";
|
||||||
import { useTheme } from "next-themes";
|
import { useTheme } from "next-themes";
|
||||||
|
import type { ThirdwebClient } from "thirdweb";
|
||||||
import { PayEmbed } from "thirdweb/react";
|
import { PayEmbed } from "thirdweb/react";
|
||||||
import { getSDKTheme } from "../../../../../../components/sdk-component-theme";
|
import { getSDKTheme } from "../../../../../../components/sdk-component-theme";
|
||||||
|
|
||||||
export function PayModalButton(props: { chainId: number; label: string }) {
|
export function PayModalButton(props: {
|
||||||
|
chainId: number;
|
||||||
|
label: string;
|
||||||
|
client: ThirdwebClient;
|
||||||
|
}) {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
const client = useThirdwebClient();
|
|
||||||
const trackEvent = useTrack();
|
const trackEvent = useTrack();
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog>
|
||||||
@@ -35,7 +38,7 @@ export function PayModalButton(props: { chainId: number; label: string }) {
|
|||||||
dialogCloseClassName="focus:ring-0"
|
dialogCloseClassName="focus:ring-0"
|
||||||
>
|
>
|
||||||
<PayEmbed
|
<PayEmbed
|
||||||
client={client}
|
client={props.client}
|
||||||
theme={getSDKTheme(theme === "dark" ? "dark" : "light")}
|
theme={getSDKTheme(theme === "dark" ? "dark" : "light")}
|
||||||
className="!w-auto"
|
className="!w-auto"
|
||||||
payOptions={{
|
payOptions={{
|
||||||
|
|||||||
+6
-2
@@ -6,7 +6,7 @@ import { ToolTipLabel } from "@/components/ui/tooltip";
|
|||||||
import { useCustomConnectModal } from "@3rdweb-sdk/react/components/connect-wallet";
|
import { useCustomConnectModal } from "@3rdweb-sdk/react/components/connect-wallet";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import type { Chain } from "thirdweb";
|
import type { Chain, ThirdwebClient } from "thirdweb";
|
||||||
import {
|
import {
|
||||||
useActiveAccount,
|
useActiveAccount,
|
||||||
useActiveWalletChain,
|
useActiveWalletChain,
|
||||||
@@ -16,6 +16,7 @@ import { useDebounce } from "use-debounce";
|
|||||||
|
|
||||||
type AddChainToWalletProps = {
|
type AddChainToWalletProps = {
|
||||||
chain: Chain;
|
chain: Chain;
|
||||||
|
client: ThirdwebClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AddChainToWallet: React.FC<AddChainToWalletProps> = (props) => {
|
export const AddChainToWallet: React.FC<AddChainToWalletProps> = (props) => {
|
||||||
@@ -49,7 +50,10 @@ export const AddChainToWallet: React.FC<AddChainToWalletProps> = (props) => {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
// Connect directly to this chain
|
// Connect directly to this chain
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return customConnectModal({ chain: props.chain });
|
return customConnectModal({
|
||||||
|
chain: props.chain,
|
||||||
|
client: props.client,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// switch to this chain
|
// switch to this chain
|
||||||
|
|||||||
+23
-5
@@ -4,7 +4,7 @@ import { CopyTextButton } from "@/components/ui/CopyTextButton";
|
|||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { ToolTipLabel } from "@/components/ui/tooltip";
|
import { ToolTipLabel } from "@/components/ui/tooltip";
|
||||||
import { isProd } from "@/constants/env-utils";
|
import { isProd } from "@/constants/env-utils";
|
||||||
import { NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID } from "@/constants/public-envs";
|
import { NEXT_PUBLIC_DASHBOARD_CLIENT_ID } from "@/constants/public-envs";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { CircleCheckIcon, XIcon } from "lucide-react";
|
import { CircleCheckIcon, XIcon } from "lucide-react";
|
||||||
import { hostnameEndsWith } from "utils/url";
|
import { hostnameEndsWith } from "utils/url";
|
||||||
@@ -14,7 +14,7 @@ function useChainStatswithRPC(_rpcUrl: string) {
|
|||||||
let rpcUrl = _rpcUrl.replace(
|
let rpcUrl = _rpcUrl.replace(
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
"${THIRDWEB_API_KEY}",
|
"${THIRDWEB_API_KEY}",
|
||||||
NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||||
);
|
);
|
||||||
|
|
||||||
// based on the environment hit dev or production
|
// based on the environment hit dev or production
|
||||||
@@ -32,8 +32,8 @@ function useChainStatswithRPC(_rpcUrl: string) {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
jsonrpc: "2.0",
|
jsonrpc: "2.0",
|
||||||
method: "eth_blockNumber",
|
method: "eth_getBlockByNumber",
|
||||||
params: [],
|
params: ["latest", false],
|
||||||
id: 1,
|
id: 1,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
@@ -41,9 +41,12 @@ function useChainStatswithRPC(_rpcUrl: string) {
|
|||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
const latency = (performance.now() - startTimeStamp).toFixed(0);
|
const latency = (performance.now() - startTimeStamp).toFixed(0);
|
||||||
|
|
||||||
|
const blockNumber = Number.parseInt(json.result.number, 16);
|
||||||
|
const blockGasLimit = Number.parseInt(json.result.gasLimit, 16);
|
||||||
return {
|
return {
|
||||||
latency,
|
latency,
|
||||||
blockNumber: Number.parseInt(json.result, 16),
|
blockNumber,
|
||||||
|
blockGasLimit,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
refetchInterval: (query) => {
|
refetchInterval: (query) => {
|
||||||
@@ -115,6 +118,21 @@ export function ChainLiveStats(props: { rpc: string }) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</PrimaryInfoItem>
|
</PrimaryInfoItem>
|
||||||
|
|
||||||
|
{/* Block Gas Limit */}
|
||||||
|
<PrimaryInfoItem title="Block Gas Limit" titleIcon={<PulseDot />}>
|
||||||
|
{stats.isError ? (
|
||||||
|
<p className="fade-in-0 animate-in text-destructive-text">N/A</p>
|
||||||
|
) : stats.data ? (
|
||||||
|
<p className="fade-in-0 animate-in">
|
||||||
|
{stats.data.blockGasLimit ?? "N/A"}
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<div className="flex h-[28px] w-[140px] py-1">
|
||||||
|
<Skeleton className="h-full w-full" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</PrimaryInfoItem>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -1,5 +1,6 @@
|
|||||||
import { ExternalLinkIcon } from "lucide-react";
|
import { ExternalLinkIcon } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import type { ThirdwebClient } from "thirdweb";
|
||||||
import type { ChainMetadata } from "thirdweb/chains";
|
import type { ChainMetadata } from "thirdweb/chains";
|
||||||
import { ChainIcon } from "../../../../components/server/chain-icon";
|
import { ChainIcon } from "../../../../components/server/chain-icon";
|
||||||
import { PayModalButton } from "../client/PayModal";
|
import { PayModalButton } from "../client/PayModal";
|
||||||
@@ -8,6 +9,7 @@ import { SectionTitle } from "./SectionTitle";
|
|||||||
|
|
||||||
export function BuyFundsSection(props: {
|
export function BuyFundsSection(props: {
|
||||||
chain: ChainMetadata;
|
chain: ChainMetadata;
|
||||||
|
client: ThirdwebClient;
|
||||||
}) {
|
}) {
|
||||||
const sanitizedChainName = props.chain.name.replace("Mainnet", "").trim();
|
const sanitizedChainName = props.chain.name.replace("Mainnet", "").trim();
|
||||||
|
|
||||||
@@ -45,6 +47,7 @@ export function BuyFundsSection(props: {
|
|||||||
<PayModalButton
|
<PayModalButton
|
||||||
chainId={props.chain.chainId}
|
chainId={props.chain.chainId}
|
||||||
label={`Bridge to ${sanitizedChainName}`}
|
label={`Bridge to ${sanitizedChainName}`}
|
||||||
|
client={props.client}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="h-4" />
|
<div className="h-4" />
|
||||||
|
|||||||
+4
-1
@@ -1,3 +1,4 @@
|
|||||||
|
import type { ThirdwebClient } from "thirdweb";
|
||||||
import type { ChainMetadata } from "thirdweb/chains";
|
import type { ChainMetadata } from "thirdweb/chains";
|
||||||
import { getFaucetClaimAmount } from "../../../../../../api/testnet-faucet/claim/claim-amount";
|
import { getFaucetClaimAmount } from "../../../../../../api/testnet-faucet/claim/claim-amount";
|
||||||
import { ChainIcon } from "../../../../components/server/chain-icon";
|
import { ChainIcon } from "../../../../components/server/chain-icon";
|
||||||
@@ -8,8 +9,9 @@ import { SectionTitle } from "./SectionTitle";
|
|||||||
export async function FaucetSection(props: {
|
export async function FaucetSection(props: {
|
||||||
chain: ChainMetadata;
|
chain: ChainMetadata;
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
|
client: ThirdwebClient;
|
||||||
}) {
|
}) {
|
||||||
const { chain, isLoggedIn } = props;
|
const { chain, isLoggedIn, client } = props;
|
||||||
|
|
||||||
// Check eligibility.
|
// Check eligibility.
|
||||||
const sanitizedChainName = chain.name.replace("Mainnet", "").trim();
|
const sanitizedChainName = chain.name.replace("Mainnet", "").trim();
|
||||||
@@ -44,6 +46,7 @@ export async function FaucetSection(props: {
|
|||||||
<div className="h-8" />
|
<div className="h-8" />
|
||||||
|
|
||||||
<FaucetButton
|
<FaucetButton
|
||||||
|
client={client}
|
||||||
chain={chain}
|
chain={chain}
|
||||||
amount={amountToGive}
|
amount={amountToGive}
|
||||||
isLoggedIn={isLoggedIn}
|
isLoggedIn={isLoggedIn}
|
||||||
|
|||||||
+3
@@ -1,6 +1,7 @@
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import type { ThirdwebClient } from "thirdweb";
|
||||||
import type { ChainMetadata } from "thirdweb/chains";
|
import type { ChainMetadata } from "thirdweb/chains";
|
||||||
import { mapV4ChainToV5Chain } from "../../../../../../../../contexts/map-chains";
|
import { mapV4ChainToV5Chain } from "../../../../../../../../contexts/map-chains";
|
||||||
import { ChainIcon } from "../../../../components/server/chain-icon";
|
import { ChainIcon } from "../../../../components/server/chain-icon";
|
||||||
@@ -10,6 +11,7 @@ type ChainHeaderProps = {
|
|||||||
headerImageUrl?: string;
|
headerImageUrl?: string;
|
||||||
logoUrl?: string;
|
logoUrl?: string;
|
||||||
chain: ChainMetadata;
|
chain: ChainMetadata;
|
||||||
|
client: ThirdwebClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: improve the behavior when clicking "Get started with thirdweb", currently just redirects to the dashboard
|
// TODO: improve the behavior when clicking "Get started with thirdweb", currently just redirects to the dashboard
|
||||||
@@ -51,6 +53,7 @@ export function ChainHeader(props: ChainHeaderProps) {
|
|||||||
{/* Desktop only */}
|
{/* Desktop only */}
|
||||||
<div className="hidden flex-row gap-2 lg:flex">
|
<div className="hidden flex-row gap-2 lg:flex">
|
||||||
<AddChainToWallet
|
<AddChainToWallet
|
||||||
|
client={props.client}
|
||||||
chain={
|
chain={
|
||||||
// Do not include chain overrides for chain pages
|
// Do not include chain overrides for chain pages
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
getAuthToken,
|
getAuthToken,
|
||||||
getAuthTokenWalletAddress,
|
getAuthTokenWalletAddress,
|
||||||
} from "../../../../api/lib/getAuthToken";
|
} from "../../../../api/lib/getAuthToken";
|
||||||
|
import { TeamHeader } from "../../../../team/components/TeamHeader/team-header";
|
||||||
import { StarButton } from "../../components/client/star-button";
|
import { StarButton } from "../../components/client/star-button";
|
||||||
import { getChain, getChainMetadata } from "../../utils";
|
import { getChain, getChainMetadata } from "../../utils";
|
||||||
import { AddChainToWallet } from "./components/client/add-chain-to-wallet";
|
import { AddChainToWallet } from "./components/client/add-chain-to-wallet";
|
||||||
@@ -95,7 +96,10 @@ The following is the user's message:
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="flex grow flex-col">
|
||||||
|
<div className="border-border border-b bg-card">
|
||||||
|
<TeamHeader />
|
||||||
|
</div>
|
||||||
<NebulaChatButton
|
<NebulaChatButton
|
||||||
isLoggedIn={!!authToken}
|
isLoggedIn={!!authToken}
|
||||||
networks={chain.testnet ? "testnet" : "mainnet"}
|
networks={chain.testnet ? "testnet" : "mainnet"}
|
||||||
@@ -160,6 +164,7 @@ The following is the user's message:
|
|||||||
headerImageUrl={chainMetadata?.headerImgUrl}
|
headerImageUrl={chainMetadata?.headerImgUrl}
|
||||||
logoUrl={chain.icon?.url}
|
logoUrl={chain.icon?.url}
|
||||||
chain={chain}
|
chain={chain}
|
||||||
|
client={client}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="h-4 md:h-8" />
|
<div className="h-4 md:h-8" />
|
||||||
@@ -206,6 +211,7 @@ The following is the user's message:
|
|||||||
<div className="w-full sm:hidden">
|
<div className="w-full sm:hidden">
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<AddChainToWallet
|
<AddChainToWallet
|
||||||
|
client={client}
|
||||||
chain={
|
chain={
|
||||||
// Do not include chain overrides for chain pages
|
// Do not include chain overrides for chain pages
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
@@ -225,7 +231,7 @@ The following is the user's message:
|
|||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
|
import { serverThirdwebClient } from "@/constants/thirdweb-client.server";
|
||||||
import { ImageResponse } from "next/og";
|
import { ImageResponse } from "next/og";
|
||||||
import { download } from "thirdweb/storage";
|
import { download } from "thirdweb/storage";
|
||||||
import { fetchChain } from "utils/fetchChain";
|
import { fetchChain } from "utils/fetchChain";
|
||||||
import { serverThirdwebClient } from "../../../../../../@/constants/thirdweb-client.server";
|
|
||||||
|
|
||||||
// Route segment config
|
// Route segment config
|
||||||
export const runtime = "edge";
|
export const runtime = "edge";
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
|
||||||
import { CircleAlertIcon } from "lucide-react";
|
import { CircleAlertIcon } from "lucide-react";
|
||||||
import { getRawAccount } from "../../../../account/settings/getAccount";
|
import { getRawAccount } from "../../../../account/settings/getAccount";
|
||||||
import { getChain, getChainMetadata } from "../../utils";
|
import { getChain, getChainMetadata } from "../../utils";
|
||||||
@@ -16,6 +17,7 @@ export default async function Page(props: {
|
|||||||
const params = await props.params;
|
const params = await props.params;
|
||||||
const chain = await getChain(params.chain_id);
|
const chain = await getChain(params.chain_id);
|
||||||
const chainMetadata = await getChainMetadata(chain.chainId);
|
const chainMetadata = await getChainMetadata(chain.chainId);
|
||||||
|
const client = getClientThirdwebClient();
|
||||||
const isDeprecated = chain.status === "deprecated";
|
const isDeprecated = chain.status === "deprecated";
|
||||||
|
|
||||||
const account = await getRawAccount();
|
const account = await getRawAccount();
|
||||||
@@ -42,9 +44,9 @@ export default async function Page(props: {
|
|||||||
|
|
||||||
{/* Faucet / Buy Funds */}
|
{/* Faucet / Buy Funds */}
|
||||||
{chain.testnet ? (
|
{chain.testnet ? (
|
||||||
<FaucetSection chain={chain} isLoggedIn={!!account} />
|
<FaucetSection chain={chain} isLoggedIn={!!account} client={client} />
|
||||||
) : chain.services.find((c) => c.service === "pay" && c.enabled) ? (
|
) : chain.services.find((c) => c.service === "pay" && c.enabled) ? (
|
||||||
<BuyFundsSection chain={chain} />
|
<BuyFundsSection chain={chain} client={client} />
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{/* Chain Overview */}
|
{/* Chain Overview */}
|
||||||
|
|||||||
+1
@@ -30,6 +30,7 @@ export const CancelTab: React.FC<CancelTabProps> = ({
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3 pt-3">
|
<div className="flex flex-col gap-3 pt-3">
|
||||||
<TransactionButton
|
<TransactionButton
|
||||||
|
client={contract.client}
|
||||||
isLoggedIn={isLoggedIn}
|
isLoggedIn={isLoggedIn}
|
||||||
txChainID={contract.chain.id}
|
txChainID={contract.chain.id}
|
||||||
transactionCount={1}
|
transactionCount={1}
|
||||||
|
|||||||
+3
@@ -485,6 +485,7 @@ export const CreateListingsForm: React.FC<CreateListingsFormProps> = ({
|
|||||||
>
|
>
|
||||||
<FormLabel>Contract address</FormLabel>
|
<FormLabel>Contract address</FormLabel>
|
||||||
<SolidityInput
|
<SolidityInput
|
||||||
|
client={contract.client}
|
||||||
solidityType="address"
|
solidityType="address"
|
||||||
formContext={form}
|
formContext={form}
|
||||||
{...form.register("selected.contractAddress", {
|
{...form.register("selected.contractAddress", {
|
||||||
@@ -558,6 +559,7 @@ export const CreateListingsForm: React.FC<CreateListingsFormProps> = ({
|
|||||||
width="140px"
|
width="140px"
|
||||||
height="140px"
|
height="140px"
|
||||||
requireInteraction
|
requireInteraction
|
||||||
|
client={contract.client}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -658,6 +660,7 @@ export const CreateListingsForm: React.FC<CreateListingsFormProps> = ({
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<TransactionButton
|
<TransactionButton
|
||||||
|
client={contract.client}
|
||||||
isLoggedIn={isLoggedIn}
|
isLoggedIn={isLoggedIn}
|
||||||
txChainID={contract.chain.id}
|
txChainID={contract.chain.id}
|
||||||
isPending={isFormLoading}
|
isPending={isFormLoading}
|
||||||
|
|||||||
+5
-1
@@ -51,6 +51,7 @@ export const ListingDrawer: React.FC<NFTDrawerProps> = ({
|
|||||||
<div className="flex flex-row gap-6">
|
<div className="flex flex-row gap-6">
|
||||||
<NFTMediaWithEmptyState
|
<NFTMediaWithEmptyState
|
||||||
metadata={renderData.asset.metadata}
|
metadata={renderData.asset.metadata}
|
||||||
|
client={contract.client}
|
||||||
requireInteraction
|
requireInteraction
|
||||||
width="150px"
|
width="150px"
|
||||||
height="150px"
|
height="150px"
|
||||||
@@ -92,7 +93,10 @@ export const ListingDrawer: React.FC<NFTDrawerProps> = ({
|
|||||||
<p className="font-bold">Seller</p>
|
<p className="font-bold">Seller</p>
|
||||||
</GridItem>
|
</GridItem>
|
||||||
<GridItem colSpan={9}>
|
<GridItem colSpan={9}>
|
||||||
<WalletAddress address={renderData.creatorAddress} />
|
<WalletAddress
|
||||||
|
address={renderData.creatorAddress}
|
||||||
|
client={contract.client}
|
||||||
|
/>
|
||||||
</GridItem>
|
</GridItem>
|
||||||
<GridItem colSpan={3}>
|
<GridItem colSpan={3}>
|
||||||
<p className="font-bold">Listing ID</p>
|
<p className="font-bold">Listing ID</p>
|
||||||
|
|||||||
+46
-44
@@ -40,49 +40,6 @@ import { min } from "thirdweb/utils";
|
|||||||
import { ListingDrawer } from "./listing-drawer";
|
import { ListingDrawer } from "./listing-drawer";
|
||||||
import { LISTING_STATUS } from "./types";
|
import { LISTING_STATUS } from "./types";
|
||||||
|
|
||||||
const tableColumns: Column<DirectListing | EnglishAuction>[] = [
|
|
||||||
{
|
|
||||||
Header: "Listing Id",
|
|
||||||
accessor: (row) => row.id.toString(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Header: "Media",
|
|
||||||
accessor: (row) => row.asset.metadata,
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: FIXME
|
|
||||||
Cell: (cell: any) => <MediaCell cell={cell} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Header: "Name",
|
|
||||||
accessor: (row) => row.asset.metadata.name ?? "N/A",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Header: "Creator",
|
|
||||||
accessor: (row) => row.creatorAddress,
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: FIXME
|
|
||||||
Cell: ({ cell }: { cell: Cell<any, string> }) => (
|
|
||||||
<WalletAddress address={cell.value} />
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Header: "Price",
|
|
||||||
accessor: (row) =>
|
|
||||||
(row as DirectListing)?.currencyValuePerToken ||
|
|
||||||
(row as EnglishAuction)?.buyoutCurrencyValue,
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: FIXME
|
|
||||||
Cell: ({ cell }: { cell: Cell<any, any> }) => {
|
|
||||||
return (
|
|
||||||
<p className="whitespace-nowrap text-muted-foreground">
|
|
||||||
{cell.value.displayValue} {cell.value.symbol}
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Header: "Status",
|
|
||||||
accessor: (row) => LISTING_STATUS[row.status],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
interface MarketplaceTableProps {
|
interface MarketplaceTableProps {
|
||||||
contract: ThirdwebContract;
|
contract: ThirdwebContract;
|
||||||
getAllQueryResult: UseQueryResult<DirectListing[] | EnglishAuction[]>;
|
getAllQueryResult: UseQueryResult<DirectListing[] | EnglishAuction[]>;
|
||||||
@@ -132,6 +89,51 @@ export const MarketplaceTable: React.FC<MarketplaceTableProps> = ({
|
|||||||
return getValidQueryResult?.data || prevData;
|
return getValidQueryResult?.data || prevData;
|
||||||
}, [getAllQueryResult, getValidQueryResult, listingsToShow, prevData]);
|
}, [getAllQueryResult, getValidQueryResult, listingsToShow, prevData]);
|
||||||
|
|
||||||
|
const tableColumns: Column<DirectListing | EnglishAuction>[] = useMemo(() => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
Header: "Listing Id",
|
||||||
|
accessor: (row) => row.id.toString(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Header: "Media",
|
||||||
|
accessor: (row) => row.asset.metadata,
|
||||||
|
// biome-ignore lint/suspicious/noExplicitAny: FIXME
|
||||||
|
Cell: (cell: any) => <MediaCell cell={cell} client={contract.client} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Header: "Name",
|
||||||
|
accessor: (row) => row.asset.metadata.name ?? "N/A",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Header: "Creator",
|
||||||
|
accessor: (row) => row.creatorAddress,
|
||||||
|
// biome-ignore lint/suspicious/noExplicitAny: FIXME
|
||||||
|
Cell: ({ cell }: { cell: Cell<any, string> }) => (
|
||||||
|
<WalletAddress address={cell.value} client={contract.client} />
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Header: "Price",
|
||||||
|
accessor: (row) =>
|
||||||
|
(row as DirectListing)?.currencyValuePerToken ||
|
||||||
|
(row as EnglishAuction)?.buyoutCurrencyValue,
|
||||||
|
// biome-ignore lint/suspicious/noExplicitAny: FIXME
|
||||||
|
Cell: ({ cell }: { cell: Cell<any, any> }) => {
|
||||||
|
return (
|
||||||
|
<p className="whitespace-nowrap text-muted-foreground">
|
||||||
|
{cell.value.displayValue} {cell.value.symbol}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Header: "Status",
|
||||||
|
accessor: (row) => LISTING_STATUS[row.status],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}, [contract.client]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
getTableProps,
|
getTableProps,
|
||||||
getTableBodyProps,
|
getTableBodyProps,
|
||||||
@@ -235,7 +237,7 @@ export const MarketplaceTable: React.FC<MarketplaceTableProps> = ({
|
|||||||
</Th>
|
</Th>
|
||||||
))}
|
))}
|
||||||
{/* // Need to add an empty header for the drawer button */}
|
{/* // Need to add an empty header for the drawer button */}
|
||||||
<Th border="none" />
|
<Th border="none" key="drawer" />
|
||||||
</Tr>
|
</Tr>
|
||||||
))}
|
))}
|
||||||
</Thead>
|
</Thead>
|
||||||
|
|||||||
+8
-1
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import type { ThirdwebContract } from "thirdweb";
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
|
import type { ProjectMeta } from "../../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
import { ErrorPage, LoadingPage } from "../../_components/page-skeletons";
|
import { ErrorPage, LoadingPage } from "../../_components/page-skeletons";
|
||||||
import { RedirectToContractOverview } from "../../_components/redirect-contract-overview.client";
|
import { RedirectToContractOverview } from "../../_components/redirect-contract-overview.client";
|
||||||
import { useContractPageMetadata } from "../../_hooks/useContractPageMetadata";
|
import { useContractPageMetadata } from "../../_hooks/useContractPageMetadata";
|
||||||
@@ -9,6 +10,7 @@ import { ContractDirectListingsPage } from "./ContractDirectListingsPage";
|
|||||||
export function ContractDirectListingsPageClient(props: {
|
export function ContractDirectListingsPageClient(props: {
|
||||||
contract: ThirdwebContract;
|
contract: ThirdwebContract;
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
}) {
|
}) {
|
||||||
const metadataQuery = useContractPageMetadata(props.contract);
|
const metadataQuery = useContractPageMetadata(props.contract);
|
||||||
|
|
||||||
@@ -21,7 +23,12 @@ export function ContractDirectListingsPageClient(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!metadataQuery.data.isDirectListingSupported) {
|
if (!metadataQuery.data.isDirectListingSupported) {
|
||||||
return <RedirectToContractOverview contract={props.contract} />;
|
return (
|
||||||
|
<RedirectToContractOverview
|
||||||
|
contract={props.contract}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+8
-35
@@ -1,45 +1,18 @@
|
|||||||
import { notFound, redirect } from "next/navigation";
|
|
||||||
import { getRawAccount } from "../../../../../../account/settings/getAccount";
|
import { getRawAccount } from "../../../../../../account/settings/getAccount";
|
||||||
import { getContractPageParamsInfo } from "../../_utils/getContractFromParams";
|
import type { PublicContractPageParams } from "../../types";
|
||||||
import { getContractPageMetadata } from "../../_utils/getContractPageMetadata";
|
import { SharedDirectListingsPage } from "./shared-direct-listings-page";
|
||||||
import { ContractDirectListingsPage } from "./ContractDirectListingsPage";
|
|
||||||
import { ContractDirectListingsPageClient } from "./ContractDirectListingsPage.client";
|
|
||||||
|
|
||||||
export default async function Page(props: {
|
export default async function Page(props: {
|
||||||
params: Promise<{
|
params: Promise<PublicContractPageParams>;
|
||||||
contractAddress: string;
|
|
||||||
chain_id: string;
|
|
||||||
}>;
|
|
||||||
}) {
|
}) {
|
||||||
const params = await props.params;
|
const [params, account] = await Promise.all([props.params, getRawAccount()]);
|
||||||
const account = await getRawAccount();
|
|
||||||
const info = await getContractPageParamsInfo(params);
|
|
||||||
|
|
||||||
if (!info) {
|
|
||||||
notFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info.isLocalhostChain) {
|
|
||||||
return (
|
|
||||||
<ContractDirectListingsPageClient
|
|
||||||
contract={info.clientContract}
|
|
||||||
isLoggedIn={!!account}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { isDirectListingSupported, isInsightSupported } =
|
|
||||||
await getContractPageMetadata(info.serverContract);
|
|
||||||
|
|
||||||
if (!isDirectListingSupported) {
|
|
||||||
redirect(`/${params.chain_id}/${params.contractAddress}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContractDirectListingsPage
|
<SharedDirectListingsPage
|
||||||
contract={info.clientContract}
|
contractAddress={params.contractAddress}
|
||||||
|
chainIdOrSlug={params.chain_id}
|
||||||
|
projectMeta={undefined}
|
||||||
isLoggedIn={!!account}
|
isLoggedIn={!!account}
|
||||||
isInsightSupported={isInsightSupported}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
import { notFound } from "next/navigation";
|
||||||
|
import type { ProjectMeta } from "../../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
|
import { redirectToContractLandingPage } from "../../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||||
|
import { getContractPageParamsInfo } from "../../_utils/getContractFromParams";
|
||||||
|
import { getContractPageMetadata } from "../../_utils/getContractPageMetadata";
|
||||||
|
import { ContractDirectListingsPage } from "./ContractDirectListingsPage";
|
||||||
|
import { ContractDirectListingsPageClient } from "./ContractDirectListingsPage.client";
|
||||||
|
|
||||||
|
export async function SharedDirectListingsPage(props: {
|
||||||
|
contractAddress: string;
|
||||||
|
chainIdOrSlug: string;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
|
isLoggedIn: boolean;
|
||||||
|
}) {
|
||||||
|
const info = await getContractPageParamsInfo({
|
||||||
|
contractAddress: props.contractAddress,
|
||||||
|
chainIdOrSlug: props.chainIdOrSlug,
|
||||||
|
teamId: props.projectMeta?.teamId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!info) {
|
||||||
|
notFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.isLocalhostChain) {
|
||||||
|
return (
|
||||||
|
<ContractDirectListingsPageClient
|
||||||
|
contract={info.clientContract}
|
||||||
|
isLoggedIn={props.isLoggedIn}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { isDirectListingSupported, isInsightSupported } =
|
||||||
|
await getContractPageMetadata(info.serverContract);
|
||||||
|
|
||||||
|
if (!isDirectListingSupported) {
|
||||||
|
redirectToContractLandingPage({
|
||||||
|
chainIdOrSlug: props.chainIdOrSlug,
|
||||||
|
contractAddress: props.contractAddress,
|
||||||
|
projectMeta: props.projectMeta,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ContractDirectListingsPage
|
||||||
|
contract={info.clientContract}
|
||||||
|
isLoggedIn={props.isLoggedIn}
|
||||||
|
isInsightSupported={isInsightSupported}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
+8
-1
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import type { ThirdwebContract } from "thirdweb";
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
|
import type { ProjectMeta } from "../../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
import { ErrorPage, LoadingPage } from "../../_components/page-skeletons";
|
import { ErrorPage, LoadingPage } from "../../_components/page-skeletons";
|
||||||
import { RedirectToContractOverview } from "../../_components/redirect-contract-overview.client";
|
import { RedirectToContractOverview } from "../../_components/redirect-contract-overview.client";
|
||||||
import { useContractPageMetadata } from "../../_hooks/useContractPageMetadata";
|
import { useContractPageMetadata } from "../../_hooks/useContractPageMetadata";
|
||||||
@@ -9,6 +10,7 @@ import { ContractEnglishAuctionsPage } from "./ContractEnglishAuctionsPage";
|
|||||||
export function ContractEnglishAuctionsPageClient(props: {
|
export function ContractEnglishAuctionsPageClient(props: {
|
||||||
contract: ThirdwebContract;
|
contract: ThirdwebContract;
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
}) {
|
}) {
|
||||||
const metadataQuery = useContractPageMetadata(props.contract);
|
const metadataQuery = useContractPageMetadata(props.contract);
|
||||||
|
|
||||||
@@ -21,7 +23,12 @@ export function ContractEnglishAuctionsPageClient(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!metadataQuery.data.isEnglishAuctionSupported) {
|
if (!metadataQuery.data.isEnglishAuctionSupported) {
|
||||||
return <RedirectToContractOverview contract={props.contract} />;
|
return (
|
||||||
|
<RedirectToContractOverview
|
||||||
|
contract={props.contract}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-37
@@ -1,46 +1,18 @@
|
|||||||
import { notFound, redirect } from "next/navigation";
|
|
||||||
import { getRawAccount } from "../../../../../../account/settings/getAccount";
|
import { getRawAccount } from "../../../../../../account/settings/getAccount";
|
||||||
import { getContractPageParamsInfo } from "../../_utils/getContractFromParams";
|
import type { PublicContractPageParams } from "../../types";
|
||||||
import { getContractPageMetadata } from "../../_utils/getContractPageMetadata";
|
import { SharedEnglishAuctionsPage } from "./shared-english-auctions-page";
|
||||||
import { ContractEnglishAuctionsPage } from "./ContractEnglishAuctionsPage";
|
|
||||||
import { ContractEnglishAuctionsPageClient } from "./ContractEnglishAuctionsPage.client";
|
|
||||||
|
|
||||||
export default async function Page(props: {
|
export default async function Page(props: {
|
||||||
params: Promise<{
|
params: Promise<PublicContractPageParams>;
|
||||||
contractAddress: string;
|
|
||||||
chain_id: string;
|
|
||||||
}>;
|
|
||||||
}) {
|
}) {
|
||||||
const params = await props.params;
|
const [params, account] = await Promise.all([props.params, getRawAccount()]);
|
||||||
const info = await getContractPageParamsInfo(params);
|
|
||||||
|
|
||||||
if (!info) {
|
|
||||||
notFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
const twAccount = await getRawAccount();
|
|
||||||
|
|
||||||
if (info.isLocalhostChain) {
|
|
||||||
return (
|
|
||||||
<ContractEnglishAuctionsPageClient
|
|
||||||
contract={info.clientContract}
|
|
||||||
isLoggedIn={!!twAccount}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { isEnglishAuctionSupported, isInsightSupported } =
|
|
||||||
await getContractPageMetadata(info.serverContract);
|
|
||||||
|
|
||||||
if (!isEnglishAuctionSupported) {
|
|
||||||
redirect(`/${params.chain_id}/${params.contractAddress}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContractEnglishAuctionsPage
|
<SharedEnglishAuctionsPage
|
||||||
contract={info.clientContract}
|
contractAddress={params.contractAddress}
|
||||||
isLoggedIn={!!twAccount}
|
chainIdOrSlug={params.chain_id}
|
||||||
isInsightSupported={isInsightSupported}
|
projectMeta={undefined}
|
||||||
|
isLoggedIn={!!account}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
import { notFound } from "next/navigation";
|
||||||
|
import type { ProjectMeta } from "../../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
|
import { redirectToContractLandingPage } from "../../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||||
|
import { getContractPageParamsInfo } from "../../_utils/getContractFromParams";
|
||||||
|
import { getContractPageMetadata } from "../../_utils/getContractPageMetadata";
|
||||||
|
import { ContractEnglishAuctionsPage } from "./ContractEnglishAuctionsPage";
|
||||||
|
import { ContractEnglishAuctionsPageClient } from "./ContractEnglishAuctionsPage.client";
|
||||||
|
|
||||||
|
export async function SharedEnglishAuctionsPage(props: {
|
||||||
|
contractAddress: string;
|
||||||
|
chainIdOrSlug: string;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
|
isLoggedIn: boolean;
|
||||||
|
}) {
|
||||||
|
const info = await getContractPageParamsInfo({
|
||||||
|
contractAddress: props.contractAddress,
|
||||||
|
chainIdOrSlug: props.chainIdOrSlug,
|
||||||
|
teamId: props.projectMeta?.teamId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!info) {
|
||||||
|
notFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.isLocalhostChain) {
|
||||||
|
return (
|
||||||
|
<ContractEnglishAuctionsPageClient
|
||||||
|
contract={info.clientContract}
|
||||||
|
isLoggedIn={props.isLoggedIn}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const metadata = await getContractPageMetadata(info.serverContract);
|
||||||
|
|
||||||
|
if (!metadata.isEnglishAuctionSupported) {
|
||||||
|
redirectToContractLandingPage({
|
||||||
|
contractAddress: props.contractAddress,
|
||||||
|
chainIdOrSlug: props.chainIdOrSlug,
|
||||||
|
projectMeta: props.projectMeta,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ContractEnglishAuctionsPage
|
||||||
|
contract={info.clientContract}
|
||||||
|
isLoggedIn={props.isLoggedIn}
|
||||||
|
isInsightSupported={metadata.isInsightSupported}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
+14
-2
@@ -1,8 +1,10 @@
|
|||||||
import { SkeletonContainer } from "@/components/ui/skeleton";
|
import { SkeletonContainer } from "@/components/ui/skeleton";
|
||||||
import { TrackedLinkTW } from "@/components/ui/tracked-link";
|
import { TrackedLinkTW } from "@/components/ui/tracked-link";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { type NFT, ZERO_ADDRESS } from "thirdweb";
|
import { type NFT, type ThirdwebClient, ZERO_ADDRESS } from "thirdweb";
|
||||||
import { NFTMediaWithEmptyState } from "tw-components/nft-media";
|
import { NFTMediaWithEmptyState } from "tw-components/nft-media";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
|
import { buildContractPagePath } from "../_utils/contract-page-path";
|
||||||
|
|
||||||
type NFTWithContract = NFT & { contractAddress: string; chainId: number };
|
type NFTWithContract = NFT & { contractAddress: string; chainId: number };
|
||||||
|
|
||||||
@@ -29,6 +31,8 @@ interface NFTCardsProps {
|
|||||||
trackingCategory: string;
|
trackingCategory: string;
|
||||||
isPending: boolean;
|
isPending: boolean;
|
||||||
allNfts?: boolean;
|
allNfts?: boolean;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
|
client: ThirdwebClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const NFTCards: React.FC<NFTCardsProps> = ({
|
export const NFTCards: React.FC<NFTCardsProps> = ({
|
||||||
@@ -36,6 +40,8 @@ export const NFTCards: React.FC<NFTCardsProps> = ({
|
|||||||
trackingCategory,
|
trackingCategory,
|
||||||
isPending,
|
isPending,
|
||||||
allNfts,
|
allNfts,
|
||||||
|
projectMeta,
|
||||||
|
client,
|
||||||
}) => {
|
}) => {
|
||||||
const dummyData = useMemo(() => {
|
const dummyData = useMemo(() => {
|
||||||
return Array.from({
|
return Array.from({
|
||||||
@@ -69,6 +75,7 @@ export const NFTCards: React.FC<NFTCardsProps> = ({
|
|||||||
requireInteraction
|
requireInteraction
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
|
client={client}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
@@ -87,7 +94,12 @@ export const NFTCards: React.FC<NFTCardsProps> = ({
|
|||||||
<TrackedLinkTW
|
<TrackedLinkTW
|
||||||
category={trackingCategory}
|
category={trackingCategory}
|
||||||
label="view_nft"
|
label="view_nft"
|
||||||
href={`/${token.chainId}/${token.contractAddress}/nfts/${tokenId}`}
|
href={buildContractPagePath({
|
||||||
|
projectMeta,
|
||||||
|
chainIdOrSlug: token.chainId.toString(),
|
||||||
|
contractAddress: token.contractAddress,
|
||||||
|
subpath: `/nfts/${tokenId}`,
|
||||||
|
})}
|
||||||
className="before:absolute before:inset-0"
|
className="before:absolute before:inset-0"
|
||||||
>
|
>
|
||||||
{v.name}
|
{v.name}
|
||||||
|
|||||||
+4
@@ -126,8 +126,10 @@ const getClaimConditionTypeFromPhase = (
|
|||||||
if (!phase.snapshot) {
|
if (!phase.snapshot) {
|
||||||
return "public";
|
return "public";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phase.snapshot) {
|
if (phase.snapshot) {
|
||||||
if (
|
if (
|
||||||
|
phase.price === "0" &&
|
||||||
typeof phase.snapshot !== "string" &&
|
typeof phase.snapshot !== "string" &&
|
||||||
phase.snapshot.length === 1 &&
|
phase.snapshot.length === 1 &&
|
||||||
phase.snapshot.some(
|
phase.snapshot.some(
|
||||||
@@ -526,6 +528,7 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
|
|||||||
form.setValue(`phases.${index}.snapshot`, snapshot)
|
form.setValue(`phases.${index}.snapshot`, snapshot)
|
||||||
}
|
}
|
||||||
isDisabled={!canEditForm}
|
isDisabled={!canEditForm}
|
||||||
|
client={contract.client}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ClaimsConditionFormContext.Provider
|
<ClaimsConditionFormContext.Provider
|
||||||
@@ -656,6 +659,7 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
|
|||||||
hasRemovedPhases ||
|
hasRemovedPhases ||
|
||||||
!isMultiPhase ? (
|
!isMultiPhase ? (
|
||||||
<TransactionButton
|
<TransactionButton
|
||||||
|
client={contract.client}
|
||||||
isLoggedIn={isLoggedIn}
|
isLoggedIn={isLoggedIn}
|
||||||
txChainID={contract.chain.id}
|
txChainID={contract.chain.id}
|
||||||
transactionCount={1}
|
transactionCount={1}
|
||||||
|
|||||||
+1
@@ -94,6 +94,7 @@ export const ResetClaimEligibility: React.FC<ResetClaimEligibilityProps> = ({
|
|||||||
return (
|
return (
|
||||||
<AdminOnly contract={contract} fallback={<div className="pb-5" />}>
|
<AdminOnly contract={contract} fallback={<div className="pb-5" />}>
|
||||||
<TransactionButton
|
<TransactionButton
|
||||||
|
client={contract.client}
|
||||||
isLoggedIn={isLoggedIn}
|
isLoggedIn={isLoggedIn}
|
||||||
transactionCount={1}
|
transactionCount={1}
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
+8
-2
@@ -14,7 +14,7 @@ import { useCsvUpload } from "hooks/useCsvUpload";
|
|||||||
import { CircleAlertIcon, DownloadIcon, UploadIcon } from "lucide-react";
|
import { CircleAlertIcon, DownloadIcon, UploadIcon } from "lucide-react";
|
||||||
import { useRef } from "react";
|
import { useRef } from "react";
|
||||||
import type { Column } from "react-table";
|
import type { Column } from "react-table";
|
||||||
import { ZERO_ADDRESS } from "thirdweb";
|
import { type ThirdwebClient, ZERO_ADDRESS } from "thirdweb";
|
||||||
import { CsvDataTable } from "../csv-data-table";
|
import { CsvDataTable } from "../csv-data-table";
|
||||||
|
|
||||||
interface SnapshotAddressInput {
|
interface SnapshotAddressInput {
|
||||||
@@ -30,6 +30,7 @@ interface SnapshotUploadProps {
|
|||||||
isDisabled: boolean;
|
isDisabled: boolean;
|
||||||
value?: SnapshotAddressInput[] | undefined;
|
value?: SnapshotAddressInput[] | undefined;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
client: ThirdwebClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
const csvParser = (items: SnapshotAddressInput[]): SnapshotAddressInput[] => {
|
const csvParser = (items: SnapshotAddressInput[]): SnapshotAddressInput[] => {
|
||||||
@@ -49,6 +50,7 @@ const SnapshotViewerSheetContent: React.FC<SnapshotUploadProps> = ({
|
|||||||
isDisabled,
|
isDisabled,
|
||||||
value,
|
value,
|
||||||
onClose,
|
onClose,
|
||||||
|
client,
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
normalizeQuery,
|
normalizeQuery,
|
||||||
@@ -59,7 +61,11 @@ const SnapshotViewerSheetContent: React.FC<SnapshotUploadProps> = ({
|
|||||||
noCsv,
|
noCsv,
|
||||||
reset,
|
reset,
|
||||||
removeInvalid,
|
removeInvalid,
|
||||||
} = useCsvUpload<SnapshotAddressInput>({ csvParser, defaultRawData: value });
|
} = useCsvUpload<SnapshotAddressInput>({
|
||||||
|
csvParser,
|
||||||
|
defaultRawData: value,
|
||||||
|
client,
|
||||||
|
});
|
||||||
|
|
||||||
const paginationPortalRef = useRef<HTMLDivElement>(null);
|
const paginationPortalRef = useRef<HTMLDivElement>(null);
|
||||||
const normalizeData = normalizeQuery.data;
|
const normalizeData = normalizeQuery.data;
|
||||||
|
|||||||
+11
-2
@@ -3,10 +3,13 @@
|
|||||||
import { useDashboardRouter } from "@/lib/DashboardRouter";
|
import { useDashboardRouter } from "@/lib/DashboardRouter";
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import type { ThirdwebContract } from "thirdweb";
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
|
import { buildContractPagePath } from "../_utils/contract-page-path";
|
||||||
import { LoadingPage } from "./page-skeletons";
|
import { LoadingPage } from "./page-skeletons";
|
||||||
|
|
||||||
export function RedirectToContractOverview(props: {
|
export function RedirectToContractOverview(props: {
|
||||||
contract: ThirdwebContract;
|
contract: ThirdwebContract;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
}) {
|
}) {
|
||||||
const router = useDashboardRouter();
|
const router = useDashboardRouter();
|
||||||
const redirected = useRef(false);
|
const redirected = useRef(false);
|
||||||
@@ -17,8 +20,14 @@ export function RedirectToContractOverview(props: {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
redirected.current = true;
|
redirected.current = true;
|
||||||
router.replace(`/${props.contract.chain.id}/${props.contract.address}`);
|
const landingPage = buildContractPagePath({
|
||||||
}, [router, props.contract]);
|
projectMeta: props.projectMeta,
|
||||||
|
chainIdOrSlug: props.contract.chain.id.toString(),
|
||||||
|
contractAddress: props.contract.address,
|
||||||
|
});
|
||||||
|
|
||||||
|
router.replace(landingPage);
|
||||||
|
}, [router, props]);
|
||||||
|
|
||||||
return <LoadingPage />;
|
return <LoadingPage />;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -6,9 +6,11 @@ import { ConfigureNetworks } from "components/configure-networks/ConfigureNetwor
|
|||||||
import { CheckIcon, CircleAlertIcon, RotateCcwIcon } from "lucide-react";
|
import { CheckIcon, CircleAlertIcon, RotateCcwIcon } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { addChainOverrides } from "stores/chainStores";
|
import { addChainOverrides } from "stores/chainStores";
|
||||||
|
import type { ThirdwebClient } from "thirdweb";
|
||||||
|
|
||||||
export function ConfigureCustomChain(props: {
|
export function ConfigureCustomChain(props: {
|
||||||
chainSlug: string;
|
chainSlug: string;
|
||||||
|
client: ThirdwebClient;
|
||||||
}) {
|
}) {
|
||||||
const { chainSlug } = props;
|
const { chainSlug } = props;
|
||||||
const isSlugNumber = Number.isInteger(Number(chainSlug));
|
const isSlugNumber = Number.isInteger(Number(chainSlug));
|
||||||
@@ -61,6 +63,7 @@ export function ConfigureCustomChain(props: {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
editChain={undefined}
|
editChain={undefined}
|
||||||
|
client={props.client}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
-1
@@ -43,7 +43,6 @@ export async function getContractMetadataHeaderData(
|
|||||||
fetchDashboardContractMetadata(contract),
|
fetchDashboardContractMetadata(contract),
|
||||||
fetchPublishedContractsFromDeploy({
|
fetchPublishedContractsFromDeploy({
|
||||||
contract,
|
contract,
|
||||||
client: contract.client,
|
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import type { MinimalTeamsAndProjects } from "components/contract-components/contract-deploy-form/add-to-project-card";
|
import type { MinimalTeamsAndProjects } from "components/contract-components/contract-deploy-form/add-to-project-card";
|
||||||
import type { ThirdwebClient, ThirdwebContract } from "thirdweb";
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
import type { ChainMetadata } from "thirdweb/chains";
|
import type { ChainMetadata } from "thirdweb/chains";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
import { ErrorPage, LoadingPage } from "../_components/page-skeletons";
|
import { ErrorPage, LoadingPage } from "../_components/page-skeletons";
|
||||||
import { useContractPageMetadata } from "../_hooks/useContractPageMetadata";
|
import { useContractPageMetadata } from "../_hooks/useContractPageMetadata";
|
||||||
import { getContractPageSidebarLinks } from "../_utils/getContractPageSidebarLinks";
|
import { getContractPageSidebarLinks } from "../_utils/getContractPageSidebarLinks";
|
||||||
@@ -15,7 +16,7 @@ export function ContractPageLayoutClient(props: {
|
|||||||
contract: ThirdwebContract;
|
contract: ThirdwebContract;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
teamsAndProjects: MinimalTeamsAndProjects | undefined;
|
teamsAndProjects: MinimalTeamsAndProjects | undefined;
|
||||||
client: ThirdwebClient;
|
projectMeta: ProjectMeta | undefined;
|
||||||
}) {
|
}) {
|
||||||
const metadataQuery = useContractPageMetadata(props.contract);
|
const metadataQuery = useContractPageMetadata(props.contract);
|
||||||
const headerMetadataQuery = useQuery({
|
const headerMetadataQuery = useQuery({
|
||||||
@@ -39,6 +40,7 @@ export function ContractPageLayoutClient(props: {
|
|||||||
chainSlug: props.chainMetadata.slug,
|
chainSlug: props.chainMetadata.slug,
|
||||||
contractAddress: props.contract.address,
|
contractAddress: props.contract.address,
|
||||||
metadata: metadataQuery.data,
|
metadata: metadataQuery.data,
|
||||||
|
projectMeta: props.projectMeta,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+6
-4
@@ -4,8 +4,9 @@ import { SidebarLayout } from "@/components/blocks/SidebarLayout";
|
|||||||
import type { DashboardContractMetadata } from "@3rdweb-sdk/react/hooks/useDashboardContractMetadata";
|
import type { DashboardContractMetadata } from "@3rdweb-sdk/react/hooks/useDashboardContractMetadata";
|
||||||
import type { MinimalTeamsAndProjects } from "components/contract-components/contract-deploy-form/add-to-project-card";
|
import type { MinimalTeamsAndProjects } from "components/contract-components/contract-deploy-form/add-to-project-card";
|
||||||
import { DeprecatedAlert } from "components/shared/DeprecatedAlert";
|
import { DeprecatedAlert } from "components/shared/DeprecatedAlert";
|
||||||
import type { ThirdwebClient, ThirdwebContract } from "thirdweb";
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
import type { ChainMetadata } from "thirdweb/chains";
|
import type { ChainMetadata } from "thirdweb/chains";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
import { ContractMetadata } from "./contract-metadata";
|
import { ContractMetadata } from "./contract-metadata";
|
||||||
import { PrimaryDashboardButton } from "./primary-dashboard-button";
|
import { PrimaryDashboardButton } from "./primary-dashboard-button";
|
||||||
|
|
||||||
@@ -15,8 +16,8 @@ export function ContractPageLayout(props: {
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
sidebarLinks: SidebarLink[];
|
sidebarLinks: SidebarLink[];
|
||||||
dashboardContractMetadata: DashboardContractMetadata | undefined;
|
dashboardContractMetadata: DashboardContractMetadata | undefined;
|
||||||
client: ThirdwebClient;
|
|
||||||
teamsAndProjects: MinimalTeamsAndProjects | undefined;
|
teamsAndProjects: MinimalTeamsAndProjects | undefined;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
externalLinks:
|
externalLinks:
|
||||||
| {
|
| {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -31,7 +32,7 @@ export function ContractPageLayout(props: {
|
|||||||
dashboardContractMetadata,
|
dashboardContractMetadata,
|
||||||
externalLinks,
|
externalLinks,
|
||||||
teamsAndProjects,
|
teamsAndProjects,
|
||||||
client,
|
projectMeta,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -46,6 +47,7 @@ export function ContractPageLayout(props: {
|
|||||||
externalLinks={externalLinks}
|
externalLinks={externalLinks}
|
||||||
/>
|
/>
|
||||||
<PrimaryDashboardButton
|
<PrimaryDashboardButton
|
||||||
|
projectMeta={projectMeta}
|
||||||
contractAddress={contract.address}
|
contractAddress={contract.address}
|
||||||
chain={contract.chain}
|
chain={contract.chain}
|
||||||
contractInfo={{
|
contractInfo={{
|
||||||
@@ -54,7 +56,7 @@ export function ContractPageLayout(props: {
|
|||||||
contractAddress: contract.address,
|
contractAddress: contract.address,
|
||||||
}}
|
}}
|
||||||
teamsAndProjects={teamsAndProjects}
|
teamsAndProjects={teamsAndProjects}
|
||||||
client={client}
|
client={contract.client}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<DeprecatedAlert chain={chainMetadata} />
|
<DeprecatedAlert chain={chainMetadata} />
|
||||||
|
|||||||
+14
-16
@@ -82,21 +82,19 @@ export const MetadataHeader: React.FC<MetadataHeaderProps> = ({
|
|||||||
</h1>
|
</h1>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{chain && (
|
<Link
|
||||||
<Link
|
href={`/${chain.slug}`}
|
||||||
href={`/${chain.slug}`}
|
className="flex w-fit shrink-0 items-center gap-2 rounded-3xl border border-border bg-card px-2.5 py-1.5 hover:bg-accent"
|
||||||
className="flex w-fit shrink-0 items-center gap-2 rounded-3xl border border-border bg-card px-2.5 py-1.5 hover:bg-accent"
|
>
|
||||||
>
|
<ChainIconClient
|
||||||
<ChainIconClient
|
src={chain.icon?.url}
|
||||||
src={chain.icon?.url}
|
client={client}
|
||||||
client={client}
|
className="size-4"
|
||||||
className="size-4"
|
/>
|
||||||
/>
|
{cleanedChainName && (
|
||||||
{cleanedChainName && (
|
<span className="text-xs">{cleanedChainName}</span>
|
||||||
<span className="text-xs">{cleanedChainName}</span>
|
)}
|
||||||
)}
|
</Link>
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -115,7 +113,7 @@ export const MetadataHeader: React.FC<MetadataHeaderProps> = ({
|
|||||||
<CopyAddressButton
|
<CopyAddressButton
|
||||||
address={address}
|
address={address}
|
||||||
copyIconPosition="left"
|
copyIconPosition="left"
|
||||||
className="bg-card text-xs"
|
className="bg-card px-2.5 py-1.5 text-xs"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
+30
-4
@@ -25,7 +25,9 @@ import { usePathname } from "next/navigation";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import type { Chain, ThirdwebClient } from "thirdweb";
|
import type { Chain, ThirdwebClient } from "thirdweb";
|
||||||
import { useAddContractToProject } from "../../../../../team/[team_slug]/[project_slug]/hooks/project-contracts";
|
import { useAddContractToProject } from "../../../../../team/[team_slug]/[project_slug]/(sidebar)/hooks/project-contracts";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
|
import { buildContractPagePath } from "../_utils/contract-page-path";
|
||||||
|
|
||||||
const TRACKING_CATEGORY = "add_to_dashboard_upsell";
|
const TRACKING_CATEGORY = "add_to_dashboard_upsell";
|
||||||
|
|
||||||
@@ -36,6 +38,7 @@ type AddToDashboardCardProps = {
|
|||||||
hideCodePageLink?: boolean;
|
hideCodePageLink?: boolean;
|
||||||
teamsAndProjects: MinimalTeamsAndProjects | undefined;
|
teamsAndProjects: MinimalTeamsAndProjects | undefined;
|
||||||
client: ThirdwebClient;
|
client: ThirdwebClient;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PrimaryDashboardButton: React.FC<AddToDashboardCardProps> = ({
|
export const PrimaryDashboardButton: React.FC<AddToDashboardCardProps> = ({
|
||||||
@@ -45,9 +48,17 @@ export const PrimaryDashboardButton: React.FC<AddToDashboardCardProps> = ({
|
|||||||
hideCodePageLink,
|
hideCodePageLink,
|
||||||
teamsAndProjects,
|
teamsAndProjects,
|
||||||
client,
|
client,
|
||||||
|
projectMeta,
|
||||||
}) => {
|
}) => {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
|
||||||
|
const codePagePath = buildContractPagePath({
|
||||||
|
projectMeta,
|
||||||
|
chainIdOrSlug: contractInfo.chainSlug,
|
||||||
|
contractAddress: contractAddress,
|
||||||
|
subpath: "/code",
|
||||||
|
});
|
||||||
|
|
||||||
// if user is not logged in
|
// if user is not logged in
|
||||||
if (!teamsAndProjects) {
|
if (!teamsAndProjects) {
|
||||||
if (hideCodePageLink) {
|
if (hideCodePageLink) {
|
||||||
@@ -57,9 +68,7 @@ export const PrimaryDashboardButton: React.FC<AddToDashboardCardProps> = ({
|
|||||||
if (!pathname?.endsWith("/code")) {
|
if (!pathname?.endsWith("/code")) {
|
||||||
return (
|
return (
|
||||||
<Button variant="outline" asChild className="gap-2">
|
<Button variant="outline" asChild className="gap-2">
|
||||||
<Link
|
<Link href={codePagePath}>
|
||||||
href={`/${contractInfo.chainSlug}/${contractInfo.contractAddress}/code`}
|
|
||||||
>
|
|
||||||
<CodeIcon className="size-4" />
|
<CodeIcon className="size-4" />
|
||||||
Code Snippets
|
Code Snippets
|
||||||
</Link>
|
</Link>
|
||||||
@@ -70,6 +79,21 @@ export const PrimaryDashboardButton: React.FC<AddToDashboardCardProps> = ({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if user is on a project page
|
||||||
|
if (projectMeta) {
|
||||||
|
return (
|
||||||
|
<Button variant="default" asChild>
|
||||||
|
<Link
|
||||||
|
href={`/${contractInfo.chainSlug}/${contractAddress}`}
|
||||||
|
target="_blank"
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
View Asset Page <ExternalLinkIcon className="size-3.5" />
|
||||||
|
</Link>
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AddToProjectButton
|
<AddToProjectButton
|
||||||
contractAddress={contractAddress}
|
contractAddress={contractAddress}
|
||||||
@@ -147,6 +171,8 @@ function AddToProjectModalContent(props: {
|
|||||||
teamId: params.teamId,
|
teamId: params.teamId,
|
||||||
projectId: params.projectId,
|
projectId: params.projectId,
|
||||||
chainId: props.chainId,
|
chainId: props.chainId,
|
||||||
|
deploymentType: undefined,
|
||||||
|
contractType: undefined,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
|
|
||||||
|
export function buildContractPagePath(params: {
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
|
chainIdOrSlug: string;
|
||||||
|
contractAddress: string;
|
||||||
|
subpath?: `/${string}`;
|
||||||
|
}) {
|
||||||
|
const { projectMeta, chainIdOrSlug, contractAddress, subpath } = params;
|
||||||
|
if (projectMeta) {
|
||||||
|
return `/team/${projectMeta.teamSlug}/${projectMeta.projectSlug}/contract/${chainIdOrSlug}/${contractAddress}${subpath || ""}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `/${chainIdOrSlug}/${contractAddress}${subpath || ""}`;
|
||||||
|
}
|
||||||
+6
-3
@@ -7,10 +7,11 @@ import { getUserThirdwebClient } from "../../../../../api/lib/getAuthToken";
|
|||||||
|
|
||||||
export async function getContractPageParamsInfo(params: {
|
export async function getContractPageParamsInfo(params: {
|
||||||
contractAddress: string;
|
contractAddress: string;
|
||||||
chain_id: string;
|
chainIdOrSlug: string;
|
||||||
|
teamId: string | undefined;
|
||||||
}) {
|
}) {
|
||||||
const contractAddress = getCheckSummedAddress(params.contractAddress);
|
const contractAddress = getCheckSummedAddress(params.contractAddress);
|
||||||
const chainSlugOrId = params.chain_id;
|
const chainSlugOrId = params.chainIdOrSlug;
|
||||||
const chainMetadata = await fetchChainWithLocalOverrides(chainSlugOrId);
|
const chainMetadata = await fetchChainWithLocalOverrides(chainSlugOrId);
|
||||||
|
|
||||||
if (!chainMetadata) {
|
if (!chainMetadata) {
|
||||||
@@ -31,7 +32,9 @@ export async function getContractPageParamsInfo(params: {
|
|||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
chain: mapV4ChainToV5Chain(chainMetadata),
|
chain: mapV4ChainToV5Chain(chainMetadata),
|
||||||
// if we have the auth token pass it into the client
|
// if we have the auth token pass it into the client
|
||||||
client: await getUserThirdwebClient(),
|
client: await getUserThirdwebClient({
|
||||||
|
teamId: params.teamId,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
+8
-1
@@ -1,4 +1,6 @@
|
|||||||
import type { SidebarBaseLink, SidebarLink } from "@/components/blocks/Sidebar";
|
import type { SidebarBaseLink, SidebarLink } from "@/components/blocks/Sidebar";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
|
import { buildContractPagePath } from "./contract-page-path";
|
||||||
import type { ContractPageMetadata } from "./getContractPageMetadata";
|
import type { ContractPageMetadata } from "./getContractPageMetadata";
|
||||||
|
|
||||||
type SidebarBaseLinkWithHide = SidebarBaseLink & {
|
type SidebarBaseLinkWithHide = SidebarBaseLink & {
|
||||||
@@ -9,8 +11,13 @@ export function getContractPageSidebarLinks(data: {
|
|||||||
metadata: ContractPageMetadata;
|
metadata: ContractPageMetadata;
|
||||||
contractAddress: string;
|
contractAddress: string;
|
||||||
chainSlug: string;
|
chainSlug: string;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
}) {
|
}) {
|
||||||
const layoutPrefix = `/${data.chainSlug}/${data.contractAddress}`;
|
const layoutPrefix = buildContractPagePath({
|
||||||
|
projectMeta: data.projectMeta,
|
||||||
|
chainIdOrSlug: data.chainSlug,
|
||||||
|
contractAddress: data.contractAddress,
|
||||||
|
});
|
||||||
|
|
||||||
const generalLinks: SidebarBaseLinkWithHide[] = [
|
const generalLinks: SidebarBaseLinkWithHide[] = [
|
||||||
{
|
{
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
import { resolveFunctionSelectors } from "lib/selectors";
|
||||||
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
|
import { isERC20 } from "thirdweb/extensions/erc20";
|
||||||
|
|
||||||
|
export type NewPublicPageType = "erc20";
|
||||||
|
|
||||||
|
export async function shouldRenderNewPublicPage(
|
||||||
|
contract: ThirdwebContract,
|
||||||
|
): Promise<false | { type: NewPublicPageType }> {
|
||||||
|
try {
|
||||||
|
const functionSelectors = await resolveFunctionSelectors(contract).catch(
|
||||||
|
() => undefined,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!functionSelectors) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isERC20Contract = isERC20(functionSelectors);
|
||||||
|
|
||||||
|
if (isERC20Contract) {
|
||||||
|
return {
|
||||||
|
type: "erc20",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-1
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import type { ThirdwebContract } from "thirdweb";
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
import { ErrorPage, LoadingPage } from "../_components/page-skeletons";
|
import { ErrorPage, LoadingPage } from "../_components/page-skeletons";
|
||||||
import { RedirectToContractOverview } from "../_components/redirect-contract-overview.client";
|
import { RedirectToContractOverview } from "../_components/redirect-contract-overview.client";
|
||||||
import { useContractPageMetadata } from "../_hooks/useContractPageMetadata";
|
import { useContractPageMetadata } from "../_hooks/useContractPageMetadata";
|
||||||
@@ -8,6 +9,7 @@ import { AccountSigners } from "./components/account-signers";
|
|||||||
|
|
||||||
export function AccountSignersClient(props: {
|
export function AccountSignersClient(props: {
|
||||||
contract: ThirdwebContract;
|
contract: ThirdwebContract;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
}) {
|
}) {
|
||||||
const metadataQuery = useContractPageMetadata(props.contract);
|
const metadataQuery = useContractPageMetadata(props.contract);
|
||||||
|
|
||||||
@@ -20,7 +22,12 @@ export function AccountSignersClient(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!metadataQuery.data.isAccountPermissionsSupported) {
|
if (!metadataQuery.data.isAccountPermissionsSupported) {
|
||||||
return <RedirectToContractOverview contract={props.contract} />;
|
return (
|
||||||
|
<RedirectToContractOverview
|
||||||
|
contract={props.contract}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <AccountSigners contract={props.contract} />;
|
return <AccountSigners contract={props.contract} />;
|
||||||
|
|||||||
+8
-1
@@ -3,6 +3,7 @@ import { Badge } from "@/components/ui/badge";
|
|||||||
import { Flex, SimpleGrid, useBreakpointValue } from "@chakra-ui/react";
|
import { Flex, SimpleGrid, useBreakpointValue } from "@chakra-ui/react";
|
||||||
import { formatDistance } from "date-fns/formatDistance";
|
import { formatDistance } from "date-fns/formatDistance";
|
||||||
import { useAllChainsData } from "hooks/chains/allChains";
|
import { useAllChainsData } from "hooks/chains/allChains";
|
||||||
|
import type { ThirdwebClient } from "thirdweb";
|
||||||
import { useActiveAccount } from "thirdweb/react";
|
import { useActiveAccount } from "thirdweb/react";
|
||||||
import { Card, Heading, Text } from "tw-components";
|
import { Card, Heading, Text } from "tw-components";
|
||||||
|
|
||||||
@@ -16,11 +17,13 @@ export type AccountSignerType = {
|
|||||||
interface AccountSignerProps {
|
interface AccountSignerProps {
|
||||||
item: AccountSignerType;
|
item: AccountSignerType;
|
||||||
contractChainId: number;
|
contractChainId: number;
|
||||||
|
client: ThirdwebClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AccountSigner: React.FC<AccountSignerProps> = ({
|
export const AccountSigner: React.FC<AccountSignerProps> = ({
|
||||||
item,
|
item,
|
||||||
contractChainId,
|
contractChainId,
|
||||||
|
client,
|
||||||
}) => {
|
}) => {
|
||||||
const address = useActiveAccount()?.address;
|
const address = useActiveAccount()?.address;
|
||||||
const { idToChain } = useAllChainsData();
|
const { idToChain } = useAllChainsData();
|
||||||
@@ -43,7 +46,11 @@ export const AccountSigner: React.FC<AccountSignerProps> = ({
|
|||||||
flexDir={{ base: "column", lg: "row" }}
|
flexDir={{ base: "column", lg: "row" }}
|
||||||
>
|
>
|
||||||
<Heading size="label.lg">
|
<Heading size="label.lg">
|
||||||
<WalletAddress shortenAddress={isMobile} address={signer} />
|
<WalletAddress
|
||||||
|
shortenAddress={isMobile}
|
||||||
|
address={signer}
|
||||||
|
client={client}
|
||||||
|
/>
|
||||||
</Heading>
|
</Heading>
|
||||||
<div className="flex flex-row gap-2">
|
<div className="flex flex-row gap-2">
|
||||||
{isAdmin ? <Badge>Admin Key</Badge> : <Badge>Scoped key</Badge>}
|
{isAdmin ? <Badge>Admin Key</Badge> : <Badge>Scoped key</Badge>}
|
||||||
|
|||||||
+1
@@ -40,6 +40,7 @@ export const AccountSigners: React.FC<AccountSignersProps> = ({ contract }) => {
|
|||||||
<AccountSigner
|
<AccountSigner
|
||||||
key={item.signer}
|
key={item.signer}
|
||||||
item={item}
|
item={item}
|
||||||
|
client={contract.client}
|
||||||
contractChainId={contract.chain.id}
|
contractChainId={contract.chain.id}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
+10
-29
@@ -1,34 +1,15 @@
|
|||||||
import { notFound, redirect } from "next/navigation";
|
import type { PublicContractPageParams } from "../types";
|
||||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
import { SharedContractAccountPermissionsPage } from "./shared-account-permissions-page";
|
||||||
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
|
|
||||||
import { AccountSignersClient } from "./AccountSigners.client";
|
|
||||||
import { AccountSigners } from "./components/account-signers";
|
|
||||||
|
|
||||||
export default async function Page(props: {
|
export default async function Page(props: {
|
||||||
params: Promise<{
|
params: Promise<PublicContractPageParams>;
|
||||||
contractAddress: string;
|
|
||||||
chain_id: string;
|
|
||||||
}>;
|
|
||||||
}) {
|
}) {
|
||||||
const params = await props.params;
|
const params = await props.params;
|
||||||
const info = await getContractPageParamsInfo(params);
|
return (
|
||||||
|
<SharedContractAccountPermissionsPage
|
||||||
if (!info) {
|
contractAddress={params.contractAddress}
|
||||||
notFound();
|
chainIdOrSlug={params.chain_id}
|
||||||
}
|
projectMeta={undefined}
|
||||||
|
/>
|
||||||
const { clientContract, serverContract, isLocalhostChain } = info;
|
);
|
||||||
|
|
||||||
if (isLocalhostChain) {
|
|
||||||
return <AccountSignersClient contract={clientContract} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { isAccountPermissionsSupported } =
|
|
||||||
await getContractPageMetadata(serverContract);
|
|
||||||
|
|
||||||
if (!isAccountPermissionsSupported) {
|
|
||||||
redirect(`/${params.chain_id}/${params.contractAddress}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return <AccountSigners contract={clientContract} />;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+47
@@ -0,0 +1,47 @@
|
|||||||
|
import { notFound } from "next/navigation";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
|
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||||
|
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||||
|
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
|
||||||
|
import { AccountSignersClient } from "./AccountSigners.client";
|
||||||
|
import { AccountSigners } from "./components/account-signers";
|
||||||
|
|
||||||
|
export async function SharedContractAccountPermissionsPage(props: {
|
||||||
|
contractAddress: string;
|
||||||
|
chainIdOrSlug: string;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
|
}) {
|
||||||
|
const info = await getContractPageParamsInfo({
|
||||||
|
contractAddress: props.contractAddress,
|
||||||
|
chainIdOrSlug: props.chainIdOrSlug,
|
||||||
|
teamId: props.projectMeta?.teamId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!info) {
|
||||||
|
notFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
const { clientContract, serverContract, isLocalhostChain } = info;
|
||||||
|
|
||||||
|
if (isLocalhostChain) {
|
||||||
|
return (
|
||||||
|
<AccountSignersClient
|
||||||
|
contract={clientContract}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { isAccountPermissionsSupported } =
|
||||||
|
await getContractPageMetadata(serverContract);
|
||||||
|
|
||||||
|
if (!isAccountPermissionsSupported) {
|
||||||
|
redirectToContractLandingPage({
|
||||||
|
chainIdOrSlug: props.chainIdOrSlug,
|
||||||
|
contractAddress: props.contractAddress,
|
||||||
|
projectMeta: props.projectMeta,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return <AccountSigners contract={clientContract} />;
|
||||||
|
}
|
||||||
+9
-1
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import type { ThirdwebContract } from "thirdweb";
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
import type { ChainMetadata } from "thirdweb/chains";
|
import type { ChainMetadata } from "thirdweb/chains";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
import { ErrorPage, LoadingPage } from "../_components/page-skeletons";
|
import { ErrorPage, LoadingPage } from "../_components/page-skeletons";
|
||||||
import { RedirectToContractOverview } from "../_components/redirect-contract-overview.client";
|
import { RedirectToContractOverview } from "../_components/redirect-contract-overview.client";
|
||||||
import { useContractPageMetadata } from "../_hooks/useContractPageMetadata";
|
import { useContractPageMetadata } from "../_hooks/useContractPageMetadata";
|
||||||
@@ -11,6 +12,7 @@ export function AccountPageClient(props: {
|
|||||||
contract: ThirdwebContract;
|
contract: ThirdwebContract;
|
||||||
chainMetadata: ChainMetadata;
|
chainMetadata: ChainMetadata;
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
}) {
|
}) {
|
||||||
const metadataQuery = useContractPageMetadata(props.contract);
|
const metadataQuery = useContractPageMetadata(props.contract);
|
||||||
|
|
||||||
@@ -23,7 +25,12 @@ export function AccountPageClient(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!metadataQuery.data.isAccount) {
|
if (!metadataQuery.data.isAccount) {
|
||||||
return <RedirectToContractOverview contract={props.contract} />;
|
return (
|
||||||
|
<RedirectToContractOverview
|
||||||
|
contract={props.contract}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -32,6 +39,7 @@ export function AccountPageClient(props: {
|
|||||||
chainMetadata={props.chainMetadata}
|
chainMetadata={props.chainMetadata}
|
||||||
isLoggedIn={props.isLoggedIn}
|
isLoggedIn={props.isLoggedIn}
|
||||||
isInsightSupported={metadataQuery.data.isInsightSupported}
|
isInsightSupported={metadataQuery.data.isInsightSupported}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-1
@@ -3,6 +3,7 @@
|
|||||||
import type { ThirdwebContract } from "thirdweb";
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
import type { ChainMetadata } from "thirdweb/chains";
|
import type { ChainMetadata } from "thirdweb/chains";
|
||||||
import { Heading } from "tw-components";
|
import { Heading } from "tw-components";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
import { AccountBalance } from "./components/account-balance";
|
import { AccountBalance } from "./components/account-balance";
|
||||||
import { DepositNative } from "./components/deposit-native";
|
import { DepositNative } from "./components/deposit-native";
|
||||||
import { NftsOwned } from "./components/nfts-owned";
|
import { NftsOwned } from "./components/nfts-owned";
|
||||||
@@ -12,6 +13,7 @@ interface AccountPageProps {
|
|||||||
chainMetadata: ChainMetadata;
|
chainMetadata: ChainMetadata;
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
isInsightSupported: boolean;
|
isInsightSupported: boolean;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AccountPage: React.FC<AccountPageProps> = ({
|
export const AccountPage: React.FC<AccountPageProps> = ({
|
||||||
@@ -19,6 +21,7 @@ export const AccountPage: React.FC<AccountPageProps> = ({
|
|||||||
chainMetadata,
|
chainMetadata,
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
isInsightSupported,
|
isInsightSupported,
|
||||||
|
projectMeta,
|
||||||
}) => {
|
}) => {
|
||||||
const symbol = chainMetadata.nativeCurrency.symbol || "Native Token";
|
const symbol = chainMetadata.nativeCurrency.symbol || "Native Token";
|
||||||
|
|
||||||
@@ -38,13 +41,18 @@ export const AccountPage: React.FC<AccountPageProps> = ({
|
|||||||
address={contract.address}
|
address={contract.address}
|
||||||
symbol={symbol}
|
symbol={symbol}
|
||||||
chain={chainMetadata}
|
chain={chainMetadata}
|
||||||
|
client={contract.client}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex flex-row items-center justify-between">
|
<div className="flex flex-row items-center justify-between">
|
||||||
<Heading size="title.sm">NFTs owned</Heading>
|
<Heading size="title.sm">NFTs owned</Heading>
|
||||||
</div>
|
</div>
|
||||||
<NftsOwned contract={contract} isInsightSupported={isInsightSupported} />
|
<NftsOwned
|
||||||
|
contract={contract}
|
||||||
|
isInsightSupported={isInsightSupported}
|
||||||
|
projectMeta={projectMeta}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+4
-3
@@ -1,12 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useThirdwebClient } from "@/constants/thirdweb.client";
|
|
||||||
import { Input } from "@chakra-ui/react";
|
import { Input } from "@chakra-ui/react";
|
||||||
import { TransactionButton } from "components/buttons/TransactionButton";
|
import { TransactionButton } from "components/buttons/TransactionButton";
|
||||||
import { useV5DashboardChain } from "lib/v5-adapter";
|
import { useV5DashboardChain } from "lib/v5-adapter";
|
||||||
import { type ChangeEvent, useState } from "react";
|
import { type ChangeEvent, useState } from "react";
|
||||||
import type { StoredChain } from "stores/chainStores";
|
import type { StoredChain } from "stores/chainStores";
|
||||||
import { prepareTransaction, toWei } from "thirdweb";
|
import { type ThirdwebClient, prepareTransaction, toWei } from "thirdweb";
|
||||||
import { useSendAndConfirmTransaction } from "thirdweb/react";
|
import { useSendAndConfirmTransaction } from "thirdweb/react";
|
||||||
import { Card } from "tw-components";
|
import { Card } from "tw-components";
|
||||||
|
|
||||||
@@ -15,6 +14,7 @@ interface DepositNativeProps {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
chain: StoredChain;
|
chain: StoredChain;
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
|
client: ThirdwebClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DepositNative: React.FC<DepositNativeProps> = ({
|
export const DepositNative: React.FC<DepositNativeProps> = ({
|
||||||
@@ -22,8 +22,8 @@ export const DepositNative: React.FC<DepositNativeProps> = ({
|
|||||||
symbol,
|
symbol,
|
||||||
chain,
|
chain,
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
|
client,
|
||||||
}) => {
|
}) => {
|
||||||
const client = useThirdwebClient();
|
|
||||||
const { mutate: transfer, isPending } = useSendAndConfirmTransaction();
|
const { mutate: transfer, isPending } = useSendAndConfirmTransaction();
|
||||||
const [amount, setAmount] = useState("");
|
const [amount, setAmount] = useState("");
|
||||||
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
@@ -48,6 +48,7 @@ export const DepositNative: React.FC<DepositNativeProps> = ({
|
|||||||
value={amount}
|
value={amount}
|
||||||
/>
|
/>
|
||||||
<TransactionButton
|
<TransactionButton
|
||||||
|
client={client}
|
||||||
isLoggedIn={isLoggedIn}
|
isLoggedIn={isLoggedIn}
|
||||||
txChainID={v5Chain.id}
|
txChainID={v5Chain.id}
|
||||||
transactionCount={1}
|
transactionCount={1}
|
||||||
|
|||||||
+5
@@ -2,16 +2,19 @@
|
|||||||
|
|
||||||
import { useWalletNFTs } from "@3rdweb-sdk/react";
|
import { useWalletNFTs } from "@3rdweb-sdk/react";
|
||||||
import type { ThirdwebContract } from "thirdweb";
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
|
import type { ProjectMeta } from "../../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
import { NFTCards } from "../../_components/NFTCards";
|
import { NFTCards } from "../../_components/NFTCards";
|
||||||
|
|
||||||
interface NftsOwnedProps {
|
interface NftsOwnedProps {
|
||||||
contract: ThirdwebContract;
|
contract: ThirdwebContract;
|
||||||
isInsightSupported: boolean;
|
isInsightSupported: boolean;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const NftsOwned: React.FC<NftsOwnedProps> = ({
|
export const NftsOwned: React.FC<NftsOwnedProps> = ({
|
||||||
contract,
|
contract,
|
||||||
isInsightSupported,
|
isInsightSupported,
|
||||||
|
projectMeta,
|
||||||
}) => {
|
}) => {
|
||||||
const { data: walletNFTs, isPending: isWalletNFTsLoading } = useWalletNFTs({
|
const { data: walletNFTs, isPending: isWalletNFTsLoading } = useWalletNFTs({
|
||||||
chainId: contract.chain.id,
|
chainId: contract.chain.id,
|
||||||
@@ -24,6 +27,8 @@ export const NftsOwned: React.FC<NftsOwnedProps> = ({
|
|||||||
|
|
||||||
return nfts.length !== 0 ? (
|
return nfts.length !== 0 ? (
|
||||||
<NFTCards
|
<NFTCards
|
||||||
|
client={contract.client}
|
||||||
|
projectMeta={projectMeta}
|
||||||
nfts={nfts.map((nft) => ({
|
nfts={nfts.map((nft) => ({
|
||||||
id: BigInt(nft.id),
|
id: BigInt(nft.id),
|
||||||
supply: BigInt(nft.supply),
|
supply: BigInt(nft.supply),
|
||||||
|
|||||||
+8
-42
@@ -1,51 +1,17 @@
|
|||||||
import { notFound, redirect } from "next/navigation";
|
|
||||||
import { getRawAccount } from "../../../../../account/settings/getAccount";
|
import { getRawAccount } from "../../../../../account/settings/getAccount";
|
||||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
import type { PublicContractPageParams } from "../types";
|
||||||
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
|
import { SharedContractAccountPage } from "./shared-account-page";
|
||||||
import { AccountPage } from "./AccountPage";
|
|
||||||
import { AccountPageClient } from "./AccountPage.client";
|
|
||||||
|
|
||||||
export default async function Page(props: {
|
export default async function Page(props: {
|
||||||
params: Promise<{
|
params: Promise<PublicContractPageParams>;
|
||||||
contractAddress: string;
|
|
||||||
chain_id: string;
|
|
||||||
}>;
|
|
||||||
}) {
|
}) {
|
||||||
const params = await props.params;
|
const [params, account] = await Promise.all([props.params, getRawAccount()]);
|
||||||
const info = await getContractPageParamsInfo(params);
|
|
||||||
|
|
||||||
if (!info) {
|
|
||||||
notFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
const { clientContract, serverContract, chainMetadata, isLocalhostChain } =
|
|
||||||
info;
|
|
||||||
|
|
||||||
const account = await getRawAccount();
|
|
||||||
|
|
||||||
if (isLocalhostChain) {
|
|
||||||
return (
|
|
||||||
<AccountPageClient
|
|
||||||
contract={clientContract}
|
|
||||||
chainMetadata={chainMetadata}
|
|
||||||
isLoggedIn={!!account}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { isAccount, isInsightSupported } =
|
|
||||||
await getContractPageMetadata(serverContract);
|
|
||||||
|
|
||||||
if (!isAccount) {
|
|
||||||
redirect(`/${params.chain_id}/${params.contractAddress}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AccountPage
|
<SharedContractAccountPage
|
||||||
contract={clientContract}
|
contractAddress={params.contractAddress}
|
||||||
chainMetadata={chainMetadata}
|
chainIdOrSlug={params.chain_id}
|
||||||
|
projectMeta={undefined}
|
||||||
isLoggedIn={!!account}
|
isLoggedIn={!!account}
|
||||||
isInsightSupported={isInsightSupported}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
import { notFound } from "next/navigation";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
|
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||||
|
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||||
|
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
|
||||||
|
import { AccountPage } from "./AccountPage";
|
||||||
|
import { AccountPageClient } from "./AccountPage.client";
|
||||||
|
|
||||||
|
export async function SharedContractAccountPage(props: {
|
||||||
|
contractAddress: string;
|
||||||
|
chainIdOrSlug: string;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
|
isLoggedIn: boolean;
|
||||||
|
}) {
|
||||||
|
const info = await getContractPageParamsInfo({
|
||||||
|
contractAddress: props.contractAddress,
|
||||||
|
chainIdOrSlug: props.chainIdOrSlug,
|
||||||
|
teamId: props.projectMeta?.teamId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!info) {
|
||||||
|
notFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.isLocalhostChain) {
|
||||||
|
return (
|
||||||
|
<AccountPageClient
|
||||||
|
contract={info.clientContract}
|
||||||
|
chainMetadata={info.chainMetadata}
|
||||||
|
isLoggedIn={props.isLoggedIn}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { isAccount, isInsightSupported } = await getContractPageMetadata(
|
||||||
|
info.serverContract,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isAccount) {
|
||||||
|
redirectToContractLandingPage({
|
||||||
|
chainIdOrSlug: props.chainIdOrSlug,
|
||||||
|
contractAddress: props.contractAddress,
|
||||||
|
projectMeta: props.projectMeta,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AccountPage
|
||||||
|
contract={info.clientContract}
|
||||||
|
chainMetadata={info.chainMetadata}
|
||||||
|
isLoggedIn={props.isLoggedIn}
|
||||||
|
isInsightSupported={isInsightSupported}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
+13
-2
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import type { ThirdwebContract } from "thirdweb";
|
import type { ThirdwebContract } from "thirdweb";
|
||||||
|
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||||
import { ErrorPage, LoadingPage } from "../_components/page-skeletons";
|
import { ErrorPage, LoadingPage } from "../_components/page-skeletons";
|
||||||
import { RedirectToContractOverview } from "../_components/redirect-contract-overview.client";
|
import { RedirectToContractOverview } from "../_components/redirect-contract-overview.client";
|
||||||
import { useContractPageMetadata } from "../_hooks/useContractPageMetadata";
|
import { useContractPageMetadata } from "../_hooks/useContractPageMetadata";
|
||||||
@@ -9,6 +10,7 @@ import { AccountsPage } from "./AccountsPage";
|
|||||||
export function AccountsPageClient(props: {
|
export function AccountsPageClient(props: {
|
||||||
contract: ThirdwebContract;
|
contract: ThirdwebContract;
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
|
projectMeta: ProjectMeta | undefined;
|
||||||
}) {
|
}) {
|
||||||
const metadataQuery = useContractPageMetadata(props.contract);
|
const metadataQuery = useContractPageMetadata(props.contract);
|
||||||
|
|
||||||
@@ -21,10 +23,19 @@ export function AccountsPageClient(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!metadataQuery.data.isAccountFactory) {
|
if (!metadataQuery.data.isAccountFactory) {
|
||||||
return <RedirectToContractOverview contract={props.contract} />;
|
return (
|
||||||
|
<RedirectToContractOverview
|
||||||
|
contract={props.contract}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AccountsPage contract={props.contract} isLoggedIn={props.isLoggedIn} />
|
<AccountsPage
|
||||||
|
contract={props.contract}
|
||||||
|
isLoggedIn={props.isLoggedIn}
|
||||||
|
projectMeta={props.projectMeta}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user