File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
packages/hardhat-vyper/src Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,27 @@ import { VyperPluginError, getLogger } from "./util";
1414
1515const log = getLogger ( "downloader" ) ;
1616
17+ const DOWNLOAD_TIMEOUT_MS = 30_000 ;
18+
1719async function downloadFile (
1820 url : string ,
1921 destinationFile : string
2022) : Promise < void > {
2123 const { download } = await import ( "hardhat/internal/util/download" ) ;
2224 log ( `Downloading from ${ url } to ${ destinationFile } ` ) ;
23- await download ( url , destinationFile ) ;
25+
26+ const headers : { [ name : string ] : string } = { } ;
27+ // If we are running in GitHub Actions we use the GitHub token as auth to
28+ // avoid hitting a rate limit.
29+ // Inspired by https://github.com/vyperlang/vvm/blob/5c37a2f4bbebc8c5f7f1dbb8ff89a4df1070ec44/vvm/install.py#L139
30+ if ( process . env . GITHUB_TOKEN !== undefined ) {
31+ const base64 = Buffer . from ( process . env . GITHUB_TOKEN , "ascii" ) . toString (
32+ "base64"
33+ ) ;
34+ headers . Authorization = `Basic ${ base64 } ` ;
35+ }
36+
37+ await download ( url , destinationFile , DOWNLOAD_TIMEOUT_MS , headers ) ;
2438}
2539
2640type DownloadFunction = ( url : string , destinationFile : string ) => Promise < void > ;
You can’t perform that action at this time.
0 commit comments