Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Develop

See merge request company-projects/Meadow!21
  • Loading branch information
zone117x committed Sep 28, 2018
2 parents 4d832ae + 044d25f commit 1cce3b3
Show file tree
Hide file tree
Showing 620 changed files with 6,754 additions and 169 deletions.
18 changes: 9 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,12 @@ ASALocalRun/
# Meadow generated files
*.sol.cs
*.sol.resx
Meadow.UnitTestTemplate.Test/Report/
Meadow.UnitTestTemplate.ParallelTest/Report/
Meadow.VSCode.Debugger/out/
Meadow.DebugExampleTests/Report/
Meadow.DebugExampleTests/debugger_trace.txt
pwsh_testing/GeneratedAssembly/
coverage/
report/
reportgenerator/
src/Meadow.UnitTestTemplate.Test/Report/
src/Meadow.UnitTestTemplate.ParallelTest/Report/
src/Meadow.VSCode.Debugger/out/
src/Meadow.DebugExampleTests/Report/
src/Meadow.DebugExampleTests/debugger_trace.txt
src/pwsh_testing/GeneratedAssembly/
src/coverage/
src/report/
src/reportgenerator/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
install:
- npm install -g ganache-cli
script:
- cd src
- dotnet restore --configfile Nuget.Config
- dotnet msbuild -p:Configuration=Debug /maxcpucount:1 /nodeReuse:false
- dotnet test -c Debug --no-build --no-restore
35 changes: 0 additions & 35 deletions Meadow.Cli/Commands/StartTestServerCommand.cs

This file was deleted.

24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Provides an intuitive framework for writing C# tests against contract deployment

* [Writing unit tests](TODO) - getting started writing tests against Solidity contracts and generating code coverage reports.

* [Using the CLI](Meadow.Cli/README.md) - contract deployment and interaction against testnode or production.
* [Using the CLI](src/Meadow.Cli/README.md) - contract deployment and interaction against testnode or production.

* [VSCode Solidity Debugger](TODO)

Expand All @@ -55,14 +55,14 @@ Provides an intuitive framework for writing C# tests against contract deployment

| Library | Package | |
|---------|-----------|-------------|
| [Meadow.EVM](Meadow.EVM) | [![nuget](https://img.shields.io/nuget/v/Meadow.EVM.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.EVM) | An Ethereum Virtual Machine that includes: <ul><li>Instructions/opcodes, calling conventions/messages/return values, memory/stack, logs/events, gas, charges/limits, precompiles, contract creation logic. <li>Core Ethereum components: account storage, transaction receipts, transaction pool, blocks, world state, snapshoting/reverting, chain, mining/consensus mechanism/scoring/difficulty/uncles. <li>Underlying dependencies: configuration/genesis block/fork/versioning/chain ID support, modified Merkle Patricia Trees, bloom filters, elliptic curve signing + public key recovery, Ethash, in-memory storage database.</ul> |
| [Meadow.TestNode](Meadow.TestNode) | [![nuget](https://img.shields.io/nuget/v/Meadow.TestNode.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.TestNode) | Ethereum "personal blockchain" / "test node" / "RPC Server" / "Ethereum client". Ran as either a standalone server or via programmatic setup / teardown during unit test execution. Supports several non-standard RPC methods for debugging, testing, and coverage report generation. |
| [Meadow.SolCodeGen](Meadow.SolCodeGen) | [![nuget](https://img.shields.io/nuget/v/Meadow.SolCodeGen.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.SolCodeGen) | Tool that compiles Solidity source files and generates a C# class for each contract. All public methods and events in the contract ABI are translated to corresponding idiomatic C# methods and event log classes. Solidity NatSpec comments / docs are also translated to IntelliSense / code-completion tooltips. This nuget package can be simply added to a project and Solidity files in the project `contracts` directory are automatically compiled. |
| [Meadow.CoverageReport](Meadow.CoverageReport) | [![nuget](https://img.shields.io/nuget/v/Meadow.CoverageReport.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.CoverageReport) | Generates HTML and JSON code coverage reports for Solidity source files. Uses execution trace data from the EVM. |
| [Meadow.UnitTestTemplate](Meadow.UnitTestTemplate) | [![nuget](https://img.shields.io/nuget/v/Meadow.UnitTestTemplate.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.UnitTestTemplate) | Test harness providing seamless integration between MSTest and Solidity contracts. Provides a simple workflow where Solidity source files are dropped into a unit test project and C# contract code is automatically generated. C# unit tests can easily deploy/call/transact with contracts. RPC test node servers & clients are automatically boostrapped and provided to unit tests. Code coverage reports are automatically generated after unit tests are ran. |
| [Meadow.Cli](Meadow.Cli) | [![nuget](https://img.shields.io/nuget/v/Meadow.Cli.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.Cli) | Tool that allows contract deployments and interaction through the command line. Solidity source files are live-compiled using a file system watcher. Can be ran against a automatically bootstrapped test RPC node or an externally configured node. Leverages PowerShell Core to a provide cross platform REPL-like environment with powerful tab-completion when interacting with contracts. |
| [Meadow.VSCode.Debugger](Meadow.VSCode.Debugger) | TODO.. | Solidity debugger extension for VSCode supporting beakpoints, stepping, rewinding, call stacks, local & state variable inspection. |
| [Meadow.Core](Meadow.Core) | [![nuget](https://img.shields.io/nuget/v/Meadow.Core.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.Core) | <ul><li>RLP and ABI encoding & decoding utils. <li>Implementations of Ethereum / solidity types such as Address, UInt256, Hash, etc. <li>BIP32, BIP39, BIP44, HD account derivation implementation. <li>Fast managed Keccak hashing. <li> ECDSA / secp256k1 utils.</ul> |
| [Meadow.JsonRpc](Meadow.JsonRpc) | [![nuget](https://img.shields.io/nuget/v/Meadow.JsonRpc.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.JsonRpc) | <ul><li>.NET types for the Ethereum JSON-RPC request & response data structures. <li>.NET interface for all RPC methods. <li>Serialization for JSON/hex object formats <-> Solidity/.NET types.</ul> |
| [Meadow.JsonRpc.Client](Meadow.JsonRpc.Client) | [![nuget](https://img.shields.io/nuget/v/Meadow.JsonRpc.Client.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.JsonRpc.Client) | JSON-RPC client implementation, supported transports: http, WebSocket, and IPC. |
| [Meadow.JsonRpc.Server](Meadow.JsonRpc.Server) | [![nuget](https://img.shields.io/nuget/v/Meadow.JsonRpc.Server.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.JsonRpc.Server) | Fast and lightweight HTTP and WebSockets JSON-RPC server - using Kestrel and managed sockets. |
| [Meadow.EVM](src/Meadow.EVM) | [![nuget](https://img.shields.io/nuget/v/Meadow.EVM.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.EVM) | An Ethereum Virtual Machine that includes: <ul><li>Instructions/opcodes, calling conventions/messages/return values, memory/stack, logs/events, gas, charges/limits, precompiles, contract creation logic. <li>Core Ethereum components: account storage, transaction receipts, transaction pool, blocks, world state, snapshoting/reverting, chain, mining/consensus mechanism/scoring/difficulty/uncles. <li>Underlying dependencies: configuration/genesis block/fork/versioning/chain ID support, modified Merkle Patricia Trees, bloom filters, elliptic curve signing + public key recovery, Ethash, in-memory storage database.</ul> |
| [Meadow.TestNode](src/Meadow.TestNode) | [![nuget](https://img.shields.io/nuget/v/Meadow.TestNode.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.TestNode) | Ethereum "personal blockchain" / "test node" / "RPC Server" / "Ethereum client". Ran as either a standalone server or via programmatic setup / teardown during unit test execution. Supports several non-standard RPC methods for debugging, testing, and coverage report generation. |
| [Meadow.SolCodeGen](src/Meadow.SolCodeGen) | [![nuget](https://img.shields.io/nuget/v/Meadow.SolCodeGen.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.SolCodeGen) | Tool that compiles Solidity source files and generates a C# class for each contract. All public methods and events in the contract ABI are translated to corresponding idiomatic C# methods and event log classes. Solidity NatSpec comments / docs are also translated to IntelliSense / code-completion tooltips. This nuget package can be simply added to a project and Solidity files in the project `contracts` directory are automatically compiled. |
| [Meadow.CoverageReport](src/Meadow.CoverageReport) | [![nuget](https://img.shields.io/nuget/v/Meadow.CoverageReport.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.CoverageReport) | Generates HTML and JSON code coverage reports for Solidity source files. Uses execution trace data from the EVM. |
| [Meadow.UnitTestTemplate](src/Meadow.UnitTestTemplate) | [![nuget](https://img.shields.io/nuget/v/Meadow.UnitTestTemplate.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.UnitTestTemplate) | Test harness providing seamless integration between MSTest and Solidity contracts. Provides a simple workflow where Solidity source files are dropped into a unit test project and C# contract code is automatically generated. C# unit tests can easily deploy/call/transact with contracts. RPC test node servers & clients are automatically boostrapped and provided to unit tests. Code coverage reports are automatically generated after unit tests are ran. |
| [Meadow.Cli](src/Meadow.Cli) | [![nuget](https://img.shields.io/nuget/v/Meadow.Cli.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.Cli) | Tool that allows contract deployments and interaction through the command line. Solidity source files are live-compiled using a file system watcher. Can be ran against a automatically bootstrapped test RPC node or an externally configured node. Leverages PowerShell Core to a provide cross platform REPL-like environment with powerful tab-completion when interacting with contracts. |
| [Meadow.VSCode.Debugger](src/Meadow.VSCode.Debugger) | TODO.. | Solidity debugger extension for VSCode supporting beakpoints, stepping, rewinding, call stacks, local & state variable inspection. |
| [Meadow.Core](src/Meadow.Core) | [![nuget](https://img.shields.io/nuget/v/Meadow.Core.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.Core) | <ul><li>RLP and ABI encoding & decoding utils. <li>Implementations of Ethereum / solidity types such as Address, UInt256, Hash, etc. <li>BIP32, BIP39, BIP44, HD account derivation implementation. <li>Fast managed Keccak hashing. <li> ECDSA / secp256k1 utils.</ul> |
| [Meadow.JsonRpc](src/Meadow.JsonRpc) | [![nuget](https://img.shields.io/nuget/v/Meadow.JsonRpc.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.JsonRpc) | <ul><li>.NET types for the Ethereum JSON-RPC request & response data structures. <li>.NET interface for all RPC methods. <li>Serialization for JSON/hex object formats <-> Solidity/.NET types.</ul> |
| [Meadow.JsonRpc.Client](src/Meadow.JsonRpc.Client) | [![nuget](https://img.shields.io/nuget/v/Meadow.JsonRpc.Client.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.JsonRpc.Client) | JSON-RPC client implementation, supported transports: http, WebSocket, and IPC. |
| [Meadow.JsonRpc.Server](src/Meadow.JsonRpc.Server) | [![nuget](https://img.shields.io/nuget/v/Meadow.JsonRpc.Server.svg?colorB=blue)](https://www.nuget.org/packages/Meadow.JsonRpc.Server) | Fast and lightweight HTTP and WebSockets JSON-RPC server - using Kestrel and managed sockets. |
6 changes: 4 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ install:
Install-Product node $env:nodejs_version
npm install -g ganache-cli
cache:
- packages -> **\packages.config
build_script:
- ps: >-
cd src
dotnet restore --configfile Nuget.Config --ignore-failed-sources
dotnet msbuild -p:Configuration=Debug /maxcpucount:1 /nodeReuse:false
test_script:
- ps: >-
Start-Process ganache-cli -PassThru -ArgumentList "--port=7545"
cd src
dotnet test --no-build --no-restore -c Debug
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.PowerShell.Commands;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Runtime.InteropServices;
using System;
using System.Collections;
using System.Collections.Concurrent;
Expand All @@ -26,6 +27,7 @@
using System.Reflection;
using System.Resources;
using System.Runtime.Loader;
using System.Security;
using System.Security.Cryptography;
using System.Text;

Expand Down Expand Up @@ -59,7 +61,7 @@ protected override void EndProcessing()
{
accountDerivation = new HDAccountDerivation(Mnemonic);
}

var accountKeys = new List<(Address Address, EthereumEcdsa Account)>();

foreach (var account in EthereumEcdsa.Generate(config.AccountCount, accountDerivation))
Expand All @@ -82,11 +84,18 @@ protected override void EndProcessing()
[Alias("readAccounts")]
public class LoadAccountsCommand : PSCmdlet
{

[Parameter(Mandatory = false, Position = 0)]
public string FilePath { get; set; } = LocalAccountsUtil.DEFAULT_FILE_NAME;

[Parameter(Mandatory = false)]
public string Password { get; set; }
//Changed string to secure string for use in console. This should prevent the recall of the characters that comprise the password from Std error/Std out/Verbose messages.
//I believe it does this by immediately sending the individual characters to a location in unmanaged memory and returning a pointer for retrieval.
//This is also prioritized by GC when no longer needed, and called by the dispose method.
//to use a secure string as the password -> Read-Accounts -FilePath 'Path/to/file' -Password (ConvertTo-SecureString -String 'password' -AsPlaintext -Force)
//In both instances of use, I have had to convert the password and dispose of it immediately, so it does not stay in memory past the single command use and has to be reconverted for further uses.

[Parameter(Mandatory = false, Position = 2)]
public SecureString Password { get; set; }

protected override void EndProcessing()
{
Expand All @@ -113,17 +122,22 @@ protected override void EndProcessing()

if (dataJson.TryGetValue(LocalAccountsUtil.JSON_ENCRYPTED_ACCOUNTS_KEY, out var token))
{
if (string.IsNullOrWhiteSpace(Password))
if (Password.Length == 0)
{
Host.UI.WriteErrorLine($"No password parameter specified and accounts are encryped in file {FilePath}");
return;
}
else
{
Password.MakeReadOnly();
}

var encrypedAccounts = token.Value<string>();
string decrypedContent;
try
{
decrypedContent = AesUtil.DecryptString(encrypedAccounts, Password);
decrypedContent = AesUtil.DecryptString(encrypedAccounts, Marshal.PtrToStringAuto(Marshal.SecureStringToBSTR(Password)));
Password.Dispose();
}
catch (Exception ex)
{
Expand All @@ -136,7 +150,7 @@ protected override void EndProcessing()
}
else
{
if (!string.IsNullOrWhiteSpace(Password))
if (Password != null && Password.Length > 0)
{
Host.UI.WriteErrorLine($"Password parameter specified but accounts are encryped in file {FilePath}");
return;
Expand Down Expand Up @@ -167,7 +181,7 @@ public class WriteAccountsCommand : PSCmdlet
public string FilePath { get; set; } = LocalAccountsUtil.DEFAULT_FILE_NAME;

[Parameter(Mandatory = false)]
public string Password { get; set; }
public SecureString Password { get; set; }

[Parameter(Mandatory = false)]
public bool EncryptData = true;
Expand All @@ -190,13 +204,13 @@ protected override void EndProcessing()
filePath = Path.GetFullPath(Path.Join(SessionState.Path.CurrentLocation.Path, FilePath));
}

if (EncryptData && string.IsNullOrWhiteSpace(Password))
if (EncryptData && (Password == null || Password.Length == 0))
{
Host.UI.WriteErrorLine($"No '{nameof(Password)}' parameter is provided. To write without encryption set the '{nameof(EncryptData)}' parameter to false");
return;
}

if (!string.IsNullOrWhiteSpace(Password) && !EncryptData)
if ((Password != null && Password.Length > 0) && !EncryptData)
{
Host.UI.WriteErrorLine($"The '{nameof(EncryptData)}' parameter is set to false but the '{nameof(Password)}' parameter is provided. Pick one.");
return;
Expand All @@ -216,8 +230,10 @@ protected override void EndProcessing()

if (EncryptData)
{
Password.MakeReadOnly();
var accountJson = JsonConvert.SerializeObject(accountArrayHex, Formatting.Indented);
var encrypedAccountsString = AesUtil.EncryptString(accountJson, Password);
var encrypedAccountsString = AesUtil.EncryptString(accountJson, Marshal.PtrToStringAuto(Marshal.SecureStringToBSTR(Password)));
Password.Dispose();
dataObj[LocalAccountsUtil.JSON_ENCRYPTED_ACCOUNTS_KEY] = encrypedAccountsString;
}
else
Expand All @@ -229,8 +245,8 @@ protected override void EndProcessing()
{
var choices = new Collection<ChoiceDescription>(new[]
{
new ChoiceDescription("Cancel"),
new ChoiceDescription("Overwrite")
new ChoiceDescription("&Cancel"),
new ChoiceDescription("&Overwrite")
});
var overwrite = Host.UI.PromptForChoice($"File already exists at {filePath}", "Continue and overwite existing file?", choices, 0);
if (overwrite != 1)
Expand Down
File renamed without changes.

0 comments on commit 1cce3b3

Please sign in to comment.