Skip to content

Commit

Permalink
[vyper] Use the GITHUB_TOKEN and increase timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
alcuadrado committed Dec 29, 2022
1 parent b24b994 commit 633f20b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/hardhat-vyper/src/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,27 @@ import { VyperPluginError, getLogger } from "./util";

const log = getLogger("downloader");

const DOWNLOAD_TIMEOUT_MS = 30_000;

async function downloadFile(
url: string,
destinationFile: string
): Promise<void> {
const { download } = await import("hardhat/internal/util/download");
log(`Downloading from ${url} to ${destinationFile}`);
await download(url, destinationFile);

const headers: { [name: string]: string } = {};
// If we are running in GitHub Actions we use the GitHub token as auth to
// avoid hitting a rate limit.
// Inspired by https://github.com/vyperlang/vvm/blob/5c37a2f4bbebc8c5f7f1dbb8ff89a4df1070ec44/vvm/install.py#L139
if (process.env.GITHUB_TOKEN !== undefined) {
const base64 = Buffer.from(process.env.GITHUB_TOKEN, "ascii").toString(
"base64"
);
headers.Authorization = `Basic ${base64}`;
}

await download(url, destinationFile, DOWNLOAD_TIMEOUT_MS, headers);
}

type DownloadFunction = (url: string, destinationFile: string) => Promise<void>;
Expand Down

0 comments on commit 633f20b

Please sign in to comment.