9266ff4bd8
* feat: add new bridge contract logic * chore: remove unused contract from provider * chore: remove minimum as no longer exists * feat: use new withdrawals contract, but allow for old contract for token * feat: power contracts selection by a flag * style: lint * Update libs/smart-contracts/src/contracts/collateral-bridge-new.ts Co-authored-by: Matthew Russell <mattrussell36@gmail.com> * chore: rename env var as per feedback * chore: consistent varaible names as per PR comments * chore: add back in checks for minimum as per PR comments * style: formatting Co-authored-by: Matthew Russell <mattrussell36@gmail.com>
33 lines
851 B
TypeScript
33 lines
851 B
TypeScript
import {
|
|
CollateralBridge,
|
|
CollateralBridgeNew,
|
|
} from '@vegaprotocol/smart-contracts';
|
|
import { useWeb3React } from '@web3-react/core';
|
|
import { useMemo } from 'react';
|
|
import { useEthereumConfig } from './use-ethereum-config';
|
|
|
|
export const useBridgeContract = (isNewContract: boolean) => {
|
|
const { provider } = useWeb3React();
|
|
const { config } = useEthereumConfig();
|
|
|
|
const contract = useMemo(() => {
|
|
if (!provider || !config) {
|
|
return null;
|
|
}
|
|
|
|
const signer = provider.getSigner();
|
|
|
|
return isNewContract
|
|
? new CollateralBridgeNew(
|
|
config.collateral_bridge_contract.address,
|
|
signer || provider
|
|
)
|
|
: new CollateralBridge(
|
|
config.collateral_bridge_contract.address,
|
|
signer || provider
|
|
);
|
|
}, [provider, config, isNewContract]);
|
|
|
|
return contract;
|
|
};
|