Files
js/apps/dashboard/src/@/api/contract/fetchPublishedContracts.ts
T
MananTank ad2d22558b Dashboard: File organization changes (#7788)
<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Added a hook to fetch favorite chain IDs for user accounts.
  * Introduced contract verification functionality.
  * Added UI for saving deployed contracts to projects.
  * Provided new lightweight types for teams and projects.

* **Bug Fixes**
  * Replaced NFT media cell rendering in marketplace tables for improved display and interaction.

* **Refactor**
  * Standardized and reorganized import paths across the app for improved maintainability.
  * Renamed and updated fieldset components in contract deployment forms for consistency.
  * Centralized and simplified cookie and authentication token handling.
  * Removed or relocated obsolete and redundant components and types.

* **Chores**
  * Cleaned up unused files and consolidated constants.
  * Updated and clarified type imports throughout the codebase.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-04 21:37:15 +00:00

45 lines
1.1 KiB
TypeScript

import type { ThirdwebClient } from "thirdweb";
import {
getAllPublishedContracts,
getContractPublisher,
} from "thirdweb/extensions/thirdweb";
import { resolveEns } from "@/lib/ens";
import { fetchDeployMetadata } from "./fetchDeployMetadata";
// TODO: clean this up, jesus
export async function fetchPublishedContracts(params: {
address?: string | null;
client: ThirdwebClient;
}) {
const { address, client } = params;
try {
if (!address) {
return [];
}
const resolvedAddress = (await resolveEns(address, client)).address;
if (!resolvedAddress) {
return [];
}
const tempResult = (
(await getAllPublishedContracts({
contract: getContractPublisher(client),
publisher: resolvedAddress,
})) || []
)
.filter((c) => c.contractId)
.sort((a, b) => a.contractId.localeCompare(b.contractId));
return await Promise.all(
tempResult.map(async (c) => ({
...c,
metadata: await fetchDeployMetadata(c.publishMetadataUri, client),
})),
);
} catch (e) {
console.error("Error fetching published contracts", e);
return [];
}
}