How to use the @nomiclabs/buidler/plugins.lazyObject 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-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));
  });
}
github nomiclabs / buidler / packages / buidler-truffle5 / src / index.ts View on Github external
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;
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
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,
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));
  });
}
github nomiclabs / buidler / packages / buidler-ethers / src / index.ts View on Github external
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)
          );