Skip to content

Commit

Permalink
Use embedded solcjs compiler instead of trying to download.
Browse files Browse the repository at this point in the history
  • Loading branch information
allisterb committed Jan 26, 2024
1 parent e22a8a1 commit 709ad4a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
35 changes: 35 additions & 0 deletions src/Stratis.DevEx.Base/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Stratis.DevEx
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading;

Expand Down Expand Up @@ -447,6 +448,40 @@ public static void CopyDirectory(string sourceDir, string destinationDir, bool r
op.Complete();
}

public static async Task<bool> DownloadFileAsync(string name, Uri downloadUrl, string downloadPath)
{
#pragma warning disable SYSLIB0014 // Type or member is obsolete
using (var op = Begin("Downloading {0} from {1} to {2}", name, downloadUrl, downloadPath))
{
using (var client = new WebClient())
{
try
{
var b = await client.DownloadDataTaskAsync(downloadUrl);
if (b != null)
{
File.WriteAllBytes(downloadPath, b);
op.Complete();
return true;
}
else
{
op.Abandon();
Error("Downloading {file} to {path} from {url} did not return any data.", name, downloadPath, downloadUrl);
return false;
}
}
catch (Exception ex)
{
op.Abandon();
Error(ex, "Exception thrown downloading {file} to {path} from {url}.", name, downloadPath, downloadUrl);
return false;
}
}
}
#pragma warning restore SYSLIB0014 // Type or member is obsolete
}

public static string ViewFilePath(string path, string? relativeTo = null)
{
if (!DebugEnabled)
Expand Down
12 changes: 12 additions & 0 deletions src/Stratis.VS.StratisEVM/SolidityLanguageClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ public async Task<Connection> ActivateAsync(CancellationToken token)
if (CheckRunCmdOutput(output, "Run `npm audit` for details."))
{
Info("VSCode Solidity language server installed.");
/*
if (await DownloadFileAsync("soljson-v0.8.23+commit.f704f362.js", new Uri("https://ajb.nyc3.cdn.digitaloceanspaces.com/soljson-v0.8.23+commit.f704f362.js"), Path.Combine(StratisDevDir, "soljson-v0.8.23+commit.f704f362.js")))
{
Info("VSCode Solidity language server installed.");
}
else
{
Error("Could not download Solidity compiler.");
Error("Could not install VSCode Solidity language server.");
return null;
}
*/
}
else
{
Expand Down
3 changes: 1 addition & 2 deletions src/Stratis.VS.StratisEVM/SolidityLanguageSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"solidity.telemetry": false,
"solidity.maxNumberOfProblems": 1,
"solidity.enabledAsYouTypeCompilationErrorCheck": true,
"solidity.defaultCompiler": "localFile",
"solidity.compileUsingLocalVersion": "C:\\Users\\Allister\\Downloads\\soljson-v0.8.23+commit.f704f362.js"
"solidity.defaultCompiler": "embedded"
}

0 comments on commit 709ad4a

Please sign in to comment.