Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
extendEnvironment(env => {
env.Web3 = lazyFunction(() => require("web3"));
env.web3 = lazyObject(() => {
const Web3 = require("web3");
return new Web3(new Web3HTTPProviderAdapter(env.network.provider));
});
env.pweb3 = lazyObject(() => promisifyWeb3(env.web3));
});
}
extendEnvironment(env => {
env.artifacts = lazyObject(() => {
const networkConfig = env.network.config;
const provisioner = new LazyTruffleContractProvisioner(
env.web3,
networkConfig
);
const artifacts = new TruffleEnvironmentArtifacts(
env.config.paths.artifacts,
provisioner
);
const execute = require("@nomiclabs/truffle-contract/lib/execute");
let noDefaultAccounts = false;
let defaultAccount: string | undefined = networkConfig.from;
extendEnvironment(env => {
env.Web3 = lazyFunction(() => require("web3"));
env.web3 = lazyObject(() => {
const Web3 = require("web3");
return new Web3(new Web3HTTPProviderAdapter(env.network.provider));
});
});
}
extendEnvironment(env => {
accounts = undefined;
env.artifacts = lazyObject(() => {
const provisioner = new LazyTruffleContractProvisioner(
env.web3,
env.network.config,
env.network.config.from
);
return new TruffleEnvironmentArtifacts(
env.config.paths.artifacts,
provisioner
);
});
env.assert = lazyFunction(() => require("chai").assert);
env.expect = lazyFunction(() => require("chai").expect);
env.contract = (
description: string,
extendEnvironment(env => {
env.Web3 = lazyFunction(() => require("web3"));
env.web3 = lazyObject(() => {
const Web3 = require("web3");
return new Web3(new Web3HTTPProviderAdapter(env.network.provider));
});
env.pweb3 = lazyObject(() => promisifyWeb3(env.web3));
});
}
extendEnvironment((env: BuidlerRuntimeEnvironment) => {
env.ethers = lazyObject(() => {
const { EthersProviderWrapper } = require("./ethers-provider-wrapper");
return {
provider: new EthersProviderWrapper(env.network.provider),
getContract: async (name: string) => {
const { ethers } = await import("ethers");
const artifact = await readArtifact(env.config.paths.artifacts, name);
const bytecode = artifact.bytecode;
const signers = await env.ethers.signers();
return new ethers.ContractFactory(artifact.abi, bytecode, signers[0]);
},
signers: async () => {
const accounts = await env.ethers.provider.listAccounts();
return accounts.map((account: string) =>
env.ethers.provider.getSigner(account)
);