-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
63 additions
and
100 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,28 +1,7 @@ | ||
import { useMemo } from 'react'; | ||
import { Contract } from '@ethersproject/contracts'; | ||
import { useSigner } from 'wagmi'; | ||
import { mainnet, goerli, optimismGoerli } from 'wagmi/chains'; | ||
import type { Auditor } from 'types/contracts/Auditor'; | ||
import mainnetAuditor from '@exactly-protocol/protocol/deployments/mainnet/Auditor.json' assert { type: 'json' }; | ||
import goerliAuditor from '@exactly-protocol/protocol/deployments/goerli/Auditor.json' assert { type: 'json' }; | ||
import optimismGoerliAuditor from '@exactly-protocol/protocol/deployments/optimism-goerli/Auditor.json' assert { type: 'json' }; | ||
import auditorABI from 'abi/Auditor.json' assert { type: 'json' }; | ||
import { useWeb3 } from './useWeb3'; | ||
import useContract from './useContract'; | ||
|
||
export default () => { | ||
const { data: signer } = useSigner(); | ||
const { chain } = useWeb3(); | ||
|
||
return useMemo(() => { | ||
if (!signer || !chain) return null; | ||
|
||
const address = { | ||
[goerli.id]: goerliAuditor.address, | ||
[mainnet.id]: mainnetAuditor.address, | ||
[optimismGoerli.id]: optimismGoerliAuditor.address, | ||
}[chain.id]; | ||
if (!address) return null; | ||
|
||
return new Contract(address, auditorABI, signer) as Auditor; | ||
}, [chain, signer]); | ||
return useContract<Auditor>('Auditor', auditorABI); | ||
}; |
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,33 @@ | ||
import { useState, useEffect } from 'react'; | ||
import { useSigner } from 'wagmi'; | ||
import { mainnet } from 'wagmi/chains'; | ||
import { Contract, ContractInterface } from '@ethersproject/contracts'; | ||
import { captureException } from '@sentry/nextjs'; | ||
|
||
import { useWeb3 } from './useWeb3'; | ||
|
||
export default function <T>(contractName: string, abi: ContractInterface): T | undefined { | ||
const { data: signer } = useSigner(); | ||
const { chain } = useWeb3(); | ||
|
||
const [contract, setContract] = useState<T | undefined>(undefined); | ||
|
||
useEffect(() => { | ||
const loadContract = async () => { | ||
if (!chain || !signer) return; | ||
|
||
const { address } = await import( | ||
`@exactly-protocol/protocol/deployments/${ | ||
{ [mainnet.id]: 'mainnet' }[chain.id] ?? chain.network | ||
}/${contractName}.json`, | ||
{ assert: { type: 'json' } } | ||
); | ||
|
||
setContract(new Contract(address, abi, signer) as T); | ||
}; | ||
|
||
loadContract().catch(captureException); | ||
}, [contractName, chain, signer, abi]); | ||
|
||
return contract; | ||
} |
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,33 +1,7 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useSigner } from 'wagmi'; | ||
import { mainnet } from 'wagmi/chains'; | ||
import { Contract } from '@ethersproject/contracts'; | ||
import { MarketETHRouter } from 'types/contracts'; | ||
import MarketETHRouterABI from 'abi/MarketETHRouter.json'; | ||
import { captureException } from '@sentry/nextjs'; | ||
import { useWeb3 } from './useWeb3'; | ||
import MarketETHRouterABI from 'abi/MarketETHRouter.json' assert { type: 'json' }; | ||
import useContract from './useContract'; | ||
|
||
export default (): MarketETHRouter | undefined => { | ||
const { data: signer } = useSigner(); | ||
const { chain } = useWeb3(); | ||
|
||
const [marketETHRouterContract, setMarketETHRouterContract] = useState<MarketETHRouter | undefined>(undefined); | ||
|
||
useEffect(() => { | ||
const loadMarketETHRouter = async () => { | ||
if (!chain || !signer) return; | ||
|
||
const { address } = await import( | ||
`@exactly-protocol/protocol/deployments/${ | ||
{ [mainnet.id]: 'mainnet' }[chain.id] ?? chain.network | ||
}/MarketETHRouter.json`, | ||
{ assert: { type: 'json' } } | ||
); | ||
|
||
setMarketETHRouterContract(new Contract(address, MarketETHRouterABI, signer) as MarketETHRouter); | ||
}; | ||
loadMarketETHRouter().catch(captureException); | ||
}, [chain, signer]); | ||
|
||
return marketETHRouterContract; | ||
export default () => { | ||
return useContract<MarketETHRouter>('MarketETHRouter', MarketETHRouterABI); | ||
}; |
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,24 +1,7 @@ | ||
import { useMemo } from 'react'; | ||
import { Contract } from '@ethersproject/contracts'; | ||
import { useSigner } from 'wagmi'; | ||
import { optimismGoerli } from 'wagmi/chains'; | ||
import type { RewardsController } from 'types/contracts/RewardsController'; | ||
import optimismGoerliRewardsController from '@exactly-protocol/protocol/deployments/optimism-goerli/RewardsController.json' assert { type: 'json' }; | ||
import rewardsControllerABI from 'abi/RewardsController.json' assert { type: 'json' }; | ||
import { useWeb3 } from './useWeb3'; | ||
import useContract from './useContract'; | ||
|
||
export default () => { | ||
const { data: signer } = useSigner(); | ||
const { chain } = useWeb3(); | ||
|
||
return useMemo(() => { | ||
if (!signer || !chain) return null; | ||
|
||
const address = { | ||
[optimismGoerli.id]: optimismGoerliRewardsController.address, | ||
}[chain.id]; | ||
if (!address) return null; | ||
|
||
return new Contract(address, rewardsControllerABI, signer) as RewardsController; | ||
}, [chain, signer]); | ||
return useContract<RewardsController>('RewardsController', rewardsControllerABI); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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