-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: different contracts on different chains (#920)
- Loading branch information
Showing
2 changed files
with
17 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import scaffoldConfig from "~~/scaffold.config"; | ||
import { contracts } from "~~/utils/scaffold-eth/contract"; | ||
import { useTargetNetwork } from "~~/hooks/scaffold-eth"; | ||
import { GenericContractsDeclaration, contracts } from "~~/utils/scaffold-eth/contract"; | ||
|
||
export function getAllContracts() { | ||
const contractsData = contracts?.[scaffoldConfig.targetNetworks[0].id]; | ||
return contractsData ? contractsData : {}; | ||
const DEFAULT_ALL_CONTRACTS: GenericContractsDeclaration[number] = {}; | ||
|
||
export function useAllContracts() { | ||
const { targetNetwork } = useTargetNetwork(); | ||
const contractsData = contracts?.[targetNetwork.id]; | ||
// using constant to avoid creating a new object on every call | ||
return contractsData || DEFAULT_ALL_CONTRACTS; | ||
} |