Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function getDeployedERC1820Registry () {
const config = getSingletonsConfig();
const loader = setupLoader({
provider: web3.currentProvider,
defaultGas: config.defaultGas,
defaultSender: config.defaultSender,
});
if (config.abstraction === 'truffle') {
const registry = loader.truffle.fromABI(ERC1820_REGISTRY_ABI);
return registry.at(ERC1820_REGISTRY_ADDRESS);
} else if (config.abstraction === 'web3') {
const registry = loader.web3.fromABI(ERC1820_REGISTRY_ABI);
registry.options.address = ERC1820_REGISTRY_ADDRESS;
return new web3.eth.Contract(ERC1820_REGISTRY_ABI, ERC1820_REGISTRY_ADDRESS);
} else {
import { setupLoader } from '@openzeppelin/contract-loader';
import config from './config';
import { defaultSender } from './accounts';
import { provider } from './setup-provider';
if (config.contracts.type !== 'truffle' && config.contracts.type !== 'web3') {
throw new Error(`Unknown contract type: '${config.contracts.type}'`);
}
export default setupLoader({
defaultSender,
defaultGas: config.contracts.defaultGas,
provider,
})[config.contracts.type];