Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (originalPrepareCall === undefined) {
originalPrepareCall = execute.prepareCall;
}
execute.prepareCall = async function(...args: any[]) {
const ret = await originalPrepareCall.apply(this, args);
await addFromIfNeededAndAvailable(ret.params);
return ret;
};
return artifacts;
});
env.assert = lazyFunction(() => require("chai").assert);
env.expect = lazyFunction(() => require("chai").expect);
env.contract = (
description: string,
definition: (accounts: string[]) => any
) => {
if (env.network.name === BUIDLEREVM_NETWORK_NAME) {
if (accounts === undefined) {
const {
privateToAddress,
toChecksumAddress,
bufferToHex
} = require("ethereumjs-util");
const netConfig = env.network.config as Required<
BuidlerNetworkConfig
>;
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,
definition: (accounts: string[]) => any
) => {
if (env.network.name === BUIDLEREVM_NETWORK_NAME) {
if (accounts === undefined) {
const { privateToAddress, bufferToHex } = require("ethereumjs-util");
const netConfig = env.network.config as Required<
BuidlerNetworkConfig
>;
accounts = netConfig.accounts.map(acc =>
bufferToHex(privateToAddress(acc.privateKey))
);
}
};
if (originalPrepareCall === undefined) {
originalPrepareCall = execute.prepareCall;
}
execute.prepareCall = async function(...args: any[]) {
const ret = await originalPrepareCall.apply(this, args);
await addFromIfNeededAndAvailable(ret.params);
return ret;
};
return artifacts;
});
env.assert = lazyFunction(() => require("chai").assert);
env.expect = lazyFunction(() => require("chai").expect);
env.contract = (
description: string,
definition: (accounts: string[]) => any
) => {
if (env.network.name === BUIDLEREVM_NETWORK_NAME) {
if (accounts === undefined) {
const {
privateToAddress,
toChecksumAddress,
bufferToHex
} = require("ethereumjs-util");
const netConfig = env.network.config as Required<
BuidlerNetworkConfig
>;
extendEnvironment(env => {
env.Web3 = lazyFunction(() => require("web3"));
env.web3 = lazyObject(() => {
const Web3 = require("web3");
return new Web3(new Web3HTTPProviderAdapter(env.network.provider));
});
});
}
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,
definition: (accounts: string[]) => any
) => {
if (env.network.name === BUIDLEREVM_NETWORK_NAME) {
if (accounts === undefined) {
const { privateToAddress, bufferToHex } = require("ethereumjs-util");
const netConfig = env.network.config as Required<
BuidlerNetworkConfig
>;
accounts = netConfig.accounts.map(acc =>
bufferToHex(privateToAddress(acc.privateKey))
);
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));
});
}