Compare commits

..
Author SHA1 Message Date
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
b76d298245 Version Packages (#4666)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-09-19 11:01:37 +12:00
kien-ngo c13058a711 [Dashboard] ERC20 Claim form (#4669)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR refactors the token claim functionality by replacing a Drawer with a Sheet component and updating UI elements for a better user experience.

### Detailed summary
- Replaced `Drawer` with `Sheet` component for better UI
- Updated UI elements like buttons, form controls, and labels
- Added transaction handling logic for claiming tokens

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

<!-- end pr-codex -->
2024-09-18 22:32:21 +00:00
jnsdls a78e50413e cleanup posthog (#4678)
<!-- start pr-codex -->

## PR-Codex overview
This PR updates PostHog dependencies across multiple files, replacing `posthog-js-opensource` with `posthog-js` for consistency and version upgrades.

### Detailed summary
- Replaced `posthog-js-opensource` imports with `posthog-js` in multiple files
- Updated `posthog-js` version to "1.67.1" in various package.json files

> 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-09-18 22:19:14 +00:00
MananTank 3c72aeb8f3 Team layout UI adjustments (#4680)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds upgrade team links to various components and improves search functionality by making it case-insensitive.

### Detailed summary
- Added `upgradeTeamLink` prop to `TeamHeaderUI`, `TeamAndProjectSelectorPopoverButton`, `TeamSelectorMobileMenuButton`, and `TeamSelectionUI`
- Modified search functionality to be case-insensitive for projects and teams
- Updated `TeamSelectorMobileMenuButton` prop name to `TeamSelectorMobileMenuButtonProps`
- Adjusted `TeamSelectionUI` to use the `upgradeTeamLink` prop for displaying an upgrade button

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

<!-- end pr-codex -->
2024-09-18 22:02:12 +00:00
MananTank 90662e8e49 Move pay webhooks tab to page with route in project/connect (#4677)
## 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 and improve the Pay feature in the dashboard by renaming components and updating page structures.

### Detailed summary
- Renamed `WebhooksPage` component to `PayWebhooksPage`.
- Updated page structures and components related to Pay feature.
- Refactored and improved code readability in the Pay feature section.

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

<!-- end pr-codex -->
2024-09-18 22:02:12 +00:00
MananTank 80893aa085 Remove Pay settings tab in project/connect (#4676)
## 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 `PayPageUI` component to use `clientId` instead of `apiKey` for simplicity and clarity.

### Detailed summary
- Updated `PayPageUI` component to accept `clientId` as a string instead of `apiKey`
- Removed unnecessary fields from `apiKey` object
- Updated references to `props.apiKey.key` to `props.clientId` in `PayPageUI` component

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

<!-- end pr-codex -->
2024-09-18 22:02:11 +00:00
MananTank a587ebf125 Remove AA settings from project/connect (#4675)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to replace the `SmartWallets` component with `AccountFactories` in the `AccountAbstractionPage.tsx`.

### Detailed summary
- Replaced `SmartWallets` component with `AccountFactories`.
- Updated component import paths.
- Added a comment for future improvement.

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

<!-- end pr-codex -->
2024-09-18 22:02:11 +00:00
MananTank 009edeb5f5 Remove In-app wallet settings from project/connect (#4674)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to rename the `Users` component to `InAppWalletUsersPageContent` for clarity and consistency in the embedded wallets feature.

### Detailed summary
- Renamed `Users` component to `InAppWalletUsersPageContent` for clarity
- Updated references to the renamed component in multiple files

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

<!-- end pr-codex -->
2024-09-18 22:02:10 +00:00
MananTank f5a5078ff5 Add Account Abstraction settings in product settings layout (chakra) (#4668)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
**Focus:** Refactoring SponsorshipPolicies to AccountAbstractionSettingsPage for better clarity and consistency.

### Detailed summary
- Renamed `SponsorshipPolicies` to `AccountAbstractionSettingsPage` for clarity
- Updated imports and references accordingly
- Updated form schema and component name
- Improved variable names and code readability

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

<!-- end pr-codex -->
2024-09-18 22:02:10 +00:00
MananTank c08b3b56b2 Add in-app wallet settings on project settings layout (#4667)
## 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 `Configure` component to `InAppWalletSettingsPage` and update its usage throughout the codebase.

### Detailed summary
- Renamed `Configure` component to `InAppWalletSettingsPage`
- Updated references to `Configure` component to `InAppWalletSettingsPage`
- Updated component props and types for consistency
- Added a new page file for in-app wallet settings with API key retrieval logic

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

<!-- end pr-codex -->
2024-09-18 22:02:09 +00:00
MananTank 4bda0cedc4 Remove posthog cloud (#4671)
## 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 dependencies, remove `posthog-js`, adjust script sources, and optimize the Next.js configuration.

### Detailed summary
- Updated `posthog-js` to `posthog-js-opensource`
- Removed `posthog-js` initialization in `_app.tsx`
- Adjusted script sources in `next.config.js`
- Optimized Next.js configuration for better performance

> 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-09-18 20:03:39 +00:00
jnsdls 32dbdab4e9 add contract deployment analytics back (#4672)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to add event tracking using `useTrack` hook in the custom contract deployment form.

### Detailed summary
- Added `useTrack` hook for event tracking
- Implemented tracking for contract deployment events
- Added tracking for adding contract to dashboard
- Implemented error tracking for deployment failures

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

<!-- end pr-codex -->
2024-09-18 19:08:50 +00:00
jnsdls 406de39ecd handle JWT directly in thirdwebClient (#4659)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates dependencies, simplifies ERC721 and ERC1155 updateMetadata extension params, and allows using valid JWTs for authorization.

### Detailed summary
- Updated `tailwindcss` to versions `3.4.12`
- Added `JWTString` type for valid JWTs
- Simplified updateMetadata extension params for ERC721 and ERC1155
- Updated dependencies in various packages
- Removed unnecessary imports and components
- Refactored code to use `getThirdwebClient()` consistently

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/account/components/account-balance.tsx`, `packages/service-utils/package.json`, `apps/dashboard/src/components/wallets/ConnectWalletMiniPlayground/MiniPlayground.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/components/server/chain-icon.tsx`, `apps/dashboard/src/components/wallets/PosthogIdentifier.tsx`, `apps/dashboard/src/@/constants/thirdweb.server.ts`, `apps/dashboard/src/contract-ui/tabs/listings/components/list-form.tsx`, `packages/thirdweb/package.json`, `apps/dashboard/src/pages/api/frame/base/get-tx-frame.ts`, `apps/dashboard/src/lib/rpc.ts`, `apps/dashboard/src/contract-ui/tabs/manage/components/getModuleInstalledParams.ts`, `apps/dashboard/src/components/contract-components/publisher/masked-avatar.tsx`, `apps/dashboard/src/components/smart-wallets/AccountFactories/account-cell.tsx`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/create/hooks/use-create-ecosystem.ts`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/opengraph-image.tsx`, `apps/dashboard/src/components/contract-components/publisher/edit-profile.tsx`, `apps/dashboard/src/tw-components/nft-media.tsx`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/components/client/ecosystem-header.client.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx`, `packages/thirdweb/src/utils/fetch.test.ts`, `apps/dashboard/src/components/engine/contract-subscription/contract-subscriptions-table.tsx`, `apps/dashboard/src/app/(dashboard)/contracts/deploy/[compiler_uri]/page.tsx`, `apps/dashboard/src/components/engine/contract-subscription/add-contract-subscription-button.tsx`, `apps/dashboard/src/contract-ui/tabs/account/components/deposit-native.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/utils/publishedContractOGImageTemplate.tsx`, `apps/dashboard/src/components/custom-contract/contract-header/metadata-header.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/utils/getPublishedContractsWithPublisherMapping.ts`, `apps/dashboard/src/app/login/page.tsx`, `apps/dashboard/src/contract-ui/hooks/useContractSources.ts`, `apps/dashboard/src/app/(dashboard)/tools/transaction-simulator/components/TransactionSimulator.tsx`, `apps/dashboard/src/components/selects/NetworkSelectorButton.tsx`, `apps/dashboard/src/contract-ui/tabs/split/page.tsx`, `apps/dashboard/src/components/ipfs-upload/dropzone.tsx`, `apps/dashboard/src/utils/tx-frame.ts`, `apps/dashboard/src/contract-ui/tabs/claim-conditions/components/snapshot-upload.tsx`, `apps/dashboard/src/components/explore/contract-card/index.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/PayModal.tsx`, `apps/dashboard/src/components/contract-components/contract-publish-form/index.tsx`, `apps/dashboard/src/contract-ui/tabs/nfts/components/airdrop-upload.tsx`, `packages/thirdweb/src/client/client.test.ts`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/tx/[txHash]/page.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/FaucetButton.tsx`, `apps/dashboard/src/components/contract-components/tables/cells.tsx`, `packages/thirdweb/src/extensions/erc721/drops/write/updateMetadata.ts`, `packages/thirdweb/src/utils/fetch.ts`, `apps/dashboard/src/@3rdweb-sdk/react/components/connect-wallet/index.tsx`, `apps/dashboard/src/@/constants/thirdweb.client.ts`, `apps/dashboard/src/app/(dashboard)/contracts/publish/[publish_uri]/page.tsx`, `apps/dashboard/src/components/smart-wallets/AccountFactories/index.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/[version]/page.tsx`, `packages/thirdweb/src/client/client.ts`, `packages/thirdweb/src/extensions/erc1155/drops/write/updateMetadata.ts`, `apps/dashboard/src/contract-ui/tabs/proposals/components/proposal-button.tsx`, `apps/dashboard/src/lib/ens.ts`, `apps/dashboard/src/@/components/blocks/wallet-address.tsx`, `apps/dashboard/src/@3rdweb-sdk/react/cache-keys.ts`, `apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx`, `apps/dashboard/src/components/buttons/MismatchButton.tsx`, `apps/dashboard/src/contract-ui/tabs/manage/components/ModuleForm.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/components/publish-based-deploy.tsx`, `apps/dashboard/src/contract-ui/tabs/proposals/page.tsx`, `apps/dashboard/src/contract-ui/tabs/proposals/components/proposal-form.tsx`, `apps/dashboard/src/components/contract-components/fetch-contracts-with-versions.ts`, `apps/dashboard/src/contract-ui/tabs/proposals/components/delegate-button.tsx`, `apps/dashboard/src/components/contract-components/hooks.ts`, `apps/dashboard/src/contract-ui/tabs/manage/page.tsx`, `apps/dashboard/src/pages/[chain_id]/[...paths].tsx`, `apps/dashboard/src/contract-ui/tabs/sources/page.tsx`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/useSplit.ts`, `apps/dashboard/src/components/contract-components/published-contract/index.tsx`, `apps/dashboard/src/contract-ui/tabs/proposals/components/proposal.tsx`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/useVote.ts`, `pnpm-lock.yaml`

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

<!-- end pr-codex -->
2024-09-18 18:36:17 +00:00
MananTank 25e1135dc7 Move pay tabs to pages with routes, Add pay settings page in project layout (#4658)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on restructuring the Pay section in the dashboard, improving API key handling, and fixing endpoint issues.

### Detailed summary
- Deleted `PayAnalytics.tsx` and `pay-ui.client.tsx`
- Added components for `NoApiKeys`, `PayConfig`, `APIKeySelector`
- Updated text in `ProjectGeneralSettingsPage.tsx`
- Modified page layouts and settings
- Improved API key retrieval and handling

> The following files were skipped due to too many changes: `apps/dashboard/src/app/(dashboard)/dashboard/connect/pay/page.tsx`, `apps/dashboard/src/components/pay/PayConfig.tsx`

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

<!-- end pr-codex -->
2024-09-18 18:22:45 +00:00
kien-ngo 7a07d05398 [Dashboard] Migrate TokenERC20 Drawer to Sheet (#4662)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates token transfer, mint, and burn functionality in the dashboard.

### Detailed summary
- Updated UI components for token transfer, mint, and burn
- Replaced `useTxNotifications` with custom error handling and toast notifications
- Improved transaction handling and event tracking
- Enhanced form validations and error messages

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

<!-- end pr-codex -->
2024-09-18 18:06:29 +00:00
kien-ngo 53af73c9ae [Dashboard] ERC20 burn tab (#4661)
## 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 token transfer and burn components in the dashboard.

### Detailed summary
- Updated UI components for token transfer and burn
- Replaced `react-icons` with `lucide-react` and `sonner`
- Improved error handling and notifications for token transactions

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

<!-- end pr-codex -->
2024-09-18 18:06:28 +00:00
jnsdls bb51afa723 simplify build tooling and remove redundant dependencies (#4664)
<!-- start pr-codex -->

## PR-Codex overview
This PR updates dependencies, TypeScript configurations, and package versions across multiple packages. It also refactors code in the `dashboard` app for improved functionality and type safety.

### Detailed summary
- Updated `next` version to `14.2.12` in `wallet-ui`, `playground-web`, and `portal`.
- Updated `@types/react` to `^18.3.7` in `wallet-ui`, `playground-web`, and `portal`.
- Updated `eslint` and related plugins in `dashboard` and `portal`.
- Refactored code in `dashboard` app for improved functionality and type safety.
- Updated `@walletconnect` packages to version `2.16.2` in `thirdweb`.
- Modified TypeScript configurations in `typedoc-gen` and `service-utils`.
- Updated `react-native-svg` to version `15.7.1` in `portal`.
- Updated `posthog-js` to version `1.161.6` in `wallet-ui` and `portal`.
- Updated `happy-dom` to version `^15.7.4` in `portal`.
- Updated `typescript` to version `5.6.2` in `typedoc-gen` and `dashboard`.

> The following files were skipped due to too many changes: `apps/dashboard/package.json`, `apps/dashboard/src/core-ui/sidebar/tunnel.tsx`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/useLoggedInUser.ts`, `packages/typedoc-gen/tsconfig.base.json`, `packages/service-utils/tsconfig.base.json`, `packages/service-utils/package.json`, `pnpm-lock.yaml`

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

<!-- end pr-codex -->
2024-09-18 17:56:14 +00:00
kien-ngo f66f99096a [SDK] Improve tests for marketplace DirectListings (#4619)
<!-- start pr-codex -->

## PR-Codex overview
This PR updates the Marketplace Direct Listings tests for ERC721 and ERC1155 contracts.

### Detailed summary
- Refactors test setup and contract deployment
- Updates NFT minting and approval transactions
- Improves listing creation and validation checks
- Enhances buy transaction testing for ERC721 tokens

> The following files were skipped due to too many changes: `packages/thirdweb/src/extensions/marketplace/direct-listings/direct-listings.test.ts`

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

<!-- end pr-codex -->
2024-09-18 12:40:31 +00:00
joaquim-verges 6ce7c83a3b chore: update @mobile-wallet-protocol/client to 0.0.3 (#4665)
Fixes #4663

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates `@mobile-wallet-protocol/client` to version 0.0.3 and aligns package dependencies and TypeScript type definitions.

### Detailed summary
- Updated `@mobile-wallet-protocol/client` to 0.0.3
- Aligned package dependencies
- Adjusted TypeScript type definitions for various modules

> 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-09-18 12:18:39 +00:00
kien-ngo 6e69959dc1 [Dashboard] Replace Chakra-ui's useClipboard (#4660)
## 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 code by centralizing the `useClipboard` hook and importing it where needed.

### Detailed summary
- Centralized `useClipboard` hook in a separate file
- Imported `useClipboard` in multiple components for code reusability

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

<!-- end pr-codex -->
2024-09-18 11:36:33 +00:00
kien-ngo e5393efcee [Dashboard] erc20 transfer Drawer (#4643)
chakra-ui Drawer -> Shadcn's Sheet

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces a new `Sheet` component for modals and refactors the transfer token functionality to use the `Sheet` component.

### Detailed summary
- Added `Sheet`, `SheetContent`, `SheetFooter`, `SheetHeader`, `SheetTitle`, `SheetTrigger` components
- Refactored token transfer functionality to use the new `Sheet` component
- Updated imports and dependencies to include new components and utilities

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

<!-- end pr-codex -->
2024-09-18 10:18:49 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
f68228f5b0 Version Packages (#4654)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-09-18 14:56:48 +12:00
gregfromstl acd56a7e46 Redirect to login from main ecosystem page (#4657)
## 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 authentication logic to a page component in the wallet-ui app.

### Detailed summary
- Added import for `getCurrentUser` from `@/lib/auth`
- Added import for `redirect` from `next/navigation`
- Updated `Page` function to fetch current user and redirect based on authentication status

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

<!-- end pr-codex -->
2024-09-18 01:54:21 +00:00
jnsdls 00ce74a060 Improve getNFTs compatibility for ERC1155 contracts (#4653) 2024-09-18 01:41:18 +00:00
gregfromstl ef2d406ce5 [SDK] Fix: Remove useless caching (#4656)
## 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 `fetch.ts` file in the `thirdweb` package and add unit tests in `fetch.test.ts`.

### Detailed summary
- Removed `FETCH_CACHE` and `IS_THIRDWEB_URL_CACHE` WeakMap in `fetch.ts`
- Added `IS_THIRDWEB_URL_CACHE` export in `fetch.ts`
- Added unit tests for `getClientFetch` and `isThirdwebUrl` functions in `fetch.test.ts`

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

<!-- end pr-codex -->
2024-09-18 01:28:15 +00:00
gregfromstl ebbb87b26c Simplify wallet UI redirects (#4655)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR enhances the middleware logic in the wallet-ui app by simplifying the URL path handling and removing unnecessary JWT decoding.

### Detailed summary
- Updated URL path generation logic in middleware
- Removed unused JWT decoding and user handling
- Simplified redirection based on ecosystem and URL path

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

<!-- end pr-codex -->
2024-09-18 00:06:30 +00:00
kumaryash90 e89ffd4aa2 Handle custom id for published contract (#4644)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on handling a custom id for published contracts in the `thirdweb` package.

### Detailed summary
- Added handling of custom id for published contracts in `deploy-metadata.ts` file.

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

<!-- end pr-codex -->
2024-09-17 23:44:05 +00:00
gregfromstl cf1683c3fe [SDK] Fix: Switch active connection on wallet account change (#4618)
## 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 subscription for when the account changes in the wallet manager.

### Detailed summary
- Added a subscription for "accountChanged" event in the wallet manager
- Calls `handleConnection` when the account changes
- Invokes `onConnect` with the new connected wallet
- Updates the active wallet after the account changes

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

<!-- end pr-codex -->
2024-09-17 23:23:27 +00:00
gregfromstl a46843992b [SDK] Feature: Guest accounts (#4631)
## 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 a "guest" login option in the wallet authentication system.

### Detailed summary
- Added "guest" login option for temporary accounts
- Updated locale files to support "guest" login
- Implemented "guest" authentication functionality
- Updated UI components to include "guest" login option

> The following files were skipped due to too many changes: `packages/thirdweb/src/wallets/in-app/core/authentication/types.ts`, `packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx`, `packages/thirdweb/src/react/native/ui/icons/svgs.ts`, `packages/thirdweb/src/react/web/ui/ConnectWallet/Details.tsx`, `packages/thirdweb/src/wallets/in-app/native/auth/native-auth.ts`, `packages/thirdweb/src/wallets/in-app/native/native-connector.ts`, `packages/thirdweb/src/react/web/wallets/shared/GuestLogin.tsx`, `packages/thirdweb/src/react/core/utils/walletIcon.ts`

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

<!-- end pr-codex -->
2024-09-17 23:11:24 +00:00
gregfromstl 39a6f86b3b Fix wallet UI cookie (#4652)
## 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 console log messages for user address and redirection, and update cookie settings for JWT with additional security configurations.

### Detailed summary
- Added console log messages for user address and redirection
- Updated cookie settings for JWT with additional security configurations: name, value, httpOnly, secure, sameSite, maxAge, domain, path

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

<!-- end pr-codex -->
2024-09-17 23:08:13 +00:00
MananTank 589e81c8b7 Revamp API Key settings UI, Add Project General settings (#4645)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates file paths, refactors components, and improves code readability.

### Detailed summary
- Renamed and relocated several components for better organization
- Updated function names for clarity and consistency
- Improved type imports and removed unnecessary dependencies
- Enhanced code structure and readability for easier maintenance

> The following files were skipped due to too many changes: `apps/dashboard/src/app/(dashboard)/dashboard/connect/pay/components/pay-ui.client.tsx`, `apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/ProjectGeneralSettingsPage.stories.tsx`, `apps/dashboard/src/pages/dashboard/settings/api-keys/[id].tsx`, `apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/ProjectGeneralSettingsPage.tsx`

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

<!-- end pr-codex -->
2024-09-17 22:22:53 +00:00
MananTank db16d8ba54 Set auth token everywhere ThirdwebProvider is used (#4650)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds a new `SetAuthHeaderForSDK` component to manage authentication headers for the SDK and updates providers to include it.

### Detailed summary
- Added `SetAuthHeaderForSDK` component to manage authentication headers for SDK
- Updated providers to include the new component for SDK authentication

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

<!-- end pr-codex -->
2024-09-17 22:01:45 +00:00
MananTank 9878f49790 Fix _defaultAdmin not prefilled with connected wallet address (#4649)
Not sure if this is the proper solution

refer to - https://linear.app/thirdweb/issue/DASH-255/custom-contract-deployment-issue-via-dashboard#comment-6afa6f35
2024-09-17 21:34:10 +00:00
gregfromstl a53e8ea13b [Wallet UI] Fix: Redirect properly from login page (#4646)
## 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 user authentication and ecosystem info handling in the wallet UI app.

### Detailed summary
- Added user authentication check and redirect in `layout.tsx`
- Improved error handling for fetching ecosystem info in `ecosystems.ts`
- Refactored middleware logic in `middleware.ts` for better routing

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

<!-- end pr-codex -->
2024-09-17 20:24:32 +00:00
jnsdls 5ee748921a fix auth on contract deploy (#4647) 2024-09-17 18:29:16 +00:00
kien-ngo 3be53f436d [Dashboard] Add from to claimTo (#4642)
Jake did mention sometimes we have issues with allowlist if `from` is not specified.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the `claim-form.tsx` file in both the `tokens` and `nfts` directories to include the `from` field with the account address.

### Detailed summary
- Added `from: account.address` field to the transaction object.

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

<!-- end pr-codex -->
2024-09-17 09:26:16 +00:00
Jonas DanielsandGitHub 0946d90744 no-contract-card-ssr (#4641) 2024-09-16 22:35:22 -07:00
Jonas DanielsandGitHub 97a7d83e03 update dependencies & re-run biome (#4640) 2024-09-16 21:55:28 -07:00
jnsdls ca610d6b3d move explore to app router (#4637)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is updating components and pages in the dashboard app related to exploring smart contracts.

### Detailed summary
- Updated `MaskedAvatar` component with new props and styling
- Modified `ExplorePage` layout and content
- Improved `ContractRow` component functionality
- Enhanced `ContractCard` component with initial data handling

> The following files were skipped due to too many changes: `apps/dashboard/src/components/explore/contract-card/index.tsx`, `apps/dashboard/src/app/(dashboard)/explore/[category]/page.tsx`

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

<!-- end pr-codex -->
2024-09-17 03:23:43 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
7b0040bb92 Version Packages (#4589)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-09-17 15:21:23 +12:00
joaquim-verges c320b189f6 feat: export Abi types from abitype (#4639)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on exporting Abi types in the `thirdweb` package.

### Detailed summary
- Exported Abi types like `Abi`, `AbiFunction`, `AbiReceive`, `AbiError`, `AbiEvent`, `AbiConstructor`, and `AbiFallback` from "abitype".
- Exported `toFunctionSelector` from "viem".

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

<!-- end pr-codex -->
2024-09-17 02:51:11 +00:00
jnsdls 6bb2904936 [Update] Refactor product links in ChainListRow component (#4638) 2024-09-17 02:40:08 +00:00
Joaquim VergesandGitHub 5bde07508a feat(pay): allow customizing PayEmbed metadata for top-up flow (#4621) 2024-09-17 14:17:14 +12:00
edwardysun ac4f68d5c8 Pay - Stop polling after status is complete (#4632)
## 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 `refetchInterval` logic in `useBuyWithCryptoStatus` and `useBuyWithFiatStatus` hooks based on different status conditions.

### Detailed summary
- Updated `refetchInterval` logic based on status conditions in `useBuyWithCryptoStatus` hook.
- Updated `refetchInterval` logic based on status conditions in `useBuyWithFiatStatus` hook.

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

<!-- end pr-codex -->
2024-09-17 01:10:11 +00:00
joaquim-verges 3961ef477e feat: handle function signatures and ABIs in resolveMethod (#4628)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR enhances the `resolveMethod` function in `transaction/resolve-method.ts` to handle function signatures and contract ABIs efficiently.

### Detailed summary
- Updated `resolveMethod` function to handle function signatures and contract ABIs
- Added `parseAbiItem` import and type definitions
- Modified test cases in `resolve-method.test.ts` to cover new functionality

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

<!-- end pr-codex -->
2024-09-17 00:47:38 +00:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
085ea2bf00 Bump shiki from 1.16.2 to 1.17.7 (#4626)
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-16 17:19:21 -07:00
joaquim-verges 2b6a2fda3d feat: invalidate wallet balance after successful purchases (#4630)
Fixes CNCT-1861

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on invalidating wallet balances on successful payments.

### Detailed summary
- Updated query key in `invalidateWalletBalance.test.ts`
- Modified query key logic in `invalidateWalletBalance.ts`
- Added `invalidateWalletBalance` function in `BuyScreen.tsx` to invalidate wallet balances on payment success

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

<!-- end pr-codex -->
2024-09-16 23:49:37 +00:00
joaquim-verges a5e605c65e test: conditionally run tests based on TW_SECRET_KEY (#4636)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds a conditional test runner based on the environment variable `TW_SECRET_KEY` to the test suite for ERC721, MintableERC20, MintableERC721, and MintableERC1155 modules.

### Detailed summary
- Modified test descriptions to include conditional test execution based on `TW_SECRET_KEY` environment variable.
- Updated test suite for ERC721, MintableERC20, MintableERC721, and MintableERC1155 modules to run tests conditionally.

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

<!-- end pr-codex -->
2024-09-16 23:30:29 +00:00
MananTank 85ddb175d7 Fix account abstraction factories table crash (#4629)
## 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 `useFactories` function in `AccountFactories/index.tsx`.

### Detailed summary
- Refactored the `useFactories` function to improve readability and maintainability
- Updated how factories are filtered and returned
- Updated the `contracts` prop passed to `FactoryContracts` component

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

<!-- end pr-codex -->
2024-09-16 22:25:38 +00:00
jnsdls c373ea571a remove v4 (#4627) 2024-09-16 22:00:47 +00:00
MananTank fdae05fc00 Add Export to CSV button on Connect Analytics cards (#4617)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR removes the `ExportToCSVButton` component from multiple files and centralizes it in a single location. It also adds a `valueFormatter` prop to the `ChartTooltipContent` component.

### Detailed summary
- Removed `ExportToCSVButton` from multiple files and centralized it in a single location.
- Added `valueFormatter` prop to the `ChartTooltipContent` component.

> The following files were skipped due to too many changes: `apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/analytics/_components/WalletDistributionChartCard.tsx`

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

<!-- end pr-codex -->
2024-09-16 20:45:09 +00:00
MananTank 7c1ea4a1e2 Add Project Setting pages Layout (#4620)
## 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 layout and styling of various pages in the dashboard app.

### Detailed summary
- Updated body and html styles for full height
- Added new pages for Pay Settings, In-App Wallet Settings, and Account Abstraction Settings
- Modified project selector UI link
- Updated text and layout for General Settings page
- Adjusted layout in TeamLayout and RootTeamLayout components
- Added a new Layout component for settings with sidebar links
- Added a new page for API key details with editing functionality

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

<!-- end pr-codex -->
2024-09-16 20:26:40 +00:00
jnsdls 95b3c787a3 [Update] Refactor contract publish form to use thirdweb v5 (#4605)
<!-- start pr-codex -->

## PR-Codex overview
This PR removes unnecessary files, updates type definitions, refactors contract-related components, and improves API handling.

### Detailed summary
- Removed several files related to publishing contracts and provider setup
- Updated type definitions and constants
- Refactored contract-related components for consistency
- Improved API handling and URL configurations

> The following files were skipped due to too many changes: `apps/dashboard/src/pages/explore/[category]/index.tsx`, `apps/dashboard/src/contract-ui/tabs/claim-conditions/components/claim-conditions-form/hooks.ts`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/page.tsx`, `apps/dashboard/src/contract-ui/tabs/manage/components/moduleContractInfo.ts`, `apps/dashboard/src/constants/chains.ts`, `apps/dashboard/src/components/contract-components/contract-table/cells/description.tsx`, `apps/dashboard/src/contract-ui/tabs/claim-conditions/components/claim-conditions-form/index.tsx`, `apps/dashboard/src/components/contract-components/contract-publish-form/landing-fieldset.tsx`, `apps/dashboard/src/components/contract-components/contract-publish-form/factory-fieldset.tsx`, `apps/dashboard/src/app/(dashboard)/contracts/publish/[publish_uri]/page.tsx`, `apps/dashboard/src/components/explore/contract-card/index.tsx`, `apps/dashboard/src/components/contract-components/contract-publish-form/default-factory.tsx`, `apps/dashboard/src/components/contract-components/shared/contract-id-image.tsx`, `apps/dashboard/src/components/smart-wallets/AccountFactories/index.tsx`, `apps/dashboard/src/lib/sdk.ts`, `apps/dashboard/src/contract-ui/tabs/code/components/code-overview.tsx`, `apps/dashboard/src/components/contract-components/publisher/edit-profile.tsx`, `apps/dashboard/src/pages/profile/[profileAddress].tsx`, `apps/dashboard/src/contract-ui/tabs/claim-conditions/legacy-zod-schema.ts`, `apps/dashboard/src/contract-ui/tabs/manage/components/ModuleForm.tsx`, `apps/dashboard/src/components/contract-functions/contract-function.tsx`, `apps/dashboard/src/components/contract-components/hooks.ts`, `apps/dashboard/src/components/contract-components/contract-publish-form/index.tsx`

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

<!-- end pr-codex -->
2024-09-16 19:33:35 +00:00
jnsdls 468067e47f fix direct deploy (#4616) 2024-09-16 17:21:00 +00:00
MananTank 1d0291fb9e Sidebar and team header cleanups (#4612)
## 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 layout components and improve sidebar navigation in the dashboard app.

### Detailed summary
- Refactored layout components for better structure
- Updated sidebar navigation in various pages
- Improved handling of sidebar links and layout components

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

<!-- end pr-codex -->
2024-09-16 16:45:22 +00:00
MananTank 6e5d89bf2a Add rate limit on contact-us form using redis + move to app router (#4614)
## 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 rate limiting for a HubSpot API endpoint using Redis caching.

### Detailed summary
- Added `cacheGet` and `cacheSet` functions for Redis caching
- Implemented rate limiting logic based on IP address
- Added `rateLimiter` function to handle rate limiting
- Updated handler to use `rateLimiter` before processing requests

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

<!-- end pr-codex -->
2024-09-16 16:32:48 +00:00
MananTank 2bf9fc598a Fix Empty Publish contract page (#4613)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to replace the `useSingleQueryParam` hook with `useRouter` and `useSearchParams` for better navigation handling in different components.

### Detailed summary
- Replaced `useSingleQueryParam` with `useRouter` and `useSearchParams` in multiple files for improved navigation handling.
- Updated the usage of hooks for query parameter retrieval in several components.
- Made changes to handle query parameters more efficiently in the codebase.

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

<!-- end pr-codex -->
2024-09-16 16:14:49 +00:00
Joaquim VergesandGitHub 18239dd5df chore: simplify uploaded published data (#4611) 2024-09-16 20:59:49 +12:00
jnsdls b837b690ae various dependency bumps (#4603)
<!-- start pr-codex -->

## PR-Codex overview
This PR updates various dependencies across different packages.

### Detailed summary
- Updated Vite to version 5.4.5
- Bumped `viem` to version 2.21.7
- Updated `@playwright/test` to 1.47.1
- Increased `postcss` to version 8.4.47
- Updated `tailwindcss` to 3.4.11
- Updated `@tanstack/react-query` to version 5.56.2

> 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-09-16 01:31:14 +00:00
joaquim-verges 7b94bf55fd feat: expose checkModulesCompatiblity for modular contracts (#4607)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces a new function `checkModulesCompatibility` and related tests to verify module compatibility in the `thirdweb` package.

### Detailed summary
- Added `checkModulesCompatibility` function in `modules.ts`
- Created tests for `checkModulesCompatibility` in `checkModulesCompatibility.test.ts`
- Implemented `checkModulesCompatibility` logic in `checkModulesCompatibility.ts`
- Updated `arrays.ts` with a new utility function

> The following files were skipped due to too many changes: `packages/thirdweb/test/src/bytecode/mintable-erc20.ts`, `packages/thirdweb/test/src/bytecode/claimable-erc721.ts`, `packages/thirdweb/test/src/bytecode/claimable-erc20.ts`, `packages/thirdweb/test/src/bytecode/erc20core.ts`

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

<!-- end pr-codex -->
2024-09-16 01:16:42 +00:00
joaquim-verges 3009a0f6e5 feat: expose publishContract extension (#4604)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR exposes a new extension `publishContract` and refactors metadata handling in the `thirdweb` package.

### Detailed summary
- Exposed `publishContract` extension
- Refactored metadata handling in `deploy-metadata.ts`
- Updated `publisher.ts` with export changes
- Added new functions and types in `semver.ts`
- Introduced `publishContract` and related functions in `publish.ts`
- Added tests for `publishContract` in `publish.test.ts`

> The following files were skipped due to too many changes: `packages/thirdweb/src/extensions/thirdweb/write/publish.test.ts`

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

<!-- end pr-codex -->
2024-09-16 00:04:13 +00:00
joaquim-verges 07b949dd8c fix(pay): allow topping up from a different wallet with the same currency (#4602)
Fixes CNCT-1835

<!-- start pr-codex -->

---

## PR-Codex overview
This PR allows topping up from a different wallet with the same currency.

### Detailed summary
- Enable topping up from a different wallet with the same currency
- Rename "Seller" to "Receiver" in ConfirmationScreen
- Modify condition in showSwapFlow to include "fund_wallet" mode

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

<!-- end pr-codex -->
2024-09-15 22:12:10 +00:00
jnsdls 575c3e3141 react-query v4 -> v5 (#4600)
<!-- start pr-codex -->

## PR-Codex overview
This PR updates loading states in various components to use `isPending` instead of `isLoading`.

### Detailed summary
- Replaced `isLoading` with `isPending` in multiple components for loading state handling.

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/manage/components/InstalledModulesTable.tsx`, `apps/dashboard/src/components/pay/PayAnalytics/hooks/usePayCustomers.ts`, `apps/dashboard/src/components/pay/PayConfig.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/components/server/chain-header.tsx`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/components/client/add-partner-form.client.tsx`, `apps/dashboard/src/components/pay/PayAnalytics/components/PaymentHistory.tsx`, `apps/dashboard/src/contract-ui/tabs/split/components/distribute-button.tsx`, `apps/dashboard/src/components/onboarding/LinkWallet.tsx`, `apps/dashboard/src/components/pay/PayAnalytics/components/TotalVolumePieChart.tsx`, `apps/dashboard/package.json`, `apps/dashboard/src/components/pay/PayAnalytics/hooks/usePayPurchases.ts`, `apps/dashboard/src/components/engine/configuration/local-config.tsx.tsx`, `apps/dashboard/src/components/settings/ApiKeys/Create/index.tsx`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/components/server/partners-table.tsx`, `apps/dashboard/src/contract-ui/components/solidity-inputs/string-input.tsx`, `apps/dashboard/src/components/settings/Account/Billing/index.tsx`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/components/client/update-partner-form.client.tsx`, `apps/dashboard/src/contract-ui/tabs/nfts/page.tsx`, `apps/dashboard/src/components/configure-networks/Form/IconUpload.tsx`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/create/hooks/use-create-ecosystem.ts`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/create/components/client/create-ecosystem-form.client.tsx`, `apps/dashboard/src/components/engine/engine-instances-table.tsx`, `apps/dashboard/src/components/engine/contract-subscription/contract-subscriptions-table.tsx`, `apps/dashboard/src/components/pay/PayAnalytics/components/PayCustomersTable.tsx`, `apps/dashboard/src/pages/api/revalidate/publish.ts`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/hooks/use-update-ecosystem.ts`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/hooks/use-add-partner.ts`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/hooks/use-delete-partner.ts`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/hooks/use-update-partner.ts`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx`, `apps/dashboard/src/contract-ui/tabs/shared-components/marketplace-table.tsx`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/query/useQueryWithNetwork.ts`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/pay/components/webhooks.client.tsx`, `apps/dashboard/src/components/contract-components/tables/deployed-contracts.tsx`, `apps/dashboard/src/contract-ui/tabs/proposals/components/proposal.tsx`, `apps/dashboard/src/components/app-layouts/app.tsx`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/components/client/integration-permissions-toggle.client.tsx`, `apps/dashboard/src/app/account/settings/AccountSettingsPageUI.tsx`, `apps/dashboard/src/components/cmd-k-search/index.tsx`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/useLoggedInUser.ts`, `apps/dashboard/src/components/contract-components/hooks.ts`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/useRegistry.ts`, `apps/dashboard/src/contract-ui/tabs/manage/components/ModuleForm.tsx`, `apps/dashboard/src/app/team/[team_slug]/(team)/~/settings/general/GeneralSettingsPage.tsx`, `apps/dashboard/src/components/storage/your-files.tsx`, `apps/dashboard/src/components/contract-functions/interactive-abi-function.tsx`, `apps/dashboard/src/components/ipfs-upload/dropzone.tsx`, `apps/dashboard/src/core-ui/nft-drawer/useNftDrawerTabs.tsx`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts`, `pnpm-lock.yaml`, `apps/dashboard/src/contract-ui/hooks/useRouteConfig.tsx`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/useEngine.ts`

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

<!-- end pr-codex -->
2024-09-15 21:32:49 +00:00
joaquim-verges a4a41364cd feat: add optional wallet.getAdminAccount(), new useAdminWallet() hook and auto auth when using inapp+smart accounts (#4601)
Fixes CNCT-1833

## PR-Codex overview
This PR introduces a new `useAdminWallet()` hook for smart wallets and adds functionality for automatic authentication with in-app and smart accounts.

### Detailed summary
- Added `getAdminAccount` method to `Wallet` interface
- Created `useAdminWallet()` hook to get admin wallet for smart wallets
- Automatic authentication for in-app and smart accounts
- Updated various files to implement the new hook and method

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

<!-- end pr-codex -->
2024-09-15 20:34:38 +00:00
jnsdls eba1c60895 appease the knip overlords (#4594)
<!-- start pr-codex -->

## PR-Codex overview
This PR focuses on refactoring and updating various components, types, and functions across the dashboard app.

### Detailed summary
- Deleted several UI components and hooks
- Updated types and functions across different files
- Refactored component props and functions

> The following files were skipped due to too many changes: `apps/dashboard/src/utils/fetchChain.ts`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/components/module-list.client.tsx`, `apps/dashboard/src/components/analytics/area-chart.tsx`, `apps/dashboard/knip.json`, `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/constants.ts`, `apps/dashboard/src/components/contract-components/published-contract/index.tsx`, `apps/dashboard/src/lib/search.ts`, `apps/dashboard/src/@3rdweb-sdk/react/cache-keys.ts`, `apps/dashboard/src/components/contract-components/contract-table-v2/index.tsx`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts`, `apps/dashboard/src/@3rdweb-sdk/react/hooks/useEngine.ts`, `apps/dashboard/package.json`, `apps/dashboard/src/components/contract-components/hooks.ts`, `apps/dashboard/src/constants/mappings.ts`, `pnpm-lock.yaml`

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

<!-- end pr-codex -->
2024-09-15 03:49:07 +00:00
jnsdls 1168bc702f make --turbo work (#4593)
## 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 file paths for image sources and add the `--turbo` flag to the `next dev` script for improved performance.

### Detailed summary
- Updated file paths for image sources in multiple components
- Added `--turbo` flag to `next dev` script in `package.json` for improved performance

> The following files were skipped due to too many changes: `apps/dashboard/src/pages/sdk.tsx`, `apps/dashboard/src/pages/learn/index.tsx`, `apps/dashboard/src/pages/solutions/gaming.tsx`, `apps/dashboard/src/pages/solutions/commerce.tsx`, `apps/dashboard/src/pages/community/ambassadors.tsx`

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

<!-- end pr-codex -->
2024-09-15 03:49:06 +00:00
jnsdls 06ef6f0a07 remove @thirdweb-dev/react (#4591)
## 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 dependencies and refactor provider setup in the `apps/dashboard` directory.

### Detailed summary
- Updated dependencies for `@tanstack/react-query` and `@tanstack/react-table`
- Removed unused imports and code related to `@thirdweb-dev/react`
- Refactored provider setup in `apps/dashboard/src/components/app-layouts/provider-setup.tsx` and `apps/dashboard/src/components/app-layouts/providers.tsx`

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

<!-- end pr-codex -->
2024-09-15 03:49:05 +00:00
jnsdls 390aedcc8a remove claimconditions legacy (#4590)
## 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 claim conditions components and improve error handling.

### Detailed summary
- Refactored components related to claim conditions
- Improved error handling in `errorParser.tsx`
- Updated transaction button component
- Enhanced ERC20 amount conversion logic
- Streamlined wallet confirmation logic

> The following files were skipped due to too many changes: `apps/dashboard/src/contract-ui/tabs/claim-conditions/components/snapshot-upload.tsx`, `apps/dashboard/src/contract-ui/tabs/claim-conditions/components/claim-conditions-form/hooks.ts`, `apps/dashboard/src/contract-ui/tabs/claim-conditions/components/claim-conditions-form/index.tsx`

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

<!-- end pr-codex -->
2024-09-15 03:49:04 +00:00
jnsdls ebe4975aa3 permissions in v5 (#4588)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to refactor permissions handling in the dashboard.

### Detailed summary
- Refactored permissions handling to use `useReadContract`
- Removed `isPrebuilt` checks in `ContractPermission`
- Updated `getAllRoleMembers` and `createSetAllRoleMembersTx`
- Removed unnecessary imports and variables

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

<!-- end pr-codex -->
2024-09-15 00:25:26 +00:00
Jonas DanielsandGitHub 9c8beac7fe [Update] Add special case for zero address in WalletAddress component (#4599) 2024-09-14 17:22:59 -07:00
gregfromstl dc250225d2 [Playground] Feature: Track tab state in URL (#4597)
## 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 `tab` parameter to the `Page` component in the sign-in button page and update the `RightSection` component to handle the tab switching functionality.

### Detailed summary
- Added `tab` parameter to `Page` component
- Updated `RightSection` to handle tab switching functionality based on the `tab` parameter
- Utilized `useRouter` and `useMemo` for tab handling
- Implemented tab switching functionality in `RightSection`

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

<!-- end pr-codex -->
2024-09-15 00:11:24 +00:00
Jonas DanielsandGitHub 11437524e4 [Update] Replace redirect with notFound for 404 handling (#4596) 2024-09-14 17:10:18 -07:00
Jonas DanielsandGitHub 1a56ed6214 [Update] Resolve avatar URI using thirdwebClient (#4598) 2024-09-14 17:10:00 -07:00
jnsdls b2a2c9784a [Update] Refactor setOverrides() call and IPFS URL resolution (#4587)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to refactor the codebase to run `setOverrides()` function on app load efficiently.

### Detailed summary
- Moved `setOverrides()` function calls to run on app load in various files
- Added `useEffect` hooks to ensure `setOverrides()` runs once on app load
- Updated `replaceIpfsUrl` function to use `resolveScheme` with `thirdwebClient`
- Imported `setOverrides` function in multiple files for app initialization

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

<!-- end pr-codex -->
2024-09-14 19:52:27 +00:00
kien-ngo 5abc652871 [Dashboard] Fix missing Vote contract UI (#4592)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the condition in `useRouteConfig.tsx` to check for "VoteERC20" instead of "Vote".

### Detailed summary
- Updated condition to check for "VoteERC20" instead of "Vote" in `useRouteConfig.tsx` for enabling/disabling a component.

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

<!-- end pr-codex -->
2024-09-14 15:56:56 +00:00
kien-ngo fb0daabbf6 [Dashboard] Remove extensionDetectedState (#4557)
<!-- start pr-codex -->

## PR-Codex overview
This PR focuses on exposing Marketplace extensions for feature detection. It updates extension detection states and refactors extension method imports.

### Detailed summary
- Exposed Marketplace extensions for feature detection
- Refactored extension method imports to use `ExtensionDetectedState`
- Added functions to check support for specific methods in Marketplace extensions

> The following files were skipped due to too many changes: `packages/thirdweb/src/extensions/marketplace/direct-listings/read/getListing.ts`, `packages/thirdweb/src/extensions/marketplace/direct-listings/write/buyFromListing.ts`, `packages/thirdweb/src/exports/extensions/marketplace.ts`, `packages/thirdweb/src/extensions/marketplace/english-auctions/read/getWinningBid.ts`, `packages/thirdweb/src/extensions/marketplace/english-auctions/write/bidInAuction.ts`, `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-09-14 01:26:53 +00:00
jnsdls b142b8a893 remove custom publisher context (#4586) 2024-09-14 00:16:24 +00:00
MananTank e80a87a0d8 Fix Engine Page contract subscriptions crash + some form validation (#4585)
## 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 contract address validation and error handling in the contract subscription feature.

### Detailed summary
- Added `isAddress` function for contract address validation
- Improved error handling for invalid contract addresses and URLs

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

<!-- end pr-codex -->
2024-09-14 00:02:10 +00:00
jnsdls ce45cb2f24 [Update] Refine billing alert message for plan-specific scenarios (#4584) 2024-09-13 23:21:26 +00:00
MananTank de362ba2f5 Refactor Create API Key Modal, Add in teams for creating projects (#4583)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds functionality to create projects in the dashboard UI.

### Detailed summary
- Added `createProject` functionality to various components
- Updated global CSS variables
- Created `LazyCreateAPIKeyDialog` for project creation dialog
- Updated UI components for project creation functionality

> The following files were skipped due to too many changes: `apps/dashboard/src/stories/stubs.ts`, `apps/dashboard/src/pages/dashboard/settings/api-keys/index.tsx`, `apps/dashboard/src/components/settings/ApiKeys/Create/CreateApiKeyModal.stories.tsx`, `apps/dashboard/src/app/team/[team_slug]/(team)/TeamOverviewPage.tsx`, `apps/dashboard/src/components/settings/ApiKeys/Create/index.tsx`

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

<!-- end pr-codex -->
2024-09-13 23:08:24 +00:00
jnsdls ece86ccdc3 v5 deploy dashboard changes (#4498)
<!-- start pr-codex -->

## PR-Codex overview
This PR deprecates functions, updates types, refactors components, and adds modules for contract deployment.

### Detailed summary
- Deprecated functions in favor of new ones
- Updated types and added necessary type assertions
- Refactored components with new props and imports
- Added modules for contract deployment and handling metadata

> The following files were skipped due to too many changes: `apps/dashboard/src/app/(dashboard)/published-contract/utils/module-base-64.ts`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/components/module-list.client.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/components/uri-based-deploy.tsx`, `pnpm-lock.yaml`, `apps/dashboard/src/app/(dashboard)/published-contract/components/contract-actions-deploy.client.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/components/contract-info.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/components/contract-actions-published.client.tsx`, `packages/thirdweb/src/utils/any-evm/deploy-metadata.ts`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/utils/getPublishedContractsWithPublisherMapping.ts`, `packages/thirdweb/package.json`, `apps/dashboard/src/app/(dashboard)/contracts/deploy/[compiler_uri]/page.tsx`, `apps/dashboard/src/contract-ui/tabs/code/components/code-overview.tsx`, `apps/dashboard/src/components/contract-components/contract-deploy-form/trusted-forwarders-fieldset.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/layout.tsx`, `apps/dashboard/src/components/contract-components/contract-deploy-form/contract-metadata-fieldset.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/components/contract-header.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/components/breadcrumbs.client.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/opengraph-image.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/page.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/[version]/opengraph-image.tsx`, `packages/thirdweb/src/utils/abi/normalizeFunctionParams.ts`, `apps/dashboard/src/app/(dashboard)/published-contract/components/version-selector.tsx`, `packages/thirdweb/src/contract/deployment/deploy-with-abi.ts`, `apps/dashboard/src/contract-ui/tabs/manage/components/getModuleInstalledParams.ts`, `packages/thirdweb/src/extensions/prebuilts/get-required-transactions.test.ts`, `apps/dashboard/src/app/(dashboard)/published-contract/[publisher]/[contract_id]/[version]/page.tsx`, `apps/dashboard/src/app/(dashboard)/published-contract/components/publish-based-deploy.tsx`, `apps/dashboard/src/components/contract-components/fetch-contracts-with-versions.ts`, `apps/dashboard/src/components/contract-functions/contract-function.tsx`, `apps/dashboard/src/components/contract-components/contract-deploy-form/modular-contract-default-modules-fieldset.tsx`, `packages/thirdweb/src/extensions/prebuilts/get-required-transactions.ts`, `apps/dashboard/src/pages/api/og/publishedContract.tsx`, `apps/dashboard/src/components/contract-components/published-contract/index.tsx`, `apps/dashboard/src/components/contract-components/hooks.ts`, `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-09-13 19:16:20 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
d115307db1 Version Packages (#4570)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-09-13 12:01:55 -07:00
gregfromstl 5d3b39587b [React] Feature: Can hide certain wallets in the wallet switcher (#4582)
Adds the ability to hide certain wallets in the wallet switcher

```tsx
      <ConnectButton
        client={client}
        detailsModal={{
          // We hide the in-app wallet so they can't switch to it
          hiddenWallets: ["inApp"],
        }}
        accountAbstraction={{
          chain: baseSepolia,
          sponsorGas: true,
        }}
      />
```

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to add the ability to hide specific wallets in the wallet switcher UI component.

### Detailed summary
- Added `hiddenWallets` prop to `ConnectButton`, `DetailsModal`, `WalletSwitcherConnectionScreen`, `BuyScreen`, and `PayEmbed` components.
- Implemented filtering of connected wallets based on `hiddenWallets` in `WalletManagerScreen` and `WalletSwitcherDrawerContent`.
- Updated types to include `WalletId` for consistency across components.

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

<!-- end pr-codex -->
2024-09-13 18:37:29 +00:00
Jonas DanielsandGitHub 53015711fe update next version (#4576) 2024-09-13 10:42:33 -07:00
gregfromstl 5058fdb470 [SDK] Feature: X auth (#4571)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds authentication support for a new provider 'X' across various components and modules.

### Detailed summary
- Added 'X' authentication provider
- Updated authentication types and components
- Implemented 'X' authentication in multiple files

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

<!-- end pr-codex -->
2024-09-13 06:12:59 +00:00
Jonas DanielsandGitHub a47bc2233c [Update] Add address validation in WalletAddress and AddAdminButton components (#4575) 2024-09-12 21:12:47 -07:00
Edward SunandGitHub 390180592a Add preferredProvider in buyWithFiat (#4546) 2024-09-12 17:37:57 -07:00
joaquim-verges 285321b193 docs: Update in-app wallet backend API link (#4572)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates redirects and icon imports in the `portal` app and refactors the sidebar in `sidebar.tsx`.

### Detailed summary
- Added a new redirect for in-app wallet details on the server
- Reordered icon imports in `sidebar.tsx`
- Updated sidebar links for In-App Wallet and Ecosystem Wallet pages

> The following files were skipped due to too many changes: `apps/portal/src/app/connect/sidebar.tsx`

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

<!-- end pr-codex -->
2024-09-13 00:06:10 +00:00
0xFirekeeper 8035923cda .net 2.1 docs hotfix (#4569)
<!-- start pr-codex -->

## PR-Codex overview
This PR simplifies the OTP login process in the `page.mdx` file by removing the retry logic and adding a comment for handling failed login attempts.

### Detailed summary
- Removed `canRetry` variable and related logic
- Added a comment for handling failed login attempts

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

<!-- end pr-codex -->
2024-09-12 23:26:42 +00:00
gregfromstl c0778cb930 [SDK] Feature: Export uri parsing utils (#4565)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR adds `parseAvatarRecord` and `parseNftUri` utilities for ENS avatars and NFT URIs. Detailed summary:

### Detailed summary
- Added `parseAvatarRecord` and `parseNftUri` functions for ENS avatars and NFT URIs
- Updated `common.ts` and `ens.ts` with new exports
- Created `parseNftUri` function in `parseNft.ts`
- Added `parseAvatarRecord` function in `avatar.ts`

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

<!-- end pr-codex -->
2024-09-12 22:12:44 +00:00
arcoraven db1f79678c fix: incorrect gasLimit reference in Engine (#4566)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to update the gas settings override mechanism for write transactions in the contract page.

### Detailed summary
- Updated gas settings override mechanism for transactions
- Removed individual `gasLimit` and `gasPrice` fields
- Added `gas`, `maxFeePerGas`, and `maxPriorityFeePerGas` fields
- Fields are now optional and will be estimated if omitted

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

<!-- end pr-codex -->
2024-09-12 20:54:40 +00:00
0xFirekeeper 113468e361 .NET 2.1 // Unity 5.1 Docs (#4564)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to add new methods and documentation for interacting with smart wallets in the .NET SDK.

### Detailed summary
- Added methods for getting personal wallet, all admins, active signers, transaction count, and transferring in .NET SDK
- Updated documentation for In-App Wallet and Ecosystem Wallet login methods

> The following files were skipped due to too many changes: `apps/portal/src/app/dotnet/wallets/providers/ecosystem-wallet/page.mdx`, `apps/portal/src/app/dotnet/sidebar.tsx`, `apps/portal/src/app/unity/v5/wallets/ecosystem-wallet/page.mdx`

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

<!-- end pr-codex -->
2024-09-12 20:15:25 +00:00
MananTank a24de21f00 Fix no redirect to dashboard if user is already logged in and lands on login page (#4561)
Did not go the middleware route here because even if we properly check the logged in status in middleware and redirect - it's possible for user to get stuck in that case if for some reason the wallet never gets into "connecting" status and so the useLoggedInUser query never runs and never redirects the user to login page ( and even if it did - they would immediately get redirected to other page because they have a "valid" auth cookie )

so safest solution here is to let the user land on login page and once then redirect from there after wallet connection + sign in is done

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to refactor the login process in the dashboard app.

### Detailed summary
- Removed unused imports and functions
- Refactored `doLogin` function to handle redirect logic internally
- Added `useDashboardRouter` hook to handle navigation
- Improved error handling and redirect logic in the login process

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

<!-- end pr-codex -->
2024-09-12 18:37:42 +00:00
Joaquim VergesandGitHub 2d2e6cb380 test: Update ERC1967 proxy constructor data parameter (#4563) 2024-09-13 06:36:47 +12:00
MananTank 03c21903c9 Fix Popular chain missing icons on dashboard (#4562)
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the `connect-wallet` component to include support for popular chains with metadata.

### Detailed summary
- Added `useSupportedChainsRecord` import
- Added `chainsRecord` state
- Added `popularChainsWithMeta` state
- Updated `chainSections` to use `popularChainsWithMeta`
- Updated dependencies for `useMemo` in `chainSections`

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

<!-- end pr-codex -->
2024-09-12 18:13:09 +00:00
4425 changed files with 735331 additions and 430193 deletions
+1 -27
View File
@@ -10,33 +10,7 @@
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [
"bundlers-esbuild",
"bundlers-vite",
"bundlers-webpack",
"bundlers-swc",
"runtimes-node-commonjs",
"runtimes-node-module",
"playground-web",
"thirdweb-dashboard",
"wallet-ui",
"portal",
"@thirdweb-dev/auth",
"@thirdweb-dev/chains",
"@thirdweb-dev/cli",
"@thirdweb-dev/contracts-js",
"@thirdweb-dev/crypto",
"@thirdweb-dev/generated-abis",
"@thirdweb-dev/merkletree",
"@thirdweb-dev/pay",
"@thirdweb-dev/payments",
"@thirdweb-dev/react",
"@thirdweb-dev/react-core",
"@thirdweb-dev/sdk",
"@thirdweb-dev/storage",
"@thirdweb-dev/unity-js-bridge",
"@thirdweb-dev/wallets"
],
"ignore": ["playground-web", "thirdweb-dashboard", "wallet-ui", "portal"],
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"updateInternalDependents": "always",
"onlyUpdatePeerDependentsWhenOutOfRange": true
+2 -26
View File
@@ -3,42 +3,18 @@
# default ownership group
- @jnsdls @joaquim-verges @MananTank @gregfromstl
# legacy packages
legacy_packages/auth/ @jnsdls @joaquim-verges
legacy_packages/chains/ @jnsdls @joaquim-verges
legacy_packages/cli/ @jnsdls @joaquim-verges
legacy_packages/contracts-js/ @jnsdls @joaquim-verges
legacy_packages/crypto/ @jnsdls @joaquim-verges
legacy_packages/generated-abis/ @jnsdls @joaquim-verges
legacy_packages/merkletree/ @jnsdls @joaquim-verges
legacy_packages/pay/ @jnsdls @joaquim-verges
legacy_packages/payments/ @jnsdls @joaquim-verges
legacy_packages/react/ @MananTank @jnsdls @joaquim-verges
legacy_packages/react-core/ @MananTank @jnsdls @joaquim-verges
legacy_packages/react-native/ @jnsdls @joaquim-verges
legacy_packages/react-native-compat/ @jnsdls @joaquim-verges
legacy_packages/sdk/ @joaquim-verges @jnsdls
legacy_packages/storage/ @jnsdls @joaquim-verges
legacy_packages/wallets/ @MananTank @jnsdls @joaquim-verges
# legacy e2e
legacy_e2e/ @jnsdls
# packages
packages/thirdweb/ @joaquim-verges @gregfromstl @jnsdls
## specific thirdweb pieces
packages/thirdweb/src/react/ @joaquim-verges @gregfromstl @MananTank @jnsdls
packages/thirdweb/src/react/ @joaquim-verges @gregfromstl @MananTank @jnsdls @edwardysun
packages/thirdweb/src/reactive/ @joaquim-verges @gregfromstl @MananTank @jnsdls
packages/thirdweb/src/gas/ @joaquim-verges @jnsdls
packages/thirdweb/src/pay/ @joaquim-verges @gregfromstl @MananTank @jnsdls
packages/thirdweb/src/pay/ @joaquim-verges @gregfromstl @MananTank @jnsdls @edwardysun
packages/typedoc-gen/ @MananTank @jnsdls @joaquim-verges
packages/service-utils/ @arcoraven @jnsdls @joaquim-verges
packages/eslint-config-thirdweb/ @jnsdls @joaquim-verges
packages/tw-tsconfig/ @jnsdls @joaquim-verges
packages/unity-js-bridge/ @joaquim-verges @0xFirekeeper @jnsdls
# apps
apps/ @jnsdls @joaquim-verges
-3
View File
@@ -5,9 +5,6 @@ dashboard:
playground:
- changed-files:
- any-glob-to-any-file: "apps/playground-web/**/*"
legacy_packages:
- changed-files:
- any-glob-to-any-file: "legacy-packages/**/*"
packages:
- changed-files:
- any-glob-to-any-file: "packages/**/*"
-113
View File
@@ -1,113 +0,0 @@
name: CI (Legacy Packages)
on:
push:
branches: ["main"]
paths:
- "legacy_packages/**"
- "legacy_e2e/**"
- "package.json"
pull_request:
types: [opened, synchronize]
paths:
- "legacy_packages/**"
- "legacy_e2e/**"
- "package.json"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# To use Remote Caching, uncomment the next lines and follow the steps below.
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TW_SECRET_KEY: ${{ secrets.TW_SECRET_KEY }}
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:
- name: Check out the code
uses: actions/checkout@v4
- name: Setup & Install
uses: ./.github/composite-actions/install
- name: Build Packages
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
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Setup & Install
uses: ./.github/composite-actions/install
- 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
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Setup & Install
uses: ./.github/composite-actions/install
- run: pnpm test:legacy
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
directory: legacy_packages/
flags: legacy_packages
verbose: true
e2e:
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
timeout-minutes: 15
name: E2E Tests
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Setup & Install
uses: ./.github/composite-actions/install
- name: Install Playwright
run: npx playwright install --with-deps
- name: Run e2e tests
run: pnpm e2e:legacy
env:
NODE_OPTIONS: "--max_old_space_size=4096"
CLI_E2E_API_KEY: ${{ secrets.CLI_E2E_API_KEY }}
-1
View File
@@ -8,7 +8,6 @@ on:
paths:
- ".changeset/**"
- "packages/**"
- "legacy_packages/**"
branches:
- main
-58
View File
@@ -1,58 +0,0 @@
name: Sync chains every hour
on:
# temporarily disabled chain syncing
# schedule:
# - cron: "0 * * * *" # Runs every hour
workflow_dispatch: # Allows you to manually run the workflow from the Actions tab
jobs:
sync-chains:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.35
- name: Run chains sync
run: bun run db:sync
working-directory: ./legacy_packages/chains
- name: Check for Changes
id: git-check
run: |
if git diff --quiet; then
echo "CHANGES_FOUND=false" >> $GITHUB_ENV
else
echo "CHANGES_FOUND=true" >> $GITHUB_ENV
fi
- name: Create or Update sync-chains.md
if: env.CHANGES_FOUND == 'true'
run: |
echo '---' > .changeset/sync-chains.md
echo '"@thirdweb-dev/chains": patch' >> .changeset/sync-chains.md
echo '---' >> .changeset/sync-chains.md
echo '' >> .changeset/sync-chains.md
echo 'Synced Chains Package' >> .changeset/sync-chains.md
- name: Commit Changes
if: env.CHANGES_FOUND == 'true'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
git commit -m "chore(chains): sync from db"
- name: Create or Update Pull Request
if: env.CHANGES_FOUND == 'true'
uses: peter-evans/create-pull-request@v6
with:
title: "chore(chains): update chains"
branch: "sync-chains"
body: "This PR was automatically created by a GitHub Action. It updates the chains package with the latest changes from the database."
commit-message: "chore(chains): sync from db"
-5
View File
@@ -10,7 +10,6 @@ dist-ssr
.cache
server/dist
public/dist
./legacy_packages/contracts-js/abis
.idea/
.yalc/
yalc.lock
@@ -18,9 +17,6 @@ yalc.lock
playwright-report/
.env/
# Artifacts
legacy_packages/cli/artifacts/
# codecov binary
codecov
@@ -28,7 +24,6 @@ codecov
sitemap*.xml
# typedoc
legacy_packages/*/typedoc/*
packages/*/typedoc/*
*storybook.log
@@ -1,6 +0,0 @@
---
"@thirdweb-dev/cli": minor
"thirdweb": minor
---
Adds --expo option to cli
@@ -1,5 +0,0 @@
---
"@thirdweb-dev/sdk": patch
---
ZkCandy addresses
@@ -1,6 +0,0 @@
---
"@thirdweb-dev/cli": patch
"@thirdweb-dev/sdk": patch
---
Override contract publish id on CLI
@@ -1,17 +0,0 @@
---
"@thirdweb-dev/merkletree": patch
"@thirdweb-dev/react-core": patch
"@thirdweb-dev/payments": patch
"@thirdweb-dev/storage": patch
"@thirdweb-dev/wallets": patch
"@thirdweb-dev/chains": patch
"@thirdweb-dev/crypto": patch
"@thirdweb-dev/service-utils": patch
"@thirdweb-dev/react": patch
"@thirdweb-dev/auth": patch
"@thirdweb-dev/cli": patch
"@thirdweb-dev/pay": patch
"@thirdweb-dev/sdk": patch
---
update dependencies
@@ -1,5 +0,0 @@
---
"@thirdweb-dev/react": patch
---
Fix error when doing buy with Crypto transaction with InApp wallet
@@ -1,5 +0,0 @@
---
"@thirdweb-dev/sdk": patch
---
Fix EIP155 check for create2 factory deployment
@@ -1,6 +0,0 @@
---
"@thirdweb-dev/wallets": patch
"@thirdweb-dev/sdk": patch
---
respect gas overrides if they are passed in
@@ -1,5 +0,0 @@
---
"@thirdweb-dev/react": patch
---
Fix wallet app not opening when using ConnectButton inside an iframe
@@ -1,5 +0,0 @@
---
"@thirdweb-dev/chains": patch
---
Synced Chains Package
+1 -28
View File
@@ -2,9 +2,7 @@ module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"plugin:@next/next/recommended",
"plugin:promise/recommended",
"plugin:storybook/recommended",
],
rules: {
@@ -98,7 +96,7 @@ module.exports = {
],
},
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "import", "react-compiler"],
plugins: ["@typescript-eslint", "react-compiler"],
parserOptions: {
ecmaVersion: 2019,
ecmaFeatures: {
@@ -115,31 +113,6 @@ module.exports = {
},
},
overrides: [
{
files: "src/core-ui/**/*",
rules: {
// no restricted imports
"@typescript-eslint/no-restricted-imports": [
"error",
{
paths: [
{
name: "@thirdweb-dev/sdk",
message:
"core-ui should not import from @thirdweb-dev/sdk. (except for types)",
allowTypeImports: true,
},
{
name: "@thirdweb-dev/react",
message:
"core-ui should not import from @thirdweb-dev/react. (except for types)",
allowTypeImports: true,
},
],
},
],
},
},
// disable restricted imports in tw-components
{
files: "src/tw-components/**/*",
+13 -5
View File
@@ -1,8 +1,16 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.1/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
"extends": ["../../biome.json"],
"files": {
"ignore": ["src/graphql/**"]
}
"overrides": [
{
"include": ["src/css/swagger-ui.css"],
"linter": {
"rules": {
"suspicious": {
"noImportantInKeyframe": "off"
}
}
}
}
]
}
+3 -2
View File
@@ -1,7 +1,8 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"next": true,
"ignore": ["src/graphql/**", "src/theme/*"],
"ignore": ["src/@/components/ui/**"],
"project": ["src/**"],
"ignoreBinaries": ["only-allow"]
"ignoreBinaries": ["only-allow", "knip", "biome"],
"ignoreDependencies": ["@storybook/blocks", "@thirdweb-dev/service-utils"]
}
-2
View File
@@ -1,7 +1,6 @@
// @ts-check
/**
*
* @returns {Promise<import("@thirdweb-dev/chains").Chain[]>}
*/
async function fetchChainsFromApi() {
const res = await fetch(`https://api.thirdweb.com/v1/chains`, {
@@ -21,7 +20,6 @@ async function fetchChainsFromApi() {
/**
*
* @param {number|string} chainIdOrSlug
* @returns {Promise<import("@thirdweb-dev/chains").Chain>}
*/
async function getSingleChain(chainIdOrSlug) {
const res = await fetch(
+4 -5
View File
@@ -8,7 +8,7 @@ const ContentSecurityPolicy = `
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;
script-src 'self' 'unsafe-eval' 'unsafe-inline' 'wasm-unsafe-eval' 'inline-speculation-rules' *.thirdweb.com *.thirdweb-dev.com vercel.live js.stripe.com portal.usecontext.io;
connect-src * data: blob:;
worker-src 'self' blob:;
block-all-mixed-content;
@@ -144,7 +144,6 @@ const moduleExports = {
reactStrictMode: true,
experimental: {
scrollRestoration: true,
esmExternals: "loose",
webpackBuildWorker: true,
serverSourceMaps: false,
},
@@ -214,7 +213,7 @@ module.exports = withBundleAnalyzer(
* See: https://github.com/getsentry/sentry-javascript/issues/10468#issuecomment-2004710692
*/
disableServerWebpackPlugin: true,
},
),
),
}
)
)
);
+25 -63
View File
@@ -4,15 +4,14 @@
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"dev": "next dev",
"dev": "next dev --turbo",
"build": "next build",
"start": "next start",
"format": "biome format ./src --write",
"lint": "biome check ./src && eslint ./src",
"lint": "biome check ./src && knip && eslint ./src",
"fix": "biome check ./src --fix && eslint ./src --fix",
"gen:theme-typings": "chakra-cli tokens src/theme/index.ts",
"postinstall": "pnpm run gen:theme-typings",
"find:unused": "next-unused",
"postbuild": "next-sitemap",
"build:analyze": "ANALYZE=true pnpm run build",
"knip": "knip",
@@ -45,20 +44,15 @@
"@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.30.0",
"@shazow/whatsabi": "^0.14.1",
"@stripe/react-stripe-js": "^2.7.3",
"@stripe/stripe-js": "^3.5.0",
"@tanstack/react-query": "^4.36.1",
"@tanstack/react-query": "5.56.2",
"@tanstack/react-table": "^8.17.3",
"@thirdweb-dev/react": "workspace:*",
"@thirdweb-dev/sdk": "workspace:*",
"@thirdweb-dev/service-utils": "workspace:*",
"@thirdweb-dev/storage": "workspace:*",
"@vercel/og": "^0.6.2",
"abitype": "1.0.5",
"chakra-react-select": "^4.7.6",
@@ -67,23 +61,21 @@
"color": "^4.2.3",
"compare-versions": "^6.1.0",
"date-fns": "^3.6.0",
"ethers": "5.7.2",
"flat": "^6.0.1",
"framer-motion": "11.5.4",
"fuse.js": "7.0.0",
"ioredis": "^5.4.1",
"ipaddr.js": "^2.2.0",
"lottie-react": "^2.4.0",
"lucide-react": "0.439.0",
"next": "14.2.9",
"lucide-react": "0.441.0",
"next": "14.2.12",
"next-plausible": "^3.12.0",
"next-seo": "^6.5.0",
"next-themes": "^0.3.0",
"nextjs-toploader": "^1.6.12",
"papaparse": "^5.4.1",
"pluralize": "^8.0.0",
"posthog-js": "1.161.3",
"posthog-js-opensource": "npm:[email protected]",
"posthog-js": "1.67.1",
"prism-react-renderer": "^2.3.1",
"prismjs": "^1.29.0",
"qrcode": "^1.5.3",
@@ -97,7 +89,6 @@
"react-intersection-observer": "^9.10.3",
"react-markdown": "^9.0.1",
"react-otp-input": "^3.1.1",
"react-query-v5": "npm:@tanstack/[email protected]",
"react-responsive-carousel": "^3.2.23",
"react-table": "^7.8.0",
"recharts": "^2.12.7",
@@ -111,31 +102,29 @@
"thirdweb": "workspace:*",
"tiny-invariant": "^1.3.3",
"use-debounce": "^10.0.1",
"vaul": "^0.9.1",
"zksync-ethers": "5.9.0",
"zod": "3.23.8"
},
"devDependencies": {
"@chakra-ui/cli": "^2.4.1",
"@chromatic-com/storybook": "^1.5.0",
"@next/bundle-analyzer": "14.2.9",
"@next/eslint-plugin-next": "^14.2.9",
"@playwright/test": "1.47.0",
"@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/addon-viewport": "^8.2.9",
"@storybook/blocks": "^8.2.9",
"@storybook/nextjs": "^8.2.9",
"@storybook/react": "^8.2.9",
"@storybook/test": "^8.2.9",
"@chromatic-com/storybook": "2.0.2",
"@next/bundle-analyzer": "14.2.12",
"@next/eslint-plugin-next": "14.2.12",
"@playwright/test": "1.47.1",
"@storybook/addon-essentials": "8.3.1",
"@storybook/addon-interactions": "8.3.1",
"@storybook/addon-links": "8.3.1",
"@storybook/addon-onboarding": "8.3.1",
"@storybook/addon-viewport": "8.3.1",
"@storybook/blocks": "8.3.1",
"@storybook/nextjs": "8.3.1",
"@storybook/react": "8.3.1",
"@storybook/test": "8.3.1",
"@types/color": "^3.0.6",
"@types/node": "20.14.9",
"@types/papaparse": "^5.3.14",
"@types/pluralize": "^0.0.33",
"@types/qrcode": "^1.5.5",
"@types/react": "^18.3.5",
"@types/react": "^18.3.7",
"@types/react-dom": "^18",
"@types/react-table": "^7.7.20",
"@types/spdx-correct": "^3.1.3",
@@ -146,39 +135,12 @@
"checkly": "^4.8.1",
"eslint": "8.57.0",
"eslint-config-biome": "1.8.3",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-react-compiler": "0.0.0-experimental-9ed098e-20240725",
"eslint-plugin-react-compiler": "0.0.0-experimental-ca16900-20240916",
"eslint-plugin-storybook": "^0.8.0",
"next-sitemap": "^4.2.3",
"next-unused": "^0.0.6",
"storybook": "^8.2.9",
"tailwindcss": "^3.4.10",
"postcss": "8.4.47",
"storybook": "8.3.1",
"tailwindcss": "3.4.12",
"typescript": "5.6.2"
},
"next-unused": {
"alias": {},
"include": [
"components",
"hooks",
"schema",
"theme",
"utils",
"@3rdweb-sdk",
"constants",
"tw-components",
"contract-ui"
],
"exclude": [
"node_modules",
"types",
"tw-components"
],
"entrypoints": []
},
"browserslist": [
"defaults",
"unreleased versions",
"not UCAndroid > 0"
]
}
}
@@ -1,12 +1,9 @@
import type { Meta, StoryObj } from "@storybook/react";
import {
BadgeContainer,
mobileViewport,
} from "../../../../../../../stories/utils";
import { BadgeContainer, mobileViewport } from "../../../stories/utils";
import { DangerSettingCard } from "./DangerSettingCard";
const meta = {
title: "Team/Settings/components/DangerCard",
title: "blocks/DangerSettingCard",
component: Story,
parameters: {
nextjs: {
@@ -3,10 +3,13 @@ import { Button } from "@/components/ui/button";
import { useMutation } from "@tanstack/react-query";
import { DownloadIcon } from "lucide-react";
import { toast } from "sonner";
import { cn } from "../../lib/utils";
export function ExportToCSVButton(props: {
getData: () => Promise<{ header: string[]; rows: string[][] }>;
fileName: string;
disabled?: boolean;
className?: string;
}) {
const exportMutation = useMutation({
mutationFn: async () => {
@@ -26,12 +29,13 @@ export function ExportToCSVButton(props: {
return (
<Button
variant="outline"
className="border flex gap-2 items-center text-xs"
disabled={props.disabled}
className={cn("border flex gap-2 items-center text-xs", props.className)}
onClick={async () => {
exportMutation.mutate();
}}
>
{exportMutation.isLoading ? (
{exportMutation.isPending ? (
<>
Downloading
<Spinner className="size-3" />
@@ -1,12 +1,9 @@
import type { Meta, StoryObj } from "@storybook/react";
import {
BadgeContainer,
mobileViewport,
} from "../../../../../../../stories/utils";
import { BadgeContainer, mobileViewport } from "../../../stories/utils";
import { SettingsCard } from "./SettingsCard";
const meta = {
title: "Team/Settings/components/SettingsCard",
title: "blocks/SettingsCard",
component: Story,
parameters: {
nextjs: {
@@ -1,9 +1,10 @@
import { Spinner } from "@/components/ui/Spinner/Spinner";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import type React from "react";
export function SettingsCard(props: {
bottomText: string;
bottomText: React.ReactNode;
header?: {
description: string | undefined;
title: string;
@@ -12,13 +13,14 @@ export function SettingsCard(props: {
errorText: string | undefined;
noPermissionText: string | undefined;
saveButton?: {
onClick: () => void;
onClick?: () => void;
disabled: boolean;
isLoading: boolean;
type?: "submit";
};
}) {
return (
<div className="border rounded-lg bg-muted/50 relative">
<div className="border border-border rounded-lg bg-muted/50 relative">
<div
className={cn(
"border-b border-border px-4 lg:px-6 py-6 relative",
@@ -59,6 +61,7 @@ export function SettingsCard(props: {
onClick={props.saveButton.onClick}
disabled={props.saveButton.disabled || props.saveButton.isLoading}
variant="outline"
type={props.saveButton.type}
>
{props.saveButton.isLoading && <Spinner className="size-3" />}
{props.saveButton.isLoading ? "Saving" : "Save"}
@@ -14,7 +14,7 @@ export type SidebarLink = {
};
};
export type SidebarContentProps = {
type SidebarContentProps = {
header?: React.ReactNode;
links: SidebarLink[];
className?: string;
@@ -3,7 +3,7 @@ import { mobileViewport } from "../../../stories/utils";
import { SidebarLayout } from "./SidebarLayout";
const meta = {
title: "layouts/SidebarLayout",
title: "blocks/SidebarLayout",
component: Story,
parameters: {
nextjs: {
@@ -19,7 +19,7 @@ import {
} from "@/components/ui/chart";
import { useMemo } from "react";
export type ThirdwebAreaChartProps<TConfig extends ChartConfig> = {
type ThirdwebAreaChartProps<TConfig extends ChartConfig> = {
// metadata
title: string;
description?: string;
@@ -19,7 +19,7 @@ import {
} from "@/components/ui/chart";
import { useMemo } from "react";
export type ThirdwebBarChartProps<TConfig extends ChartConfig> = {
type ThirdwebBarChartProps<TConfig extends ChartConfig> = {
// metadata
title: string;
description?: string;
@@ -6,8 +6,10 @@ import {
HoverCardContent,
HoverCardTrigger,
} from "@/components/ui/hover-card";
import { useThirdwebClient } from "@/constants/thirdweb.client";
import { Check, Copy, ExternalLinkIcon } from "lucide-react";
import { useMemo, useState } from "react";
import { type ThirdwebClient, isAddress } from "thirdweb";
import { ZERO_ADDRESS } from "thirdweb";
import {
Blobbie,
@@ -16,7 +18,6 @@ import {
useSocialProfiles,
} from "thirdweb/react";
import { resolveScheme } from "thirdweb/storage";
import { thirdwebClient } from "../../constants/client";
import { cn } from "../../lib/utils";
import { Badge } from "../ui/badge";
import { Button } from "../ui/button";
@@ -26,8 +27,10 @@ export function WalletAddress(props: {
shortenAddress?: boolean;
className?: string;
}) {
const thirdwebClient = useThirdwebClient();
// default back to zero address if no address provided
const address = useMemo(() => props.address || ZERO_ADDRESS, [props.address]);
const [shortenedAddress, lessShortenedAddress] = useMemo(() => {
return [
props.shortenAddress !== false
@@ -44,6 +47,15 @@ export function WalletAddress(props: {
const [isCopied, setIsCopied] = useState(false);
if (!isAddress(address)) {
return <span>Invalid Address ({address})</span>;
}
// special case for zero address
if (address === ZERO_ADDRESS) {
return <span className="font-mono cursor-pointer">{shortenedAddress}</span>;
}
const copyToClipboard = async () => {
try {
await navigator.clipboard.writeText(address);
@@ -66,7 +78,11 @@ export function WalletAddress(props: {
)}
>
{address && (
<WalletAvatar address={address} profiles={profiles.data || []} />
<WalletAvatar
address={address}
profiles={profiles.data || []}
thirdwebClient={thirdwebClient}
/>
)}
<span className="font-mono cursor-pointer">
{profiles.data?.[0]?.name || shortenedAddress}
@@ -167,6 +183,7 @@ export function WalletAddress(props: {
function WalletAvatar(props: {
address: string;
profiles: SocialProfile[];
thirdwebClient: ThirdwebClient;
}) {
const avatar = useMemo(() => {
return props.profiles.find(
@@ -180,7 +197,7 @@ function WalletAvatar(props: {
<div className="size-6 overflow-hidden rounded-full">
{avatar ? (
<MediaRenderer
client={thirdwebClient}
client={props.thirdwebClient}
src={avatar}
className="size-6"
/>
@@ -61,6 +61,7 @@ const BreadcrumbPage = React.forwardRef<
HTMLSpanElement,
React.ComponentPropsWithoutRef<"span">
>(({ className, ...props }, ref) => (
// biome-ignore lint/a11y/useFocusableInteractive: required
<span
ref={ref}
role="link"
+5 -1
View File
@@ -113,6 +113,7 @@ const ChartTooltipContent = React.forwardRef<
indicator?: "line" | "dot" | "dashed";
nameKey?: string;
labelKey?: string;
valueFormatter?: (v: unknown) => string | undefined;
}
>(
(
@@ -130,6 +131,7 @@ const ChartTooltipContent = React.forwardRef<
color,
nameKey,
labelKey,
valueFormatter,
},
ref,
) => {
@@ -243,7 +245,9 @@ const ChartTooltipContent = React.forwardRef<
</div>
{item.value && (
<span className="font-mono font-medium tabular-nums text-foreground">
{item.value}
{valueFormatter
? valueFormatter(item.value) || item.value
: item.value}
</span>
)}
</div>
@@ -34,6 +34,7 @@ export function CheckboxWithLabel(props: {
className?: string;
}) {
return (
// biome-ignore lint/a11y/noLabelWithoutControl: cannot do this here because the checkbox is a child of the label
<label
className={cn(
"flex gap-2 items-start text-muted-foreground text-sm cursor-pointer select-none [&>button]:mt-0.5",
@@ -41,7 +41,7 @@ const DialogContent = React.forwardRef<
<DialogPrimitive.Content
ref={ref}
className={cn(
"fixed grid w-full max-w-lg gap-4 border bg-background p-6 shadow-lg duration-300 rounded-t-xl md:rounded-lg border-border",
"fixed grid w-full md:max-w-lg gap-4 border bg-background p-6 shadow-lg duration-300 rounded-t-xl md:rounded-lg border-border",
// on mobile - put the dialog at the bottom of the screen, animate - slide up and fade in
"bottom-0 left-0 right-0",
"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
@@ -1,118 +0,0 @@
"use client";
import * as React from "react";
import { Drawer as DrawerPrimitive } from "vaul";
import { cn } from "@/lib/utils";
const Drawer = ({
shouldScaleBackground = true,
...props
}: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
<DrawerPrimitive.Root
shouldScaleBackground={shouldScaleBackground}
{...props}
/>
);
Drawer.displayName = "Drawer";
const DrawerTrigger = DrawerPrimitive.Trigger;
const DrawerPortal = DrawerPrimitive.Portal;
const DrawerClose = DrawerPrimitive.Close;
const DrawerOverlay = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DrawerPrimitive.Overlay
ref={ref}
className={cn("fixed inset-0 z-50 bg-black/80", className)}
{...props}
/>
));
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
const DrawerContent = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DrawerPortal>
<DrawerOverlay />
<DrawerPrimitive.Content
ref={ref}
className={cn(
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
className,
)}
{...props}
>
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
{children}
</DrawerPrimitive.Content>
</DrawerPortal>
));
DrawerContent.displayName = "DrawerContent";
const DrawerHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)}
{...props}
/>
);
DrawerHeader.displayName = "DrawerHeader";
const DrawerFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn("mt-auto flex flex-col gap-2 p-4", className)}
{...props}
/>
);
DrawerFooter.displayName = "DrawerFooter";
const DrawerTitle = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
>(({ className, ...props }, ref) => (
<DrawerPrimitive.Title
ref={ref}
className={cn(
"text-lg font-semibold leading-none tracking-tight",
className,
)}
{...props}
/>
));
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
const DrawerDescription = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
>(({ className, ...props }, ref) => (
<DrawerPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
));
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
export {
Drawer,
DrawerPortal,
DrawerOverlay,
DrawerTrigger,
DrawerClose,
DrawerContent,
DrawerHeader,
DrawerFooter,
DrawerTitle,
DrawerDescription,
};
@@ -6,7 +6,6 @@ import { cn } from "@/lib/utils";
const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
<nav
role="navigation"
aria-label="pagination"
className={cn("mx-auto flex w-full justify-center", className)}
{...props}
@@ -0,0 +1,143 @@
"use client";
import * as SheetPrimitive from "@radix-ui/react-dialog";
import { type VariantProps, cva } from "class-variance-authority";
import { X } from "lucide-react";
import * as React from "react";
import { cn } from "@/lib/utils";
const Sheet = SheetPrimitive.Root;
const SheetTrigger = SheetPrimitive.Trigger;
const SheetClose = SheetPrimitive.Close;
const SheetPortal = SheetPrimitive.Portal;
const SheetOverlay = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Overlay
className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className,
)}
{...props}
ref={ref}
/>
));
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
const sheetVariants = cva(
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500 border-border",
{
variants: {
side: {
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
bottom:
"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
right:
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
},
},
defaultVariants: {
side: "right",
},
},
);
interface SheetContentProps
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
VariantProps<typeof sheetVariants> {}
const SheetContent = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Content>,
SheetContentProps
>(({ side = "right", className, children, ...props }, ref) => (
<SheetPortal>
<SheetOverlay />
<SheetPrimitive.Content
ref={ref}
className={cn(sheetVariants({ side }), className)}
{...props}
>
{children}
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary border-border">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</SheetPrimitive.Close>
</SheetPrimitive.Content>
</SheetPortal>
));
SheetContent.displayName = SheetPrimitive.Content.displayName;
const SheetHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-2 text-center sm:text-left border-border",
className,
)}
{...props}
/>
);
SheetHeader.displayName = "SheetHeader";
const SheetFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 border-border",
className,
)}
{...props}
/>
);
SheetFooter.displayName = "SheetFooter";
const SheetTitle = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Title
ref={ref}
className={cn(
"text-lg font-semibold text-foreground border-border",
className,
)}
{...props}
/>
));
SheetTitle.displayName = SheetPrimitive.Title.displayName;
const SheetDescription = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground border-border", className)}
{...props}
/>
));
SheetDescription.displayName = SheetPrimitive.Description.displayName;
export {
Sheet,
SheetPortal,
SheetOverlay,
SheetTrigger,
SheetClose,
SheetContent,
SheetHeader,
SheetFooter,
SheetTitle,
SheetDescription,
};
@@ -1,61 +0,0 @@
"use client";
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
import type { VariantProps } from "class-variance-authority";
import * as React from "react";
import { toggleVariants } from "@/components/ui/toggle";
import { cn } from "@/lib/utils";
const ToggleGroupContext = React.createContext<
VariantProps<typeof toggleVariants>
>({
size: "default",
variant: "default",
});
const ToggleGroup = React.forwardRef<
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
VariantProps<typeof toggleVariants>
>(({ className, variant, size, children, ...props }, ref) => (
<ToggleGroupPrimitive.Root
ref={ref}
className={cn("flex items-center justify-center gap-1", className)}
{...props}
>
<ToggleGroupContext.Provider value={{ variant, size }}>
{children}
</ToggleGroupContext.Provider>
</ToggleGroupPrimitive.Root>
));
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
const ToggleGroupItem = React.forwardRef<
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
VariantProps<typeof toggleVariants>
>(({ className, children, variant, size, ...props }, ref) => {
const context = React.useContext(ToggleGroupContext);
return (
<ToggleGroupPrimitive.Item
ref={ref}
className={cn(
toggleVariants({
variant: context.variant || variant,
size: context.size || size,
}),
className,
)}
{...props}
>
{children}
</ToggleGroupPrimitive.Item>
);
});
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
export { ToggleGroup, ToggleGroupItem };
@@ -1,45 +0,0 @@
"use client";
import * as TogglePrimitive from "@radix-ui/react-toggle";
import { type VariantProps, cva } from "class-variance-authority";
import * as React from "react";
import { cn } from "@/lib/utils";
const toggleVariants = cva(
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
{
variants: {
variant: {
default: "bg-transparent",
outline:
"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
},
size: {
default: "h-10 px-3",
sm: "h-9 px-2.5",
lg: "h-11 px-5",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
},
);
const Toggle = React.forwardRef<
React.ElementRef<typeof TogglePrimitive.Root>,
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
VariantProps<typeof toggleVariants>
>(({ className, variant, size, ...props }, ref) => (
<TogglePrimitive.Root
ref={ref}
className={cn(toggleVariants({ variant, size, className }))}
{...props}
/>
));
Toggle.displayName = TogglePrimitive.Root.displayName;
export { Toggle, toggleVariants };
+2 -2
View File
@@ -6,8 +6,8 @@ const LOGGED_IN_ONLY_PATHS = [
// anything that _starts_ with /cli is logged in only
"/cli",
"/support",
// TODO: add any other logged in only paths here
// publish page
"/contracts/publish",
];
export function isLoginRequired(pathname: string) {
-30
View File
@@ -1,30 +0,0 @@
import {
DASHBOARD_THIRDWEB_CLIENT_ID,
DASHBOARD_THIRDWEB_SECRET_KEY,
IPFS_GATEWAY_URL,
} from "@/constants/env";
import { createThirdwebClient } from "thirdweb";
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
*/
+10
View File
@@ -1,2 +1,12 @@
import { cookies } from "next/headers";
export const COOKIE_ACTIVE_ACCOUNT = "tw_active_account";
export const COOKIE_PREFIX_TOKEN = "tw_token_";
export function getActiveAccountCookie() {
return cookies().get(COOKIE_ACTIVE_ACCOUNT)?.value;
}
export function getJWTCookie(address: string) {
return cookies().get(COOKIE_PREFIX_TOKEN + address)?.value;
}
+4
View File
@@ -16,3 +16,7 @@ export const isProd =
"production";
export const PROD_OR_DEV_URL = isProd ? "thirdweb.com" : "thirdweb-dev.com";
export const DASHBOARD_STORAGE_URL =
process.env.NEXT_PUBLIC_DASHBOARD_UPLOAD_SERVER ||
"https://storage.thirdweb.com";
@@ -0,0 +1,41 @@
import {} from "@/constants/env";
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
import { useActiveAccount } from "thirdweb/react";
import type { GetAuthTokenResponse } from "../../app/api/auth/get-auth-token/route";
import { getThirdwebClient } from "./thirdweb.server";
// returns a thirdweb client with optional JWT passed i
export function useThirdwebClient(jwt?: string) {
const account = useActiveAccount();
const query = useQuery({
queryKey: ["jwt", account?.address],
// only enable the query if there is an account and no JWT is passed in directly
enabled: !!account && !jwt,
retry: false,
queryFn: async () => {
if (!account) {
throw new Error("No account");
}
const res = await fetch(
`/api/auth/get-auth-token?address=${account.address}`,
);
if (!res.ok) {
throw new Error("Failed to get auth token");
}
const json = (await res.json()) as GetAuthTokenResponse;
return json.jwt || undefined;
},
});
return useMemo(
// prfer jwt from props over the one from the token query if it exists
() => getThirdwebClient(jwt || query.data),
[jwt, query.data],
);
}
/**
* DO NOT ADD ANYTHING TO THIS FILE IF YOU ARE NOT ABSOLUTELY SURE IT IS OK
*/
@@ -0,0 +1,23 @@
import {
DASHBOARD_THIRDWEB_CLIENT_ID,
DASHBOARD_THIRDWEB_SECRET_KEY,
IPFS_GATEWAY_URL,
} from "@/constants/env";
import { createThirdwebClient } from "thirdweb";
// returns a thirdweb client with optional JWT passed in
export function getThirdwebClient(jwt?: string) {
return createThirdwebClient({
secretKey: jwt ? jwt : DASHBOARD_THIRDWEB_SECRET_KEY,
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
*/
+1 -1
View File
@@ -15,7 +15,7 @@ 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);
const LoadingRouteHref = createStore<string | undefined>(undefined);
export function useDashboardRouter() {
const router = useRouter();
+1 -1
View File
@@ -1,4 +1,4 @@
export type Store<T> = {
type Store<T> = {
getValue(): T;
setValue(newValue: T): void;
subscribe(listener: () => void): () => void;
+7 -1
View File
@@ -27,7 +27,7 @@
--muted-foreground: 0 0% 40%;
--accent-foreground: 0 0% 9%;
--destructive-foreground: 0 0% 100%;
--inverted-foreground: var(--background);
--inverted-foreground: 0 0% 100%;
--link-foreground: 221.21deg 83.19% 53.33%;
--success-text: 142.09 70.56% 35.29%;
--warning-text: 38 92% 40%;
@@ -72,6 +72,7 @@
--warning-text: 38 92% 50%;
--destructive-text: 360 72% 55%;
--success-text: 142 75% 50%;
--inverted-foreground: 0 0% 0%;
/* Borders */
--border: 0 0% 15%;
@@ -138,3 +139,8 @@
scrollbar-width: none; /* Firefox */
}
}
body,
html {
height: 100%;
}
@@ -1,6 +1,3 @@
import type { ContractType } from "constants/contracts";
import { ZERO_ADDRESS } from "thirdweb";
export const networkKeys = {
all: ["network"] as const,
chain: (chainId?: number) => [...networkKeys.all, chainId] as const,
@@ -108,58 +105,3 @@ export const engineKeys = {
queueMetrics: (engineId: string) =>
[...engineKeys.all, engineId, "queueMetrics"] as const,
};
export const contractKeys = {
all: ["contract"] as const,
lists: () => [...contractKeys.all, "list"] as const,
list: (address = ZERO_ADDRESS) => [...contractKeys.lists(), address] as const,
listWithFilters: (address = ZERO_ADDRESS, filters?: ContractType[]) =>
[...contractKeys.list(address), { filters }] as const,
details: () => [...contractKeys.all, "detail"] as const,
detail: (address: string = ZERO_ADDRESS) =>
[...contractKeys.details(), address] as const,
};
export const walletKeys = {
all: ["balance"] as const,
balances: (walletAddress: string) =>
[...splitsKeys.all, walletAddress] as const,
};
export const splitsKeys = {
all: ["splits"] as const,
lists: () => [...splitsKeys.all, "list"] as const,
list: (address = ZERO_ADDRESS) => [...splitsKeys.lists(), address] as const,
detail: (address = ZERO_ADDRESS) => [...splitsKeys.all, address] as const,
currencies: (address = ZERO_ADDRESS) =>
[...splitsKeys.detail(address), "currencies"] as const,
balances: (address = ZERO_ADDRESS) =>
[...splitsKeys.detail(address), "balances"] as const,
};
export const voteKeys = {
all: ["vote"] as const,
detail: (address = ZERO_ADDRESS) => [...voteKeys.all, address] as const,
proposals: (address = ZERO_ADDRESS) =>
[...voteKeys.detail(address), "proposals"] as const,
proposal: (proposalId = "-1", address = ZERO_ADDRESS) =>
[...voteKeys.proposals(address), proposalId] as const,
balances: (address = ZERO_ADDRESS, addresses = [] as string[]) =>
[...voteKeys.detail(address), "balances", { addresses }] as const,
delegations: (address = ZERO_ADDRESS) =>
[...voteKeys.detail(address), "delegations"] as const,
delegation: (address = ZERO_ADDRESS, userAddress = ZERO_ADDRESS) =>
[...voteKeys.delegations(address), userAddress] as const,
userHasVotedOnProposal: (
proposalId = "-1",
address = ZERO_ADDRESS,
userAddress = ZERO_ADDRESS,
) =>
[
...voteKeys.proposal(proposalId, address),
"hasVotedOnProposal",
userAddress,
] as const,
canExecuteProposal: (proposalId = "-1", address = ZERO_ADDRESS) =>
[...voteKeys.proposal(proposalId, address), "canExecute"] as const,
};
@@ -2,12 +2,15 @@
import { Spinner } from "@/components/ui/Spinner/Spinner";
import { Button } from "@/components/ui/button";
import { thirdwebClient } from "@/constants/client";
import { useThirdwebClient } from "@/constants/thirdweb.client";
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 {
useSupportedChains,
useSupportedChainsRecord,
} from "hooks/chains/configureChains";
import {
useAddRecentlyUsedChainId,
useRecentlyUsedChains,
@@ -29,6 +32,7 @@ export const CustomConnectWallet = (props: {
connectButtonClassName?: string;
detailsButtonClassName?: string;
}) => {
const thirdwebClient = useThirdwebClient();
const loginRequired =
props.loginRequired === undefined ? true : props.loginRequired;
const { theme } = useTheme();
@@ -37,12 +41,17 @@ export const CustomConnectWallet = (props: {
// const setIsNetworkConfigModalOpen = useSetIsNetworkConfigModalOpen();
const t = theme === "light" ? "light" : "dark";
const allv4Chains = useSupportedChains();
const chainsRecord = useSupportedChainsRecord();
const favChainsQuery = useFavoriteChains();
const setIsNetworkConfigModalOpen = useSetIsNetworkConfigModalOpen();
const allChains = useMemo(() => {
return allv4Chains.map(mapV4ChainToV5Chain);
}, [allv4Chains]);
const popularChainsWithMeta = useMemo(() => {
return popularChains.map((x) => chainsRecord[x.id] || x);
}, [chainsRecord]);
const chainSections = useMemo(() => {
return [
{
@@ -51,14 +60,14 @@ export const CustomConnectWallet = (props: {
},
{
label: "Popular",
chains: popularChains,
chains: popularChainsWithMeta.map(mapV4ChainToV5Chain),
},
{
label: "Recent",
chains: recentChainsv4.map(mapV4ChainToV5Chain),
},
];
}, [recentChainsv4, favChainsQuery.data]);
}, [recentChainsv4, favChainsQuery.data, popularChainsWithMeta]);
// ensures login status on pages that need it
const { isLoading, isLoggedIn } = useLoggedInUser();
@@ -140,7 +149,7 @@ export const CustomConnectWallet = (props: {
);
};
export function ConnectWalletWelcomeScreen(props: {
function ConnectWalletWelcomeScreen(props: {
theme: "light" | "dark";
subtitle?: string;
}) {
@@ -214,6 +223,7 @@ export function ConnectWalletWelcomeScreen(props: {
export function useCustomConnectModal() {
const { connect } = useConnectModal();
const { theme } = useTheme();
const thirdwebClient = useThirdwebClient();
return useCallback(
(options?: { chain?: Chain }) => {
@@ -236,7 +246,7 @@ export function useCustomConnectModal() {
theme: getSDKTheme(theme === "light" ? "light" : "dark"),
});
},
[connect, theme],
[connect, theme, thirdwebClient],
);
}
@@ -1,3 +1,2 @@
export * from "./useActiveChainId";
export * from "./useCommon";
export * from "./useWalletNFTs";
@@ -39,7 +39,11 @@ export function useQueryWithNetwork<
networkKeys.chain(activeChainId) as readonly unknown[]
).concat(queryKey) as unknown as TQueryKey;
return useQuery(combinedQueryKey, queryFn, mergedOptions);
return useQuery({
...mergedOptions,
queryKey: combinedQueryKey,
queryFn,
});
}
export function useMutationWithInvalidate<
TData = unknown,
@@ -71,19 +75,20 @@ export function useMutationWithInvalidate<
(cacheKeysToInvalidate: TQueryKey[]) => {
return Promise.all(
cacheKeysToInvalidate.map((cacheKey) => {
return queryClient.invalidateQueries(
(networkKeys.chain(activeChainId) as readonly unknown[]).concat(
cacheKey,
) as unknown[],
);
return queryClient.invalidateQueries({
queryKey: (
networkKeys.chain(activeChainId) as readonly unknown[]
).concat(cacheKey) as unknown[],
});
}),
);
},
[queryClient, activeChainId],
);
return useMutation(mutationFn, {
return useMutation({
...options,
mutationFn,
onSuccess: (...args) => {
if (options?.onSuccess) {
options.onSuccess(...args, invalidate);
@@ -172,7 +172,7 @@ interface UpdateKeyServiceInput {
actions?: string[];
}
interface CreateKeyInput {
export interface CreateKeyInput {
name?: string;
domains?: string[];
bundleIds?: string[];
@@ -254,15 +254,16 @@ export interface BillingCredit {
interface UseAccountInput {
refetchInterval?:
| number
| false
| ((
data: Account | undefined,
query: Query<
Account,
unknown,
Error,
Account,
readonly ["account", string, "me"]
>,
) => number | false);
) => number | false | undefined)
| undefined;
}
export function useAccount({ refetchInterval }: UseAccountInput = {}) {
@@ -286,7 +287,7 @@ export function useAccount({ refetchInterval }: UseAccountInput = {}) {
return json.data as Account;
},
enabled: !!user?.address && isLoggedIn,
refetchInterval: refetchInterval ?? false,
refetchInterval,
});
}
@@ -444,8 +445,8 @@ export function useUpdateAccount() {
const { user } = useLoggedInUser();
const queryClient = useQueryClient();
return useMutationWithInvalidate(
async (input: UpdateAccountInput) => {
return useMutation({
mutationFn: async (input: UpdateAccountInput) => {
invariant(user?.address, "walletAddress is required");
const res = await fetch(`${THIRDWEB_API_HOST}/v1/account`, {
@@ -465,14 +466,13 @@ export function useUpdateAccount() {
return json.data;
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
accountKeys.me(user?.address as string),
);
},
onSuccess: () => {
return queryClient.invalidateQueries({
queryKey: accountKeys.me(user?.address as string),
});
},
);
});
}
export function useUpdateAccountPlan(waitForWebhook?: boolean) {
@@ -507,13 +507,15 @@ export function useUpdateAccountPlan(waitForWebhook?: boolean) {
return json.data;
},
{
onSuccess: () => {
onSuccess: async () => {
// invalidate usage data as limits are different
queryClient.invalidateQueries(accountKeys.me(user?.address as string));
await queryClient.invalidateQueries({
queryKey: accountKeys.me(user?.address as string),
});
return queryClient.invalidateQueries(
accountKeys.usage(user?.address as string),
);
return queryClient.invalidateQueries({
queryKey: accountKeys.usage(user?.address as string),
});
},
},
);
@@ -545,9 +547,9 @@ export function useUpdateNotifications() {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
accountKeys.me(user?.address as string),
);
return queryClient.invalidateQueries({
queryKey: accountKeys.me(user?.address as string),
});
},
},
);
@@ -608,16 +610,19 @@ export function useConfirmEmail() {
return json.data;
},
{
onSuccess: () => {
onSuccess: async () => {
// invalidate related cache, since could be relinking account
queryClient.invalidateQueries(apiKeys.keys(user?.address as string));
queryClient.invalidateQueries(
accountKeys.usage(user?.address as string),
);
return queryClient.invalidateQueries(
accountKeys.me(user?.address as string),
);
return Promise.all([
queryClient.invalidateQueries({
queryKey: apiKeys.keys(user?.address as string),
}),
queryClient.invalidateQueries({
queryKey: accountKeys.usage(user?.address as string),
}),
queryClient.invalidateQueries({
queryKey: accountKeys.me(user?.address as string),
}),
]);
},
},
);
@@ -652,9 +657,9 @@ export function useResendEmailConfirmation() {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
accountKeys.me(user?.address as string),
);
return queryClient.invalidateQueries({
queryKey: accountKeys.me(user?.address as string),
});
},
},
);
@@ -688,9 +693,9 @@ export function useCreatePaymentMethod() {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
accountKeys.me(user?.address as string),
);
return queryClient.invalidateQueries({
queryKey: accountKeys.me(user?.address as string),
});
},
},
);
@@ -723,8 +728,8 @@ export function useCreateApiKey() {
const { user } = useLoggedInUser();
const queryClient = useQueryClient();
return useMutation(
async (input: CreateKeyInput) => {
return useMutation({
mutationFn: async (input: CreateKeyInput) => {
invariant(user?.address, "walletAddress is required");
const res = await fetch(`${THIRDWEB_API_HOST}/v1/keys`, {
@@ -743,14 +748,13 @@ export function useCreateApiKey() {
return json.data as ApiKey;
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
apiKeys.keys(user?.address as string),
);
},
onSuccess: () => {
return queryClient.invalidateQueries({
queryKey: apiKeys.keys(user?.address as string),
});
},
);
});
}
export function useUpdateApiKey() {
@@ -780,9 +784,9 @@ export function useUpdateApiKey() {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
apiKeys.keys(user?.address as string),
);
return queryClient.invalidateQueries({
queryKey: apiKeys.keys(user?.address as string),
});
},
},
);
@@ -814,9 +818,9 @@ export function useRevokeApiKey() {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
apiKeys.keys(user?.address as string),
);
return queryClient.invalidateQueries({
queryKey: apiKeys.keys(user?.address as string),
});
},
},
);
@@ -869,41 +873,14 @@ export const useUpdatePolicies = () => {
},
{
onSuccess: (_, variables) => {
return queryClient.invalidateQueries(["policies", variables.serviceId]);
return queryClient.invalidateQueries({
queryKey: ["policies", variables.serviceId],
});
},
},
);
};
export function useAuthorizeWalletWithAccount() {
const { user } = useLoggedInUser();
return useMutationWithInvalidate(
async (variables: { token: string; deviceName?: string }) => {
invariant(user?.address, "walletAddress is required");
const res = await fetch(`${THIRDWEB_API_HOST}/v1/jwt/authorize-wallet`, {
method: "POST",
headers: {
"Content-Type": "application/json",
authorization: `Bearer ${variables.token}`,
},
body: JSON.stringify({
deviceName: variables.deviceName,
}),
});
const json = await res.json();
if (json.error) {
throw new Error(json.error.message);
}
return json.data;
},
);
}
export function useRevokeAuthorizedWallet() {
const { user } = useLoggedInUser();
const queryClient = useQueryClient();
@@ -935,9 +912,11 @@ export function useRevokeAuthorizedWallet() {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
authorizedWallets.authorizedWallets(user?.address as string),
);
return queryClient.invalidateQueries({
queryKey: authorizedWallets.authorizedWallets(
user?.address as string,
),
});
},
},
);
@@ -965,14 +944,14 @@ export function useAuthorizedWallets() {
return json.data as AuthorizedWallet[];
},
enabled: !!user?.address && isLoggedIn,
cacheTime: 0,
gcTime: 0,
});
}
/**
*
*/
export async function fetchChainsFromApi() {
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");
@@ -1,45 +0,0 @@
export function usePascalCaseContractName(contractName: string) {
if (!contractName) {
return null;
}
if (contractName === "nft-drop") {
return "NFTDrop";
}
if (contractName === "edition-drop") {
return "EditionDrop";
}
if (contractName === "nft-collection") {
return "NFTCollection";
}
if (contractName === "edition") {
return "Edition";
}
if (contractName === "token") {
return "Token";
}
if (contractName === "marketplace") {
return "Marketplace";
}
if (contractName === "vote") {
return "Vote";
}
if (contractName === "split") {
return "Split";
}
if (contractName === "token-drop") {
return "TokenDrop";
}
if (contractName === "signature-drop") {
return "SignatureDrop";
}
if (contractName === "pack") {
return "Pack";
}
if (contractName === "multiwrap") {
return "Multiwrap";
}
if (contractName === "marketplace-v3") {
return "MarketplaceV3";
}
return contractName;
}
@@ -1,4 +1,4 @@
import { thirdwebClient } from "@/constants/client";
import { useThirdwebClient } from "@/constants/thirdweb.client";
import { useMutation } from "@tanstack/react-query";
import { upload } from "thirdweb/storage";
@@ -8,6 +8,7 @@ type DashboardUploadOptions = {
};
export function useDashboardStorageUpload(options?: DashboardUploadOptions) {
const thirdwebClient = useThirdwebClient();
return useMutation({
mutationFn: async (files: Array<File | string>): Promise<string[]> => {
const uris = await upload({
@@ -8,12 +8,6 @@ import { engineKeys } from "../cache-keys";
import { useMutationWithInvalidate } from "./query/useQueryWithNetwork";
import { useLoggedInUser } from "./useLoggedInUser";
export function useEngineConnectedInstance() {
const [instance, setInstance] = useState<EngineInstance | null>(null);
return { instance, setInstance };
}
export type EngineTier = "STARTER" | "PREMIUM" | "ENTERPRISE";
// Engine instances
@@ -116,7 +110,7 @@ export function useEngineBackendWallets(instance: string) {
});
}
export interface EngineSystemHealth {
interface EngineSystemHealth {
status: string;
engineVersion?: string;
features?: string[];
@@ -143,7 +137,7 @@ export function useEngineSystemHealth(
});
}
export interface EngineSystemQueueMetrics {
interface EngineSystemQueueMetrics {
result: {
queued: number;
pending: number;
@@ -197,24 +191,26 @@ interface UpdateVersionInput {
}
export function useEngineUpdateVersion() {
return useMutation(async (input: UpdateVersionInput) => {
invariant(input.engineId, "engineId is required");
return useMutation({
mutationFn: async (input: UpdateVersionInput) => {
invariant(input.engineId, "engineId is required");
const res = await fetch(`${THIRDWEB_API_HOST}/v1/engine/update-version`, {
method: "POST",
const res = await fetch(`${THIRDWEB_API_HOST}/v1/engine/update-version`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
engineId: input.engineId,
}),
});
// we never use the response body
res.body?.cancel();
if (!res.ok) {
throw new Error(`Unexpected status ${res.status}: ${await res.text()}`);
}
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
engineId: input.engineId,
}),
});
// we never use the response body
res.body?.cancel();
if (!res.ok) {
throw new Error(`Unexpected status ${res.status}: ${await res.text()}`);
}
},
});
}
@@ -222,8 +218,8 @@ export function useEngineRemoveFromDashboard() {
const { user } = useLoggedInUser();
const queryClient = useQueryClient();
return useMutation(
async (instanceId: string) => {
return useMutation({
mutationFn: async (instanceId: string) => {
invariant(instanceId, "instance is required");
const res = await fetch(`${THIRDWEB_API_HOST}/v1/engine/${instanceId}`, {
@@ -235,14 +231,13 @@ export function useEngineRemoveFromDashboard() {
throw new Error(`Unexpected status ${res.status}: ${await res.text()}`);
}
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
engineKeys.instances(user?.address as string),
);
},
onSuccess: () => {
return queryClient.invalidateQueries({
queryKey: engineKeys.instances(user?.address as string),
});
},
);
});
}
export interface RemoveCloudHostedInput {
@@ -255,8 +250,12 @@ export function useEngineRemoveCloudHosted() {
const { user } = useLoggedInUser();
const queryClient = useQueryClient();
return useMutation(
async ({ instanceId, reason, feedback }: RemoveCloudHostedInput) => {
return useMutation({
mutationFn: async ({
instanceId,
reason,
feedback,
}: RemoveCloudHostedInput) => {
const res = await fetch(
`${THIRDWEB_API_HOST}/v1/engine/${instanceId}/remove-cloud-hosted`,
{
@@ -274,14 +273,13 @@ export function useEngineRemoveCloudHosted() {
throw new Error(`Unexpected status ${res.status}: ${await res.text()}`);
}
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
engineKeys.instances(user?.address as string),
);
},
onSuccess: () => {
return queryClient.invalidateQueries({
queryKey: engineKeys.instances(user?.address as string),
});
},
);
});
}
export interface EditEngineInstanceInput {
@@ -294,8 +292,8 @@ export function useEngineEditInstance() {
const { user } = useLoggedInUser();
const queryClient = useQueryClient();
return useMutation(
async ({ instanceId, name, url }: EditEngineInstanceInput) => {
return useMutation({
mutationFn: async ({ instanceId, name, url }: EditEngineInstanceInput) => {
const res = await fetch(`${THIRDWEB_API_HOST}/v1/engine/${instanceId}`, {
method: "PUT",
@@ -310,14 +308,13 @@ export function useEngineEditInstance() {
throw new Error(`Unexpected status ${res.status}: ${await res.text()}`);
}
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
engineKeys.instances(user?.address as string),
);
},
onSuccess: () => {
return queryClient.invalidateQueries({
queryKey: engineKeys.instances(user?.address as string),
});
},
);
});
}
export type Transaction = {
@@ -592,7 +589,9 @@ export function useEngineAddKeypair(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.keypairs(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.keypairs(instance),
});
},
},
);
@@ -625,7 +624,9 @@ export function useEngineRemoveKeypair(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.keypairs(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.keypairs(instance),
});
},
},
);
@@ -690,7 +691,9 @@ export function useEngineCreateRelayer(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.relayers(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.relayers(instance),
});
},
},
);
@@ -723,7 +726,9 @@ export function useEngineRevokeRelayer(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.relayers(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.relayers(instance),
});
},
},
);
@@ -761,7 +766,9 @@ export function useEngineUpdateRelayer(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.relayers(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.relayers(instance),
});
},
},
);
@@ -839,7 +846,9 @@ export function useEngineSetWalletConfig(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.walletConfig(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.walletConfig(instance),
});
},
},
);
@@ -872,9 +881,9 @@ export function useEngineCreateBackendWallet(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
engineKeys.backendWallets(instance),
);
return queryClient.invalidateQueries({
queryKey: engineKeys.backendWallets(instance),
});
},
},
);
@@ -908,9 +917,9 @@ export function useEngineUpdateBackendWallet(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
engineKeys.backendWallets(instance),
);
return queryClient.invalidateQueries({
queryKey: engineKeys.backendWallets(instance),
});
},
},
);
@@ -959,9 +968,9 @@ export function useEngineImportBackendWallet(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
engineKeys.backendWallets(instance),
);
return queryClient.invalidateQueries({
queryKey: engineKeys.backendWallets(instance),
});
},
},
);
@@ -990,7 +999,9 @@ export function useEngineGrantPermissions(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.permissions(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.permissions(instance),
});
},
},
);
@@ -1023,7 +1034,9 @@ export function useEngineRevokePermissions(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.permissions(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.permissions(instance),
});
},
},
);
@@ -1056,7 +1069,9 @@ export function useEngineCreateAccessToken(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.accessTokens(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.accessTokens(instance),
});
},
},
);
@@ -1089,7 +1104,9 @@ export function useEngineRevokeAccessToken(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.accessTokens(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.accessTokens(instance),
});
},
},
);
@@ -1123,7 +1140,9 @@ export function useEngineUpdateAccessToken(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.accessTokens(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.accessTokens(instance),
});
},
},
);
@@ -1158,7 +1177,9 @@ export function useEngineCreateWebhook(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.webhooks(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.webhooks(instance),
});
},
},
);
@@ -1191,7 +1212,9 @@ export function useEngineRevokeWebhook(instance: string) {
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.webhooks(instance));
return queryClient.invalidateQueries({
queryKey: engineKeys.webhooks(instance),
});
},
},
);
@@ -1208,31 +1231,33 @@ type SendTokensInput = {
export function useEngineSendTokens(instance: string) {
const token = useLoggedInUser().user?.jwt ?? null;
return useMutation(async (input: SendTokensInput) => {
invariant(instance, "instance is required");
return useMutation({
mutationFn: async (input: SendTokensInput) => {
invariant(instance, "instance is required");
const res = await fetch(
`${instance}backend-wallet/${input.chainId}/transfer`,
{
method: "POST",
headers: {
...getEngineRequestHeaders(token),
"x-backend-wallet-address": input.fromAddress,
const res = await fetch(
`${instance}backend-wallet/${input.chainId}/transfer`,
{
method: "POST",
headers: {
...getEngineRequestHeaders(token),
"x-backend-wallet-address": input.fromAddress,
},
body: JSON.stringify({
to: input.toAddress,
amount: input.amount.toString(),
currencyAddress: input.currencyAddress,
}),
},
body: JSON.stringify({
to: input.toAddress,
amount: input.amount.toString(),
currencyAddress: input.currencyAddress,
}),
},
);
const json = await res.json();
);
const json = await res.json();
if (json.error) {
throw new Error(json.error.message);
}
if (json.error) {
throw new Error(json.error.message);
}
return json.result;
return json.result;
},
});
}
@@ -1263,8 +1288,8 @@ export function useEngineSetCorsConfiguration(instance: string) {
const queryClient = useQueryClient();
const token = useLoggedInUser().user?.jwt ?? null;
return useMutation(
async (input: SetCorsUrlInput) => {
return useMutation({
mutationFn: async (input: SetCorsUrlInput) => {
invariant(instance, "instance is required");
const res = await fetch(`${instance}configuration/cors`, {
@@ -1280,12 +1305,13 @@ export function useEngineSetCorsConfiguration(instance: string) {
return json.result;
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.corsUrls(instance));
},
onSuccess: () => {
return queryClient.invalidateQueries({
queryKey: engineKeys.corsUrls(instance),
});
},
);
});
}
export function useEngineIpAllowlistConfiguration(instance: string) {
@@ -1320,8 +1346,8 @@ export function useEngineSetIpAllowlistConfiguration(instance: string) {
const queryClient = useQueryClient();
const token = useLoggedInUser().user?.jwt ?? null;
return useMutation(
async (input: SetIpAllowlistInput) => {
return useMutation({
mutationFn: async (input: SetIpAllowlistInput) => {
invariant(instance, "instance is required");
const res = await fetch(`${instance}configuration/ip-allowlist`, {
@@ -1337,12 +1363,13 @@ export function useEngineSetIpAllowlistConfiguration(instance: string) {
return json.result;
},
{
onSuccess: () => {
return queryClient.invalidateQueries(engineKeys.ipAllowlist(instance));
},
onSuccess: () => {
return queryClient.invalidateQueries({
queryKey: engineKeys.ipAllowlist(instance),
});
},
);
});
}
export interface EngineContractSubscription {
@@ -1392,8 +1419,8 @@ export function useEngineAddContractSubscription(instance: string) {
const queryClient = useQueryClient();
const token = useLoggedInUser().user?.jwt ?? null;
return useMutation(
async (input: AddContractSubscriptionInput) => {
return useMutation({
mutationFn: async (input: AddContractSubscriptionInput) => {
invariant(instance, "instance is required");
const res = await fetch(`${instance}contract-subscriptions/add`, {
@@ -1409,17 +1436,16 @@ export function useEngineAddContractSubscription(instance: string) {
return json.result;
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
engineKeys.contractSubscriptions(instance),
);
},
onSuccess: () => {
return queryClient.invalidateQueries({
queryKey: engineKeys.contractSubscriptions(instance),
});
},
);
});
}
export interface RemoveContractSubscriptionInput {
interface RemoveContractSubscriptionInput {
contractSubscriptionId: string;
}
@@ -1427,8 +1453,8 @@ export function useEngineRemoveContractSubscription(instance: string) {
const queryClient = useQueryClient();
const token = useLoggedInUser().user?.jwt ?? null;
return useMutation(
async (input: RemoveContractSubscriptionInput) => {
return useMutation({
mutationFn: async (input: RemoveContractSubscriptionInput) => {
invariant(instance, "instance is required");
const res = await fetch(`${instance}contract-subscriptions/remove`, {
@@ -1444,14 +1470,13 @@ export function useEngineRemoveContractSubscription(instance: string) {
return json.result;
},
{
onSuccess: () => {
return queryClient.invalidateQueries(
engineKeys.contractSubscriptions(instance),
);
},
onSuccess: () => {
return queryClient.invalidateQueries({
queryKey: engineKeys.contractSubscriptions(instance),
});
},
);
});
}
export function useEngineSubscriptionsLastBlock(
@@ -1481,7 +1506,7 @@ export function useEngineSubscriptionsLastBlock(
});
}
export interface EngineResourceMetrics {
interface EngineResourceMetrics {
error: string;
data: {
cpu: number;
@@ -3,7 +3,7 @@ import { useDashboardRouter } from "@/lib/DashboardRouter";
import { useQuery } from "@tanstack/react-query";
import type { EnsureLoginResponse } from "app/api/auth/ensure-login/route";
import { usePathname } from "next/navigation";
import { useRef } from "react";
import { useEffect, useState } from "react";
import {
useActiveAccount,
useActiveWalletConnectionStatus,
@@ -27,10 +27,16 @@ export function useLoggedInUser(): {
const connectionStatus = useActiveWalletConnectionStatus();
// this is to work around the fact that `connectionStatus` ends up as "disconnected"
// which we *do* care about, but only after we have been "connecting" at least once
const statusWasEverConnecting = useRef(false);
if (connectionStatus === "connecting" || connectionStatus === "connected") {
statusWasEverConnecting.current = true;
}
const [statusWasEverConnecting, setStatusWasEverConnecting] = useState(
connectionStatus === "connecting" || connectionStatus === "connected",
);
// needs to be a useEffect for now
// eslint-disable-next-line no-restricted-syntax
useEffect(() => {
if (connectionStatus === "connecting" || connectionStatus === "connected") {
setStatusWasEverConnecting(true);
}
}, [connectionStatus]);
const query = useQuery({
// enabled if:
@@ -40,7 +46,7 @@ export function useLoggedInUser(): {
enabled:
!!pathname &&
connectionStatus !== "connecting" &&
statusWasEverConnecting.current &&
statusWasEverConnecting &&
isLoginRequired(pathname),
// the last "persist", part of the queryKey, is to make sure that we do not cache this query in indexDB
// convention in v4 of the SDK that we are (ab)using here
@@ -63,20 +69,16 @@ export function useLoggedInUser(): {
return (await res.json()) as EnsureLoginResponse;
},
onSuccess: (data) => {
if (data.redirectTo) {
router.replace(data.redirectTo);
}
if (data.jwt) {
// necessary for legacy things for now (SDK picks it up from there)
// eslint-disable-next-line react-compiler/react-compiler
window.TW_AUTH_TOKEN = data.jwt;
} else {
window.TW_AUTH_TOKEN = undefined;
}
},
});
// legit use-case for now
// eslint-disable-next-line no-restricted-syntax
useEffect(() => {
if (query.data?.redirectTo) {
router.replace(query.data.redirectTo);
}
}, [query.data?.redirectTo, router]);
// if we are "disconnected" we are not logged in
if (connectionStatus === "disconnected") {
return {
@@ -15,7 +15,7 @@ import { remove } from "thirdweb/extensions/thirdweb";
import { useActiveAccount } from "thirdweb/react";
import invariant from "tiny-invariant";
function useMultiChainRegContractList(walletAddress?: string) {
export function useMultiChainRegContractList(walletAddress?: string) {
return useQuery({
queryKey: ["dashboard-registry", walletAddress, "multichain-contract-list"],
queryFn: async () => {
@@ -88,8 +88,8 @@ export function useRemoveContractMutation() {
const { chainIdToChainRecord } = useAllChainsData();
const queryClient = useQueryClient();
const account = useActiveAccount();
return useMutation(
async (data: RemoveContractParams) => {
return useMutation({
mutationFn: async (data: RemoveContractParams) => {
invariant(chainIdToChainRecord, "chains not initialzed yet");
invariant(data.chainId, "chainId not provided");
invariant(account, "No wallet connected");
@@ -111,12 +111,13 @@ export function useRemoveContractMutation() {
},
});
},
{
onSettled: () => {
return queryClient.invalidateQueries(["dashboard-registry"]);
},
onSettled: () => {
return queryClient.invalidateQueries({
queryKey: ["dashboard-registry"],
});
},
);
});
}
type AddContractParams = {
@@ -129,8 +130,8 @@ export function useAddContractMutation() {
const queryClient = useQueryClient();
return useMutation(
async (data: AddContractParams) => {
return useMutation({
mutationFn: async (data: AddContractParams) => {
invariant(account, "cannot add a contract without an address");
return await addContractToMultiChainRegistry(
@@ -142,10 +143,11 @@ export function useAddContractMutation() {
300000n,
);
},
{
onSettled: () => {
return queryClient.invalidateQueries(["dashboard-registry"]);
},
onSettled: () => {
return queryClient.invalidateQueries({
queryKey: ["dashboard-registry"],
});
},
);
});
}
@@ -1,55 +1,62 @@
import {
queryOptions,
useMutation,
useQuery,
useQueryClient,
} from "@tanstack/react-query";
import type {
BalanceQueryRequest,
BalanceQueryResponse,
} from "pages/api/moralis/balances";
import { toast } from "sonner";
import type { ThirdwebContract } from "thirdweb";
import { type ThirdwebContract, sendAndConfirmTransaction } from "thirdweb";
import { distribute, distributeByToken } from "thirdweb/extensions/split";
import { useSendAndConfirmTransaction } from "thirdweb/react";
import { useActiveAccount } from "thirdweb/react";
import invariant from "tiny-invariant";
import { splitsKeys } from "..";
import {
useMutationWithInvalidate,
useQueryWithNetwork,
} from "./query/useQueryWithNetwork";
async function getSplitBalances(contract: ThirdwebContract) {
const query = await fetch("/api/moralis/balances", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
chainId: contract.chain.id,
address: contract.address,
} as BalanceQueryRequest),
});
if (query.status >= 400) {
throw new Error(await query.json().then((r) => r.error));
}
return query.json() as Promise<BalanceQueryResponse>;
}
function getQuery(contract: ThirdwebContract) {
return queryOptions({
queryKey: ["split-balances", contract.chain.id, contract.address],
queryFn: () => getSplitBalances(contract),
retry: false,
});
}
export function useSplitBalances(contract: ThirdwebContract) {
const chainId = contract.chain.id;
const contractAddress = contract.address;
const currencies = useQueryWithNetwork(
splitsKeys.currencies(contractAddress),
async () => {
const query = await fetch("/api/moralis/balances", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
chainId,
address: contractAddress,
} as BalanceQueryRequest),
});
if (query.status >= 400) {
throw new Error(await query.json().then((r) => r.error));
}
return query.json() as Promise<BalanceQueryResponse>;
},
{ enabled: !!chainId && !!contractAddress, retry: false },
);
return currencies;
return useQuery(getQuery(contract));
}
export function useSplitDistributeFunds(contract: ThirdwebContract) {
const contractAddress = contract.address;
const balances = useSplitBalances(contract);
const { mutateAsync } = useSendAndConfirmTransaction();
const account = useActiveAccount();
const queryClient = useQueryClient();
return useMutationWithInvalidate(
async () => {
invariant(contract, "split contract is not ready");
invariant(balances.data, "No balances to distribute");
const distributions = (balances.data || [])
return useMutation({
mutationFn: async () => {
invariant(account, "No active account");
const balances =
// get the cached data if it exists, otherwise fetch it
queryClient.getQueryData(getQuery(contract).queryKey) ||
(await queryClient.fetchQuery(getQuery(contract)));
const distributions = balances
.filter((token) => token.display_balance !== "0.0")
.map(async (currency) => {
const transaction =
@@ -59,24 +66,21 @@ export function useSplitDistributeFunds(contract: ThirdwebContract) {
contract,
tokenAddress: currency.token_address,
});
const promise = mutateAsync(transaction);
const promise = sendAndConfirmTransaction({
transaction,
account,
});
toast.promise(promise, {
success: `Successfully distributed ${currency.name}`,
error: `Error distributing ${currency.name}`,
loading: "Distributing funds",
loading: `Distributing ${currency.name}`,
});
});
return await Promise.all(distributions);
},
{
onSuccess: (_data, _variables, _options, invalidate) => {
return invalidate([
splitsKeys.currencies(contractAddress),
splitsKeys.balances(contractAddress),
splitsKeys.list(contractAddress),
]);
},
onSettled: () => {
queryClient.invalidateQueries(getQuery(contract));
},
);
});
}
@@ -1,288 +1,103 @@
import { thirdwebClient } from "@/constants/client";
import { type ThirdwebContract, getContract, toTokens } from "thirdweb";
import { useMutation } from "@tanstack/react-query";
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";
type BaseTransactionOptions,
type ThirdwebContract,
getAddress,
getContract,
toTokens,
} from "thirdweb";
import * as ERC20Ext from "thirdweb/extensions/erc20";
import * as VoteExt from "thirdweb/extensions/vote";
import { useSendAndConfirmTransaction } from "thirdweb/react";
import type { Account } from "thirdweb/wallets";
import invariant from "tiny-invariant";
import { voteKeys } from "../cache-keys";
import {
useMutationWithInvalidate,
useQueryWithNetwork,
} from "./query/useQueryWithNetwork";
export function useVoteProposalList(contract?: ThirdwebContract) {
return useQueryWithNetwork(
voteKeys.proposals(contract?.address || ""),
async () => {
invariant(contract, "contract is required");
return await getAll({ contract });
},
{
enabled: !!contract,
},
);
export async function tokensDelegated(
options: BaseTransactionOptions<{ account: Account | undefined }>,
) {
if (!options.account) {
throw new Error("Expected an account to be passed in options");
}
const tokenAddress = await VoteExt.token(options);
if (!tokenAddress) {
throw new Error("Expected a delegated token address");
}
const tokenContract = getContract({
...options.contract,
address: tokenAddress,
});
const delegatedAddress = await ERC20Ext.delegates({
contract: tokenContract,
account: options.account.address,
});
return getAddress(delegatedAddress) === getAddress(options.account.address);
}
export function useHasVotedOnProposal(
contract: ThirdwebContract,
proposalId: bigint,
export async function voteTokenBalances(
options: BaseTransactionOptions<{ addresses: string[] }>,
) {
const userAddress = useActiveAccount()?.address;
return useQueryWithNetwork(
voteKeys.userHasVotedOnProposal(
proposalId.toString(),
contract.address,
userAddress,
invariant(options.addresses.length, "addresses are required");
const tokenAddress = await VoteExt.token({ contract: options.contract });
if (!tokenAddress) {
throw new Error("Expected a delegated token address");
}
const tokenContract = getContract({
...options.contract,
address: tokenAddress,
});
const [decimals, balanceData] = await Promise.all([
ERC20Ext.decimals({ contract: tokenContract }),
Promise.all(
options.addresses.map((address) =>
ERC20Ext.balanceOf({ contract: tokenContract, address }),
),
),
async () => {
invariant(userAddress, "address is required");
return await hasVoted({ contract, proposalId, account: userAddress });
},
{
enabled: !!contract,
},
);
}
export function useCanExecuteProposal(
contract: ThirdwebContract,
proposalId: bigint,
) {
return useQueryWithNetwork(
voteKeys.canExecuteProposal(proposalId.toString(), contract.address),
async () => await canExecute({ contract, proposalId }),
{
enabled: !!contract,
},
);
}
export function useTokensDelegated(contract: ThirdwebContract) {
const userAddress = useActiveAccount()?.address;
return useQueryWithNetwork(
voteKeys.delegation(contract.address, userAddress),
async () => {
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 && !!userAddress,
},
);
}
export function useVoteTokenBalances(
contract: ThirdwebContract,
addresses: string[],
) {
return useQueryWithNetwork(
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: toTokens(balance, _decimals),
decimals: _decimals,
};
});
return await Promise.all(balances);
},
{
enabled: addresses.length > 0,
},
);
}
export interface IProposalInput {
description: string;
}
/**
* 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(
async (proposal: IProposalInput) => {
const { description } = proposal;
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(contract.address)]);
},
},
);
}
export function useDelegateMutation(contract: ThirdwebContract) {
const userAddress = useActiveAccount()?.address;
const { mutateAsync } = useSendAndConfirmTransaction();
return useMutationWithInvalidate(
async () => {
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(contract.address, userAddress)]);
},
},
);
]);
return options.addresses.map((address, index) => {
const balance = balanceData[index] || 0n;
return {
address,
balance: toTokens(balance, decimals),
decimals: decimals,
};
});
}
/**
* Get the decimals of the voting erc20 token
*
* TODO: move this into SDK extensions?
*/
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;
export async function votingTokenDecimals(options: BaseTransactionOptions) {
const tokenAddress = await VoteExt.token(options);
if (!tokenAddress) {
throw new Error("Expected a delegated token address");
}
const tokenContract = getContract({
...options.contract,
address: tokenAddress,
});
return await ERC20Ext.decimals({ contract: tokenContract });
}
interface IVoteCast {
voteType: VoteType;
reason?: string;
}
export function useCastVoteMutation(
contract: ThirdwebContract,
proposalId: bigint,
) {
const address = useActiveAccount()?.address;
const contractAddress = contract.address;
export function useDelegateMutation() {
const { mutateAsync } = useSendAndConfirmTransaction();
return useMutationWithInvalidate(
async (voteItem: IVoteCast) => {
invariant(contract, "contract is required");
invariant(address, "address is required");
const { voteType, reason } = voteItem;
const transaction = castVoteWithReason({
contract,
proposalId,
support: voteType,
reason: reason ?? "",
return useMutation({
mutationFn: async (contract: ThirdwebContract) => {
const tokenAddress = await VoteExt.token({ contract });
if (!tokenAddress) {
throw new Error("Expected a delegated token address");
}
const tokenContract = getContract({
...contract,
address: tokenAddress,
});
const transaction = ERC20Ext.delegate({
contract: tokenContract,
delegatee: contract.address,
});
return await mutateAsync(transaction);
},
{
onSuccess: (_data, _options, _variables, invalidate) => {
return invalidate([
voteKeys.proposals(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: ThirdwebContract,
proposalId: bigint,
) {
const contractAddress = contract.address;
const mutation = useSendAndConfirmTransaction();
return useMutationWithInvalidate(
async () => {
const transaction = executeProposal({ contract, proposalId });
return await mutation.mutateAsync(transaction);
},
{
onSuccess: (_data, _options, _variables, invalidate) => {
return invalidate([
voteKeys.proposals(contractAddress),
voteKeys.canExecuteProposal(proposalId.toString(), contractAddress),
]);
},
},
);
});
}
@@ -2,8 +2,8 @@
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 { useThirdwebClient } from "@/constants/thirdweb.client";
import { CustomConnectWallet } from "@3rdweb-sdk/react/components/connect-wallet";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { CanClaimResponseType } from "app/api/testnet-faucet/can-claim/CanClaimResponseType";
@@ -36,6 +36,7 @@ export function FaucetButton({
chain: ChainMetadata;
amount: string;
}) {
const client = useThirdwebClient();
const address = useActiveAccount()?.address;
const chainId = chain.chainId;
// do not include local overrides for chain pages
@@ -44,7 +45,7 @@ export function FaucetButton({
const faucetWalletBalanceQuery = useWalletBalance({
address: THIRDWEB_ENGINE_FAUCET_WALLET,
chain: definedChain,
client: thirdwebClient,
client,
});
const trackEvent = useTrack();
@@ -92,10 +93,9 @@ export function FaucetButton({
});
},
onSettled: () => {
return queryClient.invalidateQueries([
"testnet-faucet-can-claim",
chainId,
]);
return queryClient.invalidateQueries({
queryKey: ["testnet-faucet-can-claim", chainId],
});
},
});
@@ -175,7 +175,7 @@ export function FaucetButton({
});
}}
>
{claimMutation.isLoading ? (
{claimMutation.isPending ? (
<>
Claiming <Spinner className="size-3" />
</>
@@ -1,7 +1,7 @@
"use client";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { thirdwebClient } from "@/constants/client";
import { useThirdwebClient } from "@/constants/thirdweb.client";
import { useTrack } from "hooks/analytics/useTrack";
import { defineDashboardChain } from "lib/defineDashboardChain";
import { useTheme } from "next-themes";
@@ -10,6 +10,7 @@ import { getSDKTheme } from "../../../../../../components/sdk-component-theme";
export function PayModalButton(props: { chainId: number; label: string }) {
const { theme } = useTheme();
const client = useThirdwebClient();
const trackEvent = useTrack();
return (
<Dialog>
@@ -34,7 +35,7 @@ export function PayModalButton(props: { chainId: number; label: string }) {
dialogCloseClassName="focus:ring-0"
>
<PayEmbed
client={thirdwebClient}
client={client}
theme={getSDKTheme(theme === "dark" ? "dark" : "light")}
className="!w-auto"
payOptions={{
@@ -30,7 +30,7 @@ export const AddChainToWallet: React.FC<AddChainToWalletProps> = (props) => {
},
});
const [debouncedLoading] = useDebounce(switchChainMutation.isLoading, 50);
const [debouncedLoading] = useDebounce(switchChainMutation.isPending, 50);
const disabled = debouncedLoading || activeWalletChainId === props.chain?.id;
@@ -3,21 +3,17 @@
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 { DASHBOARD_THIRDWEB_CLIENT_ID, isProd } from "@/constants/env";
import { useQuery } from "@tanstack/react-query";
import { CircleCheck, XIcon } from "lucide-react";
import { useState } from "react";
import { hostnameEndsWith } from "utils/url";
import { PrimaryInfoItem } from "../server/primary-info-item";
function useChainStatswithRPC(_rpcUrl: string) {
const [shouldRefetch, setShouldRefetch] = useState(true);
let rpcUrl = _rpcUrl.replace(
// eslint-disable-next-line no-template-curly-in-string
"${THIRDWEB_API_KEY}",
thirdwebClient.clientId,
DASHBOARD_THIRDWEB_CLIENT_ID,
);
// based on the environment hit dev or production
@@ -49,12 +45,14 @@ function useChainStatswithRPC(_rpcUrl: string) {
blockNumber: Number.parseInt(json.result, 16),
};
},
refetchInterval: shouldRefetch ? 5 * 1000 : undefined,
refetchInterval: (query) => {
if (query.state.error) {
return false;
}
return 5 * 1000;
},
enabled: !!rpcUrl,
refetchOnWindowFocus: false,
onError: () => {
setShouldRefetch(false);
},
});
}
@@ -20,7 +20,6 @@ export function ChainHeader(props: ChainHeaderProps) {
// force the banner image to be 4:1 aspect ratio and full-width on mobile devices
<div className="flex flex-col">
{!props.headerImageUrl && <div className="h-8 md:hidden" />}
<AspectRatio
ratio={props.headerImageUrl ? 4 : 8}
className="border-b border-border max-sm:-mx-4"
@@ -34,7 +33,6 @@ export function ChainHeader(props: ChainHeaderProps) {
/>
)}
</AspectRatio>
{/* below header */}
<div className="relative flex flex-row justify-end items-end">
{/* chain logo */}
@@ -1,5 +1,5 @@
/* eslint-disable @next/next/no-img-element */
import { thirdwebClient } from "@/constants/client";
import { getThirdwebClient } from "@/constants/thirdweb.server";
import { ImageResponse } from "next/og";
import { download } from "thirdweb/storage";
import { fetchChain } from "utils/fetchChain";
@@ -77,8 +77,8 @@ export default async function Image({
),
// download the chain icon if there is one
chain.icon?.url && hasWorkingChainIcon
? download({ uri: chain.icon.url, client: thirdwebClient }).then((res) =>
res.arrayBuffer(),
? download({ uri: chain.icon.url, client: getThirdwebClient() }).then(
(res) => res.arrayBuffer(),
)
: undefined,
// download the background image (based on chain)
@@ -1,6 +1,7 @@
import { Badge } from "@/components/ui/badge";
import { Separator } from "@/components/ui/separator";
import { thirdwebClient } from "@/constants/client";
import { getThirdwebClient } from "@/constants/thirdweb.server";
import { mapV4ChainToV5Chain } from "contexts/map-chains";
import { ZERO_ADDRESS, toTokens } from "thirdweb";
import {
eth_getBlockByHash,
@@ -9,16 +10,17 @@ import {
getRpcClient,
} from "thirdweb/rpc";
import { hexToNumber, shortenAddress, toEther } from "thirdweb/utils";
import { mapV4ChainToV5Chain } from "../../../../../../contexts/map-chains";
import { getChain } from "../../../utils";
export default async function Page(props: {
params: { chain_id: string; txHash: `0x${string}` };
}) {
// consider if we want to pass the JWT here, likely no need to do it but we could?
const client = getThirdwebClient();
const chain = await getChain(props.params.chain_id);
const rpcRequest = getRpcClient({
client: thirdwebClient,
client,
// Do not include chain overrides for chain pages
// eslint-disable-next-line no-restricted-syntax
chain: mapV4ChainToV5Chain(chain),
@@ -5,7 +5,7 @@ import { Input } from "@/components/ui/input";
import { useDashboardRouter } from "@/lib/DashboardRouter";
import { SearchIcon, XCircleIcon } from "lucide-react";
import { usePathname, useSearchParams } from "next/navigation";
import { useRef } from "react";
import { useEffect, useRef } from "react";
import { useDebouncedCallback } from "use-debounce";
function cleanUrl(url: string) {
@@ -22,10 +22,13 @@ export const SearchInput: React.FC = () => {
const inputRef = useRef<HTMLInputElement>(null);
// hah, no need for useEffect here this just works!
if (inputRef.current?.value && !searchParams?.get("query")) {
inputRef.current.value = "";
}
// eslint-disable-next-line no-restricted-syntax
useEffect(() => {
// reset the input if the query param is removed
if (inputRef.current?.value && !searchParams?.get("query")) {
inputRef.current.value = "";
}
}, [searchParams]);
const handleSearch = useDebouncedCallback((term: string) => {
const params = new URLSearchParams(searchParams ?? undefined);
@@ -88,7 +88,7 @@ export async function ChainListRow({
key={p.name}
icon={p.icon}
label={p.name}
href={`/${chainSlug}/${p.id === "contracts" ? "" : p.id}`}
href={pidToHref(p.id)}
isEnabled={enabledServices.includes(p.id)}
/>
);
@@ -100,6 +100,29 @@ export async function ChainListRow({
);
}
function pidToHref(pid: (typeof products)[number]["id"]) {
switch (pid) {
case "account-abstraction": {
return "https://portal.thirdweb.com/connect/account-abstraction/overview";
}
case "contracts": {
return "https://portal.thirdweb.com/contracts";
}
case "connect-sdk": {
return "https://portal.thirdweb.com/connect";
}
case "engine": {
return "https://portal.thirdweb.com/engine";
}
case "pay": {
return "https://portal.thirdweb.com/connect/pay/overview";
}
case "rpc-edge": {
return "https://portal.thirdweb.com/infrastructure/rpc-edge/overview";
}
}
}
function ProductIcon(props: {
icon: React.FC<{ className?: string }>;
label: string;
@@ -117,7 +140,10 @@ function ProductIcon(props: {
)
}
>
<Link href={props.href}>
<Link
href={props.href}
target={props.href.startsWith("http") ? "_blank" : undefined}
>
<props.icon className={cn("size-8", !props.isEnabled && "grayscale")} />
</Link>
</ToolTipLabel>
@@ -91,7 +91,7 @@ export function StarButton(props: {
}}
disabled={
!loggedInUser.user?.address ||
mutation.isLoading ||
mutation.isPending ||
favChainsQuery.isLoading
}
>
@@ -1,8 +1,7 @@
/* eslint-disable @next/next/no-img-element */
import "server-only";
import { thirdwebClient } from "@/constants/client";
import { DASHBOARD_THIRDWEB_SECRET_KEY } from "@/constants/env";
import { getThirdwebClient } from "@/constants/thirdweb.server";
import { cn } from "@/lib/utils";
import { resolveScheme } from "thirdweb/storage";
@@ -15,7 +14,7 @@ export async function ChainIcon(props: {
}) {
if (props.iconUrl) {
const resolved = resolveScheme({
client: thirdwebClient,
client: getThirdwebClient(),
uri: props.iconUrl,
});
const res = await fetch(resolved, {
@@ -1,6 +1,6 @@
import "server-only";
import { redirect } from "next/navigation";
import { notFound } 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";
@@ -89,7 +89,7 @@ export async function getChain(
]);
if (!chain.data) {
redirect("/404");
notFound();
}
return {
...chain.data,
@@ -0,0 +1,37 @@
import { getThirdwebClient } from "@/constants/thirdweb.server";
import { setOverrides } from "lib/vercel-utils";
import { fetchDeployMetadata } from "thirdweb/contract";
import { DeployContractInfo } from "../../../published-contract/components/contract-info";
import { DeployFormForUri } from "../../../published-contract/components/uri-based-deploy";
setOverrides();
type DirectDeployPageProps = {
params: {
compiler_uri: string;
};
};
export default async function DirectDeployPage(props: DirectDeployPageProps) {
const parsedUri = decodeURIComponent(props.params.compiler_uri);
const metadata = await fetchDeployMetadata({
client: getThirdwebClient(),
// force `ipfs://` prefix
uri: parsedUri.startsWith("ipfs://") ? parsedUri : `ipfs://${parsedUri}`,
});
return (
<div className="container py-8 flex flex-col gap-4">
<DeployContractInfo
name={metadata.name}
displayName={metadata.displayName}
description={metadata.description}
logo={metadata.logo}
/>
<DeployFormForUri
contractMetadata={metadata}
modules={null}
pathname={`/contracts/deploy/${props.params.compiler_uri}`}
/>
</div>
);
}
@@ -0,0 +1,62 @@
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
import { getActiveAccountCookie, getJWTCookie } from "@/constants/cookie";
import { getThirdwebClient } from "@/constants/thirdweb.server";
import { ContractPublishForm } from "components/contract-components/contract-publish-form";
import { setOverrides } from "lib/vercel-utils";
import { revalidatePath } from "next/cache";
import { redirect } from "next/navigation";
import { fetchDeployMetadata } from "thirdweb/contract";
setOverrides();
type DirectDeployPageProps = {
params: {
publish_uri: string;
};
};
export default async function PublishContractPage(
props: DirectDeployPageProps,
) {
const decodedPublishUri = decodeURIComponent(props.params.publish_uri);
const publishUri = decodedPublishUri.startsWith("ipfs://")
? decodedPublishUri
: `ipfs://${decodedPublishUri}`;
const publishMetadata = await fetchDeployMetadata({
uri: publishUri,
client: getThirdwebClient(),
});
const pathname = `/contracts/publish/${props.params.publish_uri}`;
const address = getActiveAccountCookie();
if (!address) {
redirect(`/login?next=${encodeURIComponent(pathname)}`);
}
const token = getJWTCookie(address);
if (!token) {
redirect(`/login?next=${encodeURIComponent(pathname)}`);
}
return (
<div className="container py-8 flex flex-col gap-8">
<ChakraProviderSetup>
<ContractPublishForm
jwt={token}
publishMetadata={publishMetadata}
onPublishSuccess={async () => {
"use server";
// we are pretty brutal here and simply invalidate ALL published contracts (for everyone!) and versions no matter what
// TODO: we can be more granular here and only invalidate the specific contract and version etc
revalidatePath(
"/(dashboard)/published-contract/[publisher]/[contract_id]",
"layout",
);
}}
/>
</ChakraProviderSetup>
</div>
);
}
@@ -31,7 +31,7 @@ export function AddPartnerForm({ ecosystem }: { ecosystem: Ecosystem }) {
resolver: zodResolver(partnerFormSchema),
});
const { addPartner, isLoading } = useAddPartner({
const { mutateAsync: addPartner, isPending } = useAddPartner({
onSuccess: () => {
form.reset();
},
@@ -182,7 +182,7 @@ export function AddPartnerForm({ ecosystem }: { ecosystem: Ecosystem }) {
/>
</div>
<Button
disabled={isLoading}
disabled={isPending}
type="submit"
variant="outline"
className="w-full lg:w-auto"
@@ -13,7 +13,7 @@ import {
} from "@/components/ui/dropdown-menu";
import { Skeleton } from "@/components/ui/skeleton";
import { TabLinks } from "@/components/ui/tabs";
import { thirdwebClient } from "@/constants/client";
import { useThirdwebClient } from "@/constants/thirdweb.client";
import {
AlertTriangleIcon,
CheckIcon,
@@ -123,6 +123,7 @@ export function EcosystemHeader(props: {
refetchOnWindowFocus: false,
initialData: props.ecosystem,
});
const client = useThirdwebClient();
const ecosystem = fetchedEcosystem ?? props.ecosystem;
@@ -140,7 +141,7 @@ export function EcosystemHeader(props: {
<Image
src={resolveScheme({
uri: ecosystem.imageUrl,
client: thirdwebClient,
client,
})}
sizes="100px"
alt={ecosystem.name}
@@ -20,7 +20,11 @@ export function IntegrationPermissionsToggle({
}
| undefined
>();
const { updateEcosystem, variables, isLoading } = useUpdateEcosystem({
const {
mutateAsync: updateEcosystem,
variables,
isPending,
} = useUpdateEcosystem({
onError: (error) => {
const message =
error instanceof Error ? error.message : "Failed to create ecosystem";
@@ -31,14 +35,14 @@ export function IntegrationPermissionsToggle({
return (
<RadioGroup
defaultValue={ecosystem.permission}
value={isLoading ? variables?.permission : ecosystem.permission}
value={isPending ? variables?.permission : ecosystem.permission}
className="flex flex-col gap-2 py-2 md:flex-row md:gap-4"
>
<RadioGroupItemButton
value="PARTNER_WHITELIST"
id="PARTNER_WHITELIST"
className={cn(
isLoading &&
isPending &&
variables?.permission === "PARTNER_WHITELIST" &&
"animate-pulse",
)}
@@ -59,7 +63,7 @@ export function IntegrationPermissionsToggle({
value="ANYONE"
id="ANYONE"
className={cn(
isLoading && variables?.permission === "ANYONE" && "animate-pulse",
isPending && variables?.permission === "ANYONE" && "animate-pulse",
)}
onClick={() => {
if (ecosystem.permission === "ANYONE") return;
@@ -42,7 +42,7 @@ export function UpdatePartnerForm({
},
});
const { updatePartner, isLoading } = useUpdatePartner({
const { mutateAsync: updatePartner, isPending } = useUpdatePartner({
onSuccess: () => {
form.reset();
onSuccess();
@@ -195,12 +195,12 @@ export function UpdatePartnerForm({
/>
</div>
<Button
disabled={isLoading}
disabled={isPending}
type="submit"
variant="outline"
className="w-full"
>
{isLoading && <Loader2 className="size-4 mr-1 animate-spin" />}
{isPending && <Loader2 className="size-4 mr-1 animate-spin" />}
Update
</Button>
</form>
@@ -69,13 +69,14 @@ function EcosystemRow(props: {
partner: Partner;
ecosystem: Ecosystem;
}) {
const { deletePartner, isLoading: isDeleting } = useDeletePartner({
onError: (error) => {
const message =
error instanceof Error ? error.message : "Failed to delete partner";
toast.error(message);
},
});
const { mutateAsync: deletePartner, isPending: isDeleting } =
useDeletePartner({
onError: (error) => {
const message =
error instanceof Error ? error.message : "Failed to delete partner";
toast.error(message);
},
});
return (
<TableRow
@@ -2,7 +2,7 @@ import z from "zod";
import type { PartnerPermission } from "../../types";
import { isValidPermission } from "./utils";
export const isDomainRegex =
const isDomainRegex =
/^(?:\*|(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*(?:\*(?:\.[a-z0-9][a-z0-9-]{0,61}[a-z0-9](?:\.[a-z0-9][a-z0-9-]{0,61}[a-z0-9])*)?)|(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]|localhost(?::\d{1,5})?)$/;
export const partnerFormSchema = z.object({
@@ -6,7 +6,7 @@ import {
} from "@tanstack/react-query";
import type { Ecosystem, Partner } from "../../../types";
export type AddPartnerParams = {
type AddPartnerParams = {
ecosystem: Ecosystem;
name: string;
allowlistedDomains: string[];
@@ -24,7 +24,7 @@ export function useAddPartner(
const { isLoggedIn, user } = useLoggedInUser();
const queryClient = useQueryClient();
const { mutateAsync: addPartner, isLoading } = useMutation({
return useMutation({
// Returns the created partner object
mutationFn: async (params: AddPartnerParams): Promise<Partner> => {
if (!isLoggedIn || !user?.jwt) {
@@ -74,11 +74,9 @@ export function useAddPartner(
return data;
},
onSuccess: async (partner, variables, context) => {
await queryClient.invalidateQueries([
"ecosystem",
variables.ecosystem.id,
"partners",
]);
await queryClient.invalidateQueries({
queryKey: ["ecosystem", variables.ecosystem.id, "partners"],
});
if (onSuccess) {
return onSuccess(partner, variables, context);
}
@@ -86,6 +84,4 @@ export function useAddPartner(
},
...queryOptions,
});
return { addPartner, isLoading };
}
@@ -6,7 +6,7 @@ import {
} from "@tanstack/react-query";
import type { Ecosystem } from "../../../types";
export type DeletePartnerParams = {
type DeletePartnerParams = {
ecosystem: Ecosystem;
partnerId: string;
};
@@ -21,7 +21,7 @@ export function useDeletePartner(
const { isLoggedIn, user } = useLoggedInUser();
const queryClient = useQueryClient();
const { mutateAsync: deletePartner, isLoading } = useMutation({
return useMutation({
// Returns true on success
mutationFn: async (params: DeletePartnerParams): Promise<boolean> => {
if (!isLoggedIn || !user?.jwt) {
@@ -58,11 +58,9 @@ export function useDeletePartner(
return true;
},
onSuccess: async (partner, variables, context) => {
await queryClient.invalidateQueries([
"ecosystem",
variables.ecosystem.id,
"partners",
]);
await queryClient.invalidateQueries({
queryKey: ["ecosystem", variables.ecosystem.id, "partners"],
});
if (onSuccess) {
return onSuccess(partner, variables, context);
}
@@ -70,6 +68,4 @@ export function useDeletePartner(
},
...queryOptions,
});
return { deletePartner, isLoading };
}
@@ -6,7 +6,7 @@ import {
} from "@tanstack/react-query";
import type { Ecosystem } from "../../../types";
export type UpdateEcosystemParams = {
type UpdateEcosystemParams = {
ecosystem: Ecosystem;
permission: "PARTNER_WHITELIST" | "ANYONE";
};
@@ -21,11 +21,7 @@ export function useUpdateEcosystem(
const { isLoggedIn, user } = useLoggedInUser();
const queryClient = useQueryClient();
const {
mutateAsync: updateEcosystem,
isLoading,
variables,
} = useMutation({
return useMutation({
// Returns true if the update was successful
mutationFn: async (params: UpdateEcosystemParams): Promise<boolean> => {
if (!isLoggedIn || !user?.jwt) {
@@ -65,7 +61,9 @@ export function useUpdateEcosystem(
return true;
},
onSuccess: async (partner, variables, context) => {
await queryClient.invalidateQueries(["ecosystems"]);
await queryClient.invalidateQueries({
queryKey: ["ecosystems"],
});
if (onSuccess) {
return onSuccess(partner, variables, context);
}
@@ -73,6 +71,4 @@ export function useUpdateEcosystem(
},
...queryOptions,
});
return { updateEcosystem, isLoading, variables };
}
@@ -6,7 +6,7 @@ import {
} from "@tanstack/react-query";
import type { Ecosystem, Partner } from "../../../types";
export type UpdatePartnerParams = {
type UpdatePartnerParams = {
partnerId: string;
ecosystem: Ecosystem;
name: string;
@@ -25,7 +25,7 @@ export function useUpdatePartner(
const { isLoggedIn, user } = useLoggedInUser();
const queryClient = useQueryClient();
const { mutateAsync: updatePartner, isLoading } = useMutation({
return useMutation({
// Returns the created partner object
mutationFn: async (params: UpdatePartnerParams): Promise<Partner> => {
if (!isLoggedIn || !user?.jwt) {
@@ -73,11 +73,9 @@ export function useUpdatePartner(
return data;
},
onSuccess: async (partner, variables, context) => {
await queryClient.invalidateQueries([
"ecosystem",
variables.ecosystem.id,
"partners",
]);
await queryClient.invalidateQueries({
queryKey: ["ecosystem", variables.ecosystem.id, "partners"],
});
if (onSuccess) {
return onSuccess(partner, variables, context);
}
@@ -85,6 +83,4 @@ export function useUpdatePartner(
},
...queryOptions,
});
return { updatePartner, isLoading };
}
@@ -59,7 +59,7 @@ export function CreateEcosystemForm(props: {
},
});
const { createEcosystem, isLoading } = useCreateEcosystem({
const { mutateAsync: createEcosystem, isPending } = useCreateEcosystem({
onError: (error) => {
const message =
error instanceof Error ? error.message : "Failed to create ecosystem";
@@ -181,9 +181,9 @@ export function CreateEcosystemForm(props: {
type="submit"
variant="primary"
className="w-full"
disabled={isLoading}
disabled={isPending}
>
{isLoading && <Loader2 className="w-4 h-4 mr-1 animate-spin" />}
{isPending && <Loader2 className="w-4 h-4 mr-1 animate-spin" />}
Create
</Button>
)}
@@ -1,4 +1,4 @@
import { thirdwebClient } from "@/constants/client";
import { useThirdwebClient } from "@/constants/thirdweb.client";
import { useLoggedInUser } from "@3rdweb-sdk/react/hooks/useLoggedInUser";
import {
type UseMutationOptions,
@@ -8,7 +8,7 @@ import {
import { THIRDWEB_API_HOST } from "constants/urls";
import { upload } from "thirdweb/storage";
export type CreateEcosystemParams = {
type CreateEcosystemParams = {
name: string;
logo: File;
permission: "PARTNER_WHITELIST" | "ANYONE";
@@ -24,7 +24,9 @@ export function useCreateEcosystem(
const { isLoggedIn } = useLoggedInUser();
const queryClient = useQueryClient();
const { mutateAsync: createEcosystem, isLoading } = useMutation({
const client = useThirdwebClient();
return useMutation({
// Returns the created ecosystem slug
mutationFn: async (params: CreateEcosystemParams): Promise<string> => {
if (!isLoggedIn) {
@@ -32,7 +34,7 @@ export function useCreateEcosystem(
}
const imageUri = await upload({
client: thirdwebClient,
client,
files: [params.logo],
});
@@ -75,10 +77,10 @@ export function useCreateEcosystem(
if (onSuccess) {
await onSuccess(id, variables, context);
}
return queryClient.invalidateQueries(["ecosystems"]);
return queryClient.invalidateQueries({
queryKey: ["ecosystems"],
});
},
...queryOptions,
});
return { createEcosystem, isLoading };
}
@@ -0,0 +1,61 @@
import { TabPathLinks } from "@/components/ui/tabs";
import { redirect } from "next/navigation";
import { getApiKeys } from "../../../../../api/lib/getAPIKeys";
import { APIKeySelector } from "../components/APIKeySelector";
export default async function Layout(props: {
params: {
id: string;
};
children: React.ReactNode;
}) {
const apiKeys = await getApiKeys();
const firstKey = apiKeys[0];
if (!firstKey) {
redirect("/dashboard/connect/pay/no-keys");
}
const selectedKey = apiKeys.find((x) => x.id === props.params.id);
if (!selectedKey) {
redirect("/dashboard/connect/pay");
}
const layoutPath = `/dashboard/connect/pay/${selectedKey.id}`;
return (
<div>
<div className="flex-col gap-4 flex lg:flex-row w-full relative">
<div className="max-sm:w-full lg:min-w-[200px] lg:absolute right-0 bottom-3 z-10">
<APIKeySelector apiKeys={apiKeys} selectedApiKey={selectedKey} />
</div>
<TabPathLinks
className="w-full"
links={[
{
name: "Analytics",
path: layoutPath,
exactMatch: true,
},
{
name: "Webhooks",
path: `${layoutPath}/webhooks`,
},
{
name: "Settings",
path: `${layoutPath}/settings`,
},
]}
/>
</div>
<div className="h-4" />
{props.children}
</div>
);
}
export const dynamic = "force-dynamic";
@@ -0,0 +1,17 @@
import { notFound } from "next/navigation";
import { PayAnalytics } from "../../../../../../components/pay/PayAnalytics/PayAnalytics";
import { getAPIKey } from "../../../../../api/lib/getAPIKeys";
export default async function Page(props: {
params: {
id: string;
};
}) {
const apiKey = await getAPIKey(props.params.id);
if (!apiKey) {
notFound();
}
return <PayAnalytics clientId={apiKey.key} />;
}
@@ -0,0 +1,17 @@
import { notFound } from "next/navigation";
import { PayConfig } from "../../../../../../../components/pay/PayConfig";
import { getAPIKey } from "../../../../../../api/lib/getAPIKeys";
export default async function Page(props: {
params: {
id: string;
};
}) {
const apiKey = await getAPIKey(props.params.id);
if (!apiKey) {
notFound();
}
return <PayConfig apiKey={apiKey} />;
}
@@ -0,0 +1,17 @@
import { notFound } from "next/navigation";
import { getAPIKey } from "../../../../../../api/lib/getAPIKeys";
import { PayWebhooksPage } from "../../components/webhooks.client";
export default async function Page(props: {
params: {
id: string;
};
}) {
const apiKey = await getAPIKey(props.params.id);
if (!apiKey) {
notFound();
}
return <PayWebhooksPage clientId={apiKey.key} />;
}
@@ -0,0 +1,41 @@
"use client";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { useDashboardRouter } from "@/lib/DashboardRouter";
import type { ApiKey } from "@3rdweb-sdk/react/hooks/useApi";
export function APIKeySelector(props: {
apiKeys: ApiKey[];
selectedApiKey: ApiKey;
}) {
const router = useDashboardRouter();
return (
<Select
value={props.selectedApiKey.id}
onValueChange={(keyId) => {
const newKey = props.apiKeys.find((x) => x.id === keyId);
if (newKey) {
router.push(`/dashboard/connect/pay/${newKey.id}`);
}
}}
>
<SelectTrigger>
<SelectValue>{props.selectedApiKey.name}</SelectValue>
</SelectTrigger>
<SelectContent>
{props.apiKeys.map((key) => (
<SelectItem key={key.id} value={key.id}>
{key.name}
</SelectItem>
))}
</SelectContent>
</Select>
);
}
@@ -1,81 +0,0 @@
"use client";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { TabButtons } from "@/components/ui/tabs";
import type { ApiKey } from "@3rdweb-sdk/react/hooks/useApi";
import { PayAnalytics } from "components/pay/PayAnalytics/PayAnalytics";
import { PayConfig } from "components/pay/PayConfig";
import { useMemo, useState } from "react";
import { WebhooksPage } from "./webhooks.client";
export function PayUI(props: {
apiKeys: ApiKey[];
}) {
const [selectedKeyId, setSelectedKeyId] = useState<string>(
props.apiKeys[0].key,
);
const [activeTab, setActiveTab] = useState<
"settings" | "analytics" | "webhooks"
>("analytics");
const selectedKey = useMemo(() => {
// biome-ignore lint/style/noNonNullAssertion: This is a valid use case for non-null assertion
return props.apiKeys.find((key) => key.key === selectedKeyId)!;
}, [props.apiKeys, selectedKeyId]);
return (
<>
<div className="flex-col gap-4 flex lg:flex-row w-full relative">
<div className="max-sm:w-full lg:min-w-[200px] lg:absolute right-0 bottom-3 z-10">
<Select defaultValue={selectedKeyId} onValueChange={setSelectedKeyId}>
<SelectTrigger>
<SelectValue>{selectedKey?.name || selectedKeyId}</SelectValue>
</SelectTrigger>
<SelectContent>
{props.apiKeys.map((key) => (
<SelectItem key={key.key} value={key.key}>
{key.name}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<TabButtons
containerClassName="w-full"
tabs={[
{
name: "Analytics",
isActive: activeTab === "analytics",
onClick: () => setActiveTab("analytics"),
isEnabled: true,
},
{
name: "Webhooks",
isActive: activeTab === "webhooks",
onClick: () => setActiveTab("webhooks"),
isEnabled: true,
},
{
name: "Settings",
isActive: activeTab === "settings",
onClick: () => setActiveTab("settings"),
isEnabled: true,
},
]}
/>
</div>
{/* TODO: split this into sub-pages */}
{activeTab === "analytics" && <PayAnalytics clientId={selectedKey.key} />}
{activeTab === "settings" && <PayConfig apiKey={selectedKey} />}
{activeTab === "webhooks" && <WebhooksPage clientId={selectedKey.key} />}
</>
);
}
@@ -1,3 +1,5 @@
"use client";
import { CopyTextButton } from "@/components/ui/CopyTextButton";
import { Spinner } from "@/components/ui/Spinner/Spinner";
import { Button } from "@/components/ui/button";
@@ -55,11 +57,11 @@ type Webhook = {
secret: string;
};
export type WebhooksPageProps = {
type PayWebhooksPageProps = {
clientId: string;
};
export function WebhooksPage(props: WebhooksPageProps) {
export function PayWebhooksPage(props: PayWebhooksPageProps) {
const webhooksQuery = useQuery({
queryKey: ["webhooks", props.clientId],
queryFn: async () => {
@@ -154,7 +156,7 @@ const formSchema = z.object({
label: z.string().min(1, "Please enter a label."),
});
function CreateWebhookButton(props: PropsWithChildren<WebhooksPageProps>) {
function CreateWebhookButton(props: PropsWithChildren<PayWebhooksPageProps>) {
const [open, setOpen] = useState(false);
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
@@ -177,7 +179,9 @@ function CreateWebhookButton(props: PropsWithChildren<WebhooksPageProps>) {
return json.result as string;
},
onSuccess: () => {
return queryClient.invalidateQueries(["webhooks", props.clientId]);
return queryClient.invalidateQueries({
queryKey: ["webhooks", props.clientId],
});
},
});
return (
@@ -264,7 +268,7 @@ function CreateWebhookButton(props: PropsWithChildren<WebhooksPageProps>) {
</FormItem>
<DialogFooter>
<Button type="submit" disabled={createMutation.isLoading}>
<Button type="submit" disabled={createMutation.isPending}>
Create
</Button>
</DialogFooter>
@@ -276,7 +280,7 @@ function CreateWebhookButton(props: PropsWithChildren<WebhooksPageProps>) {
}
function DeleteWebhookButton(
props: PropsWithChildren<WebhooksPageProps & { webhookId: string }>,
props: PropsWithChildren<PayWebhooksPageProps & { webhookId: string }>,
) {
const [open, setOpen] = useState(false);
const queryClient = useQueryClient();
@@ -293,7 +297,9 @@ function DeleteWebhookButton(
return json.result as string;
},
onSuccess: () => {
return queryClient.invalidateQueries(["webhooks", props.clientId]);
return queryClient.invalidateQueries({
queryKey: ["webhooks", props.clientId],
});
},
});
return (
@@ -325,7 +331,7 @@ function DeleteWebhookButton(
},
);
}}
disabled={deleteMutation.isLoading}
disabled={deleteMutation.isPending}
>
Yes, Delete Webhook
</Button>
@@ -0,0 +1,31 @@
import Link from "next/link";
export default async function Layout(props: {
children: React.ReactNode;
}) {
return (
<div className="flex flex-col gap-8 w-full">
<div className="flex flex-col lg:flex-row gap-6 justify-between items-start">
<div className="max-w-[800px]">
<h1 className="text-3xl lg:text-4xl tracking-tight font-bold mb-3">
Pay
</h1>
<p className="text-muted-foreground leading-7">
Pay allows your users to purchase cryptocurrencies and execute
transactions with their credit card or debit card, or with any token
via cross-chain routing.{" "}
<Link
target="_blank"
href="https://portal.thirdweb.com/connect/pay/overview"
className="!text-link-foreground"
>
Learn more
</Link>
</p>
</div>
</div>
{props.children}
</div>
);
}
@@ -0,0 +1,5 @@
import { NoApiKeys } from "../../../../../../components/settings/ApiKeys/NoApiKeys";
export default function Page() {
return <NoApiKeys service="Pay in Connect" />;
}
@@ -1,86 +1,13 @@
import { COOKIE_ACTIVE_ACCOUNT, COOKIE_PREFIX_TOKEN } from "@/constants/cookie";
import type { ApiKey } from "@3rdweb-sdk/react/hooks/useApi";
import { NoApiKeys } from "components/settings/ApiKeys/NoApiKeys";
import { cookies } from "next/headers";
import Link from "next/link";
import { redirect } from "next/navigation";
import { PayUI } from "./components/pay-ui.client";
import { getApiKeys } from "../../../../api/lib/getAPIKeys";
async function getApiKeys(authToken: string) {
const res = await fetch(
`${process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com"}/v1/keys`,
{
method: "GET",
export default async function Page() {
const apiKeys = await getApiKeys();
const firstKey = apiKeys[0];
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authToken}`,
},
},
);
const json = await res.json();
if (json.error) {
throw new Error(json.error.message);
}
return json.data as ApiKey[];
}
export default async function DashboardConnectPayPage() {
const cookiesManager = cookies();
const activeAccount = cookiesManager.get(COOKIE_ACTIVE_ACCOUNT)?.value;
const authToken = activeAccount
? cookiesManager.get(`${COOKIE_PREFIX_TOKEN}${activeAccount}`)?.value
: null;
if (!authToken) {
// redirect to login page
redirect(`/login?next=${encodeURIComponent("/dashboard/connect/pay")}`);
if (firstKey) {
redirect(`/dashboard/connect/pay/${firstKey.id}`);
}
const apiKeys = await getApiKeys(authToken).catch((err) => {
console.error("failed to load api keys", err);
return [];
});
return (
<div className="flex flex-col gap-8 w-full">
<div className="flex flex-col lg:flex-row gap-6 justify-between items-start">
<div className="max-w-[800px]">
<h1 className="text-3xl lg:text-4xl tracking-tight font-bold mb-3">
Pay
</h1>
<p className="text-muted-foreground leading-7">
Pay allows your users to purchase cryptocurrencies and execute
transactions with their credit card or debit card, or with any token
via cross-chain routing.{" "}
<Link
target="_blank"
href="https://portal.thirdweb.com/connect/pay/overview"
className="!text-link-foreground"
>
Learn more
</Link>
</p>
</div>
</div>
{apiKeys.length > 0 ? (
<PayUI apiKeys={apiKeys} />
) : (
<NoApiKeys
service="Pay in Connect"
buttonTextOverride={apiKeys.length ? "Enable Pay" : undefined}
copyOverride={
apiKeys.length
? "You'll need to enable pay as a service in an API Key to use Pay."
: undefined
}
/>
)}
</div>
);
redirect("/dashboard/connect/pay/no-keys");
}
// because cookies() is used
export const dynamic = "force-dynamic";
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

@@ -0,0 +1,134 @@
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";
import { ContractCard } from "components/explore/contract-card";
import { DeployUpsellCard } from "components/explore/upsells/deploy-your-own";
import { ALL_CATEGORIES, getCategory } from "data/explore";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
type ExploreCategoryPageProps = {
params: {
category: string;
};
};
export const metadata: Metadata = {
title: "Explore | Smart Contracts",
description:
"Browse a large collection of ready-to-deploy contracts that have been built by thirdweb and other contract developers. Find a contract for your specific app's or game's needs.",
openGraph: {
title: "thirdweb Explore: Smart Contracts & Protocols",
},
};
export async function generateMetadatra(
props: ExploreCategoryPageProps,
): Promise<Metadata> {
const category = getCategory(props.params.category);
if (!category) {
notFound();
}
return {
title: `${category.name} Smart Contracts | Explore`,
description: `${category.description} Deploy with one click to Ethereum, Polygon, Optimism, and other EVM blockchains with thirdweb.`,
};
}
export default async function ExploreCategoryPage(
props: ExploreCategoryPageProps,
) {
const category = getCategory(props.params.category);
if (!category) {
notFound();
}
return (
<div className="flex flex-col">
<Breadcrumb className="py-4 px-6 border-b border-border">
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink asChild>
<Link href="/explore">Explore</Link>
</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>
{category.displayName || category.name}
</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
<div className="container py-8 flex flex-col gap-4">
<h1 className="mb-3 text-3xl lg:text-5xl font-bold tracking-tighter">
{category.displayName || category.name}
</h1>
<p className="text-base lg:text-lg text-muted-foreground max-w-screen-md">
{category.description}{" "}
{category.learnMore && (
<Link href={category.learnMore}>Learn more</Link>
)}
</p>
<div className="h-10" />
<div className="grid grid-cols-1 md:grid-cols-3 gap-5">
{category.contracts.map((publishedContractId, idx) => {
const publisher: string = Array.isArray(publishedContractId)
? publishedContractId[0].split("/")[0]
: publishedContractId.split("/")[0];
const contractId: string = Array.isArray(publishedContractId)
? publishedContractId[0].split("/")[1]
: publishedContractId.split("/")[1];
const modules = Array.isArray(publishedContractId)
? publishedContractId[1]
: undefined;
const overrides = Array.isArray(publishedContractId)
? publishedContractId[2]
: undefined;
return (
<ContractCard
key={publisher + contractId + overrides?.title}
publisher={publisher}
contractId={contractId}
titleOverride={overrides?.title}
descriptionOverride={overrides?.description}
tracking={{
source: category.id,
itemIndex: `${idx}`,
}}
isBeta={category.isBeta}
modules={
modules?.length
? modules.map((m) => ({
publisher: m.split("/")[0],
moduleId: m.split("/")[1],
}))
: undefined
}
/>
);
})}
</div>
<div className="h-16" />
{/* TODO: remove this once we update the deploy upsell card */}
<ChakraProviderSetup>
<DeployUpsellCard />
</ChakraProviderSetup>
</div>
</div>
);
}
export async function generateStaticParams() {
return ALL_CATEGORIES.map((category) => ({
params: { category },
}));
}

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