How to use the @nomiclabs/buidler/plugins.lazyFunction function in @nomiclabs/buidler

To help you get started, we’ve selected a few @nomiclabs/buidler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nomiclabs / buidler / packages / buidler-truffle5 / src / index.ts View on Github external
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
          >;
github nomiclabs / buidler / packages / buidler-truffle4 / src / index.ts View on Github external
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))
          );
        }
github nomiclabs / buidler / packages / buidler-truffle5 / src / index.ts View on Github external
};

      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
          >;
github nomiclabs / buidler / packages / buidler-web3 / src / index.ts View on Github external
extendEnvironment(env => {
    env.Web3 = lazyFunction(() => require("web3"));
    env.web3 = lazyObject(() => {
      const Web3 = require("web3");
      return new Web3(new Web3HTTPProviderAdapter(env.network.provider));
    });
  });
}
github nomiclabs / buidler / packages / buidler-truffle4 / src / index.ts View on Github external
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))
          );
github nomiclabs / buidler / packages / buidler-web3-legacy / src / index.ts View on Github external
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));
  });
}