Skip to content

Commit

Permalink
renamed selectedChain to selectedNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHomanics committed Dec 7, 2024
1 parent f71717f commit 2d91033
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export const useDeployedContractInfo = <TContractName extends ContractName>({
}: UseDeployedContractConfig<TContractName>) => {
const isMounted = useIsMounted();

const selectedChain = useAllowedChain(chainId as AllowedChainIds);
const deployedContract = contracts?.[selectedChain.id]?.[contractName as ContractName] as Contract<TContractName>;
const selectedNetwork = useAllowedChain(chainId as AllowedChainIds);
const deployedContract = contracts?.[selectedNetwork.id]?.[contractName as ContractName] as Contract<TContractName>;
const [status, setStatus] = useState<ContractCodeStatus>(ContractCodeStatus.LOADING);
const publicClient = usePublicClient({ chainId: selectedChain.id });
const publicClient = usePublicClient({ chainId: selectedNetwork.id });

useEffect(() => {
const checkContractDeployment = async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/nextjs/hooks/scaffold-eth/useScaffoldContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export const useScaffoldContract = <
walletClient?: TWalletClient | null;
chainId?: AllowedChainIds;
}) => {
const selectedChain = useAllowedChain(chainId as AllowedChainIds);
const selectedNetwork = useAllowedChain(chainId as AllowedChainIds);
const { data: deployedContractData, isLoading: deployedContractLoading } = useDeployedContractInfo({
contractName,
chainId: selectedChain?.id as AllowedChainIds,
chainId: selectedNetwork?.id as AllowedChainIds,
});

const publicClient = usePublicClient({ chainId: selectedChain?.id });
const publicClient = usePublicClient({ chainId: selectedNetwork?.id });

let contract = undefined;
if (deployedContractData && publicClient) {
Expand Down
10 changes: 5 additions & 5 deletions packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ export const useScaffoldEventHistory = <
watch,
enabled = true,
}: UseScaffoldEventHistoryConfig<TContractName, TEventName, TBlockData, TTransactionData, TReceiptData>) => {
const selectedChain = useAllowedChain(chainId as AllowedChainIds);
const selectedNetwork = useAllowedChain(chainId as AllowedChainIds);

const publicClient = usePublicClient({
chainId: selectedChain.id,
chainId: selectedNetwork.id,
});
const [isFirstRender, setIsFirstRender] = useState(true);

const { data: blockNumber } = useBlockNumber({ watch: watch, chainId: selectedChain.id });
const { data: blockNumber } = useBlockNumber({ watch: watch, chainId: selectedNetwork.id });

const { data: deployedContractData } = useDeployedContractInfo({
contractName,
chainId: selectedChain.id as AllowedChainIds,
chainId: selectedNetwork.id as AllowedChainIds,
});

const event =
Expand All @@ -111,7 +111,7 @@ export const useScaffoldEventHistory = <
address: deployedContractData?.address,
eventName,
fromBlock: fromBlock.toString(),
chainId: selectedChain.id,
chainId: selectedNetwork.id,
filters: JSON.stringify(filters, replacer),
},
],
Expand Down
8 changes: 4 additions & 4 deletions packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ export const useScaffoldReadContract = <
chainId,
...readConfig
}: UseScaffoldReadConfig<TContractName, TFunctionName>) => {
const selectedChain = useAllowedChain(chainId as AllowedChainIds);
const selectedNetwork = useAllowedChain(chainId as AllowedChainIds);
const { data: deployedContract } = useDeployedContractInfo({
contractName,
chainId: selectedChain.id as AllowedChainIds,
chainId: selectedNetwork.id as AllowedChainIds,
});

const { query: queryOptions, watch, ...readContractConfig } = readConfig;
// set watch to true by default
const defaultWatch = watch ?? true;

const readContractHookRes = useReadContract({
chainId: selectedChain.id,
chainId: selectedNetwork.id,
functionName,
address: deployedContract?.address,
abi: deployedContract?.abi,
Expand All @@ -62,7 +62,7 @@ export const useScaffoldReadContract = <
const queryClient = useQueryClient();
const { data: blockNumber } = useBlockNumber({
watch: defaultWatch,
chainId: selectedChain.id,
chainId: selectedNetwork.id,
query: {
enabled: defaultWatch,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export const useScaffoldWatchContractEvent = <
chainId,
onLogs,
}: UseScaffoldEventConfig<TContractName, TEventName>) => {
const selectedChain = useAllowedChain(chainId as AllowedChainIds);
const selectedNetwork = useAllowedChain(chainId as AllowedChainIds);
const { data: deployedContractData } = useDeployedContractInfo({
contractName,
chainId: selectedChain.id as AllowedChainIds,
chainId: selectedNetwork.id as AllowedChainIds,
});

const addIndexedArgsToLogs = (logs: Log[]) => logs.map(addIndexedArgsToEvent);
Expand All @@ -35,7 +35,7 @@ export const useScaffoldWatchContractEvent = <
return useWatchContractEvent({
address: deployedContractData?.address,
abi: deployedContractData?.abi as Abi,
chainId: selectedChain.id,
chainId: selectedNetwork.id,
onLogs: listenerWithIndexedArgs,
eventName,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export const useScaffoldWriteContract = <TContractName extends ContractName>({

const wagmiContractWrite = useWriteContract(writeContractParams);

const selectedChain = useAllowedChain(chainId as AllowedChainIds);
const selectedNetwork = useAllowedChain(chainId as AllowedChainIds);

const { data: deployedContractData } = useDeployedContractInfo({
contractName,
chainId: selectedChain.id as AllowedChainIds,
chainId: selectedNetwork.id as AllowedChainIds,
});

const sendContractWriteAsyncTx = async <
Expand All @@ -55,7 +55,7 @@ export const useScaffoldWriteContract = <TContractName extends ContractName>({
return;
}

if (accountChain?.id !== selectedChain.id) {
if (accountChain?.id !== selectedNetwork.id) {
notification.error("Your wallet is connected to the wrong network");
return;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ export const useScaffoldWriteContract = <TContractName extends ContractName>({
return;
}

if (accountChain?.id !== selectedChain.id) {
if (accountChain?.id !== selectedNetwork.id) {
notification.error("Your wallet is connected to the wrong network");
return;
}
Expand Down

0 comments on commit 2d91033

Please sign in to comment.