Compare commits

...
Author SHA1 Message Date
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
f47aa61915 Version Packages (#4263)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-25 11:22:32 +12:00
gregfromstl a0aea23e74 Set default auth mode to prevent double popup (#4274)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR fixes a conflict between popup and window authentication modes on Firefox.

### Detailed summary
- Set the default authentication mode to "popup" if not specified
- Ensure popup authentication mode is used when not explicitly defined

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-24 21:08:40 +00:00
1405598e7e adding api for pay direct transfers (#4224)
Co-authored-by: Joaquim Verges <[email protected]>
Co-authored-by: Edward Sun <[email protected]>
Co-authored-by: Edward Sun <[email protected]>
2024-08-23 23:45:23 +00:00
MananTank 120d61f410 Use formatNumber util for showing token balances (#4269)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update UI components to display wallet balances with up to 5 decimal places.

### Detailed summary
- Updated `formatTokenBalance` function to use `formatNumber` with 5 decimal places
- Added `formatNumber` function to format numbers with specified decimal places
- Updated balance display in UI components to use `formatNumber` with conditional decimal places based on the value

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-23 22:12:08 +00:00
jnsdls 2973ba1f54 [Update] Make bundle ID regex case-insensitive (#4268)
BLOCKED BY: https://github.com/thirdweb-dev/api-server/pull/1019
2024-08-23 21:00:49 +00:00
Alec AnanianandGitHub 7a2de70310 react: add hideSwitchWallet param to wallet details modal (#4267) 2024-08-23 13:37:51 -07:00
gregfromstl 659cb03eea [Docs] Feature: Automatically unroll function inputs and outputs (#4236)
## Problem solved

Previously we made no attempt to unroll function inputs and outputs in the docs. This made things difficult to quickly scan since every function has a typed input and output object you would have to navigate to.

This PR is a first attempt at basic unrolling functionality of these typed inputs and outputs.

Before:
<img width="929" alt="Screenshot 2024-08-21 at 3 20 24 PM" src="https://github.com/user-attachments/assets/e73eae8b-98b5-40c9-8f63-f17e3a0a63d7">

After:
<img width="933" alt="Screenshot 2024-08-21 at 3 20 49 PM" src="https://github.com/user-attachments/assets/b5d8d847-9c70-45ec-aaf6-95b4215b3418">

As an additional readability bonus, the input and output sections now start as an open accordion.

Note: There are still improvements to be made especially on functions with more complex types. These functions' interfaces should be simplified in future versions.

## Next Steps
Future features should add nested input descriptions (supported by typedoc but not `typedoc-better-json`). Future SDK versions should use simpler, explicitly typed inputs and outputs to simplify the unrolling process (and easier LSP support for users).

## To Test
Open the preview URL, click around to various functions and inspect the parameter and return types

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates transaction handling and TypeScript documentation rendering.

### Detailed summary
- Added `fetchDocBySlug` function to fetch TypeScript docs by slug
- Modified `SendTransactionOptions` to use interface instead of type
- Updated TypeScript documentation rendering to include interface docs for return types and parameter types

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-23 18:24:48 +00:00
jnsdls 8128d127ce [Update] Refine billing alert messages and usage limit notifications (#4266) 2024-08-23 17:55:29 +00:00
MananTank d401a13cdc Add Storybook in Dashboard (#4265)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to integrate Storybook into the project, configure Storybook addons, and create a Button component story.

### Detailed summary
- Added Storybook configuration files for setup
- Integrated Storybook for UI component development
- Created a story for the Button component with light and dark themes
- Updated package.json with Storybook dependencies

> The following files were skipped due to too many changes: `pnpm-lock.yaml`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-23 17:08:31 +00:00
gregfromstl 41fbdafcf7 [TS SDK] Feature: Add account overload to signMessage (#4250)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR enhances the `signMessage` function in the `thirdweb` package by adding support to pass an account for signing messages, in addition to a private key.

### Detailed summary
- Added overload to `signMessage` to accept an account for signing messages
- Updated `signMessage` function to handle both private key and account options
- Updated tests to cover new account signing functionality

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-23 16:29:04 +00:00
MananTank 44e8e7bce2 Buy Fiat Currency selection updates in Pay UI (#4244)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces support for Japanese Yen (JPY) as a fiat currency option in the Pay UI.

### Detailed summary
- Added JPY as a supported fiat currency
- Updated currency selection UI components
- Added JPYIcon for visual representation
- Implemented default currency selection based on user's location

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-23 06:10:06 +00:00
jnsdls 201a4b3b8f [Update] Refine billing alerts based on account status and usage limits (#4261) 2024-08-23 05:59:32 +00:00
jnsdls 716a4d8c26 [Update] Expand CSP for style-src and font-src to include Vercel domains (#4262)
tl;dr: https://vercel.com/docs/workflow-collaboration/vercel-toolbar/managing-toolbar#using-a-content-security-policy
2024-08-23 05:54:30 +00:00
jnsdls 9a86559c36 [Update] Enhance billing alerts based on account plan and usage limits (#4259)
<!-- start pr-codex -->

## PR-Codex overview
This PR adds conditional alerts based on user's usage and plan in the billing section.

### Detailed summary
- Added `isFreePlan` and `isGrowthPlan` constants based on user's plan
- Updated conditions to show alerts based on usage limits and plan
- Included specific messages for different scenarios and plans

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-23 05:22:14 +00:00
jnsdls 3853e17656 [Refactor] Update useQuery implementation and remove unused imports (#4258) 2024-08-23 03:05:51 +00:00
jnsdls ac2bb59fa0 [Refactor] Update useQuery implementation across multiple hooks (#4257) 2024-08-23 01:20:48 +00:00
Jonas DanielsandGitHub 14696d32fc [Update] Enhance ContractOverviewPage component rendering (#4256) 2024-08-22 17:26:29 -07:00
jnsdls dc903ae029 [Refactor] Update account count fetching using thirdweb hooks (#4255)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to refactor the `sdk.ts` file by removing unused imports and simplifying the `getThirdwebSDK` function.

### Detailed summary
- Removed unused imports and type declarations in `sdk.ts`
- Simplified the `getThirdwebSDK` function parameters
- Improved performance by optimizing the `sdkKey` calculation
- Removed signer update logic in `getThirdwebSDK`
- Refactored `account-cell.tsx` by updating imports and using `thirdweb` library functions
- Updated `useAccountCount` function to use `getContract` and `useReadContract` from `thirdweb` library

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-23 00:14:01 +00:00
FirekeeperandGitHub be03c28b5d .NET 1.5.0 / Unity 5.0.0-beta.4 Docs (#4199) 2024-08-22 17:07:53 -07:00
kien-ngo bdf9507de8 [Dashboard] Overview page (#4222)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates various components in the contract UI to use the `useContract` hook and `ThirdwebContract` type for better contract handling.

### Detailed summary
- Updated components to use `useContract` hook and `ThirdwebContract` type
- Removed unnecessary imports and code duplication
- Refactored contract-related logic for improved readability

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/overview/components/ContractChecklist.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 23:48:19 +00:00
edwardysun 86d2bafd72 Remove Coming Soon on Pay webhooks dashboard event type (#4254)
## Problem solved

Removes "Coming Soon" badge - confusing UI

<!-- start pr-codex -->

---

## PR-Codex overview
This PR removes the `Badge` component from the `CreateWebhookButton` in `webhooks.client.tsx`.

### Detailed summary
- Removed the `Badge` component from the form field in the `CreateWebhookButton`.
- Updated the `FormLabel` to remove the "Coming Soon" text.
- Adjusted the `Select` component with a default value and placeholder.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 23:42:58 +00:00
MananTank 6b9bfb6ec7 Connect Playground UI tweaks (#4252)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to optimize the sidebar, improve accordion behavior, and enhance UI components.

### Detailed summary
- Removed unnecessary class from `Sidebar` component
- Adjusted styling in `page.tsx` for responsiveness
- Added functionality to close other accordions when one is opened
- Updated dependencies and added animations to `CustomAccordion`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 23:38:14 +00:00
MananTank 8a618d7bd3 Migrate Mini connect playground to v5 in connect landing page (#4249)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates wallet functionality in the dashboard:

### Detailed summary
- Updated wallet options and social login methods
- Improved theme selection and modal size handling
- Removed unused components and assets

> The following files were skipped due to too many changes: `apps/dashboard/src/components/wallets/ConnectWalletMiniPlayground/MiniPlayground.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 23:01:26 +00:00
jnsdls e97412bec8 [Refactor] Replace BigNumber with native BigInt operations (#4248)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The PR focuses on refactoring and optimizing Solidity-related functions and updating contract-related hooks and queries for ERC721 and ERC1155 in the dashboard.

### Detailed summary
- Refactored `calculateIntMinValues` and `calculateIntMaxValues` functions for better performance.
- Updated contract-related hooks and queries for ERC721 and ERC1155 in `ContractChecklist.tsx`.
- Replaced `BigNumber` with `BigInt` for improved handling of integer values.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 22:47:30 +00:00
jnsdls 626072cc0d remove unused code (#4247)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to remove unused files, update dependencies, and refactor code structure.

### Detailed summary
- Removed unused files related to maps, gas estimator, and components
- Refactored `useHeightObserver` function
- Updated dependencies like `@tanstack/react-query` and `@stripe/react-stripe-js`
- Removed unused code related to contract code snippets and event handling
- Updated package versions and removed `idb-keyval` dependency

> The following files were skipped due to too many changes: `pnpm-lock.yaml`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 22:21:14 +00:00
kien-ngo 5d6b1e1d0a [Dashboard] Migrate type: ProfileMetadata + ProfileMetadataInput (#4109)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates import paths for `ProfileMetadata` and `ProfileMetadataInput` to `constants/schemas`.

### Detailed summary
- Updated import paths for `ProfileMetadata` and `ProfileMetadataInput` to `constants/schemas` in multiple files.
- Added `ProfileSchemaInput` and `ProfileSchemaOutput` in `schemas.ts`.
- Updated type-casting in `fetchPublisherProfile` function.
- Changed parameter type in `useEditProfileMutation` function.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 21:52:16 +00:00
jnsdls b1323ea211 [Refactor] Update useQuery implementation in API hooks (#4246)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to refactor API query functions in the dashboard app to use `useQuery` with explicit query keys and query functions.

### Detailed summary
- Refactored `useApiChains` and `useFeatureContractCodeSnippetQuery` to use `useQuery` with specified query keys and query functions.
- Updated API query functions to be more explicit and maintainable.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 21:45:56 +00:00
jnsdls cbbb414141 [Refactor] Remove query persistence and update import paths (#4245) 2024-08-22 21:33:55 +00:00
MananTank 0417ab45f1 Remove connect playground in dashboard (#4243)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update links and paths related to the Connect Wallet Playground feature.

### Detailed summary
- Updated links to direct to `https://playground.thirdweb.com/connect/sign-in/button`
- Removed references to the deleted Connect Wallet Playground feature
- Updated sidebar and navigation links
- Updated redirects to new playground URL

> The following files were skipped due to too many changes: `apps/dashboard/src/components/wallets/ConnectWalletMiniPlayground/MiniPlayground.tsx`, `pnpm-lock.yaml`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 21:09:21 +00:00
kien-ngo c49bbd3389 [Dashboard] Remove ethers from list-form (#4241)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to refactor the CreateListingsForm component in the listings tab to handle auction creation with improved currency handling.

### Detailed summary
- Refactored currency handling for auction creation
- Added `toUnits` and `toWei` functions
- Imported `decimals` from `thirdweb/extensions/erc20`
- Updated auction creation logic to handle different currencies

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 20:55:15 +00:00
kien-ngo f192875547 [Dashboard] Remove bignumber-input since it is for Claim phase v1 (#4242)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to remove the `WaitingTimeInput` component from the `ClaimConditionsPhase` component and related imports.

### Detailed summary
- Deleted `WaitingTimeInput` component import and usage in `ClaimConditionsPhase`
- Removed `WaitingTimeInput` component from the conditional rendering based on `isClaimPhaseV1`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 20:43:49 +00:00
MananTank 55bf1ad5a3 Add Storybook for SDK (#4230)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to add Storybook configuration, update dependencies, and improve story components.

### Detailed summary
- Added Storybook configuration for `storybook` and `build-storybook`
- Updated dependencies for Storybook addons and Vite
- Improved story components for `ConnectButton` and `PayEmbed`
- Defined absolute paths in Storybook config for addons
- Added global CSS styling for Storybook preview
- Created utility functions for story client and wallet adapter

> The following files were skipped due to too many changes: `pnpm-lock.yaml`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 16:36:54 +00:00
kien-ngo 01dd80fad9 [Dashboard] Hide AnnouncementBanner for Onchain Olympics [Merge after Aug 21] (#4176)
Merge this PR after Aug 21 🙏
2024-08-22 09:38:41 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
279d81ec35 Version Packages (#4223)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-22 18:43:24 +12:00
joaquim-verges d93ec63cd7 fix(inApp): fix passkeyDomain prop not being respected on login web (#4239)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on fixing the passkey domain issue in the authentication process.

### Detailed summary
- Updated `types.ts` to remove optional domain object
- Modified `web-connector.ts` to use `passkeyDomain` instead of domain object for `rp` properties

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 05:01:31 +00:00
joaquim-verges a7f4484702 smart wallet dev tests (#4226)
## Problem solved

Adding a small test preset for dev to test smart wallet dev infra

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to add support for running tests in a test environment and to enhance smart wallet functionality.

### Detailed summary
- Added support for running tests in a test environment
- Updated smart wallet functionality for policy tests
- Modified fetch logic for `localhost` and `test` environments

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 04:45:29 +00:00
gregfromstl b38308d893 [TS SDK] Feature: Enable external redirect authentication for electron support (#4237)
Adds the ability to pass a `redirectUrl` and `redirectExternally` boolean to `authenticate`. This will allow electron apps to authenticate with in-app wallet social auth.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces a new authentication mode "window" and enables external redirects for electron support.

### Detailed summary
- Added a new authentication mode "window" for in-app authentication
- Enabled external redirects for electron support
- Updated authentication modes in various files
- Updated authentication methods to support new mode and redirect URL

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 04:40:30 +00:00
MananTank 7ef1c721ef Update Playground (#4178)
Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

This PR introduces new authentication features, refactors UI components, adds redirect functionality, and enhances code formatting.

- Added new authentication features
- Refactored UI components
- Added redirect functionality
- Enhanced code formatting

> The following files were skipped due to too many changes: `apps/playground-web/src/app/providers.tsx`, `apps/playground-web/src/components/ui/input.tsx`, `apps/playground-web/src/app/connect/sign-in/components/types.ts`, `apps/playground-web/src/components/ui/CustomRadioGroup.tsx`, `apps/playground-web/package.json`, `apps/playground-web/src/components/ui/CopyButton.tsx`, `packages/thirdweb/src/react/web/ui/ConnectWallet/WalletSelector.tsx`, `apps/playground-web/src/components/code/RenderCode.tsx`, `apps/playground-web/src/components/code/code.client.tsx`, `apps/playground-web/src/app/connect/sign-in/components/CollapsibleSection.tsx`, `apps/playground-web/src/components/ui/checkbox.tsx`, `apps/playground-web/src/app/AppSidebar.tsx`, `apps/playground-web/src/components/ui/DynamicHeight.tsx`, `apps/playground-web/src/components/ui/switch.tsx`, `apps/playground-web/src/components/code/code-example.tsx`, `apps/playground-web/src/components/blocks/APIHeader.tsx`, `apps/playground-web/src/app/layout.tsx`, `apps/playground-web/src/components/code/code.tsx`, `apps/playground-web/src/components/ui/radio-group.tsx`, `packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx`, `apps/playground-web/src/app/connect/sign-in/components/LocaleFormControl.tsx`, `apps/playground-web/src/components/ui/button.tsx`, `apps/playground-web/src/components/ui/scroll-area.tsx`, `apps/playground-web/src/app/connect/sign-in/embed/page.tsx`, `apps/playground-web/src/app/connect/sign-in/headless/page.tsx`, `apps/playground-web/src/components/ui/tooltip.tsx`, `apps/playground-web/src/components/ui/CustomAccordion.tsx`, `apps/playground-web/src/app/MobileHeader.tsx`, `apps/playground-web/src/app/connect/sign-in/button/page.tsx`, `apps/playground-web/public/thirdweb.svg`, `apps/playground-web/src/app/connect/sign-in/components/InAppWalletFormGroup.tsx`, `apps/playground-web/src/app/globals.css`, `apps/playground-web/src/app/connect/auth/page.tsx`, `apps/playground-web/src/app/connect/pay/page.tsx`, `apps/playground-web/src/components/ui/ScrollShadow/ScrollShadow.tsx`, `apps/playground-web/src/app/connect/in-app-wallet/page.tsx`, `apps/playground-web/src/app/connect/blockchain-api/page.tsx`, `apps/playground-web/src/app/connect/account-abstraction/page.tsx`, `apps/playground-web/src/app/connect/sign-in/components/WalletsSelection.tsx`, `pnpm-lock.yaml`, `apps/playground-web/src/components/ui/sidebar.tsx`, `apps/playground-web/src/app/connect/sign-in/components/CodeGen.tsx`, `apps/playground-web/src/app/connect/sign-in/components/ColorFormGroup.tsx`, `apps/playground-web/src/components/ui/select.tsx`, `apps/playground-web/src/app/connect/sign-in/button/RightSection.tsx`, `apps/playground-web/src/app/connect/sign-in/button/LeftSection.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-22 01:14:22 +05:30
MananTank c48a0b1105 Remove collapse toggle from Trusted Forwards form control in deploy page (#4231)
FIXES: DASH-167
2024-08-21 17:37:16 +00:00
kien-ngo 6b9b3efb51 [Dashboard] Account page v5 (#4219)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update the contract UI components to use the latest contract data and improve the account creation process.

### Detailed summary
- Updated `useRouteConfig.tsx` to conditionally render `LazyContractAccountsPage`
- Refactored `CreateAccountButton.tsx` to use `ThirdwebContract`
- Modified `page.tsx` to use `ThirdwebContract` and `ExtensionDetectedState` types

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-21 17:14:01 +00:00
kien-ngo 654cbbaa2e [Dashboard] Permission page to v5 (#4218)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to implement a feature that detects and handles permissions enumerable in contracts.

### Detailed summary
- Added detection and handling of `PermissionsEnumerable` feature in contracts
- Updated components to utilize the detected `PermissionsEnumerable` flag
- Refactored and optimized contract permission handling logic

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-21 17:13:58 +00:00
Joe-ThirdwebandGitHub 88bbbd5a01 Joe - Chainlist Page update 0gLabs (#4233) 2024-08-21 10:10:51 -07:00
kien-ngo 0c2fd4db98 [Dashboard] Remove ethers from int-input (#4234)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR replaces `parseEther` with `toWei` in `SolidityIntInput` component for input conversion.

### Detailed summary
- Replaced `parseEther` with `toWei` for input conversion
- Updated import from `thirdweb`
- Removed unused import of `useCallback`
- Updated `Button` import from `tw-components`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-21 17:02:45 +00:00
kien-ngo 2c37732984 [SDK] Fix abi param parsing (#4229)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to enhance the parsing functionality for Solidity types in the contract UI components and transaction handling.

### Detailed summary
- Added parsing logic for `string` type in `parseAbiParams`
- Improved handling of different data types in contract transactions
- Added test cases for parsing `string` and `number` in contract transactions

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-21 17:02:36 +00:00
MananTank 783e448e2e Stricter correctness rules in biome (#4216)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to remove unnecessary error handling blocks in various catch statements.

### Detailed summary
- Removed error variable from catch blocks in multiple files.
- Simplified catch blocks to just `catch {}` where error handling was not required.

> The following files were skipped due to too many changes: `apps/dashboard/src/utils/fetchChain.ts`, `packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.ts`, `packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts`, `packages/thirdweb/src/auth/verify-hash.ts`, `packages/thirdweb/src/contract/verification/constructor-params.ts`, `apps/wallet-ui/src/components/NftModal.tsx`, `apps/playground-web/src/components/in-app-wallet/connect-button.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/components/server/ChainOverviewSection.tsx`, `packages/thirdweb/src/extensions/erc721/lazyMinting/write/createDelayedRevealBatch.ts`, `packages/thirdweb/src/react/web/ui/ConnectWallet/screens/WalletConnectReceiverScreen.tsx`, `apps/dashboard/src/contract-ui/components/solidity-inputs/helpers.ts`, `packages/service-utils/src/core/api.ts`, `apps/playground-web/src/components/in-app-wallet/sponsored-tx.tsx`, `apps/playground-web/src/components/account-abstraction/sponsored-tx.tsx`, `apps/playground-web/src/app/connect/auth/page.tsx`, `apps/dashboard/src/components/contract-components/hooks.ts`, `packages/thirdweb/src/wallets/in-app/native/helpers/auth/middleware.ts`, `apps/dashboard/src/lib/sdk.ts`, `apps/playground-web/src/app/page.tsx`, `apps/dashboard/src/contexts/configured-chains.tsx`, `legacy_packages/unity-js-bridge/src/thirdweb-bridge.ts`, `packages/thirdweb/src/cli/commands/generate/generate.ts`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-21 09:56:04 +00:00
MananTank 6c87d7ba3a Add useHookAtTopLevel rule in biome and fix lint errors (#4213)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to address linting issues related to the use of hooks at the top level in various components.

### Detailed summary
- Added `correctness` rule in `biome.json` for `useHookAtTopLevel`
- Added error handling and comments for `useQuery` in `useReadContract` functions
- Refactored `RNImage.tsx` to use `useMemo` for image handling
- Improved error handling in `ViewNFTs.tsx` for `fetchNFTs` function

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-21 01:11:23 +00:00
kien-ngo 6b8bde1abf [Dashboard] Replace useSDKChainId (#4217)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to refactor hook dependencies in the dashboard component to use `useDashboardEVMChainId` instead of `useSDKChainId`.

### Detailed summary
- Updated imports to use `useDashboardEVMChainId` from `@3rdweb-sdk/react`
- Replaced all instances of `useSDKChainId` with `useDashboardEVMChainId`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-21 00:40:41 +00:00
kien-ngo 81b33c7d7c [Dashboard] useContractEvents to v5 (#4215)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates event handling in the dashboard by refactoring components, adding type definitions, and improving event filtering.

### Detailed summary
- Refactored components to handle events using `ThirdwebContract` type
- Added type definitions for `InternalTransaction` and `PreparedEvent`
- Improved event filtering and handling in `useActivity` and `EventsFeed`
- Updated `LatestEvents` and `ContractEventsPage` components to use `ThirdwebContract` type

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/events/components/events-feed.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-21 00:40:40 +00:00
kien-ngo e37ac839b2 [Dashboard] claim-condition page (#4208)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update claim conditions for ERC721, ERC1155, and ERC20 contracts.

### Detailed summary
- Updated claim condition tabs for ERC721, ERC1155, and ERC20 contracts
- Added detection of new claim conditions for different contract types
- Refactored components to use updated contract information

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-21 00:24:22 +00:00
kien-ngo 462e1fd2aa [Dashboard] chore: remove getErc (1155) (#4207)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to refactor the `useNFTDrawerTabs` function in the `useNftDrawerTabs.tsx` file to use `isERC1155` instead of `erc1155` for better clarity.

### Detailed summary
- Refactored references from `erc1155` to `isERC1155` for clarity
- Updated `contractAddress` and `chainId` values to use `contract` object properties instead of `erc1155`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 23:58:29 +00:00
kien-ngo b4d8be4f91 [Dashboard] Remove some stuff from claim-condition-form (#4206)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the Claim Conditions Form component to use the `useReadContract` hook and `decimals` extension from `thirdweb/extensions/erc20`.

### Detailed summary
- Replaced `useTokenDecimals` with `useReadContract` for token decimals retrieval
- Added `decimals` import from `thirdweb/extensions/erc20`
- Added `useReadContract` import from `thirdweb/react`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 23:57:54 +00:00
kien-ngo 15b7e8cfb8 [Dashboard] Remove type UploadProgressEvent (#4205)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to re-export `UploadProgressEvent` type and import it in `batch-lazy-mint-button.tsx`.

### Detailed summary
- Re-exported `UploadProgressEvent` type from `progress-box.tsx`
- Imported `UploadProgressEvent` in `batch-lazy-mint-button.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 23:57:52 +00:00
kien-ngo 886094fbac [Dashboard] Migrate /code page to v5 (#4204)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR improves contract code rendering in the dashboard.

### Detailed summary
- Updated rendering logic for contract code in various components
- Added type `AbiType` for compatibility
- Refactored `ContractCodePage` to use `ThirdwebContract` instead of `contractAddress`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 22:36:27 +00:00
gregandGitHub 0a1bce8fa8 FIX: In-App Metadata Image Display (#4214) 2024-08-20 15:19:37 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3ccfa981a8 chore(deps): bump @sentry/nextjs from 8.9.2 to 8.26.0 (#4182)
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-20 15:10:32 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
fb96e83081 chore(deps-dev): bump tailwindcss from 3.4.4 to 3.4.10 (#4183)
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-20 14:57:14 -07:00
Jonas DanielsandGitHub 9768b0c0b7 [Refactor] Update account plan management and remove trial-related logic (#4221) 2024-08-20 14:55:26 -07:00
Jonas DanielsandGitHub 2312f61329 [Update] Replace abuse redirect with email link (#4220) 2024-08-20 14:54:50 -07:00
Jonas DanielsandGitHub 042439aab9 [Refactor] Remove Twitter handles from ambassadors list (#4209) 2024-08-20 14:54:04 -07:00
kien-ngo 0368ee538e [Dashboard] Add useDashboardOwnedNFTs hook (#4203)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update the `quantityOwned` type in the NFTs types, add a new hook for getting owned NFTs, and make adjustments in the Create Listings Form component.

### Detailed summary
- Updated `quantityOwned` type to `bigint` in NFTs types.
- Added `useDashboardOwnedNFTs` hook for fetching owned NFTs.
- Adjusted logic in Create Listings Form component for using the new hook and contract handling.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 21:37:09 +00:00
gregfromstl c6d4aef91b Revert "Dashboard: Allow more domains (#4192)" (#4212)
This reverts commit 4bf8296546.

## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the domain validation logic in `validations.ts` to allow only "localhost" as a domain prefix.

### Detailed summary
- Updated domain validation to allow only "localhost" as a domain prefix.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 21:15:09 +00:00
kien-ngo 86c953f18e [Dashboard] Remove useContract from Explorer page (#4202)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update contract-related components and hooks to use `ThirdwebContract` instead of `SmartContract`.

### Detailed summary
- Updated components and hooks to use `ThirdwebContract` instead of `SmartContract`
- Added conditional rendering based on contract and ABI availability
- Removed unnecessary imports and code snippets

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 20:33:38 +00:00
MananTank 4ce4072031 Hide Buy Funds section on testnet chain pages (#4210)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds a conditional rendering for a `FaucetSection` component based on the `chain.testnet` value in the `page.tsx` file of the `chainPage` in the dashboard.

### Detailed summary
- Added conditional rendering for `FaucetSection` based on `chain.testnet` value
- Renamed "Buy Funds" to "Faucet / Buy Funds"
- Updated rendering logic for `FaucetSection` and `BuyFundsSection` based on `chain.testnet` and service availability

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 20:18:41 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
bd42363602 Version Packages (#4175)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-20 11:27:36 -07:00
gregfromstl 42cdc3a2bc UI Cleanup (#4191)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the connect modal styles and adds support for wallet authentication in the authentication flow.

### Detailed summary
- Updated connect modal styles
- Added support for wallet authentication
- Modified styles for various UI components
- Added a new component for copying addresses
- Improved wallet image rendering based on wallet type

> The following files were skipped due to too many changes: `packages/thirdweb/src/wallets/custom/smart/image.ts`, `packages/thirdweb/src/react/web/ui/ConnectWallet/Details.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 17:52:34 +00:00
MananTank 4abf7a7f25 Fix Conditionally rendered hook error in Buy with Fiat flow (#4211)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on fixing a conditionally rendered hook error when buying funds using fiat.

### Detailed summary
- Added a new `onPostOnrampSuccess` function to handle successful post onramp swap
- Changed the logic to report fiat status instead of post onramp swap status after successful swap

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 17:31:14 +00:00
kien-ngo 8b0fd13adb [Dashboard] Sources page to v5 (#4201)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update contract-related components and hooks, resolve ABI types, and improve UX in the dashboard.

### Detailed summary
- Updated components and hooks related to contracts
- Resolved ABI types with `abitype`
- Improved UX in the dashboard by updating sources display

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 17:11:57 +00:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
20bd3aa399 chore(deps): bump tailwind-merge from 2.4.0 to 2.5.2 (#4189)
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-20 10:10:48 -07:00
joaquim-verges fcfd22c01e feat(adapters): add documentation for wagmi and privy integration (#4198)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update the usage of adapters in the thirdweb SDK for compatibility with different libraries.

### Detailed summary
- Updated adapter names in sidebar links
- Added new adapters in sidebar
- Modified the conversion process for ethers5 and ethers6 adapters
- Added examples for using thirdweb SDK with wagmi and privy

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 16:54:22 +00:00
kien-ngo 8dc23e376e [Dashboard] Fix import path (#4200)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the dashboard contract UI tabs page by removing unused imports and refactoring some dependencies.

### Detailed summary
- Removed unused import `thirdwebClient`
- Refactored dependencies related to `3rdweb-sdk/react` and `3rdweb-dev/react`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 10:12:12 +00:00
Kien NgoandGitHub 542f97dc4b [Dashboard] Migrate useContractSources to v5 (#4145) 2024-08-20 21:04:19 +12:00
kien-ngo 46ca21d128 [Dashboard] Explorer page to v5 (#4174)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to enhance contract function interaction by integrating V5 features and updating contract call handling.

### Detailed summary
- Added `useV5DashboardChain` and `getContract` from `lib/v5-adapter` and `thirdweb` respectively
- Updated `ContractFunction` component to use V5 contract and handle contract calls
- Updated `InteractiveAbiFunction` component to use `ThirdwebContract` and improve contract call handling

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 08:45:43 +00:00
kien-ngo 551349cbc6 [Dashboard] envs clean-up (#4170)
- [x] Remove a lof of duplicated instances of `ThirdwebClient` & env variables across multiple files
- [x] There's only 1 main ThirdwebClient from now on which can be imported from `lib/thirdweb-client`. It can switch between clientId and secretKey depends on the environment
- [x] All env variables like `DASHBOARD_THIRDWEB_CLIENT_ID`, `DASHBOARD_THIRDWEB_SECRET_KEY`, `isProd` etc. now live inside `@/constants/env`

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates import paths and constants related to the `thirdwebClient` and `isProd` across multiple files.

### Detailed summary
- Updated import paths for `thirdwebClient` and `isProd`
- Replaced `constants/rpc` with `constants/env`
- Removed unused imports and constants

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/overview/page.tsx`, `apps/dashboard/src/contract-ui/tabs/nfts/components/airdrop-tab.tsx`, `apps/dashboard/src/components/app-layouts/app.tsx`, `apps/dashboard/src/components/app-layouts/provider-setup.tsx`, `apps/dashboard/src/contract-ui/tabs/manage/page.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/opengraph-image.tsx`, `apps/dashboard/src/lib/sdk.ts`, `apps/dashboard/src/@/constants/client.ts`, `apps/dashboard/src/app/(dashboard)/(chain)/components/server/chain-icon.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/FaucetButton.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/tx/[txHash]/page.tsx`, `apps/dashboard/src/pages/api/moralis/balances.ts`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 07:55:31 +00:00
gregfromstl 4bf8296546 Dashboard: Allow more domains (#4192)
Requested for electron app domains

<!-- start pr-codex -->

---

## PR-Codex overview
This PR loosens the domain validation in `validations.ts` to allow cases where strict validation was causing issues.

### Detailed summary
- Loosened domain validation to allow cases where strict validation was too limiting
- Updated the condition to check if the domain includes ":" instead of splitting it

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 07:34:44 +00:00
Joaquim VergesandGitHub 7efef7d9e1 feat(pay): show pay modal when insufficient balance for gas cost (#4194) 2024-08-20 19:29:52 +12:00
kien-ngo 4d85aa56c6 [Dashboard] Fix types for contract published version (#4197)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the `publish.tsx` and `index.tsx` files to handle cases where `version` is undefined by defaulting to "latest".

### Detailed summary
- In `publish.tsx`, added a default value of "latest" if `v` is undefined in the `SelectItem` component.
- In `index.tsx`, changed the `version` type from `string` to `string | undefined` and added a default value of "latest" if `version` is undefined when constructing the `PublishedContractOG` object.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 07:18:40 +00:00
Jonas DanielsandGitHub decc1a56d2 [Fix] Handle optional versions in contract publishing (#4196) 2024-08-19 21:57:27 -07:00
joaquim-verges a60db3a057 feat(adapters): add documentation and examples for ethers5, ethers6, and viem adapters (#4195)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to introduce adapters for converting between Thirdweb and ethers.js/viem objects.

### Detailed summary
- Added `ethers5Adapter` and `ethers6Adapter` for Thirdweb to ethers.js conversion
- Added `viemAdapter` for Thirdweb to viem conversion
- Convert Thirdweb accounts, contracts, clients to ethers.js/viem and vice versa

> The following files were skipped due to too many changes: `packages/thirdweb/src/adapters/viem.ts`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 04:51:32 +00:00
Jonas DanielsandGitHub 377f176b10 [Refactor] Replace max with min function and update import paths (#4193) 2024-08-19 20:08:13 -07:00
joaquim-verges 5ead75e41a fix(dashboard): update Expo Starter repo URL (#4190)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update the repository link in the Expo Starter template from `node-starter` to `expo-starter`.

### Detailed summary
- Updated repository link from "https://github.com/thirdweb-example/node-starter" to "https://github.com/thirdweb-example/expo-starter".

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 00:32:31 +00:00
MananTank 8836c27b8d Fix Table loading spinner position (#4187)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds a `className="relative"` to various `TableContainer` components in different files for improved styling consistency.

### Detailed summary
- Added `className="relative"` to `TableContainer` in `contract-table/index.tsx`
- Added `className="relative"` to `TableContainer` in `contract-table-v2/index.tsx`
- Added `className="relative"` to `TableContainer` in `deployed-contracts.tsx`
- Added `className="relative"` to `TableContainer` in `table.tsx`
- Added `className="relative"` to `TableContainer` in `marketplace-table.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-20 00:04:50 +00:00
kien-ngo cbd6fd87d0 [SDK] Update Lens test (#4188)
<!-- start pr-codex -->

## PR-Codex overview
This PR focuses on updating a test in `resolveAddress.test.ts` to run only if a secret key is provided.

### Detailed summary
- Updated test to run only if `process.env.TW_SECRET_KEY` is provided.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-19 21:51:35 +00:00
kien-ngo ef9cc55b69 [Dashboard] Remove v4 code on some Marketplace components
(#4128)

## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR exposes `max()` and `min()` utility methods for bigints and updates marketplace-related components to use these methods for better handling of large numbers.

### Detailed summary
- Exposes `max()` and `min()` utility methods for bigints in `thirdweb/utils`
- Updates components in `dashboard` related to marketplace to use `max()` and `min()` for handling large numbers efficiently

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/overview/components/MarketplaceDetails.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-19 20:06:26 +00:00
kien-ngo 15899ea231 [Dashboard] Fix styling for no-image NFT (#4181)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update the styling of the `NFTMedia` component by adding explicit `width` and `height` properties.

### Detailed summary
- Added inline styles for `width` and `height` based on `props`
- Updated `className` to include `border-border` class

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-19 19:47:32 +00:00
kien-ngo bd4669984d [Portal] Update some docs (#4177)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to introduce gasless transaction configurations and transaction annotations.

### Detailed summary
- Added gasless transaction configurations for Engine, OpenZeppelin, and Biconomy providers
- Introduced transaction annotations for Engine, OpenZeppelin, and gasless options
- Updated transaction button components to include transaction annotations
- Exposed GaslessOptions type for gasless transactions configuration

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-19 19:29:55 +00:00
MananTank fb799ccb6d Move publish metadata spinner inside form, show error message (#4180)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds an error message display for failed metadata fetch in the `CustomContractForm` component.

### Detailed summary
- Added error message display for failed metadata fetch
- Imported `InfoIcon` component
- Removed conditional rendering for loading spinner outside the form provider block

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-19 18:24:20 +00:00
kien-ngo c8f7a68225 [Dashboard] (partial) useContract removal (#4111)
Slowly moving everything upward. This PR mainly focuses on removing `useContract` from the page level (`page.tsx` files)

Routes to test:
- [x] direct listings page
- [x] english auction page
- [x] Split contract page
- [x] Contract account page
- [x] contract settings page
- [x] contract token page

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update various components to use `ThirdwebContract` instead of `contractAddress` and `chainId`.

### Detailed summary
- Update components to use `ThirdwebContract` instead of `contractAddress` and `chainId`
- Replace `useContract` calls with `contract.address`
- Import `ThirdwebContract` type for type checking

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/shared-components/marketplace-table.tsx`, `apps/dashboard/src/contract-ui/tabs/shared-components/cancel-tab.tsx`, `apps/dashboard/src/contract-ui/tabs/shared-components/listing-drawer.tsx`, `apps/dashboard/src/contract-ui/tabs/english-auctions/components/table.tsx`, `apps/dashboard/src/contract-ui/tabs/direct-listings/components/table.tsx`, `apps/dashboard/src/contract-ui/tabs/english-auctions/page.tsx`, `apps/dashboard/src/contract-ui/tabs/direct-listings/page.tsx`, `apps/dashboard/src/contract-ui/tabs/split/page.tsx`, `apps/dashboard/src/contract-ui/tabs/overview/page.tsx`, `apps/dashboard/src/contract-ui/tabs/shared-components/list-button.tsx`, `apps/dashboard/src/contract-ui/tabs/account-permissions/page.tsx`, `apps/dashboard/src/contract-ui/tabs/embed/page.tsx`, `apps/dashboard/src/contract-ui/tabs/settings/page.tsx`, `apps/dashboard/src/contract-ui/tabs/account/page.tsx`, `apps/dashboard/src/contract-ui/tabs/tokens/page.tsx`, `apps/dashboard/src/contract-ui/hooks/useRouteConfig.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-19 18:12:53 +00:00
gregfromstl 246701d615 Wallet Linking UI (#4124)
https://github.com/user-attachments/assets/abf70934-8070-4844-8f15-8db6ec40c116

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds the ability to link a wallet in the Connect UI.

### Detailed summary
- Added a new `linkWallet` field in locale types for various languages
- Updated UI components to support linking a wallet
- Introduced `WalletAuth` component for wallet authentication
- Modified wallet selection behavior in `WalletSelector` component

> The following files were skipped due to too many changes: `packages/thirdweb/src/react/web/ui/ConnectWallet/WalletSelector.tsx`, `packages/thirdweb/src/react/web/wallets/shared/PassKeyLogin.tsx`, `packages/thirdweb/src/react/web/wallets/in-app/WalletAuth.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-19 17:01:20 +00:00
Joaquim VergesandGitHub cb591aa6af feat(pay): only show pay modal if the active account doesnt have enough funds (#4172) 2024-08-19 21:15:54 +12:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
09927f3ac5 Version Packages (#4162)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-19 20:17:56 +12:00
gregfromstl 7778063458 Improve Blobbie Appearance (#4173)
Blobbies now select from a subset of predefined colors to form a basic radial gradient form the bottom right corner.

![image](https://github.com/user-attachments/assets/5b708533-506d-417d-ac49-2356aa0a2247)

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the appearance of the Blobbie avatar in the ConnectWallet feature of `thirdweb`.

### Detailed summary
- Updated Blobbie appearance with unique gradient colors based on address
- Replaced complex color pairing logic with predefined color options
- Simplified Blobbie rendering logic for better performance

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-19 06:17:43 +00:00
Joaquim VergesandGitHub 574ff0295d feat(dashboard): update apple-app-site-association for universal links (#4171) 2024-08-19 11:54:40 +12:00
kien-ngo a43907e2df [SDK] resolveAddress for Lens handles (#4150)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to enhance the `Lens` extension in the `thirdweb` package by adding the ability to resolve addresses and handle crypto transactions efficiently.

### Detailed summary
- Added `resolveAddress` function for handling crypto transactions with lens handles
- Updated contract addresses and overrides for Lens smart contracts
- Created tests for `resolveAddress` function to ensure correct address resolution

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-18 23:10:46 +00:00
kien-ngo f6d6c86ec0 [Dashboard] Fix ENS resolve issue (#4168)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the `thirdwebClient` configuration in `thirdweb-client.ts` to include a `secretKey` option if `DASHBOARD_THIRDWEB_SECRET_KEY` is defined.

### Detailed summary
- Updated `thirdwebClient` configuration to include `secretKey` if `DASHBOARD_THIRDWEB_SECRET_KEY` is defined
- Added conditional logic for `secretKey` presence

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-18 22:21:10 +00:00
Joaquim VergesandGitHub 23041c013f feat(dashboard): add apple universal link association (#4169) 2024-08-19 10:04:20 +12:00
kien-ngo 43f9319ac7 [SDK] Add GaslessOptions to useSendAndConfirmTransaction (#4165)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to add Gasless transaction support for the `sendTransaction` and `sendAndConfirmTransaction` functions, as well as for the `useSendTransaction` and `useSendAndConfirmTransaction` hooks.

### Detailed summary
- Added `GaslessOptions` support to `sendTransaction`
- Introduced Gasless usage with `thirdweb Engine` in various transaction-related functions and hooks
- Added `GaslessOptions` configuration to `useSendTransaction` and `useSendAndConfirmTransaction` hooks
- Updated documentation and examples to showcase Gasless transaction usage

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-18 10:05:37 +00:00
kien-ngo fc8daaa2bc [Dashboard] Remove ethers.js (#4163)
<!-- start pr-codex -->

## PR-Codex overview
This PR focuses on exporting a utility method `isBytes` and updating types to `bigint`.

### Detailed summary
- Exported `isBytes` utility method
- Updated `nextTokenIdToMint` type to `bigint`
- Updated imports for `isAddress`, `isBytes`, and `isHex`
- Refactored display balance calculations to use `toTokens` function

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/nfts/components/batch-lazy-mint-button.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-18 07:04:05 +00:00
kien-ngo 9133b45700 [Dashboard] useVote to v5 (#4154)
<!-- start pr-codex -->

## PR-Codex overview
This PR updates TypeScript documentation and refactors Vote-related components for clarity and consistency.

### Detailed summary
- Updated TypeScript documentation for `ProposalVoteInfo`
- Refactored `VoteButton` and `DelegateButton` components to use `ThirdwebContract`
- Improved display of voting token decimals in `Proposal` component

> The following files were skipped due to too many changes: `apps/dashboard/src/@3rdweb-sdk/react/hooks/useVote.ts`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-18 05:02:05 +00:00
kien-ngo 44c78f4643 [Dashboard] useRemoveContractMutation to v5 + minor cleanups (#4155)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to refactor gasless transaction handling in the Dashboard by centralizing contract addresses and relayer URLs.

### Detailed summary
- Introduced `MULTICHAIN_REGISTRY_CONTRACT` constant for contract address
- Centralized relayer URL and forwarder address in `DASHBOARD_ENGINE_RELAYER_URL` and `DASHBOARD_FORWARDER_ADDRESS`
- Updated functions to use centralized constants for contract addresses and relayer URLs

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-18 03:55:32 +00:00
kien-ngo 7aee37b10f [Dashboard] Replace useSDKChainId with useDashboardEVMChainId (#4144)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to replace the usage of `useSDKChainId` with `useDashboardEVMChainId` in multiple components for better compatibility and functionality.

### Detailed summary
- Replaced `useSDKChainId` with `useDashboardEVMChainId` in multiple components.
- Updated imports and dependencies accordingly.
- Improved compatibility and functionality for the dashboard.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-18 03:43:32 +00:00
kien-ngo 23a665bdaa [Dashboard] Remove v4 type: OptionalPropertiesInput (#4158)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to update the type definition for `attributes` in the `IPropertyFieldValues` interface.

### Detailed summary
- Updated `OptionalPropertiesInput` type definition to be a key-value pair object
- Changed `attributes` type in `IPropertyFieldValues` interface to use the updated type definition

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-18 03:32:30 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
9e46b5b94e Version Packages (#4121)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-18 12:37:18 +12:00
gregfromstl e0dcc64256 Fix connect button border in firefox (#4160)
Corrects an issue with the border visibility in firefox by explicitly specifying the div height

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on fixing the connect button border issue on Firefox browser.

### Detailed summary
- Added `height: "50px"` to the button style in `Details.tsx` for proper display on Firefox.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-18 00:03:46 +00:00
gregfromstl f0d6e343ee Adds EIP-1271 Signature Validation Fallback (#4156)
This PR EIP-1271 fallback for smart contract validation since not all chains support the deployless call used in 6792 flow.

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to fix smart contract wallet signature validation on older chains.

### Detailed summary
- Updated the prompt text for signing in on the wallet UI
- Added a fallback to EIP1271 validation for chains not supporting eth_call simulation
- Introduced a new function `verifyEip1271Signature` for EIP1271 signature validation

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-17 23:43:45 +00:00
gregfromstl cf4443a9eb Improve Blobbie Algo (#4159)
![image](https://github.com/user-attachments/assets/cfc34112-3b94-4125-8aba-4a065d7c9ec2)
![image](https://github.com/user-attachments/assets/9daf26b0-fde8-4a77-bebf-a77f94d444f2)
![image](https://github.com/user-attachments/assets/91c4ceb1-c3c0-4be6-a654-d233b699495a)
![image](https://github.com/user-attachments/assets/7a298ad2-7fa4-4967-a7ea-7e9ec2fcf7be)

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to improve the Blobbie algorithm for generating unique gradient avatars based on provided addresses.

### Detailed summary
- Updated color calculation logic for better color pairing
- Removed unused `nearestColor` function
- Refactored color and position calculations for Blobbie avatar
- Adjusted ellipse positions and sizes for better visual representation

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-17 23:12:15 +00:00
gregfromstl 355795a2d4 Fix text wrapping on connect button (#4157)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on fixing text wrapping on the Connect Button in the `Details.tsx` file.

### Detailed summary
- Added `whiteSpace: "nowrap"` to prevent text wrapping
- Updated styles for better button display

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-17 19:37:43 +00:00
kien-ngo 5fda794569 [SDK] Add more VoteERC20 extensions (for Dashboard) (#4139)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR exposes ERC20Vote extensions and adds more Vote contract extensions.

### Detailed summary
- Exposed ERC20Vote extensions
- Added more Vote contract extensions
- Updated types for vote and proposal states
- Implemented functions for proposal existence, execution, and voting counts

> The following files were skipped due to too many changes: `packages/thirdweb/src/extensions/vote/read/getAll.ts`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-17 12:28:02 +00:00
kien-ngo 93b3bad783 [SDK] Expose thirdweb extensions (for Dashboard) (#4149)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to export contracts related to Publisher, Multichain Registry, and Contract Factory functionalities.

### Detailed summary
- Added Publisher contract exports for reading and writing operations
- Added Multichain Registry exports for reading and writing operations
- Added Contract Factory export for deploying proxies

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-17 12:02:02 +00:00
Joaquim VergesandGitHub f5952621ab feat(wallet): handle eth_sendTransaction when doing zksync direct deploys (#4153) 2024-08-17 23:52:10 +12:00
kien-ngo 1d9f4e5e3e [Dashboard] MismatchButton to v5 (#4152)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-17 10:01:56 +00:00
gregfromstl 2e99057f90 feat(wallet-ui): initial app (#3478)
1. Created a new `.env.example` file specifying the `NEXT_PUBLIC_ROOT_DOMAIN` variable.
2. Updated `.gitignore` to include `.env*.local` instead of `.env*`.
3. Modified the `Layout` component in `[ecosystem]/layout.tsx` to accept `children` and `params` properties and display the ecosystem and children elements.
4. Updated the `Page` component in `[ecosystem]/page.tsx` to return a simple `div` with the text `Page`.
5. Added a new `middleware.ts` file to handle dynamic routing based on the request host, matching all paths except for specific routes (e.g., `/api`, `/_next`, `/_static`). Rewrites the URL to point to either the root application or the appropriate ecosystem dynamic route.

---

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on adding ecosystem-related features and improving UI components.

### Detailed summary
- Added `Ecosystem` and token types
- Updated `biome.json` schema
- Implemented revalidate function
- Added NFT loading and card components
- Updated environment variables
- Improved layout and metadata handling
- Added new UI components like `Skeleton`, `Label`, and `Input`
- Enhanced client and ecosystem API integration

> The following files were skipped due to too many changes: `apps/wallet-ui/src/lib/chains.ts`, `apps/wallet-ui/src/components/ui/sonner.tsx`, `apps/wallet-ui/src/components/ConnectButton.tsx`, `apps/wallet-ui/src/app/[ecosystem]/login/page.tsx`, `apps/wallet-ui/src/app/[ecosystem]/(ui)/layout.tsx`, `apps/wallet-ui/src/components/ui/badge.tsx`, `apps/wallet-ui/src/components/ui/popover.tsx`, `apps/wallet-ui/src/middleware.ts`, `apps/wallet-ui/src/lib/assets/erc20.ts`, `apps/wallet-ui/src/components/ui/button.tsx`, `apps/wallet-ui/src/components/NftCard.tsx`, `apps/wallet-ui/src/components/NftGallery.tsx`, `apps/wallet-ui/src/lib/auth.ts`, `apps/wallet-ui/src/lib/assets/erc721.ts`, `apps/wallet-ui/src/app/[ecosystem]/(ui)/wallet/[address]/layout.tsx`, `apps/wallet-ui/src/util/simplehash.ts`, `apps/wallet-ui/src/components/ChainCombobox.tsx`, `apps/wallet-ui/src/components/TransactionToastProvider.tsx`, `apps/wallet-ui/src/app/globals.css`, `apps/wallet-ui/src/components/ChainIcon.tsx`, `apps/wallet-ui/src/components/ui/dialog.tsx`, `apps/wallet-ui/src/components/ui/form.tsx`, `apps/wallet-ui/src/components/ui/command.tsx`, `apps/wallet-ui/src/components/NftModal.tsx`, `pnpm-lock.yaml`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-17 08:08:48 +00:00
gregfromstl 13764f1abb Connect UI Profile Image Improvements (#4126)
<!-- start pr-codex -->

## PR-Codex overview
This PR focuses on cosmetic improvements to the Connect UI, introduces Blobbie component for unique avatars, and updates button styles and sizes.

### Detailed summary
- Increased `minWidth` of `TransactionButton` to 165px
- Updated `defaultButtonTitle` in `en.ts`
- Added `Blobbie` component for unique avatars
- Updated button styles and sizes in `ConnectButton.tsx`
- Added `shortenAddress` import in `wallet.ts`
- Updated styles in `Details.tsx` and `DetailsModal`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-17 08:03:28 +00:00
iuwqyir 997c3945a7 export usageEventSchema and UsageEvent (#4147)
## Problem solved

Almost the same as https://github.com/thirdweb-dev/js/pull/4122. Made a new PR, because hadn't setup commit signing for graphite, so it failed to merge

Exports the Zod schema for usage events. This way it can be used for validate the message before sending it to the usage tracker queue.
Moved it under core because it is not tied to worker logic and can be used outside workers.
Also exported `UsageEvent` and `usageEventSchema` under node, because I think core is not exported

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to export `usageEventSchema` for Cloudflare worker and define `UsageEvent` schema for node.

### Detailed summary
- Exported `usageEventSchema` for Cloudflare worker and defined `UsageEvent` schema for node
- Added detailed schema for usage events with various optional fields

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-16 21:15:34 +00:00
MananTank 2bf2e1eec4 Update Engine page header (#4125)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces UI improvements to the Engine page layout, including new components, styling updates, and a modal for updating the Engine version.

### Detailed summary
- Added `CopyTextButton`, `Button`, and `Separator` components
- Updated styling and structure of the Engine page layout
- Implemented a modal for updating the Engine version
- Added new icons and components for UI enhancements

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-16 20:37:12 +00:00
MananTank 9b3725a56e Migrate Engine list UI to shadcn/tailwind (#4123)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR enhances UI components in the dashboard app.

### Detailed summary
- Updated tooltip styling in `tooltip.tsx`.
- Refactored dropdown menu in `dropdown-menu.tsx`.
- Improved table UI with dropdown menus in `TWTable.tsx`.
- Implemented modals for editing and removing engine instances in `engine-instances-table.tsx`.

> The following files were skipped due to too many changes: `apps/dashboard/src/components/engine/engine-instances-table.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-16 20:37:11 +00:00
MananTank beafe43f46 Move Engine import from Modal to /dashboard/engine/import (#4119)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to refactor the Engine sidebar component and improve error handling in Engine pages.

### Detailed summary
- Refactored `EngineSidebar` component
- Improved error handling with `PageLoading` and `EngineErrorPage`
- Added import functionality for Engine instances

> The following files were skipped due to too many changes: `apps/dashboard/src/pages/dashboard/engine/import.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-16 20:37:11 +00:00
Winston YeoandGitHub 214a74c36a chore: add authentication method to usage tracking (#4146) 2024-08-16 20:17:57 +00:00
MananTank d0e3c4defc Fix hydration error in markdown renderer + property and ts cleanup (#4141)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR refactors the `MarkdownRenderer` component in `published-contract`.

### Detailed summary
- Refactored heading components (`h1`, `h2`, `h3`, `h4`, `h5`, `h6`) to remove explicit `any` type
- Refactored `a`, `code`, `p`, `table`, `th`, `td`, `ul`, `ol`, `li` components to use cleaned props without `node`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-16 18:30:57 +00:00
MananTank 0cdf34ea98 Move Engine pages from client Router to Pages Router (#4113)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR upgrades Engine navigation links, adds new pages for Engine management, and refactors list styling.

### Detailed summary
- Updated Engine navigation links
- Added new pages for Engine management
- Refactored list styling in components

> The following files were skipped due to too many changes: `apps/dashboard/src/components/engine/engine-instances-table.tsx`, `apps/dashboard/src/pages/dashboard/engine/create.tsx`, `apps/dashboard/src/components/engine/EnginePageLayout.tsx`, `apps/dashboard/src/components/engine/engine-list.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-16 15:45:43 +00:00
MananTank b1632a3df1 Add force-dynamic declaration for pages using cookies - fix sentry errors (#4140)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to add a new export `dynamic = "force-dynamic"` in three files due to the usage of `cookies()`.

### Detailed summary
- Added `export const dynamic = "force-dynamic"` in `page.tsx` under `dashboard/connect/pay`
- Added `export const dynamic = "force-dynamic"` in `page.tsx` under `dashboard/connect/ecosystem`
- Added `export const dynamic = "force-dynamic"` in `layout.tsx` under `dashboard/connect/ecosystem/[slug]/(active)`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-16 15:34:13 +00:00
jnsdls d3f43a757b [Optimize] Add CI optimization step using Graphite action (#4115)
tl;dr: https://graphite.dev/docs/stacking-and-ci#reducing-ci-runs-for-github-actions

<!-- start pr-codex -->

---

## PR-Codex overview
This PR optimizes the CI workflow by adding a step to skip unnecessary processes based on a condition.

### Detailed summary
- Added `optimize_ci` job with skip condition
- Updated `build`, `lint`, `test`, `e2e`, and `size` jobs to depend on `optimize_ci` and skip if condition is met

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 21:22:24 +00:00
gregfromstl 825352476c fix: throw when no encryption key (#4120)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on enhancing security by throwing an error when no encryption key is provided for custom authentication.

### Detailed summary
- Added error throwing when encryption key is missing for custom JWT authentication
- Added error throwing when encryption key is missing for custom auth endpoint authentication

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 21:17:20 +00:00
arcoraven 8caa095a67 fix: update transaction drawer labels (#4118)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to enhance transaction details display in the dashboard by adding support for effective gas price calculation and showing additional information like account address and block number.

### Detailed summary
- Added `effectiveGasPrice` field to calculate transaction fee
- Displayed account address and linked to explorer
- Differentiated recipient address and contract address
- Showed transaction value in tokens and symbol
- Linked block number to explorer

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 19:22:51 +00:00
jnsdls 997e1197e9 analytics overhaul (#4107)
<!-- start pr-codex -->

## PR-Codex overview
This PR enhances blockchain analytics in the dashboard. It introduces support for analytics on specific chains and updates chart components for better visualization.

### Detailed summary
- Added `CHAINSAW_API_KEY` environment variable for contract analytics
- Updated chart components for better visualization
- Improved analytics support for specific chains
- Refactored chart styling for better UI/UX

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/overview/components/Analytics.tsx`, `apps/dashboard/src/contract-ui/tabs/analytics/page.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 15:29:50 +00:00
Jonas DanielsandGitHub c9ac25fe3f Version Packages (#4114) 2024-08-15 07:38:54 -07:00
Wyatt MufsonandGitHub 79260c8cd0 Add new auth fields for redirect (#4099) 2024-08-15 07:30:59 -07:00
MananTank cf8badbc46 Move Network Configuration Form+Modal to shadcn/tailwind (#4105)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates various UI components for consistency and usability.

### Detailed summary
- Updated styling for `ClaimConditionsForm`, `CustomChainRenderer`, `ToolTipLabel`, `RpcInput`, `ChainIdInput`, `TooltipBox`, `ConfigureNetworkModal`, `ResetClaimEligibility`, `NetworkIdInput`, `IconUpload`, and `ConfigureNetworks`.
- Replaced `TooltipBox` with `ToolTipLabel` and `CircleHelpIcon`.
- Added `Input` from `@/components/ui/input`.
- Removed unnecessary imports.
- Replaced `Modal` components with `Dialog` and `DialogContent`.
- Used `toast` for error notifications.
- Updated button styling and functionality.

> The following files were skipped due to too many changes: `apps/dashboard/src/components/configure-networks/ConfigureNetworks.tsx`, `apps/dashboard/src/pages/[chain_id]/[...paths].tsx`, `apps/dashboard/src/components/configure-networks/ConfigureNetworkForm.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 05:59:21 +00:00
MananTank 09e4d80b89 Show Top Progress Bar on navigation initiated using useRouter hook (#4097)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates Next.js navigation usage in the dashboard app to `useDashboardRouter` from `@/lib/DashboardRouter`.

### Detailed summary
- Replaces `useRouter` with `useDashboardRouter` in multiple files
- Adds `DashboardRouterTopProgressBar` component import in layout files
- Introduces `useDashboardRouter` import in various components
- Defines `createStore` function in `@/lib/reactive.ts`

> The following files were skipped due to too many changes: `apps/dashboard/src/@/lib/DashboardRouter.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 05:48:22 +00:00
kien-ngo 1edd6c7e4c embed-setup.tsx to v5 (#4108)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to enhance the Contract Embed feature by integrating with `thirdwebClient` and `useV5DashboardChain`.

### Detailed summary
- Added `thirdwebClient` and `useV5DashboardChain` for contract setup
- Updated `contract` type to `ThirdwebContract`
- Refactored `buildIframeSrc` function to use `ThirdwebContract` properties

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 05:37:15 +00:00
kien-ngo 588f19639f [Dashboard] ContractMetadata settings to v5 (#4100)
<!-- start pr-codex -->

## PR-Codex overview
This PR updates the SettingsMetadata component in the contract UI to handle contract data more efficiently.

### Detailed summary
- Refactored the SettingsMetadata component to use ThirdwebContract type
- Updated schema imports and data handling
- Removed unnecessary dependencies and functions

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 05:26:34 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
f2c12781ef Version Packages (#4044)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-15 17:14:31 +12:00
kien-ngo 9d7d513d37 [Dashboard] PrimarySaleRecipient to v5 (#4098)
<!-- start pr-codex -->

## PR-Codex overview
This PR focuses on updating the contract UI settings for primary sale recipient address handling.

### Detailed summary
- Updated handling of primary sale recipient address in contract settings UI
- Refactored usage of Thirdweb SDK functions
- Added error handling for invalid recipient address
- Improved transaction handling and form reset functionality

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 01:11:20 +00:00
kien-ngo 10de2712dd [Dashboard] Remove useClaimNFT; use erc1155/claimTo (#4102)
The component in this PR is meant for Edition Drop only

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update the `ClaimTab` component to support ERC1155 contracts and improve transaction handling.

### Detailed summary
- Renamed `ClaimTab` component to `ClaimTabERC1155`.
- Updated `ClaimTabERC1155` to work with ERC1155 contracts.
- Improved transaction handling in `ClaimTabERC1155`.
- Removed unnecessary imports and updated dependencies.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 00:59:13 +00:00
gregfromstl 0ca1a79342 feat: cleanup ui (#4092)
- Reduced border radius on buttons
- Reduced connected button size
- Removed layout shift between connected and unconnected states
- Remove Rainbow from default wallets (replaced with Rabby)

https://github.com/user-attachments/assets/334f09d5-46d1-40e3-8b3a-5937771f277c

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on UI cosmetic improvements for wallet-related components.

### Detailed summary
- Added `io.rabby` wallet
- Adjusted padding and borderRadius in various components
- Modified button sizes and styles
- Updated wallet image sizes and text styles

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 00:44:18 +00:00
kien-ngo be344ac8c4 [Dashboard] Migration Royalties to v5 (#4051)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the `SettingsRoyalties` component to use new contract and royalty information and improves error handling during royalty settings updates.

### Detailed summary
- Updated `SettingsRoyalties` component to use new contract and royalty information
- Improved error handling during royalty settings updates
- Replaced `thirdweb` imports with `sonner` and `thirdweb/react`
- Refactored default royalty info handling and transaction mutation logic

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-15 00:26:39 +00:00
754ad99cfd Feat: Transaction Simulator (#3715)
Co-authored-by: Kien Ngo <[email protected]>
Co-authored-by: Manan Tank <[email protected]>
2024-08-14 17:24:31 -07:00
MananTank d6e4898458 Add Pay success tracking (#4103)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR enhances payment tracking in `MismatchButton` and `PayModalButton` components.

### Detailed summary
- Added tracking events for payment attempts and successes in `MismatchButton` and `PayModalButton`
- Utilized `useTrack` hook for event tracking
- Improved event tracking for different payment types and statuses

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-14 21:37:11 +00:00
YashandGitHub 191fb3a3a6 Modular contracts - rename extensions to modules (#3969) 2024-08-14 21:35:36 +00:00
MananTank 03a809a33f Add onPurchaseSuccess callback for Pay (#4101)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds `onPurchaseSuccess` callback to various components and hooks in the codebase, triggering when a user completes a purchase using thirdweb pay.

### Detailed summary
- Added `onPurchaseSuccess` callback to `PayEmbed`, `ConnectButton`, `TransactionButton`, and `useSendTransaction`
- Updated props in multiple components to include `onSuccess` callback parameter
- Added type definitions for `BuyWithCryptoStatus` and `BuyWithFiatStatus`
- Implemented logic to call `onSuccess` callback upon successful purchase completion

> The following files were skipped due to too many changes: `packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-14 21:05:41 +00:00
kien-ngo 874ef7af4e [Dashboard] Hide ERC721 Claim button if viewing ERC1155 Drop (#4104)
For Edition Drop we have a dedicated ClaimTabERC1155 inside each Edition's page
2024-08-14 20:10:11 +00:00
joaquim-verges ef9c7df220 feat(native): add passkey support in connect UI (#4077)
## Problem solved

Added passkey UI in connect for react native

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces passkey login support in React Native.

### Detailed summary
- Updated colors in the design system
- Added passkey domain logic
- Improved wallet loading components
- Added passkey authentication screen
- Updated wallet icons and images

> The following files were skipped due to too many changes: `packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-14 19:44:37 +00:00
joaquim-verges a640a1e147 feat(inapp): add passkey authentication for native clients (#4022)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces support for `passkeyDomain` in in-app wallets, updates error handling in signup screens, and improves storage handling.

### Detailed summary
- Added `passkeyDomain` support in in-app wallets
- Updated error handling in signup screens
- Improved storage handling for in-app wallets

> The following files were skipped due to too many changes: `packages/thirdweb/src/wallets/in-app/web/utils/Storage/LocalStorage.ts`, `packages/thirdweb/src/utils/bytecode/cbor-decode.ts`, `packages/thirdweb/package.json`, `packages/thirdweb/src/wallets/wallet-connect/receiver/session-store.test.ts`, `pnpm-lock.yaml`, `packages/thirdweb/src/wallets/in-app/native/native-connector.ts`, `packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts`, `packages/thirdweb/src/wallets/in-app/core/authentication/passkeys.ts`, `packages/thirdweb/src/wallets/in-app/native/auth/passkeys.ts`, `packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-14 19:44:35 +00:00
kien-ngo 52678e02a8 [Dashboard] use MediaRenderer for contract's avatar (#4095)
- [x] Contract metadata header now uses <MediaRenderer /> instead of <Image/>
This way is works with videos and it gets rid of that weird border-radius bug (see image)

<img width="324" alt="image" src="https://github.com/user-attachments/assets/a57f95c1-eb45-4e6f-8121-0d10358c7c6b">

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to refactor the `MetadataHeader` component in the custom-contract folder by replacing the `resolveScheme` function with `MediaRenderer` for image rendering.

### Detailed summary
- Replaced `resolveScheme` with `MediaRenderer` for image rendering
- Updated image rendering logic with additional props
- Removed unused imports and variables

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-14 14:04:07 +00:00
MananTank b9ed7535a4 Fix Connection with Safe using WalletConnect Link (#4091)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on fixing the connection with Safe using WalletConnect link.

### Detailed summary
- Added support for Safe supported chains in WalletConnect
- Updated chain selection logic based on walletId
- Included specific chains for Safe connection

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-14 11:39:29 +00:00
Joaquim VergesandGitHub 70d4a5a3db fix(dashboard): fix wrong 'version' prop import (#4096) 2024-08-14 21:51:56 +12:00
jnsdls ea28704a04 [Refactor] Remove unused functions and improve faucet validation (#4093) 2024-08-14 00:50:22 +00:00
jnsdls 814024ae24 [Chore] Remove unused 'amount' field from FaucetButton component and claim route (#4090)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update the testnet faucet claim route to fix issues related to the amount handling.

### Detailed summary
- Removed `amount` from request payload
- Updated amount handling in the faucet claim route to always transfer 0.01
- Improved error handling and response consistency

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 23:11:24 +00:00
joaquim-verges 9d3fa73da7 feat(dashboard): bring zksync signer back to direct deploys (#4089)
## Problem solved

for direct deploys, right now go back to the zksync ethers signer wrapper - will implement it properly inside account v5
2024-08-13 22:14:05 +00:00
jnsdls fea4a4afe8 [Fix] Remove unused loginRequired prop from MismatchButton component (#4088)
<!-- start pr-codex -->

## PR-Codex overview
This PR updates the `MismatchButton.tsx` component in the dashboard app.

### Detailed summary
- Updated `CustomConnectWallet` component with new props
- Removed `loginRequired={false}` prop from `CustomConnectWallet` usage

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 22:00:38 +00:00
Phillip HoandGitHub 2e16f9ecef chore: Add queue metrics to dashboard (#4075) 2024-08-13 21:59:34 +00:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1032bc7cc4 chore(deps): bump @stripe/react-stripe-js from 2.7.2 to 2.7.3 (#4063)
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-13 13:02:34 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
7e6d1decfc chore(deps-dev): bump react-native from 0.74.2 to 0.74.5 (#4061)
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-13 12:48:51 -07:00
jnsdls 73b2c512ce [Chore] Add temporary redirect for /gas to /explore and remove GasPage component (#4087) 2024-08-13 18:14:18 +00:00
MananTank 13cda91d10 Remove sign-in requirement for TransactionButton (#4086)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the `MismatchButton` component in the dashboard by adding the `loginRequired` prop to `CustomConnectWallet`.

### Detailed summary
- Added `loginRequired={false}` prop to `CustomConnectWallet` in `MismatchButton.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 17:58:37 +00:00
MananTank e91421a252 Fix isLoggedin auth action (#4085)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the authentication logic in `auth-actions.ts` to check for a matching creatorWalletAddress in the JSON data.

### Detailed summary
- Updated condition to check for `creatorWalletAddress` in JSON data instead of `address`.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 17:45:31 +00:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
74c6bca538 chore(deps): bump @hookform/resolvers from 3.6.0 to 3.9.0 (#4064)
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-13 10:45:02 -07:00
MananTank 23beb9d263 Add validation for NFT claim amount to be integer (#4080)
## Problem solved

Short description of the bug fixed or feature added
2024-08-13 17:21:15 +00:00
jnsdls 69657377f4 [Fix] Lower faucet amount to 0.01 (#4084) 2024-08-13 16:48:33 +00:00
MananTank 9db4b293a5 dynamically import onboarding components - reduce Stripe errors and bundle size (#4081)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the codebase by implementing lazy loading for onboarding components to improve performance.

### Detailed summary
- Implemented lazy loading for onboarding components
- Added `LazyOnboardingBilling` component for billing
- Updated multiple files to use lazy loading for onboarding components

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 16:37:26 +00:00
MananTank 867d2dae8a Fix useLayoutEffect warnings (#4079)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the usage of `useLayoutEffect` to `useIsomorphicLayoutEffect` for consistent server-side rendering compatibility.

### Detailed summary
- Replaces `useLayoutEffect` with `useIsomorphicLayoutEffect` in multiple files
- Ensures consistent rendering behavior across client and server side

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 16:26:34 +00:00
MananTank cb27dafca7 Do not show "No Funds" Modal when switch chain is required (#4083)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to handle a specific condition `networksMismatch` before executing the button's `onClick` functionality.

### Detailed summary
- Added a condition to check for `networksMismatch` before executing the button's `onClick` functionality.
- Stored the event reference in `eventRef.current` when `networksMismatch` is true.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 16:21:33 +00:00
kien-ngo 6b7eedeecb [Dash] various small updates and fixes (#4076)
- [x] Fix clipboard value for the [copy button] inside /explorer page
- [x] Better handling for some edge cases where the contract's compilation target is a very long string
- [x] Instead of displaying "Custom" for non-thirdweb contracts, display the contract type based on the compilation target

<hr />

Before:
<img width="1241" alt="image" src="https://github.com/user-attachments/assets/397cc15f-5941-4a5c-ae11-cae5a7a7fbde">

After:
<img width="830" alt="image" src="https://github.com/user-attachments/assets/2a353e9c-04c8-4d6d-b15f-c26b7f423213">

<hr />

Before:
<img width="665" alt="image" src="https://github.com/user-attachments/assets/93465f35-d3c4-466c-b9cd-ab905c4fc6f1">

After:
<img width="667" alt="image" src="https://github.com/user-attachments/assets/24c59796-913d-42a4-95a2-2a63e6e726c3">

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to enhance how contract metadata is displayed in the dashboard.

### Detailed summary
- Improved handling of long contract names from the thirdweb endpoint
- Updated the display of contract type in the contract table
- Refactored the usage of contract metadata in different components

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 07:16:13 +00:00
MananTank 53da850397 Fix Various "couldn't be rendered statically" errors in Sentry (#4067)
TLDR; is - In the Chain landing page, we don't really care about filtering the popular contracts - so I removed so we can statically render the chain page,

Added force-dynamic for /popular and /trending pages where we allow filtering by search params

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to implement dynamic rendering using searchParams and improve sorting functionality in the dashboard pages.

### Detailed summary
- Implemented dynamic rendering using `searchParams`
- Updated sorting functionality in trending pages
- Refactored `searchParams` in components
- Removed unnecessary imports

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 04:11:48 +00:00
kien-ngo de1bd6e903 [Dashboard] Fix contract query key (#4073)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to refactor the `useDashboardContractMetadata` hook to use a more descriptive query key and improve code readability.

### Detailed summary
- Refactored the query key to include contract metadata details
- Improved code readability by restructuring the Promise.all block
- Updated the return object format for consistency

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 03:56:15 +00:00
ff7f61c038 Dustin/treasure chain page update (#4072)
Co-authored-by: Jonas Daniels <[email protected]>
2024-08-12 20:26:37 -07:00
FirekeeperandGitHub 2408a7f9ed Docs - .NET 1.4.0 // Unity 5.0.0-beta.3 (#4071) 2024-08-12 20:25:49 -07:00
98bb37c1a1 chore(deps-dev): bump @swc-node/register from 1.10.0 to 1.10.9 (#4060)
Co-authored-by: dependabot <[email protected]>
2024-08-12 20:24:21 -07:00
gregfromstl 3c32b99b3a refactor(thirdweb): update siwe interface (#4045)
<!-- start pr-codex -->

## PR-Codex overview
This PR updates the SIWE interface to include a new `wallet` authentication option and refactors related methods for consistency.

### Detailed summary
- Added `wallet` as a new authentication option
- Updated interface methods to support `wallet` authentication
- Refactored SIWE-related functions for consistency

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 02:36:29 +00:00
kien-ngo e5a046ecdd [Dashboard] Fix missing contract metadata (#4070)
- [x] Remove duplicated formatCompilerMetadata method
- [x] Add getCompilerMetadata method to the SDK
- [x] Add a custom hook for Dashboard for fetching basic contract metadata (useDashboardContractMetadata)

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to add a contract utility method `getCompilerMetadata()` and update contract metadata handling in the dashboard.

### Detailed summary
- Added `getCompilerMetadata()` utility method to fetch and format compiler metadata
- Updated contract metadata handling in the dashboard components
- Added `useDashboardContractMetadata` hook for fetching contract metadata in the dashboard

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 02:07:44 +00:00
kien-ngo 237f5faf42 [Dashboard] Migrate PlatformFees to v5 (#4050)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to migrate zod schemas from SDK v4 to a new location for form validations in the dashboard.

### Detailed summary
- Migrated zod schemas for PlatformFees and Royalties from SDK v4 to `schemas.ts`
- Updated `page.tsx` and `platform-fees.tsx` to use the new zod schemas and adapt to the changes in the SDK
- Refactored form validations and platform fee settings handling in `platform-fees.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 01:50:49 +00:00
gregandGitHub ad2588b5de chore: fix deploy-split test (#4068) 2024-08-12 18:49:52 -07:00
kien-ngo db8695d0e8 [Dashboard]: Migrate major NFT features to v5 (#3998)
# High level changes
- `mint-form.tsx` is "over-abstracted" (not sure if that's the right word) - it's being used for too many different NFT features, making the code hard-to-migrate.
- solution: breaking it down to different component which makes it much easier to remove v4 code

# to test
- [x] UpdateMetadataForm
  - [x] Drop contracts
  - [x] Collection contracts
- [x] SharedMetadataForm
- [x] NFTMintForm
- [x] LazyMintForm

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces NFT extensions for ERC721 and ERC1155 contracts, adds a new `updateTokenURI` function, and updates components for NFT minting and metadata management.

### Detailed summary
- Added NFT extension with `updateTokenURI` function for ERC721 and ERC1155 contracts
- Updated components for NFT minting and metadata management

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/permissions/components/contract-permission.tsx`, `packages/thirdweb/src/extensions/erc721/write/updateTokenURI.ts`, `packages/thirdweb/src/extensions/erc1155/write/updateTokenURI.ts`, `apps/dashboard/src/contract-ui/tabs/nfts/components/shared-metadata-form.tsx`, `apps/dashboard/src/contract-ui/tabs/nfts/components/lazy-mint-form.tsx`, `apps/dashboard/src/contract-ui/tabs/nfts/components/update-metadata-form.tsx`, `apps/dashboard/src/contract-ui/tabs/nfts/components/mint-form.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 00:27:22 +00:00
MananTank 2d4a5c3384 Update Deploy modal (#4057)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to refactor the custom contract deployment process by introducing a new `DeployStatusModal` component.

### Detailed summary
- Added `DeployStatusModal` component for custom contract deployment status tracking
- Refactored `useCustomContractDeployMutation` to use `DeployStatusModal`
- Removed `DeployModalProvider` component and related context logic

> The following files were skipped due to too many changes: `apps/dashboard/src/components/contract-components/contract-deploy-form/deploy-context-modal.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-13 00:06:43 +00:00
Joaquim VergesandGitHub dbf3873aaf feat(dashboard): add handle_all_urls relation to assetlinks.json for Android app link verification (#4069) 2024-08-13 12:06:09 +12:00
MananTank b15aa4cdff Add Deploy button link on the Contract Card (#4066)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to add a deploy button with a rocket icon to the ContractCard component in the Explore section.

### Detailed summary
- Added `RocketIcon` and deploy button to `ContractCard`
- Adjusted styling of `ContractCard` component for better layout
- Linked deploy button to deployment page with `Link`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-12 23:31:51 +00:00
gregfromstl 689b8dc160 test: fix split tests (#4065)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates test descriptions in the `split` extension to run only if a secret key is present, enhancing security.

### Detailed summary
- Updated test descriptions to run only if a secret key is present
- Renamed test suites for `getAllRecipientsAddresses`, `getAllRecipientsPercentages`, and `getRecipientSplitPercentage`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-12 22:40:18 +00:00
gregfromstl 218355bf95 docs: fix multi auth jsdocs (#4056)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates documentation comments in `useProfiles.ts` and `profiles.ts` for clarity.

### Detailed summary
- Updated description comments in `profiles.ts` for clarity and consistency.
- Added `@wallet` tag to indicate in-app wallet-specific methods.
- Removed redundant descriptions to improve readability.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-12 22:01:39 +00:00
9be0a2fe85 Update Startup program page layout (#4058)
Co-authored-by: Ginessi <[email protected]>
Co-authored-by: Manan Tank <[email protected]>
2024-08-12 14:49:03 -07:00
gregfromstl 22b335b1f2 chore: delete solutions page (#4059)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to restructure the directory layout by deleting specific files and updating URL redirects related to gaming solutions.

### Detailed summary
- Deleted `page.mdx`, `layout.tsx`, and `sidebar.tsx` in `solutions` directory
- Removed images `unreal.png` and `preview.png` in `gaming/assets`
- Deleted `page.mdx` in `gaming/overview` directory
- Updated URL redirects for `/gaming`, `/solutions`, and `/solutions/gaming`
- Redirected `/gaming` to `/`
- Redirected `/solutions` to `/`
- Redirected `/solutions/gaming` to `/`
- Updated redirect from `/signature-minting` to `/contracts/design-docs/signature-mint`
- Updated reference from `/references/typescript/v5/embeddedWallet` to `/references/typescript/v5/inAppWallet`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-12 20:57:30 +00:00
MananTank dfbaeb1c3d [dashboard] Fix chains fetch failture in localhost (#4053)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to simplify the API request in the `useApi.ts` file by removing unnecessary headers and changing the request method to GET.

### Detailed summary
- Removed unnecessary headers from the API request
- Changed the request method to GET

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-12 20:46:03 +00:00
MananTank dc99b88cac Fix Chainlist can't be rendered statically error in sentry (#4054)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds a `dynamic` export to force the page as dynamic for determining table/grid view based on viewport.

### Detailed summary
- Added `dynamic` export to force page as dynamic
- Updated comments to explain the purpose of the `dynamic` export

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-12 19:13:27 +00:00
Phillip HoandGitHub 66906dbef3 chore: Engine v2-beta in docs (#4049) 2024-08-12 10:04:29 -07:00
gregfromstl 7a68e3b8ed fix(react): switch chains for SIWE (#4047)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on updating authentication logic to switch to the proper chain before signing payloads.

### Detailed summary
- Updated `getLoginPayload` to include `chainId` parameter
- Added logic to switch to the correct chain before signing payloads
- Updated initialization of `thirdwebAuth` to handle chain switching
- Imported `getCachedChain` function in `useSiweAuth.ts`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-12 05:34:36 +00:00
gregfromstl cb4b6fde85 fix(playground): do not attempt to decode nonexistent jwt (#4046)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to update how the authentication result is retrieved in the `GatedContentPreview` function.

### Detailed summary
- Refactored the authentication result retrieval logic to handle `jwt?.value` more efficiently.
- Updated the conditional check for `authResult` to account for the new retrieval logic.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-12 05:01:02 +00:00
kien-ngo 141fd53759 [Dashboard/SDK] Add more Split extensions and remove Split v4 code from Dashboard (#4033)
<!-- start pr-codex -->

## PR-Codex overview
This PR adds more functionality to the `Split` contract extensions, including deploying the `Split` contract, reading recipient addresses and percentages, and testing these features.

### Detailed summary
- Added more Split contract extensions
- Updated `deploys.ts` with new exports for deploying Split contract
- Updated `split.ts` with new exports for reading recipient addresses and percentages
- Modified `page.tsx` to display contract balance using `getContract`
- Added new files for reading recipient addresses and percentages
- Updated `account-balance.tsx` to use `getContract` and `useSplitBalances`
- Added tests for getting all recipient addresses and percentages
- Added functionality to get recipient split percentage and corresponding tests

> The following files were skipped due to too many changes: `packages/thirdweb/src/extensions/split/__generated__/Split/read/totalShares.ts`, `apps/dashboard/src/contract-ui/tabs/split/components/distribute-button.tsx`, `packages/thirdweb/test/src/test-contracts.ts`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/useSplit.ts`, `packages/thirdweb/src/extensions/prebuilts/deploy-split.ts`, `packages/thirdweb/src/extensions/prebuilts/__generated__/Split/write/initialize.ts`, `apps/dashboard/src/contract-ui/tabs/split/page.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-11 22:17:38 +00:00
joaquim-verges 478d843975 feat(dashboard): add apple-app-site-association for iOS app link verification (#4043)
## Problem solved

for passkeys on ios

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the `apple-app-site-association` and `assetlinks.json` files in the dashboard public directory to include specific app and web credentials information.

### Detailed summary
- Added `webcredentials` for specific app in `apple-app-site-association`
- Updated `sha256_cert_fingerprints` in `assetlinks.json`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-11 22:11:13 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
386fe1ce68 Version Packages (#4042)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-11 12:38:36 -07:00
jnsdls 539bdab403 [Refactor] Remove unused Bun availability check in CLI bin file (#4040)
FIXES: https://github.com/thirdweb-dev/js/issues/3991
2024-08-11 19:13:39 +00:00
jnsdls 0e3cb1338b [Hotfix] Remove async modifier from TrendingContractSection in trending-table.tsx (#4041)
FIXES: DASH-128
2024-08-11 19:02:09 +00:00
34cdd4ce95 feat(dashboard): add assetlinks.json for Android app link verification (#4039)
Co-authored-by: joaquim-verges <[email protected]>
2024-08-11 11:18:22 -07:00
Jonas DanielsandGitHub c31617436c [Chore] Remove unused 'faucet' service from chain logic (#4038) 2024-08-11 01:31:34 -07:00
Jonas DanielsandGitHub 40fbe9abb9 [Feature] Refactor chain services handling in API calls (#4037) 2024-08-11 00:08:15 -07:00
Nick PapadakisandGitHub 74e005214d Update page.mdx (#4036)
Signed-off-by: Nick Papadakis <[email protected]>
2024-08-10 20:54:45 -07:00
LubovandGitHub 1c48c20785 Update page.mdx (#4035)
Signed-off-by: Lubov <[email protected]>
2024-08-10 21:28:38 +12:00
gregfromstl 7befc61b70 Unreal 1.1 Docs (#3917)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to enhance the Thirdweb Unreal SDK documentation by adding detailed information about Blueprint system, signers, runtime settings, and common enums.

### Detailed summary
- Added documentation for Blueprint Overview, ThirdwebSigner, ThirdwebRuntimeSettings, and ThirdwebCommon.
- Updated sidebar links and icons.
- Updated tsconfig.json with consistent casing.
- Added Getting Started guide with integration steps and images.

> The following files were skipped due to too many changes: `apps/portal/src/app/unreal/thirdweb-wallet-handle/page.mdx`, `apps/portal/src/app/unreal/thirdweb-subsystem/page.mdx`, `apps/portal/src/app/unreal/thirdweb/page.mdx`, `apps/portal/src/app/unreal/page.mdx`, `apps/portal/src/app/unreal/thirdweb-function-library/page.mdx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-10 03:42:49 +00:00
MananTank 6b4503a91c Deploy form layout updates, Fix faucet claim condition (#4030)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the logic for checking if a user can claim in the testnet faucet, adds a new React switch component, refactors common form fieldsets, and improves UI components.

### Detailed summary
- Updated `canClaim` logic in testnet faucet route
- Added `@radix-ui/react-switch` component
- Refactored common form fieldsets into `Fieldset` component
- Improved UI components and form field layouts

> The following files were skipped due to too many changes: `apps/dashboard/src/components/contract-components/contract-deploy-form/platform-fee-fieldset.tsx`, `pnpm-lock.yaml`, `apps/dashboard/src/components/contract-components/contract-deploy-form/trusted-forwarders-fieldset.tsx`, `apps/dashboard/src/components/contract-components/contract-deploy-form/split-fieldset.tsx`, `apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-08-09 22:04:48 +00:00
892 changed files with 33053 additions and 20168 deletions
+22 -1
View File
@@ -19,7 +19,21 @@ env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
jobs:
optimize_ci:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check_skip.outputs.skip }}
steps:
- name: Optimize CI
id: check_skip
uses: withgraphite/graphite-ci-action@main
with:
graphite_token: ${{ secrets.GRAPHITE_OMTIMIZE_TOKEN }}
build:
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
runs-on: ubuntu-latest
name: Build Packages
steps:
@@ -33,6 +47,8 @@ jobs:
run: pnpm build:packages
lint:
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
timeout-minutes: 15
name: Lint Packages
runs-on: ubuntu-latest
@@ -51,6 +67,8 @@ jobs:
- run: pnpm lint
test:
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
timeout-minutes: 15
name: Unit Tests
runs-on: ubuntu-latest
@@ -77,6 +95,8 @@ jobs:
verbose: true
e2e:
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
timeout-minutes: 15
name: E2E Tests
runs-on: ubuntu-latest
@@ -144,8 +164,9 @@ jobs:
fi
size:
needs: optimize_ci
# only run on pull requests
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && needs.optimize_ci.outputs.skip == 'false'
timeout-minutes: 15
name: "Size"
runs-on: ubuntu-latest
+19
View File
@@ -27,7 +27,20 @@ env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
jobs:
optimize_ci:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check_skip.outputs.skip }}
steps:
- name: Optimize CI
id: check_skip
uses: withgraphite/graphite-ci-action@main
with:
graphite_token: ${{ secrets.GRAPHITE_OMTIMIZE_TOKEN }}
build:
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
runs-on: ubuntu-latest
name: Build Packages
steps:
@@ -41,6 +54,8 @@ jobs:
run: pnpm build:legacy_packages
lint:
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
timeout-minutes: 15
name: Lint Packages
runs-on: ubuntu-latest
@@ -54,6 +69,8 @@ jobs:
- run: pnpm lint:legacy
test:
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
timeout-minutes: 15
name: Unit Tests
runs-on: ubuntu-latest
@@ -74,6 +91,8 @@ jobs:
verbose: true
e2e:
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
timeout-minutes: 15
name: E2E Tests
runs-on: ubuntu-latest
+3
View File
@@ -30,3 +30,6 @@ sitemap*.xml
# typedoc
legacy_packages/*/typedoc/*
packages/*/typedoc/*
*storybook.log
storybook-static
+3
View File
@@ -18,5 +18,8 @@
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
+3
View File
@@ -40,6 +40,9 @@ NEXT_PUBLIC_STRIPE_KEY=
NEXT_PUBLIC_STRIPE_PAYMENT_METHOD_CFG_ID=
# Needed for contract analytics / blockchain data information
CHAINSAW_API_KEY=
#
# Private (server)
#
+7
View File
@@ -5,6 +5,7 @@ module.exports = {
"plugin:import/typescript",
"plugin:@next/next/recommended",
"plugin:promise/recommended",
"plugin:storybook/recommended"
],
rules: {
"react-compiler/react-compiler": "error",
@@ -80,6 +81,12 @@ module.exports = {
message:
"Import from `@chakra-ui/react` instead of `@chakra-ui/menu`.",
},
{
name: "next/navigation",
importNames: ["useRouter"],
message:
'Use `import { useDashboardRouter } from "@/lib/DashboardRouter";` instead',
},
],
},
],
+32
View File
@@ -0,0 +1,32 @@
import type { StorybookConfig } from "@storybook/nextjs";
import { dirname, join } from "node:path";
/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): string {
return dirname(require.resolve(join(value, "package.json")));
}
const config: StorybookConfig = {
stories: ["../src/**/*.stories.tsx"],
addons: [
getAbsolutePath("@storybook/addon-onboarding"),
getAbsolutePath("@storybook/addon-links"),
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@chromatic-com/storybook"),
getAbsolutePath("@storybook/addon-interactions"),
],
framework: {
name: getAbsolutePath("@storybook/nextjs"),
options: {},
},
refs: {
"@chakra-ui/react": {
disable: true,
},
},
staticDirs: ["../public"],
};
export default config;
+37
View File
@@ -0,0 +1,37 @@
import type { Preview } from "@storybook/react";
import "@/styles/globals.css";
import { Inter as interFont } from "next/font/google";
// biome-ignore lint/correctness/noUnusedImports: <explanation>
import React from "react";
import { cn } from "../src/@/lib/utils";
// Note: Wrapping the Stoy with AppRouterProviders makes the storybook server time SUPER SLOW
// so let's just not have it there - all stories should be independent from context anyway and just rely on props
const fontSans = interFont({
subsets: ["latin"],
variable: "--font-sans",
});
const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
decorators: [
(Story) => {
return (
<div className={cn("font-sans antialiased", fontSans.variable)}>
<Story />
</div>
);
},
],
};
export default preview;
+2 -2
View File
@@ -5,8 +5,8 @@ const ContentSecurityPolicy = `
img-src * data: blob:;
media-src * data: blob:;
object-src 'none';
style-src 'self' 'unsafe-inline';
font-src 'self';
style-src 'self' 'unsafe-inline' https://vercel.live;
font-src 'self' https://vercel.live https://assets.vercel.com;
frame-src * data:;
script-src 'self' 'unsafe-eval' 'unsafe-inline' 'wasm-unsafe-eval' 'inline-speculation-rules' *.thirdweb.com *.thirdweb-dev.com vercel.live js.stripe.com pg.paper.xyz portal.usecontext.io;
connect-src * data: blob:;
+21 -18
View File
@@ -18,7 +18,9 @@
"build:analyze": "ANALYZE=true pnpm run build",
"knip": "knip",
"playwright": "playwright test",
"update-checkly": "npx checkly deploy"
"update-checkly": "npx checkly deploy",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@chakra-ui/react": "^2.8.2",
@@ -27,7 +29,7 @@
"@coinbase/onchainkit": "^0.14.2",
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5",
"@hookform/resolvers": "^3.6.0",
"@hookform/resolvers": "^3.9.0",
"@n8tb1t/use-scroll-position": "^2.0.3",
"@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-aspect-ratio": "^1.0.3",
@@ -40,16 +42,15 @@
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-toggle": "^1.1.0",
"@radix-ui/react-toggle-group": "^1.1.0",
"@radix-ui/react-tooltip": "1.1.2",
"@react-icons/all-files": "^4.1.0",
"@sentry/nextjs": "^8.8.0",
"@stripe/react-stripe-js": "^2.7.2",
"@sentry/nextjs": "^8.26.0",
"@stripe/react-stripe-js": "^2.7.3",
"@stripe/stripe-js": "^3.5.0",
"@tanstack/query-async-storage-persister": "^4.36.1",
"@tanstack/react-query": "^4.36.1",
"@tanstack/react-query-persist-client": "^4.36.1",
"@tanstack/react-table": "^8.17.3",
"@thirdweb-dev/react": "workspace:*",
"@thirdweb-dev/sdk": "workspace:*",
@@ -67,7 +68,6 @@
"flat": "^6.0.1",
"framer-motion": "^11.2.12",
"fuse.js": "7.0.0",
"idb-keyval": "^6.2.1",
"ioredis": "^5.4.1",
"ipaddr.js": "^2.2.0",
"lottie-react": "^2.4.0",
@@ -81,13 +81,11 @@
"pluralize": "^8.0.0",
"posthog-js": "1.128.3",
"posthog-js-opensource": "npm:[email protected]",
"prettier": "^3.3.2",
"prism-react-renderer": "^2.3.1",
"prismjs": "^1.29.0",
"qrcode": "^1.5.3",
"react": "18.3.1",
"react-children-utilities": "^2.10.0",
"react-confetti": "^6.1.0",
"react-day-picker": "^8.10.1",
"react-dom": "18.3.1",
"react-dropzone": "^14.2.3",
@@ -105,7 +103,7 @@
"sonner": "^1.5.0",
"spdx-correct": "^3.2.0",
"swagger-ui-react": "^5.17.14",
"tailwind-merge": "^2.4.0",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7",
"thirdweb": "workspace:*",
"tiny-invariant": "^1.3.3",
@@ -116,9 +114,18 @@
},
"devDependencies": {
"@chakra-ui/cli": "^2.4.1",
"@chromatic-com/storybook": "^1.5.0",
"@next/bundle-analyzer": "^14.2.4",
"@next/eslint-plugin-next": "^14.2.4",
"@playwright/test": "^1.44.1",
"@playwright/test": "1.44.1",
"@storybook/addon-essentials": "^8.2.9",
"@storybook/addon-interactions": "^8.2.9",
"@storybook/addon-links": "^8.2.9",
"@storybook/addon-onboarding": "^8.2.9",
"@storybook/blocks": "^8.2.9",
"@storybook/nextjs": "^8.2.9",
"@storybook/react": "^8.2.9",
"@storybook/test": "^8.2.9",
"@types/color": "^3.0.6",
"@types/node": "20.14.9",
"@types/papaparse": "^5.3.14",
@@ -133,21 +140,17 @@
"@typescript-eslint/parser": "7.14.1",
"autoprefixer": "^10.4.19",
"checkly": "^4.7.0",
"dotenv": "^16.4.5",
"eslint": "8.57.0",
"eslint-config-biome": "^1.7.3",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-inclusive-language": "^2.2.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-react": "7.34.3",
"eslint-plugin-react-compiler": "0.0.0-experimental-51a85ea-20240601",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-storybook": "^0.8.0",
"knip": "^5.23.1",
"next-sitemap": "^4.2.3",
"next-unused": "^0.0.6",
"tailwindcss": "^3.4.4",
"storybook": "^8.2.9",
"tailwindcss": "^3.4.10",
"typescript": "5.5.4"
},
"next-unused": {
@@ -0,0 +1,30 @@
{
"applinks": {
"apps": ["XYHGSFAMHX.com.thirdweb.demo"],
"details": [
{
"appIDs": ["XYHGSFAMHX.com.thirdweb.demo"],
"components": [
{
"#": "no_universal_links",
"exclude": true,
"comment": "Matches any URL with a fragment that equals no_universal_links and instructs the system not to open it as a universal link."
},
{
"/": "/mobile-wallet-protocol",
"comment": "Matches any URL with a path that starts with /mobile-wallet-protocol for coinbase wallet mobile redirects."
},
{
"/": "/dashboard/*",
"exclude": true,
"comment": "no universal link for dashboard"
}
]
}
]
},
"webcredentials": {
"apps": ["XYHGSFAMHX.com.thirdweb.demo"]
},
"appclips": {}
}
@@ -0,0 +1,15 @@
[
{
"relation": [
"delegate_permission/common.handle_all_urls",
"delegate_permission/common.get_login_creds"
],
"target": {
"namespace": "android_app",
"package_name": "com.thirdweb.demo",
"sha256_cert_fingerprints": [
"40:EB:0D:96:57:F3:D8:1F:BA:87:B8:E4:26:E0:3A:DB:C8:35:96:A8:A2:B2:55:F0:B1:64:F1:39:F8:6F:7E:EB"
]
}
}
]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 779 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 694 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

+16 -9
View File
@@ -119,11 +119,6 @@ function redirects() {
destination: "/template/erc721",
permanent: false,
},
{
source: "/abuse",
destination: "https://forms.gle/v9UJtHbVw8fXypcd7",
permanent: false,
},
{
source: "/create-api-key",
destination: "/dashboard/settings/api-keys",
@@ -136,12 +131,17 @@ function redirects() {
},
{
source: "/dashboard/connect",
destination: "/dashboard/connect/playground",
destination: "/dashboard/connect/in-app-wallets",
permanent: false,
},
{
source: "/dashboard/connect/playground",
destination: "https://playground.thirdweb.com/connect/sign-in/button",
permanent: false,
},
{
source: "/dashboard/wallet",
destination: "/dashboard/connect/playground",
destination: "https://playground.thirdweb.com/connect/sign-in/button",
permanent: false,
},
{
@@ -166,7 +166,7 @@ function redirects() {
},
{
source: "/dashboard/wallets",
destination: "/dashboard/connect/playground",
destination: "https://playground.thirdweb.com/connect/sign-in/button",
permanent: false,
},
{
@@ -186,7 +186,7 @@ function redirects() {
},
{
source: "/dashboard/wallets/connect",
destination: "/dashboard/connect/playground",
destination: "https://playground.thirdweb.com/connect/sign-in/button",
permanent: false,
},
{
@@ -282,6 +282,13 @@ function redirects() {
"https://support.thirdweb.com/troubleshooting-errors/7Y1BqKNvtLdBv5fZkRZZB3/issue-linking-device-on-the-authorization-page-via-thirdweb-cli/cn9LRA3ax7XCP6uxwRYdvx",
permanent: false,
},
// temporary redirect gas -> explore page
{
source: "/gas",
destination: "/explore",
permanent: false,
},
];
}
@@ -0,0 +1,109 @@
"use client";
import { Area, AreaChart, CartesianGrid, XAxis } from "recharts";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import {
type ChartConfig,
ChartContainer,
ChartLegend,
ChartLegendContent,
ChartTooltip,
ChartTooltipContent,
} from "@/components/ui/chart";
import { useMemo } from "react";
export type ThirdwebAreaChartProps<TConfig extends ChartConfig> = {
// metadata
title: string;
description?: string;
// chart config
config: TConfig;
data: Array<Record<keyof TConfig, number> & { time: number | string | Date }>;
showLegend?: boolean;
// chart className
chartClassName?: string;
};
export function ThirdwebAreaChart<TConfig extends ChartConfig>(
props: ThirdwebAreaChartProps<TConfig>,
) {
const configKeys = useMemo(() => Object.keys(props.config), [props.config]);
return (
<Card>
<CardHeader>
<CardTitle>{props.title}</CardTitle>
{props.description && (
<CardDescription>{props.description}</CardDescription>
)}
</CardHeader>
<CardContent>
<ChartContainer config={props.config} className={props.chartClassName}>
<AreaChart
accessibilityLayer
data={props.data}
margin={{
left: 12,
right: 12,
}}
>
<CartesianGrid vertical={false} />
<XAxis
dataKey="time"
tickLine={false}
axisLine={false}
tickMargin={8}
tickFormatter={(value) => new Date(value).toLocaleDateString()}
/>
<ChartTooltip cursor={false} content={<ChartTooltipContent />} />
<defs>
{configKeys.map((key) => (
<linearGradient
key={key}
id={`fill_${key}`}
x1="0"
y1="0"
x2="0"
y2="1"
>
<stop
offset="5%"
stopColor={`var(--color-${key})`}
stopOpacity={0.8}
/>
<stop
offset="95%"
stopColor={`var(--color-${key})`}
stopOpacity={0.1}
/>
</linearGradient>
))}
</defs>
{configKeys.map((key) => (
<Area
key={key}
dataKey={key}
type="natural"
fill={`url(#fill_${key})`}
fillOpacity={0.4}
stroke={`var(--color-${key})`}
stackId="a"
/>
))}
{props.showLegend && (
<ChartLegend content={<ChartLegendContent />} />
)}
</AreaChart>
</ChartContainer>
</CardContent>
</Card>
);
}
@@ -0,0 +1,91 @@
"use client";
import { Bar, BarChart, CartesianGrid, XAxis } from "recharts";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import {
type ChartConfig,
ChartContainer,
ChartLegend,
ChartLegendContent,
ChartTooltip,
ChartTooltipContent,
} from "@/components/ui/chart";
import { useMemo } from "react";
export type ThirdwebBarChartProps<TConfig extends ChartConfig> = {
// metadata
title: string;
description?: string;
// chart config
config: TConfig;
data: Array<Record<keyof TConfig, number> & { time: number | string | Date }>;
showLegend?: boolean;
variant?: "stacked" | "grouped";
// chart className
chartClassName?: string;
};
export function ThirdwebBarChart<TConfig extends ChartConfig>(
props: ThirdwebBarChartProps<TConfig>,
) {
const configKeys = useMemo(() => Object.keys(props.config), [props.config]);
// if there are more than 4 keys then we should stack them by default
const variant =
props.variant || configKeys.length > 4 ? "stacked" : "grouped";
return (
<Card>
<CardHeader>
<CardTitle>{props.title}</CardTitle>
{props.description && (
<CardDescription>{props.description}</CardDescription>
)}
</CardHeader>
<CardContent>
<ChartContainer config={props.config} className={props.chartClassName}>
<BarChart accessibilityLayer data={props.data}>
<CartesianGrid vertical={false} />
<XAxis
dataKey="time"
tickLine={false}
axisLine={false}
tickMargin={10}
tickFormatter={(value) => new Date(value).toLocaleDateString()}
/>
<ChartTooltip content={<ChartTooltipContent hideLabel />} />
{props.showLegend && (
<ChartLegend content={<ChartLegendContent />} />
)}
{configKeys.map((key, idx) => (
<Bar
key={key}
dataKey={key}
// if stacked then they should all be the same stackId
// if grouped then they should all be unique stackId (so the key works great)
stackId={variant === "stacked" ? "a" : key}
fill={`var(--color-${key})`}
// if stacked then we need to figure out the radius based on the index in the array
// if grouped then we can just use the same radius for all
radius={
variant === "stacked"
? idx === 0
? [0, 0, 4, 4]
: idx === configKeys.length - 1
? [4, 4, 0, 0]
: [0, 0, 0, 0]
: [4, 4, 4, 4]
}
/>
))}
</BarChart>
</ChartContainer>
</CardContent>
</Card>
);
}
@@ -4,7 +4,6 @@ import { Button } from "@/components/ui/button";
import { ClientOnly } from "components/ClientOnly/ClientOnly";
import { Moon, Sun } from "lucide-react";
import { useTheme } from "next-themes";
import * as React from "react";
import { Skeleton } from "./ui/skeleton";
export function ColorModeToggle() {
@@ -0,0 +1,46 @@
import { Highlight } from "prism-react-renderer";
import { cn } from "../../lib/utils";
import { CopyButton } from "./CopyButton";
import { Card } from "./card";
interface CodeBlockProps {
code: string;
language?: string;
className?: string;
canCopy?: boolean;
}
export const CodeBlock = ({
code,
language = "sh",
canCopy = true,
}: CodeBlockProps) => {
return (
<Highlight code={code} language={language}>
{({ className, tokens, getLineProps, getTokenProps }) => (
<Card className={className}>
{canCopy && (
<CopyButton text={code} className="float-right p-2 m-2" />
)}
<div
className={cn(
"block font-mono text-sm whitespace-pre-wrap p-4 overflow-auto",
className,
)}
>
{tokens.map((line, i) => (
// biome-ignore lint/suspicious/noArrayIndexKey: index IS the key here
<div {...getLineProps({ line, key: i })} key={i}>
{line.map((token, key) => (
// biome-ignore lint/suspicious/noArrayIndexKey: index IS the key here
<span {...getTokenProps({ token, key })} key={key} />
))}
</div>
))}
</div>
</Card>
)}
</Highlight>
);
};
@@ -1,7 +1,8 @@
"use client";
import { useIsomorphicLayoutEffect } from "@/lib/useIsomorphicLayoutEffect";
import type React from "react";
import { useLayoutEffect, useRef, useState } from "react";
import { useRef, useState } from "react";
export function DynamicHeight(props: {
children: React.ReactNode;
@@ -33,11 +34,11 @@ export function DynamicHeight(props: {
);
}
export function useHeightObserver() {
function useHeightObserver() {
const elementRef = useRef<HTMLDivElement>(null);
const [height, setHeight] = useState<number | undefined>();
useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
const element = elementRef.current;
if (!element) {
return;
@@ -0,0 +1,25 @@
.unorderedList,
.orderedList {
@apply pl-5 leading-relaxed list-none text-secondary-foreground;
}
.unorderedList > li {
@apply pb-1 pl-2 list-disc;
}
.orderedList > li {
@apply pb-1 pl-2 list-decimal;
}
.unorderedList > li::marker {
@apply text-muted-foreground !m-0 text-left;
}
.orderedList > li::marker {
@apply text-muted-foreground text-left;
}
.unorderedList > li:hover::marker,
.orderedList > li:hover::marker {
@apply text-foreground;
}
@@ -0,0 +1,9 @@
import styles from "./List.module.css";
export function UnorderedList(props: { children?: React.ReactNode }) {
return <ul className={styles.unorderedList}>{props.children}</ul>;
}
export function OrderedList(props: { children?: React.ReactNode }) {
return <ul className={styles.orderedList}>{props.children}</ul>;
}
@@ -1,7 +1,8 @@
"use client";
import { useIsomorphicLayoutEffect } from "@/lib/useIsomorphicLayoutEffect";
import { cn } from "@/lib/utils";
import { useLayoutEffect, useRef } from "react";
import { useRef } from "react";
import styles from "./ScrollShadow.module.css";
export function ScrollShadow(props: {
@@ -17,7 +18,7 @@ export function ScrollShadow(props: {
const shadowRightEl = useRef<HTMLDivElement>(null);
const wrapperEl = useRef<HTMLDivElement>(null);
useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
const content = scrollableEl.current;
const shadowTop = shadowTopEl.current;
const shadowBottom = shadowBottomEl.current;
+1 -1
View File
@@ -10,7 +10,7 @@ const alertVariants = cva(
variant: {
default: "bg-background text-foreground",
destructive:
"bg-destructive/10 border-destructive/50 dark:border-destructive [&>svg]:text-destructive",
"bg-destructive/30 border-destructive/50 dark:border-destructive [&>svg]:text-destructive",
info: "bg-primary/10 border-primary/50 dark:border-primary [&>svg]:text-primary",
warning:
"bg-warning/10 border-warning/50 dark:border-warning [&>svg]:text-warning",
+1 -1
View File
@@ -9,7 +9,7 @@ const Card = React.forwardRef<
<div
ref={ref}
className={cn(
"rounded-lg border bg-card text-card-foreground shadow-sm",
"rounded-lg border border-border bg-card text-card-foreground shadow-sm",
className,
)}
{...props}
+1 -1
View File
@@ -283,7 +283,7 @@ const ChartLegendContent = React.forwardRef<
<div
ref={ref}
className={cn(
"flex items-center justify-center gap-4",
"flex items-center justify-center gap-4 overflow-x-auto",
verticalAlign === "top" ? "pb-3" : "pt-3",
className,
)}
@@ -47,7 +47,7 @@ const DropdownMenuSubContent = React.forwardRef<
<DropdownMenuPrimitive.SubContent
ref={ref}
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
"z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className,
)}
{...props}
@@ -65,7 +65,7 @@ const DropdownMenuContent = React.forwardRef<
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
"z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className,
)}
{...props}
@@ -0,0 +1,29 @@
"use client";
import * as SwitchPrimitives from "@radix-ui/react-switch";
import * as React from "react";
import { cn } from "@/lib/utils";
const Switch = React.forwardRef<
React.ElementRef<typeof SwitchPrimitives.Root>,
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
>(({ className, ...props }, ref) => (
<SwitchPrimitives.Root
className={cn(
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-foreground data-[state=unchecked]:bg-input",
className,
)}
{...props}
ref={ref}
>
<SwitchPrimitives.Thumb
className={cn(
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
)}
/>
</SwitchPrimitives.Root>
));
Switch.displayName = SwitchPrimitives.Root.displayName;
export { Switch };
+5 -2
View File
@@ -1,6 +1,9 @@
"use client";
import { useIsomorphicLayoutEffect } from "@/lib/useIsomorphicLayoutEffect";
import { cn } from "@/lib/utils";
import Link from "next/link";
import { useCallback, useLayoutEffect, useRef, useState } from "react";
import { useCallback, useRef, useState } from "react";
import { ScrollShadow } from "./ScrollShadow/ScrollShadow";
import { Button } from "./button";
@@ -126,7 +129,7 @@ function useUnderline<El extends HTMLElement>() {
setActiveTabEl(el);
}, []);
useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
if (activeTabEl && containerRef.current && lineRef.current) {
const containerRect = containerRef.current.getBoundingClientRect();
const lineEl = lineRef.current;
@@ -31,7 +31,7 @@ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
export function ToolTipLabel(props: {
children: React.ReactNode;
label: string | undefined;
label: React.ReactNode;
rightIcon?: React.ReactNode;
leftIcon?: React.ReactNode;
}) {
@@ -47,7 +47,7 @@ export function ToolTipLabel(props: {
</TooltipTrigger>
<TooltipContent
sideOffset={10}
className="max-w-[300px] leading-relaxed"
className="max-w-[400px] leading-relaxed whitespace-normal"
>
<div className="p-2 text-sm flex items-center gap-1.5">
{props.leftIcon}
-5
View File
@@ -8,10 +8,5 @@ const LOGGED_IN_ONLY_PATHS = [
];
export function isLoginRequired(pathname: string) {
// exceptions from LOGGED_IN_ONLY_PATHS
if (pathname.startsWith("/dashboard/connect/playground")) {
return false;
}
return LOGGED_IN_ONLY_PATHS.some((path) => pathname.startsWith(path));
}
+28 -9
View File
@@ -1,11 +1,30 @@
import {
DASHBOARD_THIRDWEB_CLIENT_ID,
DASHBOARD_THIRDWEB_SECRET_KEY,
IPFS_GATEWAY_URL,
} from "@/constants/env";
import { createThirdwebClient } from "thirdweb";
import { DASHBOARD_THIRDWEB_CLIENT_ID, IPFS_GATEWAY_URL } from "./env";
export const thirdwebClient = createThirdwebClient({
clientId: DASHBOARD_THIRDWEB_CLIENT_ID,
config: {
storage: {
gatewayUrl: IPFS_GATEWAY_URL,
},
},
});
export const thirdwebClient = createThirdwebClient(
DASHBOARD_THIRDWEB_SECRET_KEY
? {
secretKey: DASHBOARD_THIRDWEB_SECRET_KEY,
config: {
storage: {
gatewayUrl: IPFS_GATEWAY_URL,
},
},
}
: {
clientId: DASHBOARD_THIRDWEB_CLIENT_ID,
config: {
storage: {
gatewayUrl: IPFS_GATEWAY_URL,
},
},
},
);
/**
* DO NOT ADD ANYTHING TO THIS FILE IF YOU ARE NOT ABSOLUTELY SURE IT IS OK
*/
+6
View File
@@ -10,3 +10,9 @@ export const IPFS_GATEWAY_URL =
export const THIRDWEB_ENGINE_FAUCET_WALLET =
process.env.NEXT_PUBLIC_THIRDWEB_ENGINE_FAUCET_WALLET || "";
export const isProd =
(process.env.VERCEL_ENV || process.env.NEXT_PUBLIC_VERCEL_ENV) ===
"production";
export const PROD_OR_DEV_URL = isProd ? "thirdweb.com" : "thirdweb-dev.com";
@@ -0,0 +1,139 @@
"use client";
// eslint-disable-next-line no-restricted-imports
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import {
Suspense,
useEffect,
useMemo,
useRef,
useState,
useSyncExternalStore,
} from "react";
import { createStore } from "./reactive";
// Using useDashboardRouter instead of useRouter gives us a nice progress bar on top of the page when navigating using router.push or router.replace
// using a store instead of context to avoid triggering re-renders on root component
export const LoadingRouteHref = createStore<string | undefined>(undefined);
export function useDashboardRouter() {
const router = useRouter();
return useMemo(() => {
return {
...router,
replace(href: string, options?: { scroll?: boolean }) {
LoadingRouteHref.setValue(href);
router.replace(href, options);
},
push(href: string, options?: { scroll?: boolean }) {
LoadingRouteHref.setValue(href);
router.push(href, options);
},
};
}, [router]);
}
function useRouterLoadingStatus() {
const loadingHref = useSyncExternalStore(
LoadingRouteHref.subscribe,
LoadingRouteHref.getValue,
LoadingRouteHref.getValue,
);
const pathname = usePathname();
const searchParams = useSearchParams();
const searchParamsStr = searchParams?.toString();
const routerHref = pathname + (searchParamsStr ? `?${searchParamsStr}` : "");
const isLoading = loadingHref && loadingHref !== routerHref;
// reset loading on route load
// eslint-disable-next-line no-restricted-syntax
useEffect(() => {
if (!isLoading) {
LoadingRouteHref.setValue(undefined);
}
}, [isLoading]);
return isLoading;
}
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
// Render this on root
function DashboardRouterTopProgressBarInner() {
const isLoading = useRouterLoadingStatus();
const [progress, setProgress] = useState(0);
const progressStartedRef = useRef(false);
// eslint-disable-next-line no-restricted-syntax
useEffect(() => {
if (!isLoading) {
setProgress(0);
progressStartedRef.current = false;
return;
}
if (progressStartedRef.current) {
return;
}
let isMounted = true;
progressStartedRef.current = true;
async function updateProgressBar(progress: number, delay: number) {
if (!isMounted) {
if (!isLoading) {
setProgress(100);
}
return;
}
setProgress(progress);
await wait(delay);
// increase progress by 10% of the remaining progress
// increase the delay by 5% to slow down number of updates for slower progress
updateProgressBar(progress + (100 - progress) / 10, delay * 1.05);
}
async function startEffect() {
// if the loading state remains for atleast 500ms start the progress bar
await wait(500);
if (isMounted) {
updateProgressBar(0, 100);
}
}
startEffect();
return () => {
isMounted = false;
};
}, [isLoading]);
const width = isLoading ? progress : 100;
return (
<span
className="block fixed top-0 h-[2px] bg-blue-500"
style={{
opacity: isLoading ? "100" : "0",
width: `${width}%`,
transition: width === 0 ? "none" : "width 0.2s ease, opacity 0.3s ease",
zIndex: "100000000",
pointerEvents: "none",
}}
/>
);
}
// need to wrap with suspense because of useSearchParams usage
export function DashboardRouterTopProgressBar() {
return (
<Suspense fallback={null}>
<DashboardRouterTopProgressBarInner />
</Suspense>
);
}
+47
View File
@@ -0,0 +1,47 @@
export type Store<T> = {
getValue(): T;
setValue(newValue: T): void;
subscribe(listener: () => void): () => void;
};
/**
* Create a reactive value store
* @param initialValue - The initial value to store
* @example
* ```ts
* const store = createStore(0);
* ```
* @returns A store object
* @internal
*/
export function createStore<T>(initialValue: T): Store<T> {
type Listener = () => void;
const listeners = new Set<Listener>();
let value = initialValue;
const notify = () => {
for (const listener of listeners) {
listener();
}
};
return {
getValue() {
return value;
},
setValue(newValue: T) {
if (newValue === value) {
return;
}
value = newValue;
notify();
},
subscribe(listener: Listener) {
listeners.add(listener);
return () => {
listeners.delete(listener);
};
},
};
}
@@ -0,0 +1,4 @@
import { useEffect, useLayoutEffect } from "react";
export const useIsomorphicLayoutEffect =
typeof window !== "undefined" ? useLayoutEffect : useEffect;
+15 -10
View File
@@ -3,7 +3,8 @@
@tailwind utilities;
@layer base {
:root {
:root,
[data-theme="light"] {
/* bg - neutral */
--background: 0 0% 100%;
--secondary: 0 0% 97%;
@@ -44,7 +45,8 @@
--radius: 0.5rem;
}
.dark {
.dark,
[data-theme="dark"] {
/* bg - neutral */
--background: 0 0% 4.5%;
--secondary: 0 0% 6.5%;
@@ -94,19 +96,22 @@
/* shadcn charts */
@layer base {
:root {
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
}
.dark {
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
/* below is ai generated based on the initial */
--chart-6: 200 65% 50%;
--chart-7: 120 70% 45%;
--chart-8: 45 75% 55%;
--chart-9: 260 60% 60%;
--chart-10: 0 70% 50%;
--chart-11: 180 60% 50%;
--chart-12: 100 65% 55%;
--chart-13: 360 70% 55%;
--chart-14: 240 65% 50%;
--chart-15: 80 60% 50%;
}
}
@@ -90,8 +90,10 @@ export const engineKeys = {
health: (instance: string) =>
[...engineKeys.all, instance, "health"] as const,
latestVersion: () => [...engineKeys.all, "latestVersion"] as const,
metrics: (engineId: string) =>
[...engineKeys.all, engineId, "metrics"] as const,
systemMetrics: (engineId: string) =>
[...engineKeys.all, engineId, "systemMetrics"] as const,
queueMetrics: (engineId: string) =>
[...engineKeys.all, engineId, "queueMetrics"] as const,
};
export const contractKeys = {
@@ -3,12 +3,16 @@
import { Spinner } from "@/components/ui/Spinner/Spinner";
import { Button } from "@/components/ui/button";
import { thirdwebClient } from "@/constants/client";
import { useSupportedChains } from "@thirdweb-dev/react";
import { getSDKTheme } from "app/components/sdk-component-theme";
import { CustomChainRenderer } from "components/selects/CustomChainRenderer";
import { mapV4ChainToV5Chain } from "contexts/map-chains";
import { useTrack } from "hooks/analytics/useTrack";
import { useSupportedChains } from "hooks/chains/configureChains";
import {
useAddRecentlyUsedChainId,
useRecentlyUsedChains,
} from "hooks/chains/recentlyUsedChains";
import { useSetIsNetworkConfigModalOpen } from "hooks/networkConfigModal";
import { useTheme } from "next-themes";
import Image from "next/image";
import Link from "next/link";
@@ -16,10 +20,6 @@ import { usePathname } from "next/navigation";
import { useCallback, useMemo } from "react";
import type { Chain } from "thirdweb";
import { AutoConnect, ConnectButton, useConnectModal } from "thirdweb/react";
import { getSDKTheme } from "../../../../app/components/sdk-component-theme";
import { CustomChainRenderer } from "../../../../components/selects/CustomChainRenderer";
import { mapV4ChainToV5Chain } from "../../../../contexts/map-chains";
import { useSetIsNetworkConfigModalOpen } from "../../../../hooks/networkConfigModal";
import { useFavoriteChains } from "../../hooks/useFavoriteChains";
import { useLoggedInUser } from "../../hooks/useLoggedInUser";
import { popularChains } from "../popularChains";
@@ -1,56 +1,70 @@
import { useContract, useContractEvents } from "@thirdweb-dev/react";
import type { ContractEvent } from "@thirdweb-dev/sdk";
import { type AbiEvent, formatAbiItem } from "abitype";
import { useMemo } from "react";
import {
type PreparedEvent,
type ThirdwebContract,
prepareEvent,
} from "thirdweb";
import { useContractEvents } from "thirdweb/react";
import { useResolveContractAbi } from "./useResolveContractAbi";
interface InternalTransaction {
transactionHash: ContractEvent["transaction"]["transactionHash"];
blockNumber: ContractEvent["transaction"]["blockNumber"];
events: ContractEvent[];
export interface InternalTransaction {
transactionHash: string;
blockNumber: bigint;
events: Array<{
logIndex: number;
address: string;
eventName: string;
args: readonly unknown[] | Record<string, unknown>;
}>;
}
export function useActivity(contractAddress?: string, autoUpdate?: boolean) {
// const provider = useProvider();
const contractQuery = useContract(contractAddress);
export function useActivity(contract: ThirdwebContract, autoUpdate?: boolean) {
const abiQuery = useResolveContractAbi(contract);
const eventsQuery = useContractEvents(contractQuery.contract, undefined, {
subscribe: autoUpdate,
queryFilter: {
fromBlock: -20000,
},
// Get all the PreprareEvents from the contract abis
const events: PreparedEvent<AbiEvent>[] = useMemo(() => {
const eventsItems = (abiQuery.data || []).filter((o) => o.type === "event");
const eventSignatures = eventsItems.map((event) => formatAbiItem(event));
return eventSignatures.map((signature) =>
prepareEvent({ signature: signature as `event ${string}` }),
);
}, [abiQuery.data]);
const eventsQuery = useContractEvents({
contract,
events,
blockRange: 20000,
watch: autoUpdate,
});
return useMemo(() => {
if (!eventsQuery.data) {
return [];
}
const obj = eventsQuery.data.slice(0, 100).reduce(
(acc, curr) => {
if (acc[curr.transaction.transactionHash]) {
acc[curr.transaction.transactionHash].events.push(curr);
acc[curr.transaction.transactionHash].events.sort(
// biome-ignore lint/suspicious/noExplicitAny: FIXME
(a: any, b: any) => b.transaction.logIndex - a.transaction.logIndex,
if (acc[curr.transactionHash]) {
acc[curr.transactionHash].events.push(curr);
acc[curr.transactionHash].events.sort(
(a, b) => b.logIndex - a.logIndex,
);
if (
acc[curr.transaction.transactionHash].blockNumber >
curr.transaction.blockNumber
) {
acc[curr.transaction.transactionHash].blockNumber =
curr.transaction.blockNumber;
if (acc[curr.transactionHash].blockNumber > curr.blockNumber) {
acc[curr.transactionHash].blockNumber = curr.blockNumber;
}
} else {
acc[curr.transaction.transactionHash] = {
transactionHash: curr.transaction.transactionHash,
blockNumber: curr.transaction.blockNumber,
acc[curr.transactionHash] = {
transactionHash: curr.transactionHash,
blockNumber: curr.blockNumber,
events: [curr],
};
}
return acc;
},
{} as Record<string, InternalTransaction>,
);
return Object.values(obj).sort((a, b) => b.blockNumber - a.blockNumber);
return Object.values(obj).sort((a, b) =>
a.blockNumber > b.blockNumber ? -1 : 1,
);
}, [eventsQuery.data]);
}
@@ -73,7 +73,6 @@ export type Account = {
interface UpdateAccountInput {
name?: string;
email?: string;
plan?: AccountPlan;
linkWallet?: boolean;
subscribeToUpdates?: boolean;
onboardSkipped?: boolean;
@@ -271,9 +270,9 @@ interface UseAccountInput {
export function useAccount({ refetchInterval }: UseAccountInput = {}) {
const { user, isLoggedIn } = useLoggedInUser();
return useQuery(
accountKeys.me(user?.address as string),
async () => {
return useQuery({
queryKey: accountKeys.me(user?.address as string),
queryFn: async () => {
const res = await fetch(`${THIRDWEB_API_HOST}/v1/account/me`, {
method: "GET",
headers: {
@@ -288,19 +287,17 @@ export function useAccount({ refetchInterval }: UseAccountInput = {}) {
return json.data as Account;
},
{
enabled: !!user?.address && isLoggedIn,
refetchInterval: refetchInterval ?? false,
},
);
enabled: !!user?.address && isLoggedIn,
refetchInterval: refetchInterval ?? false,
});
}
export function useAccountUsage() {
const { user, isLoggedIn } = useLoggedInUser();
return useQuery(
accountKeys.usage(user?.address as string),
async () => {
return useQuery({
queryKey: accountKeys.usage(user?.address as string),
queryFn: async () => {
const res = await fetch(`${THIRDWEB_API_HOST}/v1/account/usage`, {
method: "GET",
headers: {
@@ -315,16 +312,16 @@ export function useAccountUsage() {
return json.data as UsageBillableByService;
},
{ enabled: !!user?.address && isLoggedIn },
);
enabled: !!user?.address && isLoggedIn,
});
}
export function useAccountCredits() {
const { user, isLoggedIn } = useLoggedInUser();
return useQuery(
accountKeys.credits(user?.address as string),
async () => {
return useQuery({
queryKey: accountKeys.credits(user?.address as string),
queryFn: async () => {
const res = await fetch(`${THIRDWEB_API_HOST}/v1/account/credits`, {
method: "GET",
@@ -347,16 +344,19 @@ export function useAccountCredits() {
return credits;
},
{ enabled: !!user?.address && isLoggedIn },
);
enabled: !!user?.address && isLoggedIn,
});
}
export function useWalletStats(clientId: string | undefined) {
const { user, isLoggedIn } = useLoggedInUser();
return useQuery(
accountKeys.walletStats(user?.address as string, clientId as string),
async () => {
return useQuery({
queryKey: accountKeys.walletStats(
user?.address as string,
clientId as string,
),
queryFn: async () => {
const res = await fetch(
`${THIRDWEB_API_HOST}/v1/account/wallets?clientId=${clientId}`,
{
@@ -375,8 +375,8 @@ export function useWalletStats(clientId: string | undefined) {
return json.data as WalletStats;
},
{ enabled: !!clientId && !!user?.address && isLoggedIn },
);
enabled: !!clientId && !!user?.address && isLoggedIn,
});
}
export function useUpdateAccount() {
@@ -419,7 +419,7 @@ export function useUpdateAccountPlan(waitForWebhook?: boolean) {
const queryClient = useQueryClient();
return useMutationWithInvalidate(
async (input: { plan: string; feedback?: string; useTrial?: boolean }) => {
async (input: { plan: string; feedback?: string }) => {
invariant(user?.address, "walletAddress is required");
const res = await fetch(`${THIRDWEB_API_HOST}/v1/account/plan`, {
@@ -495,9 +495,9 @@ export function useUpdateNotifications() {
export function useCreateBillingSession(enabled = false) {
const { user } = useLoggedInUser();
return useQuery(
accountKeys.billingSession(user?.address as string),
async () => {
return useQuery({
queryKey: accountKeys.billingSession(user?.address as string),
queryFn: async () => {
invariant(user?.address, "walletAddress is required");
const res = await fetch(
@@ -518,8 +518,8 @@ export function useCreateBillingSession(enabled = false) {
return json.data;
},
{ enabled },
);
enabled,
});
}
export function useConfirmEmail() {
@@ -637,9 +637,9 @@ export function useCreatePaymentMethod() {
export function useApiKeys() {
const { user, isLoggedIn } = useLoggedInUser();
return useQuery(
apiKeys.keys(user?.address as string),
async () => {
return useQuery({
queryKey: apiKeys.keys(user?.address as string),
queryFn: async () => {
const res = await fetch(`${THIRDWEB_API_HOST}/v1/keys`, {
method: "GET",
@@ -654,8 +654,8 @@ export function useApiKeys() {
}
return json.data as ApiKey[];
},
{ enabled: !!user?.address && isLoggedIn },
);
enabled: !!user?.address && isLoggedIn,
});
}
export function useCreateApiKey() {
@@ -885,9 +885,9 @@ export function useRevokeAuthorizedWallet() {
export function useAuthorizedWallets() {
const { user, isLoggedIn } = useLoggedInUser();
return useQuery(
authorizedWallets.authorizedWallets(user?.address as string),
async () => {
return useQuery({
queryKey: authorizedWallets.authorizedWallets(user?.address as string),
queryFn: async () => {
const res = await fetch(`${THIRDWEB_API_HOST}/v1/authorized-wallets`, {
method: "GET",
@@ -903,8 +903,9 @@ export function useAuthorizedWallets() {
return json.data as AuthorizedWallet[];
},
{ enabled: !!user?.address && isLoggedIn, cacheTime: 0 },
);
enabled: !!user?.address && isLoggedIn,
cacheTime: 0,
});
}
/**
@@ -913,12 +914,7 @@ export function useAuthorizedWallets() {
export async function fetchChainsFromApi() {
// always fetch from prod for chains for now
// TODO: re-visit this
const res = await fetch("https://api.thirdweb.com/v1/chains", {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
const res = await fetch("https://api.thirdweb.com/v1/chains");
const json = await res.json();
if (json.error) {
@@ -929,7 +925,10 @@ export async function fetchChainsFromApi() {
}
export function useApiChains() {
return useQuery(["all-chains"], async () => {
return fetchChainsFromApi();
return useQuery({
queryKey: ["all-chains"],
queryFn: () => {
return fetchChainsFromApi();
},
});
}
@@ -0,0 +1,54 @@
import { useQuery } from "@tanstack/react-query";
import type { ThirdwebContract } from "thirdweb";
import { getCompilerMetadata } from "thirdweb/contract";
import { getContractMetadata, name, symbol } from "thirdweb/extensions/common";
/**
* Fetch the contract metadata for Dashboard
*
* If the contract itself doesn't implement the metadata extension,
* we try to fall back to:
* 1. name(), symbol()
* 2. our API endpoint
*/
export function useDashboardContractMetadata(contract: ThirdwebContract) {
return useQuery({
queryKey: ["contract-metadata-header", contract.chain.id, contract.address],
queryFn: async () => {
const [contractMetadata, _name, _symbol, compilerMetadata] =
await Promise.all([
getContractMetadata({ contract }).catch(() => ({
image: "",
name: "",
symbol: "",
})),
name({ contract }).catch(() => ""),
symbol({ contract }).catch(() => ""),
getCompilerMetadata(contract).catch(() => undefined),
]);
/**
* Handle the case where the contract.thirdweb.com endpoint returns a very long name
* example url: https://contract.thirdweb.com/metadata/324/0x66E298335c5992d599132582De8eaAF75348e6e6
* In that case, we split the solidity name on ":" and take the second part
*/
if (compilerMetadata?.name.includes(":")) {
const _name = compilerMetadata.name.split(":")[1];
if (_name) {
compilerMetadata.name = compilerMetadata.name.split(":")[1];
}
}
const contractName =
contractMetadata?.name || _name || compilerMetadata?.name || "";
const contractSymbol = contractMetadata?.symbol || _symbol || "";
return {
name: contractName,
symbol: contractSymbol,
image: contractMetadata.image || "",
contractType: compilerMetadata?.name || "",
};
},
});
}
@@ -0,0 +1,41 @@
import { useQuery } from "@tanstack/react-query";
import type { NFT, ThirdwebContract } from "thirdweb";
import {
getOwnedNFTs as getOwnedERC721,
isERC721,
} from "thirdweb/extensions/erc721";
import { getOwnedNFTs as getOwnedERC1155 } from "thirdweb/extensions/erc1155";
import invariant from "tiny-invariant";
/**
* This hook is currently used for getting owned NFTs for Create DirectListing/English Auction
* It should only be used if our indexing solutions don't support the current network
*/
export function useDashboardOwnedNFTs({
contract,
owner,
disabled,
}: { owner?: string; contract?: ThirdwebContract; disabled?: boolean }) {
return useQuery({
queryKey: [
"owned-nfts",
contract?.chain.id || "",
contract?.address || "",
owner || "",
],
queryFn: async (): Promise<NFT[]> => {
invariant(contract, "Contract is required");
invariant(owner, "owner address is required");
const is721 = await isERC721({ contract });
if (is721) {
return getOwnedERC721({
contract,
owner,
});
}
// Else default to 1155
return getOwnedERC1155({ contract, address: owner });
},
enabled: !!contract && !!owner && !disabled,
});
}
@@ -25,12 +25,12 @@ export type EmbeddedWalletUser = {
export function useEmbeddedWallets(clientId: string) {
const { user, isLoggedIn } = useLoggedInUser();
return useQuery(
embeddedWalletsKeys.embeddedWallets(
return useQuery({
queryKey: embeddedWalletsKeys.embeddedWallets(
user?.address as string,
clientId as string,
),
async () => {
queryFn: async () => {
const res = await fetch(
`${THIRDWEB_EWS_API_HOST}/api/thirdweb/embedded-wallet?clientId=${clientId}&lastAccessedAt=0`,
{
@@ -46,6 +46,6 @@ export function useEmbeddedWallets(clientId: string) {
return json.walletUsers as EmbeddedWalletUser[];
},
{ enabled: !!user?.address && isLoggedIn && !!clientId },
);
enabled: !!user?.address && isLoggedIn && !!clientId,
});
}
@@ -55,9 +55,9 @@ const getEngineRequestHeaders = (token: string | null): HeadersInit => {
export function useEngineInstances() {
const { user, isLoggedIn } = useLoggedInUser();
return useQuery(
engineKeys.instances(user?.address as string),
async (): Promise<EngineInstance[]> => {
return useQuery({
queryKey: engineKeys.instances(user?.address as string),
queryFn: async (): Promise<EngineInstance[]> => {
const res = await fetch(`${THIRDWEB_API_HOST}/v1/engine`, {
method: "GET",
});
@@ -79,8 +79,8 @@ export function useEngineInstances() {
};
});
},
{ enabled: !!user?.address && isLoggedIn },
);
enabled: !!user?.address && isLoggedIn,
});
}
// GET Requests
@@ -100,9 +100,9 @@ export type BackendWallet = {
export function useEngineBackendWallets(instance: string) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery(
[engineKeys.backendWallets(instance)],
async () => {
return useQuery({
queryKey: [engineKeys.backendWallets(instance)],
queryFn: async () => {
const res = await fetch(`${instance}backend-wallet/get-all?limit=50`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -112,8 +112,8 @@ export function useEngineBackendWallets(instance: string) {
return (json.result as BackendWallet[]) || [];
},
{ enabled: !!instance && !!token },
);
enabled: !!instance && !!token,
});
}
export interface EngineSystemHealth {
@@ -126,9 +126,9 @@ export function useEngineSystemHealth(
instanceUrl: string,
pollInterval: number | false = false,
) {
return useQuery(
engineKeys.health(instanceUrl),
async () => {
return useQuery({
queryKey: engineKeys.health(instanceUrl),
queryFn: async () => {
const res = await fetch(`${instanceUrl}system/health`, {
headers: getEngineRequestHeaders(null),
});
@@ -138,23 +138,57 @@ export function useEngineSystemHealth(
const json = (await res.json()) as EngineSystemHealth;
return json;
},
{
enabled: !!instanceUrl,
refetchInterval: pollInterval,
enabled: !!instanceUrl,
refetchInterval: pollInterval,
});
}
export interface EngineSystemQueueMetrics {
result: {
queued: number;
pending: number;
latency?: {
msToSend: { p50: number; p90: number };
msToMine: { p50: number; p90: number };
};
};
}
export function useEngineQueueMetrics(
instanceUrl: string,
pollInterval: number | false = false,
) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery({
queryKey: engineKeys.queueMetrics(instanceUrl),
queryFn: async () => {
const res = await fetch(`${instanceUrl}system/queue`, {
headers: getEngineRequestHeaders(token),
});
if (!res.ok) {
throw new Error(`Unexpected status ${res.status}: ${await res.text()}`);
}
return (await res.json()) as EngineSystemQueueMetrics;
},
);
enabled: !!instanceUrl && !!token,
refetchInterval: pollInterval,
});
}
export function useEngineLatestVersion() {
return useQuery(engineKeys.latestVersion(), async () => {
const res = await fetch(`${THIRDWEB_API_HOST}/v1/engine/latest-version`, {
method: "GET",
});
if (!res.ok) {
throw new Error(`Unexpected status ${res.status}: ${await res.text()}`);
}
const json = await res.json();
return json.data.version as string;
return useQuery({
queryKey: engineKeys.latestVersion(),
queryFn: async () => {
const res = await fetch(`${THIRDWEB_API_HOST}/v1/engine/latest-version`, {
method: "GET",
});
if (!res.ok) {
throw new Error(`Unexpected status ${res.status}: ${await res.text()}`);
}
const json = await res.json();
return json.data.version as string;
},
});
}
@@ -299,6 +333,7 @@ export type Transaction = {
gasPrice?: string | null;
maxFeePerGas?: string | null;
maxPriorityFeePerGas?: string | null;
effectiveGasPrice?: string | null;
transactionType?: number | null;
transactionHash?: string | null;
queuedAt?: string | null;
@@ -347,9 +382,9 @@ type TransactionResponse = {
export function useEngineTransactions(instance: string, autoUpdate: boolean) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery(
engineKeys.transactions(instance),
async () => {
return useQuery({
queryKey: engineKeys.transactions(instance),
queryFn: async () => {
const res = await fetch(`${instance}transaction/get-all`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -359,11 +394,10 @@ export function useEngineTransactions(instance: string, autoUpdate: boolean) {
return (json.result as TransactionResponse) || {};
},
{
enabled: !!instance && !!token,
refetchInterval: autoUpdate ? 4_000 : false,
},
);
enabled: !!instance && !!token,
refetchInterval: autoUpdate ? 4_000 : false,
});
}
type WalletConfig =
@@ -388,9 +422,9 @@ type WalletConfig =
export function useEngineWalletConfig(instance: string) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery(
engineKeys.walletConfig(instance),
async () => {
return useQuery({
queryKey: engineKeys.walletConfig(instance),
queryFn: async () => {
const res = await fetch(`${instance}configuration/wallets`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -400,8 +434,8 @@ export function useEngineWalletConfig(instance: string) {
return (json.result as WalletConfig) || {};
},
{ enabled: !!instance && !!token },
);
enabled: !!instance && !!token,
});
}
type CurrencyValue = {
@@ -421,9 +455,9 @@ export function useEngineBackendWalletBalance(
invariant(chainId, "chainId is required");
return useQuery(
engineKeys.backendWalletBalance(address, chainId),
async () => {
return useQuery({
queryKey: engineKeys.backendWalletBalance(address, chainId),
queryFn: async () => {
const res = await fetch(
`${instance}backend-wallet/${chainId}/${address}/get-balance`,
{
@@ -436,8 +470,8 @@ export function useEngineBackendWalletBalance(
return (json.result as CurrencyValue) || {};
},
{ enabled: !!instance && !!address && !!chainId && !!token },
);
enabled: !!instance && !!address && !!chainId && !!token,
});
}
export type EngineAdmin = {
@@ -450,9 +484,9 @@ export function useEnginePermissions(instance: string) {
const token = useLoggedInUser().user?.jwt ?? null;
const address = useActiveAccount()?.address;
return useQuery(
engineKeys.permissions(instance),
async () => {
return useQuery({
queryKey: engineKeys.permissions(instance),
queryFn: async () => {
const res = await fetch(`${instance}auth/permissions/get-all`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -466,10 +500,9 @@ export function useEnginePermissions(instance: string) {
return (json.result as EngineAdmin[]) || [];
},
{
enabled: !!instance && !!token && !!address,
},
);
enabled: !!instance && !!token && !!address,
});
}
export type AccessToken = {
@@ -484,9 +517,9 @@ export type AccessToken = {
export function useEngineAccessTokens(instance: string) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery(
engineKeys.accessTokens(instance),
async () => {
return useQuery({
queryKey: engineKeys.accessTokens(instance),
queryFn: async () => {
const res = await fetch(`${instance}auth/access-tokens/get-all`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -496,8 +529,8 @@ export function useEngineAccessTokens(instance: string) {
return (json.result as AccessToken[]) || [];
},
{ enabled: !!instance && !!token },
);
enabled: !!instance && !!token,
});
}
export type KeypairAlgorithm = "ES256" | "RS256" | "PS256";
@@ -514,9 +547,9 @@ export type Keypair = {
export function useEngineKeypairs(instance: string) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery(
engineKeys.keypairs(instance),
async () => {
return useQuery({
queryKey: engineKeys.keypairs(instance),
queryFn: async () => {
const res = await fetch(`${instance}auth/keypair/get-all`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -526,8 +559,8 @@ export function useEngineKeypairs(instance: string) {
return (json.result as Keypair[]) || [];
},
{ enabled: !!instance && !!token },
);
enabled: !!instance && !!token,
});
}
type AddKeypairInput = {
@@ -610,9 +643,9 @@ export type EngineRelayer = {
export function useEngineRelayer(instance: string) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery(
engineKeys.relayers(instance),
async () => {
return useQuery({
queryKey: engineKeys.relayers(instance),
queryFn: async () => {
const res = await fetch(`${instance}relayer/get-all`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -622,8 +655,8 @@ export function useEngineRelayer(instance: string) {
return (json.result as EngineRelayer[]) || [];
},
{ enabled: !!instance && !!token },
);
enabled: !!instance && !!token,
});
}
export type CreateRelayerInput = {
@@ -747,9 +780,9 @@ export interface EngineWebhook {
export function useEngineWebhooks(instance: string) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery(
engineKeys.webhooks(instance),
async () => {
return useQuery({
queryKey: engineKeys.webhooks(instance),
queryFn: async () => {
const res = await fetch(`${instance}webhooks/get-all`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -759,8 +792,8 @@ export function useEngineWebhooks(instance: string) {
return (json.result as EngineWebhook[]) || [];
},
{ enabled: !!instance && !!token },
);
enabled: !!instance && !!token,
});
}
// POST REQUESTS
@@ -1206,9 +1239,9 @@ export function useEngineSendTokens(instance: string) {
export function useEngineCorsConfiguration(instance: string) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery(
engineKeys.corsUrls(instance),
async () => {
return useQuery({
queryKey: engineKeys.corsUrls(instance),
queryFn: async () => {
const res = await fetch(`${instance}configuration/cors`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -1218,8 +1251,8 @@ export function useEngineCorsConfiguration(instance: string) {
return (json.result as string[]) || [];
},
{ enabled: !!instance && !!token },
);
enabled: !!instance && !!token,
});
}
interface SetCorsUrlInput {
@@ -1262,9 +1295,9 @@ export function useEngineIpAllowlistConfiguration(instance: string) {
// if engine instance is not updated to have IP_ALLOWLIST
const { data: health } = useEngineSystemHealth(instance);
return useQuery(
engineKeys.ipAllowlist(instance),
async () => {
return useQuery({
queryKey: engineKeys.ipAllowlist(instance),
queryFn: async () => {
const res = await fetch(`${instance}configuration/ip-allowlist`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -1273,11 +1306,10 @@ export function useEngineIpAllowlistConfiguration(instance: string) {
const json = await res.json();
return (json.result as string[]) || [];
},
{
enabled:
!!instance && !!token && health?.features?.includes("IP_ALLOWLIST"),
},
);
enabled:
!!instance && !!token && health?.features?.includes("IP_ALLOWLIST"),
});
}
interface SetIpAllowlistInput {
@@ -1330,9 +1362,9 @@ export interface EngineContractSubscription {
export function useEngineContractSubscription(instance: string) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery(
engineKeys.contractSubscriptions(instance),
async () => {
return useQuery({
queryKey: engineKeys.contractSubscriptions(instance),
queryFn: async () => {
const res = await fetch(`${instance}contract-subscriptions/get-all`, {
method: "GET",
headers: getEngineRequestHeaders(token),
@@ -1341,10 +1373,9 @@ export function useEngineContractSubscription(instance: string) {
const json = await res.json();
return json.result as EngineContractSubscription[];
},
{
enabled: !!instance && !!token,
},
);
enabled: !!instance && !!token,
});
}
export interface AddContractSubscriptionInput {
@@ -1430,9 +1461,9 @@ export function useEngineSubscriptionsLastBlock(
) {
const token = useLoggedInUser().user?.jwt ?? null;
return useQuery(
engineKeys.contractSubscriptionsLastBlock(instanceUrl, chainId),
async () => {
return useQuery({
queryKey: engineKeys.contractSubscriptionsLastBlock(instanceUrl, chainId),
queryFn: async () => {
const response = await fetch(
`${instanceUrl}contract-subscriptions/last-block?chain=${chainId}`,
{
@@ -1444,11 +1475,10 @@ export function useEngineSubscriptionsLastBlock(
const json = await response.json();
return json.result.lastBlock as number;
},
{
enabled: !!instanceUrl && !!token,
refetchInterval: autoUpdate ? 5_000 : false,
},
);
enabled: !!instanceUrl && !!token,
refetchInterval: autoUpdate ? 5_000 : false,
});
}
export interface EngineResourceMetrics {
@@ -1462,12 +1492,12 @@ export interface EngineResourceMetrics {
};
}
export function useEngineResourceMetrics(engineId: string) {
export function useEngineSystemMetrics(engineId: string) {
const [enabled, setEnabled] = useState(true);
return useQuery(
engineKeys.metrics(engineId),
async () => {
return useQuery({
queryKey: engineKeys.systemMetrics(engineId),
queryFn: async () => {
const res = await fetch(
`${THIRDWEB_API_HOST}/v1/engine/${engineId}/metrics`,
);
@@ -1478,10 +1508,9 @@ export function useEngineResourceMetrics(engineId: string) {
const json = (await res.json()) as EngineResourceMetrics;
return json;
},
{
// Poll every 5s unless disabled.
enabled,
refetchInterval: 5_000,
},
);
// Poll every 5s unless disabled.
enabled,
refetchInterval: 5_000,
});
}
@@ -1,5 +1,5 @@
import { useSupportedChains } from "@thirdweb-dev/react";
import { useFavouriteChainIds } from "app/(dashboard)/(chain)/components/client/star-button";
import { useSupportedChains } from "hooks/chains/configureChains";
import { useMemo } from "react";
import type { ChainMetadata } from "thirdweb/chains";
@@ -1,16 +0,0 @@
import { useQuery } from "@tanstack/react-query";
export type GasEstimate = { gasPrice: number; ethPrice: number };
export function useGas() {
return useQuery(
["gas-price", "ethereum"],
async () => {
const res = await fetch("/api/gas");
return res.json() as Promise<GasEstimate>;
},
{
refetchInterval: 60_000,
},
);
}
@@ -1,7 +1,8 @@
import { isLoginRequired } from "@/constants/auth";
import { useDashboardRouter } from "@/lib/DashboardRouter";
import { useQuery } from "@tanstack/react-query";
import type { EnsureLoginResponse } from "app/api/auth/ensure-login/route";
import { usePathname, useRouter } from "next/navigation";
import { usePathname } from "next/navigation";
import { useRef } from "react";
import {
useActiveAccount,
@@ -20,7 +21,7 @@ export function useLoggedInUser(): {
isLoggedIn: boolean;
user: { address: string; jwt?: string } | null;
} {
const router = useRouter();
const router = useDashboardRouter();
const pathname = usePathname();
const connectedAddress = useActiveAccount()?.address;
const connectionStatus = useActiveWalletConnectionStatus();
@@ -1,47 +1,35 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useSigner } from "@thirdweb-dev/react";
import { addContractToMultiChainRegistry } from "components/contract-components/utils";
import { MULTICHAIN_REGISTRY_CONTRACT } from "constants/contracts";
import {
addContractToMultiChainRegistry,
getGaslessPolygonSDK,
} from "components/contract-components/utils";
DASHBOARD_ENGINE_RELAYER_URL,
DASHBOARD_FORWARDER_ADDRESS,
} from "constants/misc";
import type { BasicContract } from "contract-ui/types/types";
import { getAllMultichainRegistry } from "dashboard-extensions/common/read/getAllMultichainRegistry";
import { useAllChainsData } from "hooks/chains/allChains";
import { useSupportedChainsRecord } from "hooks/chains/configureChains";
import { defineDashboardChain } from "lib/defineDashboardChain";
import { thirdwebClient } from "lib/thirdweb-client";
import { useMemo } from "react";
import { getContract } from "thirdweb";
import { polygon } from "thirdweb/chains";
import { sendAndConfirmTransaction } from "thirdweb";
import { remove } from "thirdweb/extensions/thirdweb";
import { useActiveAccount } from "thirdweb/react";
import invariant from "tiny-invariant";
const MULTICHAIN_REGISTRY_ADDRESS =
"0xcdAD8FA86e18538aC207872E8ff3536501431B73";
const registryContract = getContract({
client: thirdwebClient,
address: MULTICHAIN_REGISTRY_ADDRESS,
// eslint-disable-next-line no-restricted-syntax
chain: defineDashboardChain(polygon.id, undefined),
});
function useMultiChainRegContractList(walletAddress?: string) {
return useQuery(
["dashboard-registry", walletAddress, "multichain-contract-list"],
async () => {
return useQuery({
queryKey: ["dashboard-registry", walletAddress, "multichain-contract-list"],
queryFn: async () => {
invariant(walletAddress, "walletAddress is required");
const contracts = await getAllMultichainRegistry({
contract: registryContract,
contract: MULTICHAIN_REGISTRY_CONTRACT,
address: walletAddress,
});
return contracts;
},
{
enabled: !!walletAddress,
},
);
enabled: !!walletAddress,
});
}
interface Options {
@@ -97,28 +85,30 @@ type RemoveContractParams = {
};
export function useRemoveContractMutation() {
const walletAddress = useActiveAccount()?.address;
const signer = useSigner();
const { chainIdToChainRecord } = useAllChainsData();
const queryClient = useQueryClient();
const account = useActiveAccount();
return useMutation(
async (data: RemoveContractParams) => {
invariant(
walletAddress,
"cannot add a contract without a wallet address",
);
invariant(chainIdToChainRecord, "chains not initialzed yet");
invariant(signer, "no wallet connected");
invariant(data.chainId, "chainId not provided");
invariant(account, "No wallet connected");
const { contractAddress, chainId } = data;
const gaslessPolygonSDK = getGaslessPolygonSDK(signer);
return await gaslessPolygonSDK.multiChainRegistry?.removeContract({
address: contractAddress,
chainId,
const transaction = remove({
contract: MULTICHAIN_REGISTRY_CONTRACT,
deployer: account.address,
deployment: contractAddress,
chainId: BigInt(chainId),
});
return await sendAndConfirmTransaction({
transaction,
account,
gasless: {
experimentalChainlessSupport: true,
provider: "engine",
relayerUrl: DASHBOARD_ENGINE_RELAYER_URL,
relayerForwarderAddress: DASHBOARD_FORWARDER_ADDRESS,
},
});
},
{
@@ -0,0 +1,21 @@
import { useQuery } from "@tanstack/react-query";
import type { Abi } from "abitype";
import type { ThirdwebContract } from "thirdweb";
import { resolveContractAbi } from "thirdweb/contract";
import invariant from "tiny-invariant";
export function useResolveContractAbi(contract?: ThirdwebContract) {
return useQuery({
queryKey: [
"full-contract-abi",
contract?.chain.id || "",
contract?.address || "",
],
queryFn: async () => {
invariant(contract, "contract is required");
const abi = await resolveContractAbi<Abi>(contract);
return abi;
},
enabled: !!contract,
});
}
@@ -1,29 +1,21 @@
import { useToast } from "@chakra-ui/react";
import { useSDKChainId } from "@thirdweb-dev/react";
import type { Split } from "@thirdweb-dev/sdk";
import type {
BalanceQueryRequest,
BalanceQueryResponse,
} from "pages/api/moralis/balances";
import { toast } from "sonner";
import type { ThirdwebContract } from "thirdweb";
import { distribute, distributeByToken } from "thirdweb/extensions/split";
import { useSendAndConfirmTransaction } from "thirdweb/react";
import invariant from "tiny-invariant";
import { parseErrorToMessage } from "utils/errorParser";
import { splitsKeys } from "..";
import {
useMutationWithInvalidate,
useQueryWithNetwork,
} from "./query/useQueryWithNetwork";
export function useSplitData(contract?: Split) {
return useQueryWithNetwork(
splitsKeys.list(contract?.getAddress()),
async () => contract?.getAllRecipients(),
{
enabled: !!contract,
},
);
}
export function useSplitBalances(contractAddress?: string) {
const chainId = useSDKChainId();
export function useSplitBalances(contract: ThirdwebContract) {
const chainId = contract.chain.id;
const contractAddress = contract.address;
const currencies = useQueryWithNetwork(
splitsKeys.currencies(contractAddress),
async () => {
@@ -48,72 +40,31 @@ export function useSplitBalances(contractAddress?: string) {
return currencies;
}
export function useSplitDistributeFunds(contract?: Split) {
const contractAddress = contract?.getAddress();
const balances = useSplitBalances(contractAddress);
const toast = useToast();
export function useSplitDistributeFunds(contract: ThirdwebContract) {
const contractAddress = contract.address;
const balances = useSplitBalances(contract);
const { mutateAsync } = useSendAndConfirmTransaction();
return useMutationWithInvalidate(
async () => {
invariant(contract, "split contract is not ready");
invariant(balances.data, "No balances to distribute");
const distributions = (balances.data || [])
.filter((token) => token.display_balance !== "0.0")
.map(async (currency) => {
if (currency.name === "Native Token") {
await contract
.distribute()
.then(() => {
toast({
position: "bottom",
variant: "solid",
title: "Success",
description: `Successfully distributed ${currency.name}`,
status: "success",
duration: 5000,
isClosable: true,
const transaction =
currency.name === "Native Token"
? distribute({ contract })
: distributeByToken({
contract,
tokenAddress: currency.token_address,
});
return void 0;
})
.catch((err: unknown) => {
toast({
position: "bottom",
variant: "solid",
title: `Error distributing ${currency.name}`,
description: parseErrorToMessage(err),
status: "error",
duration: 9000,
isClosable: true,
});
});
} else {
await contract
.distributeToken(currency.token_address)
.then(() => {
toast({
position: "bottom",
variant: "solid",
title: "Success",
description: `Successfully distributed ${currency.name}`,
status: "success",
duration: 5000,
isClosable: true,
});
return void 0;
})
.catch((err: unknown) => {
toast({
position: "bottom",
variant: "solid",
title: `Error distributing ${currency.name}`,
description: parseErrorToMessage(err),
status: "error",
duration: 9000,
isClosable: true,
});
});
}
const promise = mutateAsync(transaction);
toast.promise(promise, {
success: `Successfully distributed ${currency.name}`,
error: `Error distributing ${currency.name}`,
loading: "Distributing funds",
});
});
return await Promise.all(distributions);
@@ -1,18 +1,36 @@
import { useContract, useContractMetadata, useSDK } from "@thirdweb-dev/react";
import type { Vote, VoteType } from "@thirdweb-dev/sdk";
import { useActiveAccount } from "thirdweb/react";
import { thirdwebClient } from "@/constants/client";
import { type ThirdwebContract, getContract, toTokens } from "thirdweb";
import {
balanceOf,
decimals,
delegate,
delegates,
} from "thirdweb/extensions/erc20";
import {
type VoteType,
canExecute,
castVoteWithReason,
executeProposal,
getAll,
hasVoted,
propose,
token,
} from "thirdweb/extensions/vote";
import { useActiveAccount, useSendAndConfirmTransaction } from "thirdweb/react";
import invariant from "tiny-invariant";
import type { RequiredParam } from "utils/types";
import { voteKeys } from "../cache-keys";
import {
useMutationWithInvalidate,
useQueryWithNetwork,
} from "./query/useQueryWithNetwork";
export function useVoteProposalList(contract?: Vote) {
export function useVoteProposalList(contract?: ThirdwebContract) {
return useQueryWithNetwork(
voteKeys.proposals(contract?.getAddress()),
async () => await contract?.getAll(),
voteKeys.proposals(contract?.address || ""),
async () => {
invariant(contract, "contract is required");
return await getAll({ contract });
},
{
enabled: !!contract,
},
@@ -20,17 +38,20 @@ export function useVoteProposalList(contract?: Vote) {
}
export function useHasVotedOnProposal(
contract: RequiredParam<Vote>,
proposalId: string,
contract: ThirdwebContract,
proposalId: bigint,
) {
const address = useActiveAccount()?.address;
const userAddress = useActiveAccount()?.address;
return useQueryWithNetwork(
voteKeys.userHasVotedOnProposal(
proposalId,
contract?.getAddress(),
address,
proposalId.toString(),
contract.address,
userAddress,
),
async () => await contract?.hasVoted(proposalId, address),
async () => {
invariant(userAddress, "address is required");
return await hasVoted({ contract, proposalId, account: userAddress });
},
{
enabled: !!contract,
},
@@ -38,65 +59,83 @@ export function useHasVotedOnProposal(
}
export function useCanExecuteProposal(
contract: RequiredParam<Vote>,
proposalId: string,
contract: ThirdwebContract,
proposalId: bigint,
) {
return useQueryWithNetwork(
voteKeys.canExecuteProposal(proposalId, contract?.getAddress()),
async () => await contract?.canExecute(proposalId),
voteKeys.canExecuteProposal(proposalId.toString(), contract.address),
async () => await canExecute({ contract, proposalId }),
{
enabled: !!contract,
},
);
}
export function useTokensDelegated(contract?: Vote) {
const sdk = useSDK();
const address = useActiveAccount()?.address;
export function useTokensDelegated(contract: ThirdwebContract) {
const userAddress = useActiveAccount()?.address;
return useQueryWithNetwork(
voteKeys.delegation(contract?.getAddress(), address),
voteKeys.delegation(contract.address, userAddress),
async () => {
invariant(address, "address is required");
invariant(contract, "vote contract is required");
const metadata = await contract?.metadata.get();
const tokenAddress = metadata?.voting_token_address;
const tokenContract = await sdk?.getToken(tokenAddress);
const delegation = await tokenContract?.getDelegationOf(address);
return delegation?.toLowerCase() === address.toLowerCase();
invariant(userAddress, "wallet address is required");
const tokenAddress = await token({ contract });
if (!tokenAddress) {
throw new Error("Expected a delegated token address");
}
const tokenContract = getContract({
address: tokenAddress,
chain: contract.chain,
client: thirdwebClient,
});
const delegatedAddress = await delegates({
contract: tokenContract,
account: userAddress,
});
return delegatedAddress?.toLowerCase() === userAddress.toLowerCase();
},
{
enabled: !!contract && !!address,
enabled: !!contract && !!userAddress,
},
);
}
export function useVoteTokenBalances(contract?: Vote, addresses?: string[]) {
const { data } = useContractMetadata(contract);
const tokenContract = useContract(
data?.voting_token_address,
"token",
).contract;
export function useVoteTokenBalances(
contract: ThirdwebContract,
addresses: string[],
) {
return useQueryWithNetwork(
voteKeys.balances(contract?.getAddress(), addresses),
async () => {
invariant(data, "contract metadata is required");
invariant(tokenContract, "voting contract is required");
invariant(addresses, "addresses are required");
const balances = addresses.map(async (address) => {
voteKeys.balances(contract.address, addresses),
async (): Promise<
Array<{ address: string; balance: string; decimals: number }>
> => {
invariant(addresses.length, "addresses are required");
const tokenAddress = await token({ contract });
if (!tokenAddress) {
throw new Error("Expected a delegated token address");
}
const tokenContract = getContract({
address: tokenAddress,
chain: contract.chain,
client: thirdwebClient,
});
const _decimals = await decimals({ contract: tokenContract });
const balanceData = await Promise.all(
addresses.map((address) =>
balanceOf({ contract: tokenContract, address }),
),
);
const balances = addresses.map((address, index) => {
const balance = balanceData[index] || 0n;
return {
address,
balance: (await tokenContract.balanceOf(address)).displayValue,
balance: toTokens(balance, _decimals),
decimals: _decimals,
};
});
return await Promise.all(balances);
},
{
enabled: !!data && !!contract && !!addresses?.length,
enabled: addresses.length > 0,
},
);
}
@@ -105,94 +144,143 @@ export interface IProposalInput {
description: string;
}
export function useProposalCreateMutation(contractAddress?: string) {
const voteContract = useContract(contractAddress, "vote").contract;
/**
* This hook is a simplified version meant to use on the Dashboard
* since _currently_ the dashboard only supports creating proposals with descriptions
*
* todo: make an extension in the SDK that is more robust and user-friendly ?
*/
export function useProposalCreateMutation(contract: ThirdwebContract) {
const { mutateAsync } = useSendAndConfirmTransaction();
return useMutationWithInvalidate(
(proposal: IProposalInput) => {
invariant(voteContract, "contract is required");
async (proposal: IProposalInput) => {
const { description } = proposal;
return voteContract.propose(description);
const transaction = propose({
contract,
description,
targets: [contract.address],
values: [0n],
calldatas: ["0x"],
});
return await mutateAsync(transaction);
},
{
onSuccess: (_data, _options, _variables, invalidate) => {
return invalidate([voteKeys.proposals(contractAddress)]);
return invalidate([voteKeys.proposals(contract.address)]);
},
},
);
}
export function useDelegateMutation(contract?: Vote) {
const sdk = useSDK();
const address = useActiveAccount()?.address;
const contractAddress = contract?.getAddress();
export function useDelegateMutation(contract: ThirdwebContract) {
const userAddress = useActiveAccount()?.address;
const { mutateAsync } = useSendAndConfirmTransaction();
return useMutationWithInvalidate(
async () => {
invariant(address, "address is required");
invariant(contractAddress, "contract address is required");
invariant(contract, "vote contract is required");
const metadata = await contract?.metadata.get();
const tokenAddress = metadata?.voting_token_address;
const tokenContract = await sdk?.getToken(tokenAddress);
return tokenContract?.delegateTo(address);
invariant(userAddress, "address is required");
const tokenAddress = await token({ contract });
if (!tokenAddress) {
throw new Error("Expected a delegated token address");
}
const tokenContract = getContract({
address: tokenAddress,
chain: contract.chain,
client: thirdwebClient,
});
const transaction = delegate({
contract: tokenContract,
delegatee: userAddress,
});
return await mutateAsync(transaction);
},
{
onSuccess: (_data, _options, _variables, invalidate) => {
return invalidate([voteKeys.delegation(contractAddress, address)]);
return invalidate([voteKeys.delegation(contract.address, userAddress)]);
},
},
);
}
/**
* Get the decimals of the voting erc20 token
*/
export function useVotingTokenDecimals(contract: ThirdwebContract) {
return useMutationWithInvalidate(async () => {
const tokenAddress = await token({ contract });
if (!tokenAddress) {
throw new Error("Expected a delegated token address");
}
const tokenContract = getContract({
address: tokenAddress,
chain: contract.chain,
client: thirdwebClient,
});
const _decimals = await decimals({ contract: tokenContract });
return _decimals;
});
}
interface IVoteCast {
voteType: VoteType;
reason?: string;
}
export function useCastVoteMutation(
contract: RequiredParam<Vote>,
proposalId: string,
contract: ThirdwebContract,
proposalId: bigint,
) {
const address = useActiveAccount()?.address;
const contractAddress = contract?.getAddress();
const contractAddress = contract.address;
const { mutateAsync } = useSendAndConfirmTransaction();
return useMutationWithInvalidate(
async (vote: IVoteCast) => {
async (voteItem: IVoteCast) => {
invariant(contract, "contract is required");
invariant(address, "address is required");
const { voteType, reason } = vote;
return contract.vote(proposalId, voteType, reason);
const { voteType, reason } = voteItem;
const transaction = castVoteWithReason({
contract,
proposalId,
support: voteType,
reason: reason ?? "",
});
return await mutateAsync(transaction);
},
{
onSuccess: (_data, _options, _variables, invalidate) => {
return invalidate([
voteKeys.proposals(contractAddress),
voteKeys.userHasVotedOnProposal(proposalId, contractAddress, address),
voteKeys.canExecuteProposal(proposalId, contractAddress),
voteKeys.userHasVotedOnProposal(
proposalId.toString(),
contractAddress,
address,
),
voteKeys.canExecuteProposal(proposalId.toString(), contractAddress),
]);
},
},
);
}
/**
* This hook is a simplified version for the Dashboard
* It doesn't pass any extra info to the execute function
*/
export function useExecuteProposalMutation(
contract: RequiredParam<Vote>,
proposalId: string,
contract: ThirdwebContract,
proposalId: bigint,
) {
const contractAddress = contract?.getAddress();
const contractAddress = contract.address;
const mutation = useSendAndConfirmTransaction();
return useMutationWithInvalidate(
async () => {
invariant(contract, "contract is required");
return contract.execute(proposalId);
const transaction = executeProposal({ contract, proposalId });
return await mutation.mutateAsync(transaction);
},
{
onSuccess: (_data, _options, _variables, invalidate) => {
return invalidate([
voteKeys.proposals(contractAddress),
voteKeys.canExecuteProposal(proposalId, contractAddress),
voteKeys.canExecuteProposal(proposalId.toString(), contractAddress),
]);
},
},
@@ -2,18 +2,17 @@
import { Spinner } from "@/components/ui/Spinner/Spinner";
import { Button } from "@/components/ui/button";
import { thirdwebClient } from "@/constants/client";
import { THIRDWEB_ENGINE_FAUCET_WALLET } from "@/constants/env";
import { CustomConnectWallet } from "@3rdweb-sdk/react/components/connect-wallet";
import { useMutation, useQuery } from "@tanstack/react-query";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { CanClaimResponseType } from "app/api/testnet-faucet/can-claim/CanClaimResponseType";
import { mapV4ChainToV5Chain } from "contexts/map-chains";
import { useTrack } from "hooks/analytics/useTrack";
import { thirdwebClient } from "lib/thirdweb-client";
import { useRouter } from "next/navigation";
import { toast } from "sonner";
import { toUnits } from "thirdweb";
import type { ChainMetadata } from "thirdweb/chains";
import { useActiveAccount, useWalletBalance } from "thirdweb/react";
import { mapV4ChainToV5Chain } from "../../../../../../../contexts/map-chains";
function formatTime(seconds: number) {
const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
@@ -48,6 +47,9 @@ export function FaucetButton({
client: thirdwebClient,
});
const trackEvent = useTrack();
const queryClient = useQueryClient();
const claimMutation = useMutation({
mutationFn: async () => {
trackEvent({
@@ -64,7 +66,6 @@ export function FaucetButton({
body: JSON.stringify({
chainId: chainId,
toAddress: address,
amount,
}),
});
@@ -80,7 +81,6 @@ export function FaucetButton({
label: "success",
chain_id: chainId,
});
router.refresh();
},
onError: (error) => {
trackEvent({
@@ -91,6 +91,12 @@ export function FaucetButton({
errorMsg: error instanceof Error ? error.message : "Unknown error",
});
},
onSettled: () => {
return queryClient.invalidateQueries([
"testnet-faucet-can-claim",
chainId,
]);
},
});
const canClaimFaucetQuery = useQuery({
@@ -107,8 +113,6 @@ export function FaucetButton({
},
});
const router = useRouter();
const isFaucetEmpty =
faucetWalletBalanceQuery.data !== undefined &&
faucetWalletBalanceQuery.data.value < toUnits("1", 17);
@@ -2,6 +2,7 @@
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { thirdwebClient } from "@/constants/client";
import { useTrack } from "hooks/analytics/useTrack";
import { defineDashboardChain } from "lib/defineDashboardChain";
import { useTheme } from "next-themes";
import { PayEmbed } from "thirdweb/react";
@@ -9,10 +10,21 @@ import { getSDKTheme } from "../../../../../../components/sdk-component-theme";
export function PayModalButton(props: { chainId: number; label: string }) {
const { theme } = useTheme();
const trackEvent = useTrack();
return (
<Dialog>
<DialogTrigger asChild>
<Button variant="primary" className="w-full">
<Button
variant="primary"
className="w-full"
onClick={() => {
trackEvent({
category: "pay",
action: "buy",
label: "attempt",
});
}}
>
{props.label}
</Button>
</DialogTrigger>
@@ -26,6 +38,34 @@ export function PayModalButton(props: { chainId: number; label: string }) {
theme={getSDKTheme(theme === "dark" ? "dark" : "light")}
className="!w-auto"
payOptions={{
onPurchaseSuccess(info) {
if (
info.type === "crypto" &&
info.status.status !== "NOT_FOUND"
) {
trackEvent({
category: "pay",
action: "buy",
label: "success",
type: info.type,
chainId: info.status.quote.toToken.chainId,
tokenAddress: info.status.quote.toToken.tokenAddress,
amount: info.status.quote.toAmount,
});
}
if (info.type === "fiat" && info.status.status !== "NOT_FOUND") {
trackEvent({
category: "pay",
action: "buy",
label: "success",
type: info.type,
chainId: info.status.quote.toToken.chainId,
tokenAddress: info.status.quote.toToken.tokenAddress,
amount: info.status.quote.estimatedToTokenAmount,
});
}
},
prefillBuy: {
// Do not include local chain overrides for chain pages
// eslint-disable-next-line no-restricted-syntax
@@ -3,9 +3,9 @@
import { CopyTextButton } from "@/components/ui/CopyTextButton";
import { Skeleton } from "@/components/ui/skeleton";
import { ToolTipLabel } from "@/components/ui/tooltip";
import { thirdwebClient } from "@/constants/client";
import { isProd } from "@/constants/env";
import { useQuery } from "@tanstack/react-query";
import { isProd } from "constants/rpc";
import { thirdwebClient } from "lib/thirdweb-client";
import { CircleCheck, XIcon } from "lucide-react";
import { useState } from "react";
import { hostnameEndsWith } from "utils/url";
@@ -1,7 +1,6 @@
import { CopyTextButton } from "@/components/ui/CopyTextButton";
import { ExternalLinkIcon } from "lucide-react";
import Link from "next/link";
import React from "react";
import type { ChainMetadata } from "thirdweb/chains";
import { ChainLiveStats } from "../client/live-stats";
import { SectionTitle } from "./SectionTitle";
@@ -4,7 +4,7 @@ import { FaucetButton } from "../client/FaucetButton";
import { GiftIcon } from "../icons/GiftIcon";
import { SectionTitle } from "./SectionTitle";
const amountToGive = "0.1";
const amountToGive = "0.01";
export async function FaucetSection(props: { chain: ChainMetadata }) {
const { chain } = props;
@@ -1,10 +1,6 @@
/* eslint-disable @next/next/no-img-element */
import {
DASHBOARD_THIRDWEB_SECRET_KEY,
IPFS_GATEWAY_URL,
} from "@/constants/env";
import { thirdwebClient } from "@/constants/client";
import { ImageResponse } from "next/og";
import { createThirdwebClient } from "thirdweb";
import { download } from "thirdweb/storage";
import { fetchChain } from "utils/fetchChain";
@@ -66,15 +62,6 @@ const TWLogo: React.FC = () => (
export default async function Image({
params,
}: { params: { chain_id: string } }) {
const thirdwebClient = createThirdwebClient({
secretKey: DASHBOARD_THIRDWEB_SECRET_KEY,
config: {
storage: {
gatewayUrl: IPFS_GATEWAY_URL,
},
},
});
const chain = await fetchChain(params.chain_id);
if (!chain) {
return new Response("Chain not found", { status: 400 });
@@ -1,5 +1,5 @@
import { Button } from "@/components/ui/button";
import { type SortBy, fetchTopContracts } from "lib/search";
import { fetchTopContracts } from "lib/search";
import { ArrowRightIcon, CircleAlertIcon } from "lucide-react";
import Link from "next/link";
import { TrendingContractSection } from "../../../trending/components/trending-table";
@@ -14,7 +14,6 @@ import { ExplorersSection } from "./components/server/explorer-section";
export default async function Page(props: {
params: { chain_id: string };
searchParams: { page?: number; sortBy?: SortBy };
}) {
const chain = await getChain(props.params.chain_id);
const chainMetadata = await getChainMetadata(chain.chainId);
@@ -22,8 +21,6 @@ export default async function Page(props: {
const topContracts = await fetchTopContracts({
chainId: chain.chainId,
page: props.searchParams.page,
sortBy: props.searchParams.sortBy,
perPage: 3,
timeRange: "month",
});
@@ -48,13 +45,12 @@ export default async function Page(props: {
</section>
)}
{/* Buy Funds */}
{chain.services.find((c) => c.service === "pay" && c.enabled) && (
{/* Faucet / Buy Funds */}
{chain.testnet ? (
<FaucetSection chain={chain} />
) : chain.services.find((c) => c.service === "pay" && c.enabled) ? (
<BuyFundsSection chain={chain} />
)}
{/* Faucet */}
{chain.testnet && <FaucetSection chain={chain} />}
) : null}
{/* Chain Overview */}
<ChainOverviewSection chain={chain} />
@@ -83,8 +79,8 @@ export default async function Page(props: {
<TrendingContractSection
topContracts={topContracts}
chainId={chain.chainId}
searchParams={props.searchParams}
showPagination={false}
searchParams={undefined}
/>
</section>
)}
@@ -1,9 +1,11 @@
import { type SortBy, fetchTopContracts } from "lib/search";
import { CircleAlertIcon } from "lucide-react";
import React from "react";
import { TrendingContractSection } from "../../../../trending/components/trending-table";
import { getChain } from "../../../utils";
// we're using searchParams here - use dynamic rendering
export const dynamic = "force-dynamic";
export default async function Page(props: {
params: { chain_id: string };
searchParams: { page?: number; sortBy?: SortBy };
@@ -1,8 +1,7 @@
import { Badge } from "@/components/ui/badge";
import { Separator } from "@/components/ui/separator";
import { IPFS_GATEWAY_URL } from "@/constants/env";
import { DASHBOARD_THIRDWEB_SECRET_KEY } from "constants/rpc";
import { ZERO_ADDRESS, createThirdwebClient, toTokens } from "thirdweb";
import { thirdwebClient } from "@/constants/client";
import { ZERO_ADDRESS, toTokens } from "thirdweb";
import {
eth_getBlockByHash,
eth_getTransactionByHash,
@@ -16,14 +15,6 @@ import { getChain } from "../../../utils";
export default async function Page(props: {
params: { chain_id: string; txHash: `0x${string}` };
}) {
const thirdwebClient = createThirdwebClient({
secretKey: DASHBOARD_THIRDWEB_SECRET_KEY,
config: {
storage: {
gatewayUrl: IPFS_GATEWAY_URL,
},
},
});
const chain = await getChain(props.params.chain_id);
const rpcRequest = getRpcClient({
@@ -10,8 +10,9 @@ import {
} from "@/components/ui/popover";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import { Separator } from "@/components/ui/separator";
import { useDashboardRouter } from "@/lib/DashboardRouter";
import { ChevronDownIcon, Filter, XIcon } from "lucide-react";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { usePathname, useSearchParams } from "next/navigation";
import type React from "react";
import { type PropsWithChildren, useCallback, useMemo } from "react";
import { products } from "../../../components/server/products";
@@ -73,7 +74,7 @@ type FilterResetButtonProps = {
const FilterResetButton: React.FC<
PropsWithChildren<FilterResetButtonProps>
> = ({ filters, children }) => {
const router = useRouter();
const router = useDashboardRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const mutableSearchParams = useMemo(() => {
@@ -124,7 +125,7 @@ type ChainTypeFilterProps = { sectionOnly?: boolean };
export const ChainTypeFilter: React.FC<ChainTypeFilterProps> = ({
sectionOnly,
}) => {
const router = useRouter();
const router = useDashboardRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
@@ -228,7 +229,7 @@ type ChainOptionsFilterProps = { sectionOnly?: boolean };
export const ChainOptionsFilter: React.FC<ChainOptionsFilterProps> = ({
sectionOnly,
}) => {
const router = useRouter();
const router = useDashboardRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const mutableSearchParams = useMemo(() => {
@@ -332,7 +333,7 @@ type ChainServiceFilterProps = { sectionOnly?: boolean };
export const ChainServiceFilter: React.FC<ChainServiceFilterProps> = ({
sectionOnly,
}) => {
const router = useRouter();
const router = useDashboardRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const mutableSearchParams = useMemo(() => {
@@ -1,7 +1,8 @@
"use client";
import { PaginationButtons } from "@/components/pagination-buttons";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useDashboardRouter } from "@/lib/DashboardRouter";
import { usePathname, useSearchParams } from "next/navigation";
import { useCallback } from "react";
type ChainlistPaginationProps = {
@@ -15,7 +16,7 @@ export const ChainlistPagination: React.FC<ChainlistPaginationProps> = ({
}) => {
const pathname = usePathname();
const searchParams = useSearchParams();
const router = useRouter();
const router = useDashboardRouter();
const createPageURL = useCallback(
(pageNumber: number) => {
@@ -2,8 +2,9 @@
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { useDashboardRouter } from "@/lib/DashboardRouter";
import { SearchIcon, XCircleIcon } from "lucide-react";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { usePathname, useSearchParams } from "next/navigation";
import { useRef } from "react";
import { useDebouncedCallback } from "use-debounce";
@@ -15,7 +16,7 @@ function cleanUrl(url: string) {
}
export const SearchInput: React.FC = () => {
const router = useRouter();
const router = useDashboardRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
@@ -1,8 +1,9 @@
"use client";
import { Button } from "@/components/ui/button";
import { useDashboardRouter } from "@/lib/DashboardRouter";
import { Grid2X2Icon, ListIcon } from "lucide-react";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { usePathname, useSearchParams } from "next/navigation";
import { useCallback } from "react";
type hainListViewProps = {
@@ -12,7 +13,7 @@ type hainListViewProps = {
export const ChainListView: React.FC<hainListViewProps> = ({ activeView }) => {
const pathname = usePathname();
const searchParams = useSearchParams();
const router = useRouter();
const router = useDashboardRouter();
const createPageURL = useCallback(
(view: "grid" | "table") => {
@@ -96,12 +96,6 @@ async function getChainsToRender(params: SearchParams) {
// if the chain does not have all of the services in the filter, return false to filter it out
if (
!urlServiceArray.every((service) => {
// TODO improve this
// We don't have "faucet" added in services array, so for now we just check if it's testnet or not
if (service === "faucet") {
return chain.testnet;
}
return chain.services.find((s) => s.enabled && s.service === service);
})
) {
@@ -154,6 +148,10 @@ export const metadata: Metadata = {
"A list of EVM networks with RPCs, smart contracts, block explorers & faucets. Deploy smart contracts to all EVM chains with thirdweb.",
};
// we use headers() to determine if we should default to table or grid view by checking viewport
// so this page needs to be forced as dynamic
export const dynamic = "force-dynamic";
export default function ChainListPage(props: { searchParams: SearchParams }) {
const headersList = headers();
const viewportWithHint = Number(
@@ -1,12 +1,9 @@
/* eslint-disable @next/next/no-img-element */
import "server-only";
import {
DASHBOARD_THIRDWEB_SECRET_KEY,
IPFS_GATEWAY_URL,
} from "@/constants/env";
import { thirdwebClient } from "@/constants/client";
import { DASHBOARD_THIRDWEB_SECRET_KEY } from "@/constants/env";
import { cn } from "@/lib/utils";
import { createThirdwebClient } from "thirdweb";
import { resolveScheme } from "thirdweb/storage";
const fallbackChainIcon =
@@ -17,16 +14,8 @@ export async function ChainIcon(props: {
className?: string;
}) {
if (props.iconUrl) {
const client = createThirdwebClient({
secretKey: DASHBOARD_THIRDWEB_SECRET_KEY,
config: {
storage: {
gatewayUrl: IPFS_GATEWAY_URL,
},
},
});
const resolved = resolveScheme({
client,
client: thirdwebClient,
uri: props.iconUrl,
});
const res = await fetch(resolved, {
Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 KiB

@@ -6,12 +6,18 @@ export type ChainSupportedService =
| "engine"
| "account-abstraction"
| "pay"
| "faucet"
| "rpc-edge";
| "rpc-edge"
| "chainsaw";
export type ChainService = {
service: ChainSupportedService;
enabled: boolean;
status: "enabled" | "disabled";
};
export type ChainServices = {
chainId: number;
services: Array<ChainService>;
};
export type ChainMetadataWithServices = ChainMetadata & {
@@ -2,6 +2,8 @@ import "server-only";
import { redirect } from "next/navigation";
import type { ChainCTAProps } from "./[chain_id]/(chainPage)/components/server/cta-card";
import zeroGCTA from "./temp-assets/0gCTA.png";
import zeroGBanner from "./temp-assets/0gLabsBanner.png";
import alephZeroBaner from "./temp-assets/AlephZeroBanner.jpg";
import alephZeroCTA from "./temp-assets/AlephZeroCTA.jpg";
import ancient8Banner from "./temp-assets/ancient8-banner.png";
@@ -20,48 +22,75 @@ import rootStockCTABG from "./temp-assets/rootstock-cta.png";
import superpositionBanner from "./temp-assets/superpositionBanner.png";
import superpositionCTA from "./temp-assets/superpositionCTA.png";
import thirdwebBanner from "./temp-assets/thirdweb-banner.png";
import treasureBanner from "./temp-assets/treasureBanner.png";
import treasureCTA from "./temp-assets/treasureCta.png";
import vanarBanner from "./temp-assets/vanar-banner.png";
import vanarCTABG from "./temp-assets/vanar-cta.png";
import xaiBanner from "./temp-assets/xai-banner.jpg";
import type { ChainMetadataWithServices } from "./types/chain";
// END TEMPORARY
import type { ChainMetadata } from "thirdweb/chains";
import type {
ChainMetadataWithServices,
ChainService,
ChainServices,
} from "./types/chain";
const THIRDWEB_API_HOST =
process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com";
export async function getChains() {
const response = await fetch(
`${THIRDWEB_API_HOST}/v1/chains?includeServices=true`,
// revalidate every hour
{ next: { revalidate: 60 * 60 } },
);
const [chains, chainServices] = await Promise.all([
fetch(
`${THIRDWEB_API_HOST}/v1/chains`,
// revalidate every 60 minutes
{ next: { revalidate: 60 * 60 } },
).then((res) => res.json()) as Promise<{ data: ChainMetadata[] }>,
fetch(
`${THIRDWEB_API_HOST}/v1/chains/services`,
// revalidate every 60 minutes
{ next: { revalidate: 60 * 60 } },
).then((res) => res.json()) as Promise<{
data: Record<number, Array<ChainService>>;
}>,
]);
if (!response.ok) {
response.body?.cancel();
if (!chains.data.length) {
throw new Error("Failed to fetch chains");
}
return (await response.json()).data as ChainMetadataWithServices[];
return chains.data.map((c) => ({
...c,
services: chainServices.data[c.chainId] || [],
})) satisfies ChainMetadataWithServices[];
}
export async function getChain(
chainIdOrSlug: string,
): Promise<ChainMetadataWithServices> {
const res = await fetch(
`${THIRDWEB_API_HOST}/v1/chains/${chainIdOrSlug}?includeServices=true`,
// revalidate every 15 minutes
{ next: { revalidate: 15 * 60 } },
);
const [chain, chainServices] = await Promise.all([
fetch(
`${THIRDWEB_API_HOST}/v1/chains/${chainIdOrSlug}`,
// revalidate every 15 minutes
{ next: { revalidate: 15 * 60 } },
).then((res) => res.json()) as Promise<{ data: ChainMetadata }>,
fetch(
`${THIRDWEB_API_HOST}/v1/chains/${chainIdOrSlug}/services`,
// revalidate every 15 minutes
{ next: { revalidate: 15 * 60 } },
).then((res) => res.json()) as Promise<{ data: ChainServices }>,
]);
const result = await res.json();
if (!result.data) {
if (!chain.data) {
redirect("/404");
}
return result.data as ChainMetadataWithServices;
return {
...chain.data,
services: chainServices.data.services,
} satisfies ChainMetadataWithServices;
}
type ChainMetadata = Partial<{
type ExtraChainMetadata = Partial<{
headerImgUrl: string;
about: string;
gasSponsored: boolean;
@@ -275,13 +304,13 @@ const chainMetaRecord = {
},
//0G-Newton-Testnet
16600: {
headerImgUrl: thirdwebBanner.src,
headerImgUrl: zeroGBanner.src,
about:
"0G is an infinitely scalable data availability layer and data storage system that provides the necessary infrastructure to scale Web3 and bring novel use cases on-chain.",
"ZeroGravity (0G) is the first infinitely scalable and decentralized data availability layer with a built-in general-purpose storage layer.",
cta: {
backgroundImageUrl: thirdwebCTA.src,
title: "",
buttonLink: "https://0g.ai/",
backgroundImageUrl: zeroGCTA.src,
title: "Unlock web3's full potential with 0G",
buttonLink: "https://docs.0g.ai/0g-doc",
buttonText: "Learn more",
},
},
@@ -321,12 +350,24 @@ const chainMetaRecord = {
buttonText: "Learn more",
},
},
} satisfies Record<number, ChainMetadata>;
//treasure
978657: {
headerImgUrl: treasureBanner.src,
about:
'Treasure is the decentralized game console. Powered by $MAGIC, the Treasure L2 serves as the base layer for the best cryptonative games and projects. Treasure and its network of "Infinity Chains" L3s offers EVM compatibility, massive scale, and decentralized infrastructure enshrined throughout. Combined with a passionate community and builder support, developers on Treasure are equipped with all of the tools they need to not only build great games and products, but also distribute to the masses.',
cta: {
backgroundImageUrl: treasureCTA.src,
title: "Start building on Treasure!",
buttonLink: "https://portal.treasure.lol",
buttonText: "Learn more",
},
},
} satisfies Record<number, ExtraChainMetadata>;
// END TEMPORARY
export async function getChainMetadata(
chainId: number,
): Promise<ChainMetadata | null> {
): Promise<ExtraChainMetadata | null> {
// TODO: fetch this from the API
if (chainId in chainMetaRecord) {
return chainMetaRecord[chainId as keyof typeof chainMetaRecord];
@@ -51,3 +51,6 @@ export default async function Layout({
</div>
);
}
// because cookies() is used
export const dynamic = "force-dynamic";
@@ -15,11 +15,11 @@ import { ImageUpload } from "@/components/ui/image-upload";
import { Input } from "@/components/ui/input";
import { RadioGroup, RadioGroupItemButton } from "@/components/ui/radio-group";
import { ToolTipLabel } from "@/components/ui/tooltip";
import { useDashboardRouter } from "@/lib/DashboardRouter";
import { AccountStatus, useAccount } from "@3rdweb-sdk/react/hooks/useApi";
import { zodResolver } from "@hookform/resolvers/zod";
import { Loader2 } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
@@ -49,7 +49,7 @@ export function CreateEcosystemForm() {
>();
const { data: billingAccountInfo } = useAccount();
const router = useRouter();
const router = useDashboardRouter();
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
@@ -113,3 +113,6 @@ export default async function Page() {
</main>
);
}
// because cookies() is used
export const dynamic = "force-dynamic";
@@ -7,20 +7,15 @@ const SIDEBAR_SECTIONS = [
title: "Connect",
items: [
{
id: "playground",
title: "Playground",
href: "/dashboard/connect/playground",
id: "embedded-wallets",
title: "In-App Wallets",
href: "/dashboard/connect/in-app-wallets",
},
{
id: "analytics",
title: "Analytics",
href: "/dashboard/connect/analytics",
},
{
id: "embedded-wallets",
title: "In-App Wallets",
href: "/dashboard/connect/in-app-wallets",
},
{
id: "ecosystem",
title: "Ecosystem Wallets",
@@ -36,6 +31,11 @@ const SIDEBAR_SECTIONS = [
title: "Pay",
href: "/dashboard/connect/pay",
},
{
id: "playground",
title: "Playground",
href: "https://playground.thirdweb.com/connect/sign-in/button",
},
],
},
] satisfies Array<SidebarNavSection>;
@@ -1,6 +1,5 @@
import { CopyTextButton } from "@/components/ui/CopyTextButton";
import { Spinner } from "@/components/ui/Spinner/Spinner";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -247,9 +246,7 @@ function CreateWebhookButton(props: PropsWithChildren<WebhooksPageProps>) {
{/* Note: this is a "fake" form field since there is nothing to select yet */}
<FormItem>
<FormLabel>
Event Type <Badge variant="outline">Coming Soon</Badge>
</FormLabel>
<FormLabel>Event Type</FormLabel>
<Select disabled defaultValue="purchase_complete">
<SelectTrigger className="w-full">
<SelectValue placeholder="Purchase Complete" />
@@ -79,3 +79,6 @@ export default async function DashboardConnectPayPage() {
</div>
);
}
// because cookies() is used
export const dynamic = "force-dynamic";
@@ -73,7 +73,7 @@ function prepareEmailBody(
}
export async function createTicketAction(
previousState: State,
_previousState: State,
formData: FormData,
) {
const cookieManager = cookies();
@@ -7,6 +7,7 @@ const links: {
name: string;
segment: string;
}[] = [
{ name: "Transaction Simulator", segment: "transaction-simulator" },
{ name: "Wei Converter", segment: "wei-converter" },
{ name: "Hex Converter", segment: "hex-converter" },
{ name: "Unix Time Converter", segment: "unixtime-converter" },
@@ -21,7 +21,7 @@ export const HexConverter = () => {
setHex(toHex(args.dec));
setDec(args.dec);
}
} catch (e) {}
} catch {}
};
return (
@@ -0,0 +1,387 @@
"use client";
import { CodeBlock } from "@/components/ui/CodeBlock";
import { CopyTextButton } from "@/components/ui/CopyTextButton";
import { Spinner } from "@/components/ui/Spinner/Spinner";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { ToolTipLabel } from "@/components/ui/tooltip";
import { thirdwebClient } from "@/constants/client";
import type { Abi, AbiFunction } from "abitype";
import { useV5DashboardChain } from "lib/v5-adapter";
import { ArrowDown } from "lucide-react";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { MdOutlineAccountBalanceWallet } from "react-icons/md";
import {
getContract,
prepareContractCall,
resolveMethod,
simulateTransaction,
toSerializableTransaction,
toWei,
} from "thirdweb";
import { resolveContractAbi } from "thirdweb/contract";
import { useActiveAccount } from "thirdweb/react";
import { parseAbiParams } from "thirdweb/utils";
import { ShareButton } from "../../components/share";
export type SimulateTransactionForm = {
chainId: number;
from: string;
to: string;
functionName: string;
functionArgs: string;
value: string;
};
type State = {
success: boolean;
message: string;
codeExample: string;
shareUrl: string;
};
export const TransactionSimulator = (props: {
searchParams: Partial<SimulateTransactionForm>;
}) => {
const activeAccount = useActiveAccount();
const initialFormValues = props.searchParams;
const [isLoading, setIsLoading] = useState(false);
const [state, setState] = useState<State>({
success: false,
message: "",
codeExample: "",
shareUrl: "",
});
const form = useForm<SimulateTransactionForm>();
const chainId = form.watch("chainId");
const chain = useV5DashboardChain(
Number.isInteger(Number(chainId)) ? chainId : undefined,
);
async function handleSimulation(data: SimulateTransactionForm) {
try {
setIsLoading(true);
const { from, to, value, functionArgs, functionName } = data;
if (!chain) {
throw new Error("Invalid chainId");
}
const contract = getContract({
client: thirdwebClient,
chain,
address: to,
});
const abi = (await resolveContractAbi(contract)) as Abi;
const abiItem = abi.find(
(o) => o.type === "function" && o.name === functionName,
) as AbiFunction;
if (!abiItem) {
throw new Error(`Contract does not have method \`${functionName}]\``);
}
const inputParams = functionArgs
? functionArgs.split(/[\n,]+/).map((arg) => arg.trim())
: [];
if (abiItem.inputs.length !== inputParams.length) {
throw new Error(
`Param length mismatch. Expected ${abiItem.inputs.length} params. Received ${
inputParams.length
}`,
);
}
// Parse to proper types
const types = abiItem.inputs.map((o) => o.type);
const params = parseAbiParams(types, inputParams);
const codeExample = getCodeExample(
{
chainId: chain.id,
from,
to,
value,
functionArgs,
functionName,
},
params,
);
const shareUrl = getShareUrl({
chainId: chain.id,
from,
to,
value,
functionArgs,
functionName,
});
const transaction = prepareContractCall({
contract,
method: resolveMethod(functionName),
params,
value: value ? toWei(value) : undefined,
});
const [simulateResult, populatedTransaction] = await Promise.all([
simulateTransaction({
from,
transaction,
}),
toSerializableTransaction({
from,
transaction,
}),
]);
setState({
success: true,
message: `result: ${simulateResult.length > 0 ? simulateResult.join(",") : "Method did not return a result."}\n
${Object.keys(populatedTransaction)
.map((key) => {
let _val = populatedTransaction[key as keyof typeof populatedTransaction];
if (key === "value" && !_val) {
_val = 0;
}
return `${key}: ${_val}\n`;
})
.join("")}`,
codeExample,
shareUrl,
});
} catch (err) {
setState({
success: false,
message: `${err}`,
codeExample: "",
shareUrl: "",
});
}
setIsLoading(false);
}
return (
<div className="max-w-[800px] space-y-4">
<p>
Simulate a transaction on any EVM chain. Account Abstraction support is
coming soon.
</p>
<form
onSubmit={form.handleSubmit(handleSimulation)}
className="space-y-4 flex-col"
>
<Card className="flex flex-col gap-4 p-4">
<div className="flex gap-2 sm:items-center flex-col sm:flex-row">
<Label htmlFor="chainId" className="min-w-60">
Chain ID
</Label>
<Input
type="number"
required
placeholder="The chain ID of the sender wallet"
defaultValue={initialFormValues.chainId}
{...form.register("chainId", { required: true })}
// Hide spinner.
className="[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"
/>
</div>
<div className="flex gap-2 sm:items-center flex-col sm:flex-row">
<Label htmlFor="from" className="min-w-60">
From Address
</Label>
<Input
required
placeholder="The sender wallet address"
defaultValue={initialFormValues.from}
{...form.register("from", { required: true })}
/>
{activeAccount && (
<ToolTipLabel label="Use current wallet address">
<Button
variant="ghost"
size="icon"
onClick={() => form.setValue("from", activeAccount.address)}
>
<MdOutlineAccountBalanceWallet />
</Button>
</ToolTipLabel>
)}
</div>
</Card>
<div className="flex justify-center">
<ArrowDown />
</div>
<Card className="flex flex-col gap-4 p-4">
<div className="flex gap-2 sm:items-center flex-col sm:flex-row">
<Label htmlFor="to" className="min-w-60">
Contract Address
</Label>
<Input
placeholder="The contract address to call"
defaultValue={initialFormValues.to}
{...form.register("to", { required: true })}
/>
</div>
<div className="flex gap-2 sm:items-center flex-col sm:flex-row">
<Label htmlFor="functionName" className="min-w-60">
Function Name
</Label>
<Input
placeholder="The contract function name (i.e. mintTo)"
defaultValue={initialFormValues.functionName}
{...form.register("functionName", { required: true })}
/>
</div>
<div className="flex gap-2 sm:items-center flex-col sm:flex-row">
<Label htmlFor="functionArgs" className="min-w-60">
Function Arguments
</Label>
<Textarea
placeholder="Comma-separated arguments to call the function"
rows={3}
className="bg-transparent"
{...form.register("functionArgs")}
defaultValue={
initialFormValues.functionArgs
? decodeURIComponent(initialFormValues.functionArgs)
: undefined
}
/>
</div>
<div className="flex gap-2 sm:items-center flex-col sm:flex-row">
<Label htmlFor="value" className="min-w-60">
Value
</Label>
<Input
{...form.register("value")}
placeholder={`The amount of native currency to send (e.g "0.01")`}
/>
</div>
<Button type="submit">
{isLoading ? (
<>
<Spinner className="w-4 h-4 mr-2" />
Simulating
</>
) : (
"Simulate Transaction"
)}
</Button>
</Card>
</form>
{state.message && (
<>
<div className="flex justify-center">
<ArrowDown />
</div>
<Card className="max-w-[800px] p-4">
<p className="text-sm font-mono whitespace-pre-wrap overflow-auto">
{state.success
? "--- ✅ Simulation succeeded ---\n"
: "--- ❌ Simulation failed ---\n"}
{state.message}
</p>
</Card>
</>
)}
<div className="flex justify-between">
{state.shareUrl && (
<CopyTextButton
textToShow="Copy Simulation Link"
tooltip="Copy Simulation Link"
textToCopy={state.shareUrl}
copyIconPosition="right"
/>
)}
<ShareButton
cta="Share on X"
href="https://twitter.com/intent/tweet?text=Easy-to-use%20transaction%20simulator%20by%20thirdweb%20%F0%9F%98%8D&url=https%3A%2F%2Fthirdweb.com%2Ftools%2Ftransaction-simulator"
/>
</div>
{state.codeExample && (
<div className="max-w-[800px] flex flex-col gap-2 pt-16 ">
<a
href="https://portal.thirdweb.com/references/typescript/v5/simulateTransaction"
target="_blank"
rel="noopener noreferrer"
className="underline"
>
Connect SDK example
</a>
<CodeBlock code={state.codeExample} language="typescript" />
</div>
)}
</div>
);
};
// Generate code example with input values.
const getCodeExample = (
parsedData: SimulateTransactionForm,
params: unknown[],
) => {
const displayParams = params.map((item) => {
if (typeof item === "bigint") {
return `${item.toString()}n`;
}
if (typeof item === "string") {
return `"${item}"`;
}
if (
typeof item === "object" &&
item !== null &&
!Array.isArray(item) &&
Object.prototype.toString.call(item) === "[object Object]"
) {
return JSON.stringify(item);
}
return item;
});
return `import {
getContract,
defineChain,
prepareContractCall,
createThirdwebClient
} from "thirdweb";
const client = createThirdwebClient({
// use secretKey instead of clientId in backend environment
clientId: "your-client-id",
});
const contract = getContract({
client,
chain: defineChain(${parsedData.chainId}),
address: "${parsedData.to}",
});
const transaction = prepareContractCall({
contract,
method: resolveMethod("${parsedData.functionName}"),
params: [${displayParams.join(", ")}],
value: ${parsedData.value ? `${parsedData.value}n` : ""},
});
const result = await simulateTransaction({
from: "${parsedData.from}",
transaction,
});`;
};
// Generate share link from input values.
const getShareUrl = (parsedData: SimulateTransactionForm) => {
const url = new URL(`${window.location.origin}/tools/transaction-simulator`);
url.searchParams.set("chainId", parsedData.chainId.toString());
url.searchParams.set("from", parsedData.from);
url.searchParams.set("to", parsedData.to);
url.searchParams.set("functionName", parsedData.functionName);
url.searchParams.set(
"functionArgs",
encodeURIComponent(parsedData.functionArgs),
);
url.searchParams.set("value", parsedData.value);
return url.href;
};
@@ -0,0 +1,17 @@
import type { Metadata } from "next";
import {
type SimulateTransactionForm,
TransactionSimulator,
} from "./components/TransactionSimulator";
export const metadata: Metadata = {
title: "thirdweb Transaction Simulator",
description:
"Simulate any EVM transaction. Get gas estimates and onchain error messages to debug your contract calls.",
};
export default async function Page(props: {
searchParams: Partial<SimulateTransactionForm>;
}) {
return <TransactionSimulator searchParams={props.searchParams} />;
}

Some files were not shown because too many files have changed in this diff Show More