-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: no more hardcoded contract address nor network config, rely…
… on wagmi and viem
- Loading branch information
Showing
9 changed files
with
51 additions
and
47 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
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,23 +1,13 @@ | ||
export const SUPPORTED_CHAINS = { | ||
421613: { | ||
chainName: "Arbitrum Goerli", | ||
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 }, | ||
rpcUrls: ["https://goerli-rollup.arbitrum.io/rpc"], | ||
blockExplorerUrls: ["https://goerli.arbiscan.io/"], | ||
}, | ||
}; | ||
|
||
export const DEFAULT_CHAIN = 421613; | ||
import { Chain, arbitrumGoerli, gnosisChiado } from "@wagmi/chains"; | ||
|
||
export const SUPPORTED_CHAINIDS = Object.keys(SUPPORTED_CHAINS).map((x) => parseInt(x)); | ||
export const DEFAULT_CHAIN = arbitrumGoerli.id; | ||
|
||
export const QUERY_CHAINS = { | ||
10200: { | ||
chainName: "Chiado Testnet", | ||
nativeCurrency: { name: "xDAI", symbol: "xDAI", decimals: 18 }, | ||
rpcUrls: ["https://rpc.eu-central-2.gateway.fm/v3/gnosis/archival/chiado"], | ||
blockExplorerUrls: ["https://blockscout.chiadochain.net"], | ||
}, | ||
export const SUPPORTED_CHAINS: Record<number, Chain> = { | ||
[arbitrumGoerli.id]: arbitrumGoerli, | ||
}; | ||
export const SUPPORTED_CHAIN_IDS = Object.keys(SUPPORTED_CHAINS); | ||
|
||
export const QUERY_CHAINIDS = Object.keys(QUERY_CHAINS).map((x) => parseInt(x)); | ||
export const QUERY_CHAINS: Record<number, Chain> = { | ||
[gnosisChiado.id]: gnosisChiado, | ||
}; | ||
export const QUERY_CHAIN_IDS = Object.keys(QUERY_CHAINS); |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Abi, PublicClient } from "viem"; | ||
import { usePublicClient } from "wagmi"; | ||
import { GetContractArgs, GetContractResult } from "wagmi/actions"; | ||
import { getPinakionV2, pinakionV2ABI, getWeth, getPnkFaucet, wethABI, pnkFaucetABI } from "./contracts/generated"; | ||
|
||
type Config = Omit<GetContractArgs<Abi, unknown>, "abi" | "address"> & { | ||
chainId?: any; | ||
}; | ||
|
||
export const useContractAddress = <TAbi extends Abi>( | ||
getter: (c: Config) => GetContractResult<TAbi, PublicClient> | ||
): GetContractResult<TAbi, PublicClient> => { | ||
const publicClient = usePublicClient(); | ||
return getter({ walletClient: publicClient }); | ||
}; | ||
|
||
export const usePNKAddress = () => { | ||
return useContractAddress<typeof pinakionV2ABI>(getPinakionV2)?.address; | ||
}; | ||
|
||
export const useWETHAddress = () => { | ||
return useContractAddress<typeof wethABI>(getWeth)?.address; | ||
}; | ||
|
||
export const usePNKFaucetAddress = () => { | ||
return useContractAddress<typeof pnkFaucetABI>(getPnkFaucet)?.address; | ||
}; |
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
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