ensure ethereumProvider
This commit is contained in:
parent
bce4f0059f
commit
fed3f2e820
|
@ -13,7 +13,7 @@ import { ERC20 } from './types/ERC20';
|
|||
import { Bridge as IBridge } from './types/Bridge';
|
||||
import Header from './components/Header';
|
||||
import { getSNTAvalanche, getSNTEthereum, getBridge } from './utils/contracts';
|
||||
import { goerliProvider, avaProvider } from './utils/providers'
|
||||
import { ethereumProvider, avaProvider } from './utils/providers'
|
||||
import { ethereumAddress, avalancheAddress } from './constants/bridges';
|
||||
|
||||
const { useState, useEffect } = React;
|
||||
|
@ -21,7 +21,6 @@ const { useState, useEffect } = React;
|
|||
function App() {
|
||||
const classes: any = useStyles();
|
||||
const [provider, setProvider] = useState<Web3Provider>();
|
||||
const [ethereumProvider, setEthereumProvider] = useState<Provider>();
|
||||
const [account, setAccount] = useState<string>('');
|
||||
const [sntEthereum, setSntEthereum] = useState<ERC20>();
|
||||
const [sntAvalanche, setSntAvalanche] = useState<ERC20>();
|
||||
|
@ -38,7 +37,7 @@ function App() {
|
|||
|
||||
useEffect(() => {
|
||||
if (provider) {
|
||||
const sntEthereum: ERC20 = getSNTEthereum(goerliProvider);
|
||||
const sntEthereum: ERC20 = getSNTEthereum(ethereumProvider);
|
||||
const sntAvalanche: ERC20 = getSNTAvalanche(avaProvider);
|
||||
setSntEthereum(sntEthereum);
|
||||
setSntAvalanche(sntAvalanche);
|
||||
|
@ -51,7 +50,7 @@ function App() {
|
|||
avalancheBridge.isRelayer(account).then(isRelayer => {
|
||||
setIsRelayer(isRelayer)
|
||||
});
|
||||
const ethereumBridge: IBridge = getBridge(ethereumAddress, provider);
|
||||
const ethereumBridge: IBridge = getBridge(ethereumAddress, ethereumProvider);
|
||||
setEthereumBridge(ethereumBridge);
|
||||
setAvalancheBridge(avalancheBridge);
|
||||
}, [provider])
|
||||
|
|
|
@ -21,7 +21,6 @@ type IBridgeInfo = {
|
|||
amount: string,
|
||||
account: string,
|
||||
}
|
||||
const wallet = Wallet.createRandom();
|
||||
|
||||
interface Props {
|
||||
account: string,
|
||||
|
@ -30,14 +29,6 @@ interface Props {
|
|||
sntAvalanche: ERC20 | undefined,
|
||||
ethereumBridge: IBridge | undefined,
|
||||
}
|
||||
const FUJI_BRIDGE = '0xE57Eb49689bCAE4dE61D326F7E79Bd14aB527f0f';
|
||||
const GOERLI_BRIDGE = '0xD0E461b1Dc56503fC72565FA964C28E274146D44';
|
||||
const fujiProvider = new providers.JsonRpcProvider("https://api.avax-test.network/ext/bc/C/rpc");
|
||||
const goerliProvider = new providers.InfuraProvider("goerli");
|
||||
const fujiSigner = new Wallet(wallet.privateKey, fujiProvider);
|
||||
const fujiVoidSigner = new VoidSigner(wallet.address, fujiProvider);
|
||||
const goerliVoidsigner = new VoidSigner(wallet.address, goerliProvider);
|
||||
|
||||
export const AdminBridge: React.FC<Props> = ({ account, provider, sntEthereum, sntAvalanche, ethereumBridge }) => {
|
||||
const classes: any = useStyles()
|
||||
const bridge: SymfoniBridge = useContext(BridgeContext);
|
||||
|
@ -51,23 +42,7 @@ export const AdminBridge: React.FC<Props> = ({ account, provider, sntEthereum, s
|
|||
const { fieldWidth } = classes;
|
||||
useEffect(() => {
|
||||
getDepositEvents(ethereumBridge, setDeposits)
|
||||
const doAsync = async () => {
|
||||
if (!bridge.instance) return
|
||||
console.log("Bridge is deployed at ", bridge.instance.address)
|
||||
let gBridge = new Contract(
|
||||
GOERLI_BRIDGE,
|
||||
bridge.instance.interface,
|
||||
goerliVoidsigner
|
||||
) as IBridge;
|
||||
setGoerliBridge(gBridge);
|
||||
let fBridge = new Contract(
|
||||
FUJI_BRIDGE,
|
||||
bridge.instance.interface,
|
||||
fujiVoidSigner
|
||||
) as IBridge;
|
||||
setFujiBridge(fBridge);
|
||||
};
|
||||
doAsync();
|
||||
|
||||
}, [bridge])
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -78,6 +53,8 @@ export const AdminBridge: React.FC<Props> = ({ account, provider, sntEthereum, s
|
|||
getSetBalance(sntAvalanche, account, setSntAvalancheBalance);
|
||||
}, [account])
|
||||
|
||||
console.log({deposits})
|
||||
|
||||
return (
|
||||
<Formik
|
||||
initialValues={{
|
||||
|
|
|
@ -2,8 +2,8 @@ import { Wallet, providers, Contract, VoidSigner } from "ethers";
|
|||
|
||||
const wallet = Wallet.createRandom();
|
||||
const avaURI = process.env.REACT_APP_AVALANCHE_URI || "https://api.avax-test.network/ext/bc/C/rpc";
|
||||
export const goerliProvider = new providers.InfuraProvider("goerli");
|
||||
export const ethereumProvider = new providers.InfuraProvider("goerli");
|
||||
export const avaProvider = new providers.JsonRpcProvider(avaURI);
|
||||
const avaSigner = new Wallet(wallet.privateKey, avaProvider);
|
||||
export const avaVoidSigner = new VoidSigner(wallet.address, avaProvider);
|
||||
export const goerliVoidsigner = new VoidSigner(wallet.address, goerliProvider);
|
||||
export const goerliVoidsigner = new VoidSigner(wallet.address, ethereumProvider);
|
||||
|
|
Loading…
Reference in New Issue