Files
js/@3rdweb-sdk/react/hooks/useSDK.ts
T
Nacho IacovinoandJonas Daniels fcba9f7bc1 Add all new chains (#191)
* Add all new chains

* Import from SDK

* Add RPC urls

* Fix type error

* Fix currency map

* Fix build

* Fix imports

* Add faucets, fix stuff

* Rename

* Add Optimism/Arbitrum icons

* Disable arbitrum/optimism

* Fix build

* Fix build again

* Update SDK

* Update TypeScript SDK

* Add registry

* Fix faucets

* Update embeds

* slight changes

* Update embeds

* Filter gnosis, update optimism kovan alchemy url

* Simplify transfer modal

* Remove console.logs

* Fix embeds

Co-authored-by: Jonas Daniels <[email protected]>
2022-06-14 17:02:21 -07:00

31 lines
773 B
TypeScript

import { contractKeys, networkKeys } from "../cache-keys";
import { useReadonlySDK } from "@thirdweb-dev/react";
import { SUPPORTED_CHAIN_ID } from "@thirdweb-dev/sdk";
import {
StorageSingleton,
alchemyUrlMap,
} from "components/app-layouts/providers";
import { useQuery } from "react-query";
export function useContractList(
chainId: SUPPORTED_CHAIN_ID,
walletAddress?: string,
) {
const sdk = useReadonlySDK(
alchemyUrlMap[chainId],
undefined,
StorageSingleton,
);
return useQuery(
[...networkKeys.chain(chainId), ...contractKeys.list(walletAddress)],
async () => {
const data = await sdk?.getContractList(walletAddress || "");
return data;
},
{
enabled: !!sdk && !!walletAddress && !!chainId,
},
);
}