vega-frontend-monorepo/libs/web3/src/lib/use-bridge-contract.ts
Sam Keen 1be1a78a69
Feat/537: remove old contract for collateral bridge (#998)
* Feat/537: Removed old contract and branching logic for collateral bridge

* Feat/537: Renamed all 'new' name instances in functions, files and types. Regenerated types.

* Feat/537: Added 'creation' field to withdraw-dialog.spec.tsx test
2022-08-11 11:33:45 +01:00

25 lines
629 B
TypeScript

import { CollateralBridge } from '@vegaprotocol/smart-contracts';
import { useWeb3React } from '@web3-react/core';
import { useMemo } from 'react';
import { useEthereumConfig } from './use-ethereum-config';
export const useBridgeContract = () => {
const { provider } = useWeb3React();
const { config } = useEthereumConfig();
const contract = useMemo(() => {
if (!provider || !config) {
return null;
}
const signer = provider.getSigner();
return new CollateralBridge(
config.collateral_bridge_contract.address,
signer || provider
);
}, [provider, config]);
return contract;
};