Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const createBuidlerProvider = (buidlerOptionsOrPathToConfig: string | BuidlerNetworkConfig = {}) => {
let createProvider;
let EthersProviderWrapper;
try {
createProvider = require('@nomiclabs/buidler/internal/core/providers/construction').createProvider;
EthersProviderWrapper = require('@nomiclabs/buidler-ethers/dist/ethers-provider-wrapper').EthersProviderWrapper;
} catch (error) {
console.error('To use createBuidlerProvider method you need to have the following packages installed: @nomiclabs/buidler, @nomiclabs/buidler-ethers');
throw new Error('Missing packages');
}
const buidlerOptions = getBuidlerOptions(buidlerOptionsOrPathToConfig);
const options = {...defaultBuidlerOptions, ...buidlerOptions };
return new EthersProviderWrapper(createProvider('buidlerevm', options));
};