Skip to content

Commit 95f51ae

Browse files
committed
types, try-catch
1 parent 3cf36c4 commit 95f51ae

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

apps/dashboard/src/components/contract-components/fetchPublishedContractsFromDeploy.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import {
1313
} from "thirdweb/utils";
1414
import { fetchDeployMetadata } from "./fetchDeployMetadata";
1515

16+
type ZkSolcMetadata = {
17+
source_metadata: { settings: { compilationTarget: Record<string, string> } };
18+
};
19+
1620
export async function fetchPublishedContractsFromDeploy(options: {
1721
contract: ThirdwebContract;
1822
client: ThirdwebClient;
@@ -32,26 +36,24 @@ export async function fetchPublishedContractsFromDeploy(options: {
3236
// Try fetching using contract name from compiler metadata for zksolc variants
3337
// TODO: ContractPublisher should handle multiple metadata uri for a published version
3438
if (publishURIs.length === 0 && (await isZkSyncChain(contract.chain))) {
35-
const deployMetadata = await download({
36-
uri: contractUri,
37-
client,
38-
})
39-
// biome-ignore lint/suspicious/noExplicitAny:
40-
.then((res) => res.json() as any)
41-
.catch();
42-
const contractId = Object.values(
43-
deployMetadata?.source_metadata.settings?.compilationTarget,
44-
);
45-
46-
await fetchPublishedContract({
47-
client,
48-
contractId: contractId[0] as string,
49-
publisherAddress: THIRDWEB_DEPLOYER_ADDRESS,
50-
})
51-
.then((published) => {
52-
publishURIs = [published.publishMetadataUri];
53-
})
54-
.catch();
39+
try {
40+
const deployMetadata = await download({
41+
uri: contractUri,
42+
client,
43+
}).then((res) => res.json() as unknown as ZkSolcMetadata);
44+
45+
const contractId = Object.values(
46+
deployMetadata.source_metadata.settings.compilationTarget,
47+
);
48+
49+
const published = await fetchPublishedContract({
50+
client,
51+
contractId: contractId[0] as string,
52+
publisherAddress: THIRDWEB_DEPLOYER_ADDRESS,
53+
});
54+
55+
publishURIs = [published.publishMetadataUri];
56+
} catch {}
5557
}
5658

5759
return await Promise.all(

0 commit comments

Comments
 (0)