Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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:
//
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}`
);
}
}
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;
}
}
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);
};
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`
);
}
}
}
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;
}
}
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;
}
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);
}