How to use the @nomiclabs/buidler/plugins.BuidlerPluginError 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 / artifacts.ts View on Github external
public link(
    destination: TruffleContract,
    ...libraries: TruffleContractInstance[]
  ) {
    if (libraries.length === 0) {
      return;
    }

    for (const library of libraries) {
      if (
        library.address === undefined ||
        library.constructor.network_id === undefined
      ) {
        throw new BuidlerPluginError(
          `Error while linking library ${library._json.contractName} into contract ${destination.contractName}: library not deployed.`
        );
      }
    }

    const destinationArtifact = readArtifactSync(
      this._artifactsPath,
      destination.contractName
    );

    const libraryAddresses: { [libraryName: string]: string } = {};

    const linkReferences = destinationArtifact.linkReferences;

    // Explanation of the following hacks:
    //
github nomiclabs / buidler / packages / buidler-etherscan / src / solc / SolcVersions.ts View on Github external
export async function getVersions(): Promise {
  try {
    // tslint:disable-next-line: await-promise
    return await request.get(COMPILERS_LIST_URL, { json: true });
  } catch (e) {
    throw new BuidlerPluginError(
      `Failed to obtain full solc version. Reason: ${e.message}`
    );
  }
}
github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
throw new BuidlerPluginError(
        "Docker Desktop is not running.\nPlease open it and wait until it finishes booting.",
        error
      );
    }

    if (error instanceof DockerHubConnectionError) {
      throw new BuidlerPluginError(
        `Error connecting to Docker Hub.
Please check your internet connection.`,
        error
      );
    }

    if (error instanceof DockerServerError) {
      throw new BuidlerPluginError("Docker error", error);
    }

    if (error instanceof ImageDoesntExistError) {
      throw new BuidlerPluginError(
        `Docker image ${BuidlerDocker.imageToRepoTag(
          error.image
        )} doesn't exist.
Make sure you chose a valid Vyper version.`
      );
    }

    throw error;
  }
}
github nomiclabs / buidler / packages / buidler-truffle4 / src / provisioner.ts View on Github external
Contract.deployed = async () => {
      const address = this._deploymentAddresses[Contract.contractName];

      if (address === undefined) {
        throw new BuidlerPluginError(
          "@nomiclabs/buidler-truffle5",
          `Trying to get deployed instance of ${Contract.contractName}, but none was set.`
        );
      }

      return Contract.at(address);
    };
github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
async function validateDockerIsInstalled() {
  if (!(await BuidlerDocker.isInstalled())) {
    throw new BuidlerPluginError(
      `Docker Desktop is not installed.
Please install it by following the instructions on https://www.docker.com/get-started`
    );
  }
}
github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
}

    if (error instanceof DockerHubConnectionError) {
      throw new BuidlerPluginError(
        `Error connecting to Docker Hub.
Please check your internet connection.`,
        error
      );
    }

    if (error instanceof DockerServerError) {
      throw new BuidlerPluginError("Docker error", error);
    }

    if (error instanceof ImageDoesntExistError) {
      throw new BuidlerPluginError(
        `Docker image ${BuidlerDocker.imageToRepoTag(
          error.image
        )} doesn't exist.
Make sure you chose a valid Vyper version.`
      );
    }

    throw error;
  }
}
github nomiclabs / buidler / packages / buidler-truffle4 / src / provisioner.ts View on Github external
private async _getDefaultAccount(
    txParams: any,
    isDefaultAccountRequired = true
  ) {
    if (txParams.from !== undefined) {
      return txParams.from;
    }

    if (this._defaultAccount === undefined) {
      const getAccounts = this._web3.eth.getAccounts.bind(this._web3.eth);
      const accounts = await util.promisify(getAccounts)();

      if (accounts.length === 0) {
        if (isDefaultAccountRequired) {
          throw new BuidlerPluginError(
            "There's no account available in the selected network."
          );
        }

        return undefined;
      }

      this._defaultAccount = accounts[0];
    }

    return this._defaultAccount;
  }
github nomiclabs / buidler / packages / buidler-vyper / src / compilation.ts View on Github external
async function handleCommonErrors(promise: Promise): Promise {
  try {
    return await promise;
  } catch (error) {
    if (
      error instanceof DockerNotRunningError ||
      error instanceof DockerBadGatewayError
    ) {
      throw new BuidlerPluginError(
        "Docker Desktop is not running.\nPlease open it and wait until it finishes booting.",
        error
      );
    }

    if (error instanceof DockerHubConnectionError) {
      throw new BuidlerPluginError(
        `Error connecting to Docker Hub.
Please check your internet connection.`,
        error
      );
    }

    if (error instanceof DockerServerError) {
      throw new BuidlerPluginError("Docker error", error);
    }