├── src ├── Meadow.SolCodeGen │ ├── _._ │ ├── Targets │ │ └── Meadow.SolCodeGen.targets │ ├── Util.cs │ ├── CodeGenerators │ │ └── SolcOutputHelperGenerator.cs │ └── ContractInfo.cs ├── Meadow.Core │ ├── EthTypes │ │ ├── FixedN.cs │ │ ├── IntegerTypes.cs │ │ ├── FixedN.tt │ │ └── FixedMxN.cs │ ├── RlpEncoding │ │ ├── IRLPSerializable.cs │ │ └── RLPByteArray.cs │ ├── Cryptography │ │ └── ECDSA │ │ │ ├── EthereumEcdsaKeyType.cs │ │ │ ├── Bn128 │ │ │ └── IField.cs │ │ │ └── BouncyCastleExtensions.cs │ ├── Utils │ │ ├── EthUtil.cs │ │ ├── TypeAttributeCache.cs │ │ ├── StringUtil.cs │ │ ├── ObjectPool.cs │ │ └── MiscExtensions.cs │ └── AccountDerivation │ │ ├── BIP39 │ │ └── WordListLanguage.cs │ │ ├── HDAccountDerivation.cs │ │ ├── SystemRandomAccountDerivation.cs │ │ └── AccountDerivationBase.cs ├── Meadow.VSCode.Debugger │ ├── CHANGELOG.md │ ├── meadow-icon-256x256.png │ ├── .vscodeignore │ ├── src │ │ ├── tslint.json │ │ ├── tsconfig.json │ │ └── logger.ts │ └── .vscode │ │ ├── settings.json │ │ ├── tasks.json │ │ └── launch.json ├── Meadow.SolCodeGen.Test │ ├── ContractsEmpty │ │ └── placeholder.txt │ ├── Contracts │ │ └── DeepDirectory │ │ │ └── PackageRefContract.sol │ └── Util.cs ├── Meadow.DebugExampleTests │ ├── package-lock.json │ ├── Contracts │ │ ├── MainContract.sol │ │ └── Nested │ │ │ └── NestedContract.sol │ ├── .vscode │ │ └── tasks.json │ ├── Meadow.DebugExampleTests.csproj │ ├── NestedContractTests.cs │ └── GlobalSetup.cs ├── After.Meadow.sln.targets ├── Meadow.UnitTestTemplate.Test │ ├── Contracts │ │ ├── IgnoreContract.sol │ │ ├── Mocks │ │ │ └── MockContract.sol │ │ ├── Deep │ │ │ └── Dir │ │ │ │ └── SomeContract.sol │ │ ├── MissingConstructorChild.sol │ │ ├── MissingConstructorParent.sol │ │ ├── InheritanceParent.sol │ │ ├── InheritanceChild.sol │ │ ├── BitShifting.sol │ │ └── ExceptionContract.sol │ ├── app.config │ ├── GlobalSetup.cs │ ├── NestedBranchesTests.cs │ ├── InheritanceTests.cs │ ├── Meadow.UnitTestTemplate.Test.csproj │ └── TestsIgnoredContracts.cs ├── Meadow.Cli.Test │ ├── Meadow.Cli.Test.csproj │ └── Program.cs ├── Meadow.SolCodeGen.TestApp │ ├── app.config │ ├── Contracts │ │ ├── ERC20Basic.sol │ │ ├── ERC20.sol │ │ ├── MintedCrowdsale.sol │ │ ├── ErrorContract.sol │ │ ├── MultifileInheritableContract.sol │ │ ├── MultifileInheritedContract.sol │ │ ├── FinalizableCrowdsale.sol │ │ ├── OtherContract.sol │ │ ├── Ownable.sol │ │ └── CappedCrowdsale.sol │ └── Meadow.SolCodeGen.TestApp.csproj ├── Meadow.CoverageReport.Test │ ├── UnitTest1.cs │ └── Meadow.CoverageReport.Test.csproj ├── .editorconfig ├── Meadow.UnitTestTemplate │ ├── Meadow.UnitTestTemplate.targets │ ├── RunnerEntryPoint.cs │ ├── reference-mstest-adapter.targets │ ├── MeadowTestClassAttribute.cs │ ├── Meadow.UnitTestTemplate.props │ ├── SkipCoverageAttribute.cs │ ├── ITestMethodExtensions.cs │ ├── ParallelTestClassAttribute.cs │ └── InternalTestState.cs ├── Meadow.Networking │ ├── Meadow.Networking.csproj │ ├── Protocol │ │ └── RLPx │ │ │ ├── Messages │ │ │ └── IRLPxMessage.cs │ │ │ ├── RLPxSessionRole.cs │ │ │ └── RLPxSessionState.cs │ ├── Extensions │ │ └── IPAddressExtensions.cs │ └── Configuration │ │ └── NetworkConfiguration.cs ├── Meadow.CoverageReport │ ├── AstTypes │ │ ├── Enums │ │ │ ├── AstVariableStorageLocation.cs │ │ │ └── AstDeclarationVisibility.cs │ │ ├── AstEnumMember.cs │ │ ├── AstTypeDescriptions.cs │ │ ├── AstArrayTypeName.cs │ │ ├── AstUserDefinedTypeName.cs │ │ ├── AstElementaryTypeName.cs │ │ └── AstMappingTypeName.cs │ ├── UnitTestResult.cs │ ├── Debugging │ │ ├── Variables │ │ │ ├── Enums │ │ │ │ ├── VarLocation.cs │ │ │ │ ├── VarTypeLocation.cs │ │ │ │ └── VarGenericType.cs │ │ │ ├── VarResolvingException.cs │ │ │ ├── Pairing │ │ │ │ ├── MappingKeyValuePair.cs │ │ │ │ ├── VariableValuePair.cs │ │ │ │ └── UnderlyingVariableValuePair.cs │ │ │ └── UnderlyingTypes │ │ │ │ ├── VarInt.cs │ │ │ │ ├── VarUInt.cs │ │ │ │ ├── VarBoolean.cs │ │ │ │ ├── VarFixedBytes.cs │ │ │ │ └── VarAddress.cs │ │ └── ContractExecutionException.cs │ ├── Models │ │ ├── IndexViewModel.cs │ │ ├── LibVersion.cs │ │ ├── BranchCoverageState.cs │ │ ├── SourceFileMap.cs │ │ ├── SourceFileLine.cs │ │ └── CoverageStats.cs │ ├── BranchType.cs │ ├── Meadow.CoverageReport.csproj │ ├── Views │ │ └── CoverageHeader.cshtml │ └── AnalysisResults.cs ├── Meadow.DebugAdapterServer │ ├── DebuggerTransport │ │ ├── IDebuggerTransport.cs │ │ ├── StandardInputOutputDebuggerTransport.cs │ │ └── NamedPipeServerDebuggerTransport.cs │ ├── DesiredControlFlow.cs │ ├── ProblemDebugEvent.cs │ ├── Meadow.DebugAdapterServer.csproj │ └── SolidityMeadowConfigurationProperties.cs ├── Meadow.Cli │ ├── Help │ │ ├── Meadow.Cli.hwprojs │ │ ├── Meadow.Cli.hwproj │ │ └── Watch-Solidity.md │ ├── ModuleInitializer.cs │ ├── Properties │ │ └── launchSettings.json │ └── Commands │ │ └── WatchConfigCommand.cs ├── Meadow.Contract │ ├── EventSignatureAttribute.cs │ ├── Meadow.Contract.csproj │ ├── GeneratedSolcDataAttribute.cs │ └── SolidityContractAttribute.cs ├── pwsh_testing │ ├── Contracts │ │ ├── FailDeploymentContract.sol │ │ ├── ErrorContract.sol │ │ ├── MultifileInheritedContract.sol │ │ ├── OtherContract.sol │ │ ├── MultifileInheritableContract.sol │ │ └── VarAnalysisContract.sol │ └── meadow.config.xml ├── Meadow.TestNode.Test.App │ ├── Contracts │ │ ├── FailDeploymentContract.sol │ │ ├── ErrorContract.sol │ │ ├── MultifileInheritedContract.sol │ │ ├── OtherContract.sol │ │ └── MultifileInheritableContract.sol │ └── Meadow.TestNode.Test.App.csproj ├── Meadow.JsonRpc │ ├── Meadow.JsonRpc.csproj │ ├── RpcApiMethodAttribute.cs │ ├── ArbitraryDefaults.cs │ ├── Types │ │ └── Debugging │ │ │ ├── ExecutionTrace.cs │ │ │ └── ExecutionTraceException.cs │ ├── JsonRpcRequestObject.cs │ ├── JsonConverters │ │ └── JsonRpcSerializer.cs │ └── RpcControllerExtensions.cs ├── Nuget.Config ├── Meadow.JsonRpc.Client │ ├── TransportAdapter │ │ └── ITransportAdapter.cs │ └── Meadow.JsonRpc.Client.csproj ├── Meadow.TestNode │ ├── Meadow.TestNode.csproj │ └── AccountConfiguration.cs ├── Meadow.EVM │ ├── EVM │ │ ├── Hooking │ │ │ └── EVMHookInterface.cs │ │ └── Instructions │ │ │ ├── Stack │ │ │ ├── InstructionPop.cs │ │ │ └── InstructionSwap.cs │ │ │ ├── Control Flow and IO │ │ │ ├── InstructionGetPC.cs │ │ │ ├── InstructionGas.cs │ │ │ ├── InstructionMemorySize.cs │ │ │ ├── InstructionJumpDest.cs │ │ │ ├── InstructionHalt.cs │ │ │ ├── InstructionStorageLoad.cs │ │ │ ├── InstructionMemoryStore.cs │ │ │ ├── InstructionMemoryLoad.cs │ │ │ └── InstructionMemoryStore8.cs │ │ │ ├── Environment │ │ │ ├── InstructionCodeSize.cs │ │ │ ├── InstructionCallValue.cs │ │ │ ├── InstructionCaller.cs │ │ │ ├── InstructionAddress.cs │ │ │ ├── InstructionCallDataSize.cs │ │ │ ├── InstructionBalance.cs │ │ │ ├── InstructionGasPrice.cs │ │ │ ├── InstructionOrigin.cs │ │ │ ├── InstructionReturnDataSize.cs │ │ │ └── InstructionExternalCodeSize.cs │ │ │ ├── Block Information │ │ │ ├── InstructionBlockCoinbase.cs │ │ │ ├── InstructionBlockGasLimit.cs │ │ │ ├── InstructionBlockNumber.cs │ │ │ ├── InstructionBlockTimestamp.cs │ │ │ └── InstructionBlockDifficulty.cs │ │ │ ├── Arithmetic │ │ │ ├── InstructionAdd.cs │ │ │ ├── InstructionMultiply.cs │ │ │ ├── InstructionMod.cs │ │ │ ├── InstructionDivide.cs │ │ │ ├── InstructionSubtract.cs │ │ │ ├── InstructionSignedDivide.cs │ │ │ ├── InstructionAddMod.cs │ │ │ ├── InstructionMultiplyMod.cs │ │ │ └── InstructionSignedMod.cs │ │ │ ├── System Operations │ │ │ ├── InstructionInvalid.cs │ │ │ ├── InstructionRevert.cs │ │ │ └── InstructionReturn.cs │ │ │ └── Bitwise Logic │ │ │ ├── InstructionIsZero.cs │ │ │ ├── InstructionEqual.cs │ │ │ ├── InstructionOr.cs │ │ │ ├── InstructionAnd.cs │ │ │ ├── InstructionLessThan.cs │ │ │ ├── InstructionXor.cs │ │ │ ├── InstructionGreaterThan.cs │ │ │ ├── InstructionSignedLessThan.cs │ │ │ └── InstructionSignedGreaterThan.cs │ ├── Meadow.EVM.csproj │ ├── Data Types │ │ └── Chain │ │ │ └── ConsensusBase.cs │ ├── Exceptions │ │ ├── BlockException.cs │ │ ├── TransactionException.cs │ │ └── EVMException.cs │ ├── Configuration │ │ └── EthereumChainID.cs │ └── Debugging │ │ └── Tracing │ │ └── ExecutionTraceException.cs ├── Meadow.UnitTestTemplate.ParallelTest │ ├── app.config │ └── GlobalSetup.cs ├── Directory.Build.targets ├── Meadow.JsonRpc.Server.Test │ └── Test.cs ├── Meadow.DebugAdapterProxy │ └── Meadow.DebugAdapterProxy.csproj ├── run-coverage-tests.bat ├── Before.Meadow.sln.targets ├── Meadow.JsonRpc.Server.Proxy │ ├── Meadow.JsonRpc.Server.Proxy.csproj │ └── Program.cs ├── Meadow.JsonRpc.Server │ ├── MiscUtil.cs │ └── Meadow.JsonRpc.Server.csproj ├── Meadow.Networking.Test │ └── Meadow.Networking.Test.csproj ├── Meadow.TestNode.Host │ ├── Meadow.TestNode.Host.csproj │ └── ProcessArgs.cs ├── Meadow.DebugSolSources │ ├── Meadow.DebugSolSources.csproj │ └── ProcessArgs.cs ├── Meadow.EVM.Test │ ├── Meadow.EVM.Test.csproj │ └── TransactionRlpTests.cs ├── Meadow.Core.Test │ └── Meadow.Core.Test.csproj ├── Meadow.Contract.Test │ └── Meadow.Contract.Test.csproj ├── Meadow.JsonRpc.Client.Test │ └── Meadow.JsonRpc.Client.Test.csproj └── Meadow.JsonRpc.Server.Proxy.Test │ └── Meadow.JsonRpc.Server.Proxy.Test.csproj ├── images ├── screenshot1.png ├── screenshot2.png ├── screenshot3.png ├── screenshot4.png ├── meadow-icon-64x64.png └── meadow-icon-256x256.png ├── .travis.yml ├── appveyor.yml └── LICENSE /src/Meadow.SolCodeGen/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Meadow.Core/EthTypes/FixedN.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Meadow.Core/EthTypes/IntegerTypes.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Meadow.VSCode.Debugger/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | TODO -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.Test/ContractsEmpty/placeholder.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Meadow.DebugExampleTests/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1 3 | } 4 | -------------------------------------------------------------------------------- /images/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeadowSuite/Meadow/HEAD/images/screenshot1.png -------------------------------------------------------------------------------- /images/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeadowSuite/Meadow/HEAD/images/screenshot2.png -------------------------------------------------------------------------------- /images/screenshot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeadowSuite/Meadow/HEAD/images/screenshot3.png -------------------------------------------------------------------------------- /images/screenshot4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeadowSuite/Meadow/HEAD/images/screenshot4.png -------------------------------------------------------------------------------- /images/meadow-icon-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeadowSuite/Meadow/HEAD/images/meadow-icon-64x64.png -------------------------------------------------------------------------------- /images/meadow-icon-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeadowSuite/Meadow/HEAD/images/meadow-icon-256x256.png -------------------------------------------------------------------------------- /src/Meadow.VSCode.Debugger/meadow-icon-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeadowSuite/Meadow/HEAD/src/Meadow.VSCode.Debugger/meadow-icon-256x256.png -------------------------------------------------------------------------------- /src/After.Meadow.sln.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/Meadow.VSCode.Debugger/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/test/** 4 | out/**/*.map 5 | out/preparePackage.js 6 | src/** 7 | tsconfig.json 8 | tslint.json -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen/Targets/Meadow.SolCodeGen.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.Test/Contracts/DeepDirectory/PackageRefContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | import "ExampleContract.sol"; 4 | 5 | contract PackageRefContract is ExampleContract { 6 | 7 | 8 | } -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/Contracts/IgnoreContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | contract IgnoreContract { 5 | 6 | function echoString(string val) public returns (string) { 7 | return val; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/Contracts/Mocks/MockContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | contract MockContract { 5 | 6 | function echoString(string val) public returns (string) { 7 | return val; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /src/Meadow.Cli.Test/Meadow.Cli.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/Contracts/Deep/Dir/SomeContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | contract SomeContract { 5 | 6 | function echoString(string val) public returns (string) { 7 | return val; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Meadow.Cli.Test/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Meadow.Cli.Test 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Meadow.DebugExampleTests/Contracts/MainContract.sol: -------------------------------------------------------------------------------- 1 | import "./BasicContract.sol"; 2 | 3 | pragma solidity ^0.4.24; 4 | 5 | contract Main { 6 | 7 | constructor() public { 8 | BasicContract bc = new BasicContract("test", true, 123); 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /src/Meadow.CoverageReport.Test/UnitTest1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | namespace Meadow.CoverageReport.Test 5 | { 6 | public class UnitTest1 7 | { 8 | [Fact] 9 | public void Test1() 10 | { 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.sol] 4 | end_of_line = lf 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 4 8 | 9 | [*.cs] 10 | indent_style = space 11 | indent_size = 4 12 | 13 | [*.{xml,csproj,targets,props}] 14 | indent_syle = space 15 | indent_size = 2 -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/Contracts/MissingConstructorChild.sol: -------------------------------------------------------------------------------- 1 | import "./MissingConstructorParent.sol"; 2 | 3 | pragma solidity ^0.4.11; 4 | 5 | 6 | contract MissingConstructorChild is MissingConstructorParent { 7 | 8 | function MissingConstructorChild() { } 9 | 10 | } -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/Contracts/MissingConstructorParent.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.11; 2 | 3 | contract MissingConstructorParent { 4 | 5 | uint public someNum; 6 | 7 | function MissingConstructorParent(uint _someNum) { 8 | someNum = _someNum; 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate/Meadow.UnitTestTemplate.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Exe 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Meadow.VSCode.Debugger/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-unused-expression": true, 4 | "no-duplicate-variable": true, 5 | "curly": true, 6 | "class-name": true, 7 | "semicolon": [ "always" ], 8 | "triple-equals": true, 9 | "no-var-keyword": true, 10 | "no-bitwise": true 11 | } 12 | } -------------------------------------------------------------------------------- /src/Meadow.Core/RlpEncoding/IRLPSerializable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.Core.RlpEncoding 6 | { 7 | public interface IRLPSerializable 8 | { 9 | RLPItem Serialize(); 10 | void Deserialize(RLPItem item); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Meadow.Core/Cryptography/ECDSA/EthereumEcdsaKeyType.cs: -------------------------------------------------------------------------------- 1 | namespace Meadow.Core.Cryptography.Ecdsa 2 | { 3 | /// 4 | /// Identifies the types of ECDSA keys one could provide. 5 | /// 6 | public enum EthereumEcdsaKeyType 7 | { 8 | Public, 9 | Private 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Meadow.Networking/Meadow.Networking.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Meadow.Networking/Protocol/RLPx/Messages/IRLPxMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.Networking.Protocol.RLPx.Messages 6 | { 7 | public interface IRLPxMessage 8 | { 9 | byte[] Serialize(); 10 | void Deserialize(byte[] data); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/AstTypes/Enums/AstVariableStorageLocation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.CoverageReport.AstTypes.Enums 6 | { 7 | public enum AstVariableStorageLocation 8 | { 9 | Default, 10 | Memory, 11 | Storage 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Meadow.DebugAdapterServer/DebuggerTransport/IDebuggerTransport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace Meadow.DebugAdapterServer.DebuggerTransport 5 | { 6 | public interface IDebuggerTransport : IDisposable 7 | { 8 | Stream InputStream { get; } 9 | Stream OutputStream { get; } 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/Contracts/InheritanceParent.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | contract InheritanceParent { 5 | 6 | function ensureThing(uint _num) internal returns(uint) { 7 | 8 | // quarum must be at least 1 (used to determine existence) 9 | require(_num > 0); 10 | 11 | _num++; 12 | return _num; 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/UnitTestResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Meadow.CoverageReport 4 | { 5 | public class UnitTestResult 6 | { 7 | public string Namespace { get; set; } 8 | public string TestName { get; set; } 9 | public bool Passed { get; set; } 10 | public TimeSpan Duration { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Meadow.DebugAdapterServer/DesiredControlFlow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.DebugAdapterServer 6 | { 7 | public enum DesiredControlFlow 8 | { 9 | Continue, 10 | StepInto, 11 | StepOver, 12 | StepBackwards, 13 | StepOut 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Meadow.Cli/Help/Meadow.Cli.hwprojs: -------------------------------------------------------------------------------- 1 | 2 | 1.0 3 | 44ff33c4-35ba-4b8b-96de-c35bb2b73110 4 | 5 | en-US 6 | 7 | 8 | en-US\Meadow.Cli-Help.xml 9 | en-US\about_Meadow.Cli.Help.txt 10 | 11 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/AstTypes/Enums/AstDeclarationVisibility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.CoverageReport.AstTypes.Enums 6 | { 7 | public enum AstDeclarationVisibility 8 | { 9 | Public, 10 | Private, 11 | Internal, 12 | External, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Meadow.Contract/EventSignatureAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Meadow.Contract 4 | { 5 | public class EventSignatureAttribute : Attribute 6 | { 7 | public readonly string Signature; 8 | 9 | public EventSignatureAttribute(string signature) 10 | { 11 | Signature = signature; 12 | } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/Meadow.Core/Utils/EthUtil.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Core.EthTypes; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Numerics; 5 | using System.Text; 6 | 7 | namespace Meadow.Core.Utils 8 | { 9 | public static class EthUtil 10 | { 11 | public static readonly UInt256 ONE_ETHER_IN_WEI = (UInt256)BigInteger.Pow(10, 18); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pwsh_testing/Contracts/FailDeploymentContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | contract FailDeploymentContract { 5 | 6 | 7 | constructor() public { 8 | address a = 0x0; 9 | int num = 4 + 5; 10 | someFunction(); 11 | } 12 | 13 | function someFunction() { 14 | failingFunction(); 15 | } 16 | 17 | function failingFunction() { 18 | revert(); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /src/Meadow.TestNode.Test.App/Contracts/FailDeploymentContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | contract FailDeploymentContract { 5 | 6 | 7 | constructor() public { 8 | address a = 0x0; 9 | int num = 4 + 5; 10 | someFunction(); 11 | } 12 | 13 | function someFunction() { 14 | failingFunction(); 15 | } 16 | 17 | function failingFunction() { 18 | revert(); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate/RunnerEntryPoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using System.Text; 5 | 6 | namespace Meadow.UnitTestTemplate 7 | { 8 | class RunnerEntryPoint 9 | { 10 | public static void Main(string[] args) 11 | { 12 | Meadow.UnitTestTemplate.Global.Launch(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | dotnet: 2.1.402 3 | node_js: "10" 4 | mono: none 5 | os: osx 6 | env: 7 | - DISABLE_EXTERNAL_PARALLEL_TESTS=true 8 | install: 9 | - npm install -g ganache-cli 10 | script: 11 | - cd src 12 | - dotnet restore --configfile Nuget.Config 13 | - dotnet msbuild -p:Configuration=Debug /maxcpucount:1 /nodeReuse:false 14 | - dotnet test -c Debug --no-build --no-restore -------------------------------------------------------------------------------- /src/pwsh_testing/meadow.config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Meadow.DebugExampleTests/Contracts/Nested/NestedContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | contract NestedContract { 5 | 6 | uint public number; 7 | 8 | /// @notice The constructor 9 | constructor() public { 10 | number = 12; 11 | } 12 | 13 | function incrementNumber(uint x) returns (uint) 14 | { 15 | number += x; 16 | return number; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /src/Meadow.Networking/Protocol/RLPx/RLPxSessionRole.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.Networking.Protocol.RLPx 6 | { 7 | /// 8 | /// Represents the user's role in an RLPx session/handshake. 9 | /// 10 | public enum RLPxSessionRole 11 | { 12 | Initiator, 13 | Responder 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Meadow.Cli/ModuleInitializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Reflection; 5 | using System.Text; 6 | 7 | namespace Meadow.Cli 8 | { 9 | public static class ModuleInitializer 10 | { 11 | public static void Initialize() 12 | { 13 | // Console.WriteLine("Test / debug : module initialized"); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc/Meadow.JsonRpc.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Nuget.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Meadow.Cli/Help/Meadow.Cli.hwproj: -------------------------------------------------------------------------------- 1 | 2 | 1.0 3 | 44ff33c4-35ba-4b8b-96de-c35bb2b73110 4 | 5 | en-US 6 | 7 | 8 | en-US\about_Meadow.Cli.Help.txt 9 | en-US\Meadow.Cli-Help.xml 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Meadow.Contract/Meadow.Contract.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc.Client/TransportAdapter/ITransportAdapter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Meadow.JsonRpc.Client.TransportAdapter 8 | { 9 | public interface ITransportAdapter : IDisposable 10 | { 11 | Uri EndPoint { get; } 12 | Task Request(JObject requestObject); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/Enums/VarLocation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.CoverageReport.Debugging.Variables.Enums 6 | { 7 | /// 8 | /// Represents a variables actual resulting location after parsing other location enums. 9 | /// 10 | public enum VarLocation 11 | { 12 | None, 13 | Memory, 14 | Storage 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/ContractExecutionException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Meadow.CoverageReport.Debugging 4 | { 5 | public class ContractExecutionException : Exception 6 | { 7 | public ContractExecutionException(string message, Exception inner) : base(message, inner) 8 | { 9 | 10 | } 11 | 12 | public ContractExecutionException(string message) : base(message) 13 | { 14 | 15 | } 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/Meadow.Networking/Protocol/RLPx/RLPxSessionState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.Networking.Protocol.RLPx 6 | { 7 | /// 8 | /// Indicates the state of the current RLPx session. 9 | /// 10 | public enum RLPxSessionState 11 | { 12 | Initial, 13 | AuthenticationCompleted, 14 | AcknowledgementCompleted, 15 | EstablishedEncryption 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc/RpcApiMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Meadow.JsonRpc 4 | { 5 | public class RpcApiMethodAttribute : Attribute 6 | { 7 | public readonly RpcApiMethod Method; 8 | 9 | public RpcApiMethodAttribute(RpcApiMethod method) 10 | { 11 | Method = method; 12 | } 13 | 14 | public RpcApiMethodAttribute(string method) 15 | { 16 | Method = RpcApiMethods.Create(method); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate/reference-mstest-adapter.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Meadow.VSCode.Debugger/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2017", 5 | "noImplicitAny": false, 6 | "removeComments": false, 7 | "noUnusedLocals": false, 8 | "allowUnusedLabels": true, 9 | "noImplicitThis": true, 10 | "inlineSourceMap": false, 11 | "sourceMap": true, 12 | "outDir": "../out", 13 | "preserveConstEnums": true, 14 | "strictNullChecks": true, 15 | "noUnusedParameters": false, 16 | "alwaysStrict": true 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Models/IndexViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Meadow.CoverageReport.Models 7 | { 8 | public class IndexViewModel : CoverageStats 9 | { 10 | public string SolidityCompilerVersion { get; set; } 11 | 12 | public SourceFileMap[] SourceFileMaps { get; set; } 13 | 14 | public IGrouping[] UnitTestOutcome { get; set; } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Meadow.TestNode/Meadow.TestNode.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Meadow.Core/Utils/TypeAttributeCache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using System.Text; 5 | 6 | namespace Meadow.Core.Utils 7 | { 8 | public static class TypeAttributeCache where TAttribute : Attribute 9 | { 10 | public static readonly TAttribute Attribute; 11 | 12 | static TypeAttributeCache() 13 | { 14 | Attribute = typeof(TType).GetCustomAttribute(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Hooking/EVMHookInterface.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.EVM.EVM.Hooking 6 | { 7 | /// 8 | /// Used to supply handlers for certain events, which can be used as hooks for the EVM component of the Ethereum Core. 9 | /// 10 | public class EVMHookInterface 11 | { 12 | #region Properties 13 | #endregion 14 | 15 | #region Constructors 16 | #endregion 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.ParallelTest/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Models/LibVersion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.CoverageReport.Models 6 | { 7 | public static class LibVersion 8 | { 9 | public static readonly string Version; 10 | 11 | static LibVersion() 12 | { 13 | var asm = typeof(LibVersion).Assembly; 14 | var ver = asm.GetName().Version; 15 | Version = $"{ver.Major}.{ver.Minor}.{ver.Build}"; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Meadow.Cli/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Meadow.Cli": { 4 | "commandName": "Executable", 5 | "executablePath": "pwsh", 6 | "commandLineArgs": "-NoExit -Command Import-Module $(TargetPath)", 7 | "workingDirectory": "$(SolutionDir)/pwsh_testing" 8 | }, 9 | "Host": { 10 | "commandName": "Executable", 11 | "executablePath": "dotnet", 12 | "commandLineArgs": "$(TargetPath)", 13 | "workingDirectory": "$(SolutionDir)/pwsh_testing" 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/VarResolvingException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.CoverageReport.Debugging.Variables 6 | { 7 | public class VarResolvingException : Exception 8 | { 9 | public VarResolvingException(string message, Exception inner) : base(message, inner) 10 | { 11 | 12 | } 13 | 14 | public VarResolvingException(string message) : base(message) 15 | { 16 | 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Meadow.DebugExampleTests/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "build", 8 | "command": "dotnet build", 9 | "type": "shell", 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "silent" 13 | }, 14 | "problemMatcher": "$msCompile" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /src/Meadow.DebugAdapterServer/ProblemDebugEvent.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages; 2 | using Newtonsoft.Json; 3 | 4 | namespace Meadow.DebugAdapterServer 5 | { 6 | class ProblemDebugEvent : DebugEvent 7 | { 8 | [JsonProperty("message")] 9 | public string Message { get; set; } 10 | 11 | [JsonProperty("exception")] 12 | public string Exception { get; set; } 13 | 14 | public ProblemDebugEvent() : base("problemEvent") 15 | { 16 | 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/Meadow.Cli/Commands/WatchConfigCommand.cs: -------------------------------------------------------------------------------- 1 | using Meadow.JsonRpc; 2 | using System.Collections.Generic; 3 | using System.Management.Automation; 4 | 5 | namespace Meadow.Cli.Commands 6 | { 7 | // TODO: setup file watcher for config updates 8 | 9 | 10 | [Cmdlet(ApprovedVerbs.Watch, "Config")] 11 | [Alias("watchConfig")] 12 | public class WatchConfigCommand : PSCmdlet 13 | { 14 | protected override void EndProcessing() 15 | { 16 | var config = this.ReadConfig(); 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Contracts/ERC20Basic.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | /** 5 | * @title ERC20Basic 6 | * @dev Simpler version of ERC20 interface 7 | * @dev see https://github.com/ethereum/EIPs/issues/179 8 | */ 9 | contract ERC20Basic { 10 | function totalSupply() public view returns (uint256); 11 | function balanceOf(address who) public view returns (uint256); 12 | function transfer(address to, uint256 value) public returns (bool); 13 | event Transfer(address indexed from, address indexed to, uint256 value); 14 | } 15 | -------------------------------------------------------------------------------- /src/Meadow.Core/AccountDerivation/BIP39/WordListLanguage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.Core.AccountDerivation.BIP39 6 | { 7 | /// 8 | /// The language which a given word list represents. 9 | /// 10 | public enum WordListLanguage 11 | { 12 | Chinese_Simplified, 13 | Chinese_Traditional, 14 | English, 15 | French, 16 | Italian, 17 | Japanese, 18 | Korean, 19 | Spanish, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc.Client/Meadow.JsonRpc.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Meadow.Contract/GeneratedSolcDataAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | 7 | namespace Meadow.Contract 8 | { 9 | [AttributeUsage(AttributeTargets.Assembly)] 10 | public class GeneratedSolcDataAttribute : Attribute 11 | { 12 | public readonly string SolCodeBaseHash; 13 | 14 | public GeneratedSolcDataAttribute(string solCodeBaseHash) 15 | { 16 | SolCodeBaseHash = solCodeBaseHash; 17 | } 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Models/BranchCoverageState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Meadow.CoverageReport.Models 5 | { 6 | [Flags] 7 | public enum BranchCoverageState : int 8 | { 9 | [EnumMember(Value = "none")] 10 | CoveredNone = 0, 11 | 12 | [EnumMember(Value = "if")] 13 | CoveredIf = (1 << 0), 14 | 15 | [EnumMember(Value = "else")] 16 | CoveredElse = (1 << 1), 17 | 18 | [EnumMember(Value = "both")] 19 | CoveredBoth = CoveredIf | CoveredElse 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate/MeadowTestClassAttribute.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace Meadow.UnitTestTemplate 4 | { 5 | public class MeadowTestClassAttribute : TestClassAttribute 6 | { 7 | public override TestMethodAttribute GetTestMethodAttribute(TestMethodAttribute testMethodAttribute) 8 | { 9 | return new MeadowTestMethodAttribute(); 10 | } 11 | 12 | public override bool IsDefaultAttribute() 13 | { 14 | return base.IsDefaultAttribute(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Meadow.VSCode.Debugger/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | }, 9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts 10 | "typescript.tsc.autoDetect": "off", 11 | "typescript.tsdk": "node_modules\\typescript\\lib" 12 | } -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: Visual Studio 2017 3 | environment: 4 | nodejs_version: 10.10 5 | install: 6 | - ps: >- 7 | Install-Product node $env:nodejs_version 8 | 9 | npm install -g ganache-cli 10 | build_script: 11 | - ps: >- 12 | cd src 13 | 14 | dotnet restore --configfile Nuget.Config --ignore-failed-sources 15 | 16 | dotnet msbuild -p:Configuration=Debug /maxcpucount:1 /nodeReuse:false 17 | test_script: 18 | - ps: >- 19 | Start-Process ganache-cli -PassThru -ArgumentList "--port=7545" 20 | 21 | dotnet test --no-build --no-restore -c Debug -------------------------------------------------------------------------------- /src/Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Meadow.Contract/SolidityContractAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Meadow.Contract 4 | { 5 | public class SolidityContractAttribute : Attribute 6 | { 7 | public readonly Type ContractType; 8 | public readonly string FilePath; 9 | public readonly string ContractName; 10 | 11 | public SolidityContractAttribute(Type contractType, string filePath, string contractName) 12 | { 13 | ContractType = contractType; 14 | FilePath = filePath; 15 | ContractName = contractName; 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/Enums/VarTypeLocation.cs: -------------------------------------------------------------------------------- 1 | using Meadow.CoverageReport.AstTypes; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Meadow.CoverageReport.Debugging.Variables.Enums 7 | { 8 | /// 9 | /// Represents a 's location as it is referred to by its type descriptors. 10 | /// 11 | public enum VarTypeLocation 12 | { 13 | NoneSpecified, 14 | StorageRef, 15 | StoragePtr, 16 | Memory, 17 | CallData 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Meadow.EVM/Meadow.EVM.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Contracts/ERC20.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | import "./ERC20Basic.sol"; 4 | 5 | 6 | /** 7 | * @title ERC20 interface 8 | * @dev see https://github.com/ethereum/EIPs/issues/20 9 | */ 10 | contract ERC20 is ERC20Basic { 11 | function allowance(address owner, address spender) public view returns (uint256); 12 | function transferFrom(address from, address to, uint256 value) public returns (bool); 13 | function approve(address spender, uint256 value) public returns (bool); 14 | event Approval(address indexed owner, address indexed spender, uint256 value); 15 | } 16 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/Enums/VarGenericType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.CoverageReport.Debugging.Variables.Enums 6 | { 7 | /// 8 | /// Represents a generic type for a variable. 9 | /// 10 | public enum VarGenericType 11 | { 12 | Address, 13 | Array, 14 | Boolean, 15 | ByteArrayDynamic, 16 | ByteArrayFixed, 17 | Enum, 18 | String, 19 | Struct, 20 | Int, 21 | UInt, 22 | Mapping 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc.Server.Test/Test.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Xunit; 6 | 7 | namespace Meadow.JsonRpc.Server.Test 8 | { 9 | public class Test 10 | { 11 | [Fact] 12 | public async Task SetupTeardown() 13 | { 14 | var httpServer = new JsonRpcHttpServer(new MockRpcController()); 15 | await httpServer.StartAsync(); 16 | await Task.Delay(100); 17 | await httpServer.StopAsync(); 18 | httpServer.Dispose(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Meadow.Core/Utils/StringUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Text.RegularExpressions; 5 | 6 | namespace Meadow.Core.Utils 7 | { 8 | public static class StringUtil 9 | { 10 | public static readonly Encoding UTF8 = new UTF8Encoding(false, false); 11 | 12 | static readonly Regex NewLineRegex = new Regex(@"\r\n|\n\r|\n|\r"); 13 | 14 | public static string NormalizeNewLines(string input, string newLine = "\n") 15 | { 16 | return NewLineRegex.Replace(input, newLine); 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Meadow.DebugAdapterProxy/Meadow.DebugAdapterProxy.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/BranchType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.Serialization; 4 | using System.Text; 5 | 6 | namespace Meadow.CoverageReport 7 | { 8 | [Flags] 9 | public enum BranchType 10 | { 11 | [EnumMember(Value = "none")] 12 | None, 13 | 14 | [EnumMember(Value = "if_statement")] 15 | IfStatement, 16 | 17 | [EnumMember(Value = "ternary")] 18 | Ternary, 19 | 20 | [EnumMember(Value = "assert")] 21 | Assert, 22 | 23 | [EnumMember(Value = "require")] 24 | Require 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/Contracts/InheritanceChild.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | import './InheritanceParent.sol'; 4 | 5 | contract InheritanceChild is InheritanceParent{ 6 | 7 | string[] public someStrings; 8 | 9 | 10 | function InheritanceChild() public { 11 | someStrings.push("str1"); 12 | } 13 | 14 | modifier myModifer(uint _num) { 15 | if (_num == 5) 16 | revert(); 17 | _; 18 | } 19 | 20 | function testThing(uint _num) public myModifer(_num) returns(uint) { 21 | string storage aString = someStrings[0]; 22 | uint otherNum = super.ensureThing(_num); 23 | return otherNum; 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /src/Meadow.Core/EthTypes/FixedN.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | 7 | <# /* Disable, currently unused */ return ""; #> 8 | 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Text; 12 | 13 | namespace Meadow.Core.EthTypes 14 | { 15 | public static class Fixed 16 | { 17 | <# for (var i = 1; i <= 80; i++) { #> 18 | public struct N<#=i#> : IFixedN { public int Decimals => <#=i#>; } 19 | <# } #> 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate/Meadow.UnitTestTemplate.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Meadow.UnitTestTemplate.RunnerEntryPoint 6 | $(NoWarn);NU1603;NU1701 7 | Exe 8 | 9 | 10 | 11 | 12 | RunnerEntryPoint.cs 13 | False 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Meadow.DebugAdapterServer/DebuggerTransport/StandardInputOutputDebuggerTransport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace Meadow.DebugAdapterServer.DebuggerTransport 5 | { 6 | public class StandardInputOutputDebuggerTransport : IDebuggerTransport 7 | { 8 | public Stream InputStream { get; } 9 | 10 | public Stream OutputStream { get; } 11 | 12 | public StandardInputOutputDebuggerTransport() 13 | { 14 | InputStream = Console.OpenStandardInput(); 15 | OutputStream = Console.OpenStandardOutput(); 16 | } 17 | 18 | public void Dispose() { } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate/SkipCoverageAttribute.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace Meadow.UnitTestTemplate 4 | { 5 | /// 6 | /// Prevents the post-test coverage data analysis. 7 | /// Useful for tests that create broken or unique contract deployments 8 | /// where the coverage data will fail to match to the known contracts. 9 | /// 10 | public class SkipCoverageAttribute : TestPropertyAttribute 11 | { 12 | public SkipCoverageAttribute() 13 | : base(nameof(SkipCoverageAttribute), string.Empty) 14 | { 15 | 16 | } 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/Meadow.Core/Cryptography/ECDSA/Bn128/IField.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Numerics; 4 | using System.Text; 5 | 6 | namespace Meadow.Core.Cryptography.ECDSA.Bn128 7 | { 8 | public interface IField 9 | { 10 | T Zero { get; } 11 | T One { get; } 12 | T Add(T other); 13 | T Add(BigInteger other); 14 | T Subtract(T other); 15 | T Subtract(BigInteger other); 16 | T Multiply(T other); 17 | T Multiply(BigInteger other); 18 | T Divide(T other); 19 | T Divide(BigInteger other); 20 | T Negate(); 21 | T Inverse(); 22 | T Pow(BigInteger exponent); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/run-coverage-tests.bat: -------------------------------------------------------------------------------- 1 | dotnet restore --configfile Nuget.Config 2 | dotnet msbuild -p:Configuration=Debug /maxcpucount:1 /nodeReuse:false 3 | rmdir /s /q "coverage\" 4 | rmdir /s /q "report\" 5 | mkdir "coverage\" 6 | echo {}> "coverage\coverage.json" 7 | dotnet test -c Debug --no-build --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=\"json,opencover\" /p:CoverletOutput="%cd%\coverage\coverage" /p:MergeWith="%cd%\coverage\coverage.json" 8 | dotnet tool install dotnet-reportgenerator-globaltool --tool-path reportgenerator 9 | reportgenerator\reportgenerator -reports:coverage\coverage.opencover.xml -targetdir:report "-reporttypes:HTML;Badges" 10 | rmdir /s /q "coverage\" 11 | rmdir /s /q "reportgenerator\" -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate/ITestMethodExtensions.cs: -------------------------------------------------------------------------------- 1 | using ExposedObject; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace Meadow.UnitTestTemplate 5 | { 6 | static class ITestMethodExtensions 7 | { 8 | public static TestContext GetTestContext(this ITestMethod testMethod) 9 | { 10 | // Obtain our test method options 11 | var testMethodOptions = Exposed.From(testMethod).TestMethodOptions; 12 | 13 | // Obtain our test context. 14 | var testContext = Exposed.From(testMethodOptions).TestContext as TestContext; 15 | 16 | // Return the test context 17 | return testContext; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Before.Meadow.sln.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)/Meadow.SolCodeGen/bin/Internal/netcoreapp2.1/Meadow.SolCodeGen.dll')) 4 | dotnet build "$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)/Meadow.SolCodeGen'))" -f netcoreapp2.1 -c Internal 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/AstTypes/AstEnumMember.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Meadow.CoverageReport.AstTypes 8 | { 9 | public class AstEnumMember : AstNode 10 | { 11 | #region Properties 12 | public string Name { get; } 13 | #endregion 14 | 15 | #region Constructor 16 | public AstEnumMember(JObject node) : base(node) 17 | { 18 | // Set our properties 19 | Name = node.SelectToken("name")?.Value(); 20 | } 21 | 22 | public AstEnumMember(AstNode node) : this(node.Node) { } 23 | #endregion 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Meadow.EVM/Data Types/Chain/ConsensusBase.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.Data_Types.Block; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Meadow.EVM.Data_Types.Chain 7 | { 8 | public abstract class ConsensusBase 9 | { 10 | public abstract void Initialize(State.State state, Block.Block block); 11 | public abstract bool CheckProof(State.State state, BlockHeader blockHeader); 12 | public abstract List GetUncleCandidates(Chain.PoW.ChainPoW chain, State.State state); 13 | public abstract bool VerifyUncles(State.State state, Block.Block block); 14 | public abstract void Finalize(State.State state, Block.Block block); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc.Server.Proxy/Meadow.JsonRpc.Server.Proxy.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc.Server/MiscUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Net.Sockets; 5 | using System.Text; 6 | 7 | namespace Meadow.JsonRpc.Server 8 | { 9 | public static class MiscUtil 10 | { 11 | public static int GetAvailablePort() 12 | { 13 | IPEndPoint defaultLoopbackEndpoint = new IPEndPoint(IPAddress.Loopback, port: 0); 14 | using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) 15 | { 16 | socket.Bind(defaultLoopbackEndpoint); 17 | return ((IPEndPoint)socket.LocalEndPoint).Port; 18 | } 19 | } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Meadow.Core/Cryptography/ECDSA/BouncyCastleExtensions.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Core.Utils; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Numerics; 5 | using System.Text; 6 | 7 | public static class BouncyCastleExtensions 8 | { 9 | #region Functions 10 | public static Org.BouncyCastle.Math.BigInteger ToBouncyCastleBigInteger(this BigInteger bigInteger) 11 | { 12 | return new Org.BouncyCastle.Math.BigInteger(1, BigIntegerConverter.GetBytes(bigInteger)); 13 | } 14 | 15 | public static BigInteger ToNumericsBigInteger(this Org.BouncyCastle.Math.BigInteger bcBigInteger) 16 | { 17 | return BigIntegerConverter.GetBigInteger(bcBigInteger.ToByteArrayUnsigned()); 18 | } 19 | #endregion 20 | } -------------------------------------------------------------------------------- /src/Meadow.EVM/Exceptions/BlockException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.EVM.Exceptions 6 | { 7 | /// 8 | /// An exception thrown to signal that our block encountered an error. 9 | /// 10 | public class BlockException : Exception 11 | { 12 | public BlockException() { } 13 | public BlockException(string message) : base(message) { } 14 | public BlockException(string message, Exception innerException) : base(message, innerException) { } 15 | public BlockException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc/ArbitraryDefaults.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.JsonRpc 6 | { 7 | // These defaults are not derived or based on anything reasonable specification. They are 8 | // not reliable to use in any given situation and can be dependent on implementation, chain, fork, etc. 9 | // They are only here for use in test projects since this is a commonly referenced project. 10 | // TODO: Move these into something like a Meadow.TestCommon project 11 | public static class ArbitraryDefaults 12 | { 13 | public const long DEFAULT_GAS_LIMIT = 5_000_000; 14 | public const long DEFAULT_GAS_PRICE = 100_000_000_000; 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Meadow.DebugAdapterServer/Meadow.DebugAdapterServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Meadow.EVM/Exceptions/TransactionException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.EVM.Exceptions 6 | { 7 | /// 8 | /// An exception thrown to signal that our transaction was invalid. 9 | /// 10 | public class TransactionException : Exception 11 | { 12 | public TransactionException() { } 13 | public TransactionException(string message) : base(message) { } 14 | public TransactionException(string message, Exception innerException) : base(message, innerException) { } 15 | public TransactionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Contracts/MintedCrowdsale.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | import "./Crowdsale.sol"; 4 | import "./MintableToken.sol"; 5 | 6 | 7 | /** 8 | * @title MintedCrowdsale 9 | * @dev Extension of Crowdsale contract whose tokens are minted in each purchase. 10 | * Token ownership should be transferred to MintedCrowdsale for minting. 11 | */ 12 | contract MintedCrowdsale is Crowdsale { 13 | 14 | /** 15 | * @dev Overrides delivery by minting tokens upon purchase. 16 | * @param _beneficiary Token purchaser 17 | * @param _tokenAmount Number of tokens to be minted 18 | */ 19 | function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { 20 | require(MintableToken(token).mint(_beneficiary, _tokenAmount)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Meadow.TestNode.Test.App/Meadow.TestNode.Test.App.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc/Types/Debugging/ExecutionTrace.cs: -------------------------------------------------------------------------------- 1 | using Meadow.JsonRpc.JsonConverters; 2 | using Newtonsoft.Json; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Meadow.JsonRpc.Types.Debugging 8 | { 9 | public class ExecutionTrace 10 | { 11 | /// 12 | /// Represents the list of trace points in our execution trace. 13 | /// 14 | [JsonProperty("tracepoints")] 15 | public ExecutionTracePoint[] Tracepoints { get; set; } 16 | /// 17 | /// Represents the list of exceptions in our execution trace. 18 | /// 19 | [JsonProperty("exceptions")] 20 | public ExecutionTraceException[] Exceptions { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Meadow.VSCode.Debugger/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | }, 19 | { 20 | "type": "npm", 21 | "script": "compile", 22 | "problemMatcher": [ 23 | "$tsc" 24 | ] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/Pairing/MappingKeyValuePair.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.CoverageReport.Debugging.Variables.Pairing 6 | { 7 | /// 8 | /// Represents a mapping key-value pair. 9 | /// 10 | public struct MappingKeyValuePair 11 | { 12 | #region Properties 13 | public readonly VariableValuePair Key; 14 | public readonly VariableValuePair Value; 15 | #endregion 16 | 17 | #region Constructor 18 | public MappingKeyValuePair(VariableValuePair key, VariableValuePair value) 19 | { 20 | // Set our properties 21 | Key = key; 22 | Value = value; 23 | } 24 | #endregion 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/Pairing/VariableValuePair.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.CoverageReport.Debugging.Variables.Pairing 6 | { 7 | /// 8 | /// Represents a variable definition and its underlying value. 9 | /// 10 | public struct VariableValuePair 11 | { 12 | #region Properties 13 | public readonly BaseVariable Variable; 14 | public readonly object Value; 15 | #endregion 16 | 17 | #region Constructor 18 | public VariableValuePair(BaseVariable variable, object value) 19 | { 20 | // Set our properties 21 | Variable = variable; 22 | Value = value; 23 | } 24 | #endregion 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Stack/InstructionPop.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Text; 6 | 7 | namespace Meadow.EVM.EVM.Instructions.Stack 8 | { 9 | public class InstructionPop : InstructionBase 10 | { 11 | #region Constructors 12 | /// 13 | /// Our default constructor, reads the opcode/operand information from the provided stream. 14 | /// 15 | public InstructionPop(MeadowEVM evm) : base(evm) { } 16 | #endregion 17 | 18 | #region Functions 19 | public override void Execute() 20 | { 21 | // We'll want to pop an item off of the stack. 22 | Stack.Pop(); 23 | } 24 | #endregion 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/Contracts/BitShifting.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.24; 2 | 3 | 4 | contract BitShifting { 5 | 6 | function bitwiseAnd(uint256 a, uint256 b) public pure returns (uint256) { 7 | return a & b; 8 | } 9 | 10 | function bitwiseOr(uint256 a, uint256 b) public pure returns (uint256) { 11 | return a | b; 12 | } 13 | 14 | function bitwiseXor(uint256 a, uint256 b) public pure returns (uint256) { 15 | return a ^ b; 16 | } 17 | 18 | function bitwiseNegation(uint256 a) public pure returns (uint256) { 19 | return ~a; 20 | } 21 | 22 | function bitwiseLeftShift(uint256 a, uint256 b) public pure returns (uint256) { 23 | return a << b; 24 | } 25 | 26 | function bitwiseRightShift(uint256 a, uint256 b) public pure returns (uint256) { 27 | return a >> b; 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /src/Meadow.EVM/Configuration/EthereumChainID.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.EVM.Configuration 6 | { 7 | /// 8 | /// An identifier for what Ethereum chain we are operating on, including main nets, test nets, etc. It became embedded in Transactions (and thus hashes) in Spurious Dragon to avoid replay attacks across chains. 9 | /// 10 | public enum EthereumChainID : uint 11 | { 12 | Ethereum_MainNet = 1, 13 | Morden = 2, 14 | Ropsten = 3, 15 | Rinkeby = 4, 16 | Rootstock_MainNet = 30, 17 | Rootstock_TestNet = 31, 18 | Kovan = 42, 19 | Ethereum_Classic_MainNet = 61, 20 | Ethereum_Classic_TestNet = 62, 21 | Geth_Private_Chains = 1337 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Meadow.EVM/Exceptions/EVMException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.EVM.Exceptions 6 | { 7 | /// 8 | /// A basic exception type used by our EVM to signal a failure in the virtual execution. 9 | /// This is caught and converted to a failed transaction/call result. 10 | /// 11 | public class EVMException : Exception 12 | { 13 | public EVMException() { } 14 | public EVMException(string message) : base(message) { } 15 | public EVMException(string message, Exception innerException) : base(message, innerException) { } 16 | public EVMException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Meadow.SolCodeGen.TestApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | true 7 | 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Meadow.CoverageReport.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Contracts/ErrorContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | /// @title Error Generating Contract (Testing) 4 | /// @author David Pokora 5 | /// @notice This is a contract used to generate errors to test EVM exception tracing, etc. 6 | /// @dev 7 | contract ErrorContract 8 | { 9 | /// @notice Our default contructor 10 | constructor() public 11 | { 12 | 13 | } 14 | 15 | /// @notice Raises a simple error directly in this call. 16 | function testSimpleError() 17 | { 18 | assert(false); 19 | } 20 | 21 | /// @notice Raises an error indirectly through another call. 22 | function testIndirectError() 23 | { 24 | // Call another function to generate the error. 25 | testSimpleError(); 26 | } 27 | 28 | /// @notice The fallback function 29 | function() public 30 | { 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /src/Meadow.VSCode.Debugger/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "extensionHost", 9 | "request": "launch", 10 | "name": "Extension", 11 | "runtimeExecutable": "${execPath}", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ], 15 | "outFiles": [ 16 | "${workspaceFolder}/out/**/*.js" 17 | ], 18 | "preLaunchTask": "npm: watch" 19 | }, 20 | { 21 | "type": "node", 22 | "request": "launch", 23 | "name": "Prepare Package", 24 | "preLaunchTask": "npm: watch", 25 | "program": "${workspaceFolder}/out/preparePackage.js" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Models/SourceFileMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.CoverageReport.Models 6 | { 7 | public class SourceFileMap : CoverageStats 8 | { 9 | public string IndexHtmlFilePath { get; set; } 10 | public string SolidityCompilerVersion { get; set; } 11 | 12 | /// 13 | /// This file's index in the solc sources list output. 14 | /// 15 | public int SourceFileIndex { get; set; } 16 | 17 | public string SourceFilePath { get; set; } 18 | public string SourceFileName { get; set; } 19 | public string SourceFileDirectory { get; set; } 20 | public string SourceHashSha256 { get; set; } 21 | 22 | public SourceFileLine[] SourceFileLines { get; set; } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Meadow.Networking.Test/Meadow.Networking.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Meadow.Core/Utils/ObjectPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Meadow.Core.Utils 7 | { 8 | public class ObjectPool 9 | { 10 | private ConcurrentBag _objects; 11 | private Func _objectGenerator; 12 | 13 | public ObjectPool(Func objectGenerator) 14 | { 15 | _objects = new ConcurrentBag(); 16 | _objectGenerator = objectGenerator; 17 | } 18 | 19 | public T Get() 20 | { 21 | if (_objects.TryTake(out var item)) 22 | { 23 | return item; 24 | } 25 | 26 | return _objectGenerator(); 27 | } 28 | 29 | public void Put(T item) 30 | { 31 | _objects.Add(item); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.DebugAdapterServer/SolidityMeadowConfigurationProperties.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Meadow.DebugAdapterServer 4 | { 5 | public class SolidityMeadowConfigurationProperties 6 | { 7 | [JsonProperty("type")] 8 | public string Type { get; set; } 9 | 10 | [JsonProperty("request")] 11 | public string Request { get; set; } 12 | 13 | [JsonProperty("name")] 14 | public string Name { get; set; } 15 | 16 | [JsonProperty("program")] 17 | public string Program { get; set; } 18 | 19 | [JsonProperty("stopOnEntry")] 20 | public bool StopOnEntry { get; set; } 21 | 22 | [JsonProperty("__sessionId")] 23 | public string SessionID { get; set; } 24 | 25 | [JsonProperty("workspaceDirectory")] 26 | public string WorkspaceDirectory { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.DebugExampleTests/Meadow.DebugExampleTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | Meadow.DebugExampleTests.GlobalSetup 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/AstTypes/AstTypeDescriptions.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Meadow.CoverageReport.AstTypes 7 | { 8 | public class AstTypeDescriptions 9 | { 10 | #region Properties 11 | public string TypeIdentifier { get; } 12 | public string TypeString { get; } 13 | #endregion 14 | 15 | #region Constructor 16 | public AstTypeDescriptions(JObject node) 17 | { 18 | // Set our properties 19 | TypeIdentifier = node.SelectToken("typeDescriptions.typeIdentifier")?.Value(); 20 | TypeString = node.SelectToken("typeDescriptions.typeString")?.Value(); 21 | } 22 | 23 | public AstTypeDescriptions(AstNode node) : this(node.Node) { } 24 | #endregion 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Control Flow and IO/InstructionGetPC.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | using System.Text; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Control_Flow_and_IO 9 | { 10 | public class InstructionGetPC : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionGetPC(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Push our program counter onto the stack 23 | Stack.Push(Offset); 24 | } 25 | #endregion 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/AstTypes/AstArrayTypeName.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Meadow.CoverageReport.AstTypes 7 | { 8 | public class AstArrayTypeName : AstElementaryTypeName 9 | { 10 | #region Properties 11 | public AstElementaryTypeName BaseType { get; } 12 | #endregion 13 | 14 | #region Constructor 15 | public AstArrayTypeName(JObject node) : base(node) 16 | { 17 | // Set our properties 18 | JToken keyType = node.SelectToken("baseType"); 19 | if (keyType != null) 20 | { 21 | BaseType = Create((JObject)keyType); 22 | } 23 | } 24 | 25 | public AstArrayTypeName(AstNode node) : this(node.Node) { } 26 | #endregion 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.Core/AccountDerivation/HDAccountDerivation.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Core.AccountDerivation.BIP39; 2 | 3 | namespace Meadow.Core.AccountDerivation 4 | { 5 | /// 6 | /// Acount derivation using BIP44 with Ethereum's SLIP44 registered coin index "60". 7 | /// 8 | public class HDAccountDerivation : Bip44AccountDerivation 9 | { 10 | public HDAccountDerivation(MnemonicPhrase mnemonicPhrase) 11 | : base(mnemonicPhrase, coinType: 60) 12 | { 13 | 14 | } 15 | 16 | 17 | public HDAccountDerivation(string mnemonicPhrase) 18 | : this(new MnemonicPhrase(mnemonicPhrase)) { } 19 | 20 | public static HDAccountDerivation Create(WordListLanguage language = WordListLanguage.English) 21 | { 22 | return new HDAccountDerivation(new MnemonicPhrase(language)); 23 | } 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/Meadow.TestNode.Host/Meadow.TestNode.Host.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | true 7 | true 8 | meadow-testnode 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Meadow.DebugExampleTests/NestedContractTests.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Contract; 2 | using Meadow.Core.Utils; 3 | using Meadow.EVM.Data_Types; 4 | using Meadow.JsonRpc.Types; 5 | using Meadow.UnitTestTemplate; 6 | using Microsoft.VisualStudio.TestTools.UnitTesting; 7 | using System.Globalization; 8 | using System.Numerics; 9 | using System.Threading.Tasks; 10 | 11 | namespace Meadow.DebugExampleTests 12 | { 13 | [TestClass] 14 | public class NestedContractTests : ContractTest 15 | { 16 | NestedContract _contract; 17 | 18 | protected override async Task BeforeEach() 19 | { 20 | // Deploy our test contract 21 | _contract = await NestedContract.New(RpcClient); 22 | } 23 | 24 | [TestMethod] 25 | public async Task IncrementNumber() 26 | { 27 | await _contract.incrementNumber(123).Call(); 28 | } 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.ParallelTest/GlobalSetup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | [assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)] 8 | 9 | namespace Meadow.UnitTestTemplate.ParallelTest 10 | { 11 | [TestClass] 12 | public static class GlobalSetup 13 | { 14 | [AssemblyInitialize] 15 | public static async Task Init(TestContext testContext) 16 | { 17 | await Task.CompletedTask; 18 | } 19 | 20 | [AssemblyCleanup] 21 | public static async Task Cleanup() 22 | { 23 | await Global.GenerateCoverageReport(); 24 | } 25 | 26 | public static void Main(string[] args) 27 | { 28 | Global.Launch(); 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Environment/InstructionCodeSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.EVM.Execution; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Environment 10 | { 11 | public class InstructionCodeSize : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionCodeSize(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // Push the code size to the stack. 24 | Stack.Push(EVM.Code.Length); 25 | } 26 | #endregion 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Control Flow and IO/InstructionGas.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | using System.Text; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Control_Flow_and_IO 9 | { 10 | public class InstructionGas : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionGas(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Obtain the current gas, after deductions for this instruction. 23 | Stack.Push(EVM.GasState.Gas); 24 | } 25 | #endregion 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Control Flow and IO/InstructionMemorySize.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | using System.Text; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Control_Flow_and_IO 9 | { 10 | public class InstructionMemorySize : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionMemorySize(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Push our memory segment size onto the stack. 23 | Stack.Push(Memory.Length); 24 | } 25 | #endregion 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Environment/InstructionCallValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.EVM.Execution; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Environment 10 | { 11 | public class InstructionCallValue : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionCallValue(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // Push the message value onto the stack. 24 | Stack.Push(Message.Value); 25 | } 26 | #endregion 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Contracts/MultifileInheritableContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.11; 2 | 3 | contract MultifileInheritableContract { 4 | 5 | address public owner; 6 | 7 | /** 8 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 9 | * account. 10 | */ 11 | function MultifileInheritableContract() { 12 | owner = msg.sender; 13 | } 14 | 15 | 16 | /** 17 | * @dev Throws if called by any account other than the owner. 18 | */ 19 | modifier onlyOwner() { 20 | require(msg.sender == owner); 21 | _; 22 | } 23 | 24 | 25 | /** 26 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 27 | * @param newOwner The address to transfer ownership to. 28 | */ 29 | function transferOwnership(address newOwner) onlyOwner { 30 | require(newOwner != address(0)); 31 | owner = newOwner; 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Environment/InstructionCaller.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.EVM.Execution; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Environment 10 | { 11 | public class InstructionCaller : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionCaller(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // Push the sender address of the message to the stack. 24 | Stack.Push(Message.Sender); 25 | } 26 | #endregion 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc/JsonRpcRequestObject.cs: -------------------------------------------------------------------------------- 1 | using Meadow.JsonRpc.JsonConverters; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Linq; 4 | using System; 5 | using System.Threading; 6 | 7 | namespace Meadow.JsonRpc 8 | { 9 | public class JsonRpcRequestObject 10 | { 11 | [JsonProperty("jsonrpc")] 12 | public string JsonRpc = "2.0"; 13 | 14 | [JsonProperty("method")] 15 | public string Method { get; set; } 16 | 17 | [JsonProperty("id")] 18 | public long ID { get; set; } 19 | 20 | [JsonProperty("params")] 21 | public JArray Params { get; set; } 22 | 23 | public JsonRpcRequestObject() 24 | { 25 | 26 | } 27 | 28 | public JsonRpcRequestObject(long id, string method, JArray args) 29 | { 30 | ID = id; 31 | Method = method; 32 | Params = args; 33 | } 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate/ParallelTestClassAttribute.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Meadow.UnitTestTemplate 7 | { 8 | public class ParallelTestClassAttribute : TestClassAttribute 9 | { 10 | public override TestMethodAttribute GetTestMethodAttribute(TestMethodAttribute testMethodAttribute) 11 | { 12 | // If the method attribute is already a parallel test one, we can simply return it. 13 | if (testMethodAttribute is ParallelTestMethodAttribute) 14 | { 15 | return testMethodAttribute; 16 | } 17 | 18 | // Otherwise we create a parallel test method attribute out of the regular one. 19 | return new ParallelTestMethodAttribute(base.GetTestMethodAttribute(testMethodAttribute)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Environment/InstructionAddress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.EVM.Execution; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Environment 10 | { 11 | public class InstructionAddress : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionAddress(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // Push the recipient address of the message to the stack. 24 | Stack.Push(Message.To); 25 | } 26 | #endregion 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.TestNode/AccountConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Core.AccountDerivation; 2 | 3 | namespace Meadow.TestNode 4 | { 5 | public class AccountConfiguration 6 | { 7 | /// 8 | /// The number of accounts to generate. 9 | /// Defaults to 100. 10 | /// 11 | public int AccountGenerationCount { get; set; } = 100; 12 | 13 | /// 14 | /// The balance (in ether) that accounts should be initially given. 15 | /// Defaults to 2000. 16 | /// 17 | public decimal DefaultAccountEtherBalance { get; set; } = 2000; 18 | 19 | /// 20 | /// The specification/format to use for generating accounts from the seed. 21 | /// Defaults to 22 | /// 23 | public IAccountDerivation AccountDerivationMethod { get; set; } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Environment/InstructionCallDataSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.EVM.Execution; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Environment 10 | { 11 | public class InstructionCallDataSize : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionCallDataSize(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // Push the call data size onto the stack. 24 | Stack.Push(Message.Data.Length); 25 | } 26 | #endregion 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/AstTypes/AstUserDefinedTypeName.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Meadow.CoverageReport.AstTypes 8 | { 9 | public class AstUserDefinedTypeName : AstElementaryTypeName 10 | { 11 | #region Properties 12 | /// 13 | /// The ID of the node which declares this type definition. 14 | /// 15 | public long ReferencedDeclaration { get; } 16 | #endregion 17 | 18 | #region Constructor 19 | public AstUserDefinedTypeName(JObject node) : base(node) 20 | { 21 | // Set our properties. 22 | ReferencedDeclaration = node.SelectToken("referencedDeclaration").Value(); 23 | } 24 | 25 | public AstUserDefinedTypeName(AstNode node) : this(node.Node) { } 26 | #endregion 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Control Flow and IO/InstructionJumpDest.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Text; 6 | 7 | namespace Meadow.EVM.EVM.Instructions.Control_Flow_and_IO 8 | { 9 | public class InstructionJumpDest : InstructionBase 10 | { 11 | #region Constructors 12 | /// 13 | /// Our default constructor, reads the opcode/operand information from the provided stream. 14 | /// 15 | public InstructionJumpDest(MeadowEVM evm) : base(evm) { } 16 | #endregion 17 | 18 | #region Functions 19 | public override void Execute() 20 | { 21 | // This does nothing other than mark the destination of a jump to act as a security layer against exploits. 22 | ExecutionState.JumpedLastInstruction = false; 23 | } 24 | #endregion 25 | } 26 | } -------------------------------------------------------------------------------- /src/Meadow.JsonRpc/Types/Debugging/ExecutionTraceException.cs: -------------------------------------------------------------------------------- 1 | using Meadow.JsonRpc.JsonConverters; 2 | using Newtonsoft.Json; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Meadow.JsonRpc.Types.Debugging 8 | { 9 | public class ExecutionTraceException 10 | { 11 | #region Properties 12 | /// 13 | /// DATA, variable length, a string representing the exception message. 14 | /// 15 | [JsonProperty("exception")] 16 | public string Message { get; set; } 17 | /// 18 | /// INTEGER, 32-bit, nullable, represents the trace index (if any) at which this occurred. Is null if the exception occurred outside of VM execution. 19 | /// 20 | [JsonProperty("traceIndex"), JsonConverter(typeof(JsonRpcHexConverter))] 21 | public int? TraceIndex { get; set; } 22 | #endregion 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Control Flow and IO/InstructionHalt.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Text; 6 | 7 | namespace Meadow.EVM.EVM.Instructions.Control_Flow_and_IO 8 | { 9 | public class InstructionHalt : InstructionBase 10 | { 11 | #region Constructors 12 | /// 13 | /// Our default constructor, reads the opcode/operand information from the provided stream. 14 | /// 15 | public InstructionHalt(MeadowEVM evm) : base(evm) { } 16 | #endregion 17 | 18 | #region Functions 19 | public override void Execute() 20 | { 21 | // We'll want to return with a blank result, our remaining gas, and a status indicating whether we should revert. 22 | Return(new EVMExecutionResult(EVM, null, true)); 23 | } 24 | #endregion 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Block Information/InstructionBlockCoinbase.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.Data_Types; 2 | using Meadow.EVM.EVM.Execution; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Numerics; 7 | using System.Text; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Block_Information 10 | { 11 | public class InstructionBlockCoinbase : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionBlockCoinbase(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // We'll push our coinbase address 24 | Stack.Push(EVM.State.CurrentBlock.Header.Coinbase); 25 | } 26 | #endregion 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Block Information/InstructionBlockGasLimit.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.Data_Types; 2 | using Meadow.EVM.EVM.Execution; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Numerics; 7 | using System.Text; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Block_Information 10 | { 11 | public class InstructionBlockGasLimit : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionBlockGasLimit(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // We push our gas limit onto the stack. 24 | Stack.Push(EVM.State.CurrentBlock.Header.GasLimit); 25 | } 26 | #endregion 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Block Information/InstructionBlockNumber.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.Data_Types; 2 | using Meadow.EVM.EVM.Execution; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Numerics; 7 | using System.Text; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Block_Information 10 | { 11 | public class InstructionBlockNumber : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionBlockNumber(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // We push our block number onto the stack. 24 | Stack.Push(EVM.State.CurrentBlock.Header.BlockNumber); 25 | } 26 | #endregion 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Block Information/InstructionBlockTimestamp.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.Data_Types; 2 | using Meadow.EVM.EVM.Execution; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Numerics; 7 | using System.Text; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Block_Information 10 | { 11 | public class InstructionBlockTimestamp : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionBlockTimestamp(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // We push our timestamp onto the stack. 24 | Stack.Push(EVM.State.CurrentBlock.Header.Timestamp); 25 | } 26 | #endregion 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Contracts/MultifileInheritedContract.sol: -------------------------------------------------------------------------------- 1 | 2 | import "./MultifileInheritableContract.sol"; 3 | 4 | pragma solidity ^0.4.11; 5 | 6 | 7 | contract MultifileInheritedContract is MultifileInheritableContract { 8 | 9 | function MultifileInheritedContract() payable { } 10 | 11 | /** 12 | * @dev Transfers the current balance to the owner and terminates the contract. 13 | */ 14 | function destroy() onlyOwner { 15 | selfdestruct(owner); 16 | } 17 | 18 | function destroyAndSend(address _recipient) onlyOwner { 19 | selfdestruct(_recipient); 20 | } 21 | 22 | function testFunction() public { 23 | uint test = 7; 24 | if(test == 8) 25 | test = 1; 26 | else if(test == 7) 27 | test = 2; 28 | else 29 | test = 3; 30 | } 31 | 32 | function testFunctionWithInheritedModifier() onlyOwner { 33 | uint test = 7; 34 | if(test == 8) 35 | test = 1; 36 | else if(test == 7) 37 | test = 2; 38 | else 39 | test = 3; 40 | } 41 | } -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Block Information/InstructionBlockDifficulty.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.Data_Types; 2 | using Meadow.EVM.EVM.Execution; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Numerics; 7 | using System.Text; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Block_Information 10 | { 11 | public class InstructionBlockDifficulty : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionBlockDifficulty(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // We push our difficulty onto the stack. 24 | Stack.Push(EVM.State.CurrentBlock.Header.Difficulty); 25 | } 26 | #endregion 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/Meadow.DebugSolSources/Meadow.DebugSolSources.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | true 7 | true 8 | meadow-debugsol 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen/Util.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | 6 | namespace Meadow.SolCodeGen 7 | { 8 | static class Util 9 | { 10 | public static string GetRelativeFilePath(string solSourceDir, string absolutePath) 11 | { 12 | if (string.IsNullOrEmpty(solSourceDir)) 13 | { 14 | return absolutePath; 15 | } 16 | 17 | if (absolutePath.StartsWith(solSourceDir, StringComparison.OrdinalIgnoreCase)) 18 | { 19 | absolutePath = absolutePath.Substring(solSourceDir.Length).TrimStart(new[] { '\\', '/' }); 20 | } 21 | else if (Path.IsPathRooted(absolutePath)) 22 | { 23 | throw new Exception($"Unexpected source file path from solc output: {absolutePath}, source dir: {solSourceDir}"); 24 | } 25 | 26 | return absolutePath; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Arithmetic/InstructionAdd.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Arithmetic 9 | { 10 | public class InstructionAdd : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionAdd(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Add two unsigned words off of the top of the stack. 23 | BigInteger result = Stack.Pop() + Stack.Pop(); 24 | 25 | // Push the result onto the stack. 26 | Stack.Push(result); 27 | } 28 | #endregion 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Meadow.Networking/Extensions/IPAddressExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Text; 5 | 6 | namespace Meadow.Networking.Extensions 7 | { 8 | public static class IPAddressExtensions 9 | { 10 | #region Functions 11 | /// 12 | /// Obtains the IP address as a string, compatible for use in a URI (IPv6 addresses enclosed in square brackets). 13 | /// Reference: https://tools.ietf.org/html/rfc2732 14 | /// 15 | /// The IP address to format as a string. 16 | /// Returns the IP address as a string, compatible for use in a Uri. 17 | public static string ToUriCompatibleString(this IPAddress address) 18 | { 19 | return address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6 ? $"[{address}]" : address.ToString(); 20 | } 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/System Operations/InstructionInvalid.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Definitions; 2 | using Meadow.EVM.Exceptions; 3 | using Meadow.EVM.EVM.Execution; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Numerics; 8 | using System.Text; 9 | 10 | namespace Meadow.EVM.EVM.Instructions.System_Operations 11 | { 12 | public class InstructionInvalid : InstructionBase 13 | { 14 | #region Constructors 15 | /// 16 | /// Our default constructor, reads the opcode/operand information from the provided stream. 17 | /// 18 | public InstructionInvalid(MeadowEVM evm) : base(evm) { } 19 | #endregion 20 | 21 | #region Functions 22 | public override void Execute() 23 | { 24 | // Throw our invalid instruction exception 25 | throw new EVMException($"{Opcode.ToString()} instruction hit!"); 26 | } 27 | #endregion 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Arithmetic/InstructionMultiply.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Arithmetic 9 | { 10 | public class InstructionMultiply : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionMultiply(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Multiply two unsigned words off of the top of the stack. 23 | BigInteger result = Stack.Pop() * Stack.Pop(); 24 | 25 | // Push the result onto the stack. 26 | Stack.Push(result); 27 | } 28 | #endregion 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/Contracts/ExceptionContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | contract ExceptionContract { 4 | 5 | address[] public addressArray; 6 | 7 | constructor(bool _throwOnConstructor) public { 8 | assert(!_throwOnConstructor); 9 | } 10 | 11 | function outOfBoundArrayAccess() returns(bool) { 12 | address someAddr = addressArray[4]; 13 | return true; 14 | } 15 | 16 | function doRevert() { 17 | revert("do revert hit"); 18 | } 19 | 20 | function doRequire() { 21 | bool thingDidWork = false; 22 | require(thingDidWork, "thing did not work"); 23 | } 24 | 25 | function doAssert() { 26 | bool thingDidWork = false; 27 | assert(thingDidWork); 28 | } 29 | 30 | function doThrow() { 31 | throw; 32 | } 33 | 34 | function entryFunction() { 35 | nextFunction(); 36 | } 37 | 38 | function nextFunction() { 39 | anotherFunc(); 40 | } 41 | 42 | function anotherFunc() { 43 | lastFunc(); 44 | } 45 | 46 | function lastFunc() { 47 | doAssert(); 48 | } 49 | 50 | 51 | 52 | } -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/GlobalSetup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.Reflection; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | [assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)] 10 | 11 | namespace Meadow.UnitTestTemplate.Test 12 | { 13 | [TestClass] 14 | public static class GlobalSetup 15 | { 16 | [AssemblyInitialize] 17 | public static async Task Init(TestContext testContext) 18 | { 19 | Global.HideSolidityFromReport("mocks", "IgnoreContract.sol"); 20 | await Task.CompletedTask; 21 | } 22 | 23 | [AssemblyCleanup] 24 | public static async Task Cleanup() 25 | { 26 | await Global.GenerateCoverageReport(); 27 | } 28 | 29 | public static void Main(string[] args) 30 | { 31 | Global.Launch(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Views/CoverageHeader.cshtml: -------------------------------------------------------------------------------- 1 | @using Meadow.CoverageReport.Models; 2 | @using System.Globalization; 3 | 4 | @model CoverageStats 5 | 6 | 17 | 18 |
19 | 20 | @Model.LineCoveragePercent% 21 | Lines 22 | @Model.LineCoveredCount/@Model.LineCount 23 | 24 | @Model.BranchCoveragePercent% 25 | Branches 26 | @Model.BranchCoveredCount/@Model.BranchCount 27 | 28 | @Model.FunctionCoveragePercent% 29 | Functions 30 | @Model.FunctionCoveredCount/@Model.FunctionCount 31 | 32 |
-------------------------------------------------------------------------------- /src/Meadow.EVM/Debugging/Tracing/ExecutionTraceException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.EVM.Debugging.Tracing 6 | { 7 | public class ExecutionTraceException 8 | { 9 | #region Properties 10 | /// 11 | /// The index in our which indicates the point in execution where the occurred. 12 | /// 13 | public int? TraceIndex { get; } 14 | /// 15 | /// The exception that occurred during execution. 16 | /// 17 | public Exception Exception { get; } 18 | #endregion 19 | 20 | #region Constructors 21 | public ExecutionTraceException(int? traceIndex, Exception exception) 22 | { 23 | // Set our properties 24 | TraceIndex = traceIndex; 25 | Exception = exception; 26 | } 27 | #endregion 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/pwsh_testing/Contracts/ErrorContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | /// @title Error Generating Contract (Testing) 4 | /// @author David Pokora 5 | /// @notice This is a contract used to generate errors to test EVM exception tracing, etc. 6 | /// @dev 7 | contract ErrorContract 8 | { 9 | /// @notice Our default contructor 10 | constructor() public 11 | { 12 | 13 | } 14 | 15 | /// @notice Raises a simple error directly in this call. 16 | function testSimpleError() 17 | { 18 | assert(false); 19 | } 20 | 21 | function doAssert() 22 | { 23 | assert(false); 24 | } 25 | 26 | function doRevert() 27 | { 28 | require(false, "some require message"); 29 | } 30 | 31 | function doThrow(){ 32 | throw; 33 | } 34 | 35 | /// @notice Raises an error indirectly through another call. 36 | function testIndirectError() 37 | { 38 | // Call another function to generate the error. 39 | testSimpleError(); 40 | } 41 | 42 | /// @notice The fallback function 43 | function() public 44 | { 45 | 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /src/Meadow.DebugExampleTests/GlobalSetup.cs: -------------------------------------------------------------------------------- 1 | using Meadow.UnitTestTemplate; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | using System.Reflection; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | [assembly: Parallelize(Workers = 1, Scope = ExecutionScope.MethodLevel)] 11 | 12 | namespace Meadow.DebugExampleTests 13 | { 14 | [TestClass] 15 | public static class GlobalSetup 16 | { 17 | [AssemblyInitialize] 18 | public static async Task Init(TestContext testContext) 19 | { 20 | Global.HideSolidityFromReport("mocks", "IgnoreContract.sol"); 21 | await Task.CompletedTask; 22 | } 23 | 24 | [AssemblyCleanup] 25 | public static async Task Cleanup() 26 | { 27 | await Global.GenerateCoverageReport(); 28 | } 29 | 30 | public static void Main(string[] args) 31 | { 32 | Global.Launch(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.TestNode.Test.App/Contracts/ErrorContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | /// @title Error Generating Contract (Testing) 4 | /// @author David Pokora 5 | /// @notice This is a contract used to generate errors to test EVM exception tracing, etc. 6 | /// @dev 7 | contract ErrorContract 8 | { 9 | /// @notice Our default contructor 10 | constructor() public 11 | { 12 | 13 | } 14 | 15 | /// @notice Raises a simple error directly in this call. 16 | function testSimpleError() 17 | { 18 | assert(false); 19 | } 20 | 21 | function doAssert() 22 | { 23 | assert(false); 24 | } 25 | 26 | function doRevert() 27 | { 28 | require(false, "some require message"); 29 | } 30 | 31 | function doThrow(){ 32 | throw; 33 | } 34 | 35 | /// @notice Raises an error indirectly through another call. 36 | function testIndirectError() 37 | { 38 | // Call another function to generate the error. 39 | testSimpleError(); 40 | } 41 | 42 | /// @notice The fallback function 43 | function() public 44 | { 45 | 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /src/pwsh_testing/Contracts/MultifileInheritedContract.sol: -------------------------------------------------------------------------------- 1 | 2 | import "./MultifileInheritableContract.sol"; 3 | 4 | pragma solidity ^0.4.11; 5 | 6 | 7 | contract MultifileInheritedContract is MultifileInheritableContract { 8 | 9 | function MultifileInheritedContract() payable { } 10 | 11 | /** 12 | * @dev Transfers the current balance to the owner and terminates the contract. 13 | */ 14 | function destroy() onlyOwner { 15 | selfdestruct(owner); 16 | } 17 | 18 | function destroyAndSend(address _recipient) onlyOwner { 19 | selfdestruct(_recipient); 20 | } 21 | 22 | function testFunction() public { 23 | uint test = 7; 24 | if(test == 8) 25 | test = 1; 26 | else if(test == 7) 27 | test = 2; 28 | else 29 | test = 3; 30 | } 31 | 32 | function testFunctionWithInheritedModifier() onlyOwner { 33 | uint test = 7; 34 | if(test == 8) 35 | test = 1; 36 | else if(test == 7) 37 | test = 2; 38 | else 39 | test = 3; 40 | } 41 | 42 | function testInheritedAssertThrow() 43 | { 44 | testAssertIndirect(); 45 | } 46 | } -------------------------------------------------------------------------------- /src/Meadow.DebugSolSources/ProcessArgs.cs: -------------------------------------------------------------------------------- 1 | using McMaster.Extensions.CommandLineUtils; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Meadow.DebugSolSources 7 | { 8 | class ProcessArgs 9 | { 10 | [Option("-d|--directory", "Directory of the .sol source files.", CommandOptionType.SingleValue)] 11 | public string Directory { get; } 12 | 13 | [Option("-e|--entry", "The contract entry point in the form of 'ContractName.FunctionName'", CommandOptionType.SingleValue)] 14 | public string Entry { get; } 15 | 16 | [Option("-f|--singleFile", "A single solidity file to debug.", CommandOptionType.SingleValue)] 17 | public string SingleFile { get; } 18 | 19 | public static ProcessArgs Parse(string[] args) 20 | { 21 | var app = new CommandLineApplication(throwOnUnexpectedArg: true); 22 | app.Conventions.UseDefaultConventions(); 23 | app.Parse(args); 24 | return app.Model; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Meadow.TestNode.Test.App/Contracts/MultifileInheritedContract.sol: -------------------------------------------------------------------------------- 1 | 2 | import "./MultifileInheritableContract.sol"; 3 | 4 | pragma solidity ^0.4.11; 5 | 6 | 7 | contract MultifileInheritedContract is MultifileInheritableContract { 8 | 9 | function MultifileInheritedContract() payable { } 10 | 11 | /** 12 | * @dev Transfers the current balance to the owner and terminates the contract. 13 | */ 14 | function destroy() onlyOwner { 15 | selfdestruct(owner); 16 | } 17 | 18 | function destroyAndSend(address _recipient) onlyOwner { 19 | selfdestruct(_recipient); 20 | } 21 | 22 | function testFunction() public { 23 | uint test = 7; 24 | if(test == 8) 25 | test = 1; 26 | else if(test == 7) 27 | test = 2; 28 | else 29 | test = 3; 30 | } 31 | 32 | function testFunctionWithInheritedModifier() onlyOwner { 33 | uint test = 7; 34 | if(test == 8) 35 | test = 1; 36 | else if(test == 7) 37 | test = 2; 38 | else 39 | test = 3; 40 | } 41 | 42 | function testInheritedAssertThrow() 43 | { 44 | testAssertIndirect(); 45 | } 46 | } -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/UnderlyingTypes/VarInt.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Core.AbiEncoding; 2 | using Meadow.Core.Utils; 3 | using Meadow.CoverageReport.AstTypes; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Meadow.CoverageReport.Debugging.Variables.UnderlyingTypes 9 | { 10 | public class VarInt : VarBase 11 | { 12 | #region Constructors 13 | public VarInt(string typeString) : base(typeString) 14 | { 15 | // Obtain our size in bytes 16 | int sizeBytes = VarParser.GetIntegerSizeInBytes(BaseType, GenericType); 17 | 18 | // Initialize our bounds 19 | InitializeBounds(1, sizeBytes); 20 | } 21 | #endregion 22 | 23 | #region Functions 24 | public override object ParseData(Memory data) 25 | { 26 | // Read an signed integer of the specified size 27 | return BigIntegerConverter.GetBigInteger(data.Span, true, SizeBytes); 28 | } 29 | #endregion 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/UnderlyingTypes/VarUInt.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Core.EthTypes; 2 | using Meadow.Core.Utils; 3 | using Meadow.CoverageReport.AstTypes; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Meadow.CoverageReport.Debugging.Variables.UnderlyingTypes 9 | { 10 | public class VarUInt : VarBase 11 | { 12 | #region Constructors 13 | public VarUInt(string typeString) : base(typeString) 14 | { 15 | // Obtain our size in bytes 16 | int sizeBytes = VarParser.GetIntegerSizeInBytes(BaseType, GenericType); 17 | 18 | // Initialize our bounds 19 | InitializeBounds(1, sizeBytes); 20 | } 21 | #endregion 22 | 23 | #region Functions 24 | public override object ParseData(Memory data) 25 | { 26 | // Read an unsigned integer of the specified size 27 | return BigIntegerConverter.GetBigInteger(data.Span, false, SizeBytes); 28 | } 29 | #endregion 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Bitwise Logic/InstructionIsZero.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Bitwise_Logic 9 | { 10 | public class InstructionIsZero : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionIsZero(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Checks that the assumed comparison is valid. If it is, return 1, otherwise return 0. 23 | BigInteger a = Stack.Pop(); 24 | BigInteger result = a == 0 ? 1 : 0; 25 | 26 | // Push the result onto the stack. 27 | Stack.Push(result); 28 | } 29 | #endregion 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen/CodeGenerators/SolcOutputHelperGenerator.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Contract; 2 | using Meadow.Core.Utils; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Meadow.SolCodeGen.CodeGenerators 8 | { 9 | class SolcOutputHelperGenerator : GeneratorBase 10 | { 11 | readonly byte[] _codebaseHash; 12 | 13 | public SolcOutputHelperGenerator(byte[] codebaseHash, string @namespace) : base(@namespace) 14 | { 15 | _codebaseHash = codebaseHash; 16 | } 17 | 18 | protected override string GenerateUsingDeclarations() 19 | { 20 | var hashHex = HexUtil.GetHexFromBytes(_codebaseHash); 21 | var sourceAttrTypeName = typeof(GeneratedSolcDataAttribute).FullName; 22 | var assemblyAttr = $"[assembly: {sourceAttrTypeName}(\"{hashHex}\")]"; 23 | return assemblyAttr; 24 | } 25 | 26 | protected override string GenerateClassDef() 27 | { 28 | return string.Empty; 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.EVM.Test/Meadow.EVM.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers 14 | 15 | 16 | all 17 | runtime; build; native; contentfiles; analyzers 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Meadow.Core.Test/Meadow.Core.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | false 6 | 7 | 8 | 9 | 10 | all 11 | runtime; build; native; contentfiles; analyzers 12 | 13 | 14 | 15 | 16 | all 17 | runtime; build; native; contentfiles; analyzers 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/AstTypes/AstElementaryTypeName.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Meadow.CoverageReport.AstTypes 8 | { 9 | public class AstElementaryTypeName : AstNode 10 | { 11 | #region Properties 12 | /// 13 | /// The name of our type. 14 | /// 15 | public string Name { get; } 16 | /// 17 | /// The descriptions for this type. 18 | /// 19 | public AstTypeDescriptions TypeDescriptions { get; } 20 | #endregion 21 | 22 | #region Constructor 23 | public AstElementaryTypeName(JObject node) : base(node) 24 | { 25 | // Set our properties 26 | Name = node.SelectToken("name")?.Value(); 27 | TypeDescriptions = new AstTypeDescriptions(node); 28 | } 29 | 30 | public AstElementaryTypeName(AstNode node) : this(node.Node) { } 31 | #endregion 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Arithmetic/InstructionMod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Arithmetic 9 | { 10 | public class InstructionMod : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionMod(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Modulo divide the two unsigned words off of the top of the stack. 23 | BigInteger a = Stack.Pop(); 24 | BigInteger b = Stack.Pop(); 25 | BigInteger result = b == 0 ? 0 : a % b; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.Core/Utils/MiscExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | namespace System 7 | { 8 | public static class DeconstructExtensions 9 | { 10 | public static void Deconstruct( 11 | this KeyValuePair p, 12 | out TKey key, 13 | out TValue value) 14 | { 15 | key = p.Key; 16 | value = p.Value; 17 | } 18 | 19 | } 20 | 21 | public static class ListExtensions 22 | { 23 | public static void AddRange(this List list, params T[] items) 24 | { 25 | list.AddRange(items); 26 | } 27 | } 28 | 29 | public static class SpanExtensions 30 | { 31 | public static Span AsByteSpan(this TFrom[] arr) where TFrom : 32 | #if LANG_7_3 33 | unmanaged 34 | #else 35 | struct 36 | #endif 37 | { 38 | return MemoryMarshal.Cast(arr.AsSpan()); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Arithmetic/InstructionDivide.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Arithmetic 9 | { 10 | public class InstructionDivide : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionDivide(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Divide the two unsigned words off of the top of the stack. 23 | BigInteger a = Stack.Pop(); 24 | BigInteger b = Stack.Pop(); 25 | BigInteger result = b == 0 ? 0 : a / b; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.Contract.Test/Meadow.Contract.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | false 6 | 7 | 8 | 9 | 10 | all 11 | runtime; build; native; contentfiles; analyzers 12 | 13 | 14 | 15 | 16 | all 17 | runtime; build; native; contentfiles; analyzers 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Meadow.Core/RlpEncoding/RLPByteArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.Core.RlpEncoding 6 | { 7 | /// 8 | /// Represents a byte array which can be RLP serialized. 9 | /// 10 | public class RLPByteArray : RLPItem 11 | { 12 | #region Properties 13 | /// 14 | /// The embedded raw data inside of this RLP item. 15 | /// 16 | public Memory Data { get; set; } 17 | #endregion 18 | 19 | #region Constructors 20 | /// 21 | /// Default constructor, initializes with a null data array. 22 | /// 23 | public RLPByteArray() { } 24 | /// 25 | /// Initializes an RLP byte array with the given data. 26 | /// 27 | /// The data to set for our RLP item. 28 | public RLPByteArray(Memory data) 29 | { 30 | Data = data; 31 | } 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Arithmetic/InstructionSubtract.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Arithmetic 9 | { 10 | public class InstructionSubtract : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionSubtract(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Subtract two unsigned words off of the top of the stack from eachother. 23 | BigInteger a = Stack.Pop(); 24 | BigInteger b = Stack.Pop(); 25 | BigInteger result = a - b; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Arithmetic/InstructionSignedDivide.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Arithmetic 9 | { 10 | public class InstructionSignedDivide : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionSignedDivide(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Divide the two signed words off of the top of the stack. 23 | BigInteger a = Stack.Pop(true); 24 | BigInteger b = Stack.Pop(true); 25 | BigInteger result = b == 0 ? 0 : a / b; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Bitwise Logic/InstructionEqual.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Bitwise_Logic 9 | { 10 | public class InstructionEqual : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionEqual(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Checks that the assumed comparison is valid. If it is, return 1, otherwise return 0. 23 | BigInteger a = Stack.Pop(); 24 | BigInteger b = Stack.Pop(); 25 | BigInteger result = a == b ? 1 : 0; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Bitwise Logic/InstructionOr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Bitwise_Logic 9 | { 10 | public class InstructionOr : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionOr(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Perform a bitwise OR on the first two items we pop off the stack and push the result back onto the stack. 23 | BigInteger a = Stack.Pop(); 24 | BigInteger b = Stack.Pop(); 25 | BigInteger result = a | b; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Environment/InstructionBalance.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.Data_Types.Addressing; 8 | using Meadow.EVM.EVM.Execution; 9 | 10 | namespace Meadow.EVM.EVM.Instructions.Environment 11 | { 12 | public class InstructionBalance : InstructionBase 13 | { 14 | #region Constructors 15 | /// 16 | /// Our default constructor, reads the opcode/operand information from the provided stream. 17 | /// 18 | public InstructionBalance(MeadowEVM evm) : base(evm) { } 19 | #endregion 20 | 21 | #region Functions 22 | public override void Execute() 23 | { 24 | // Obtain our address 25 | Address address = Stack.Pop(); 26 | 27 | // Obtain our balance and push it to the stack. 28 | BigInteger balance = EVM.State.GetBalance(address); 29 | Stack.Push(balance); 30 | } 31 | #endregion 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/pwsh_testing/Contracts/OtherContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | contract OtherContract { 5 | 6 | event DataEvent(uint _int1, uint _int2, uint indexed _int3, string _str, uint indexed _int7, address[] _addrs, bytes _bytes, string _mystr); 7 | 8 | event TestEvent(address indexed _addr, uint64 indexed _id, uint _val, uint _timestamp); 9 | 10 | 11 | function emitDataEvent(uint _int1, uint _int2, uint _int3) public { 12 | address[] memory addrs = new address[](12); 13 | for (uint i = 0; i < 12; i++) { 14 | addrs[i] = address(i); 15 | } 16 | bytes memory b = new bytes(9); 17 | b[3] = byte(3); 18 | 19 | emit DataEvent(_int1, _int2, _int3, 20 | "All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log.", 21 | 7, addrs, b, "another string that should be hashed since its indexed"); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/Meadow.CoverageReport.Test/Meadow.CoverageReport.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | false 6 | 7 | 8 | 9 | 10 | all 11 | runtime; build; native; contentfiles; analyzers 12 | 13 | 14 | 15 | 16 | all 17 | runtime; build; native; contentfiles; analyzers 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Bitwise Logic/InstructionAnd.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Bitwise_Logic 9 | { 10 | public class InstructionAnd : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionAnd(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Perform a bitwise AND on the first two items we pop off the stack and push the result back onto the stack. 23 | BigInteger a = Stack.Pop(); 24 | BigInteger b = Stack.Pop(); 25 | BigInteger result = a & b; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Bitwise Logic/InstructionLessThan.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Bitwise_Logic 9 | { 10 | public class InstructionLessThan : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionLessThan(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Checks that the assumed comparison is valid. If it is, return 1, otherwise return 0. 23 | BigInteger a = Stack.Pop(); 24 | BigInteger b = Stack.Pop(); 25 | BigInteger result = a < b ? 1 : 0; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Bitwise Logic/InstructionXor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Bitwise_Logic 9 | { 10 | public class InstructionXor : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionXor(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Perform a bitwise XOR on the first two items we pop off the stack and push the result back onto the stack. 23 | BigInteger a = Stack.Pop(); 24 | BigInteger b = Stack.Pop(); 25 | BigInteger result = a ^ b; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc.Client.Test/Meadow.JsonRpc.Client.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | false 6 | 7 | 8 | 9 | 10 | all 11 | runtime; build; native; contentfiles; analyzers 12 | 13 | 14 | 15 | 16 | all 17 | runtime; build; native; contentfiles; analyzers 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Bitwise Logic/InstructionGreaterThan.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Bitwise_Logic 9 | { 10 | public class InstructionGreaterThan : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionGreaterThan(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Checks that the assumed comparison is valid. If it is, return 1, otherwise return 0. 23 | BigInteger a = Stack.Pop(); 24 | BigInteger b = Stack.Pop(); 25 | BigInteger result = a > b ? 1 : 0; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.TestNode.Test.App/Contracts/OtherContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | contract OtherContract { 5 | 6 | event DataEvent(uint _int1, uint _int2, uint indexed _int3, string _str, uint indexed _int7, address[] _addrs, bytes _bytes, string _mystr); 7 | 8 | event TestEvent(address indexed _addr, uint64 indexed _id, uint _val, uint _timestamp); 9 | 10 | 11 | function emitDataEvent(uint _int1, uint _int2, uint _int3) public { 12 | address[] memory addrs = new address[](12); 13 | for (uint i = 0; i < 12; i++) { 14 | addrs[i] = address(i); 15 | } 16 | bytes memory b = new bytes(9); 17 | b[3] = byte(3); 18 | 19 | emit DataEvent(_int1, _int2, _int3, 20 | "All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log.", 21 | 7, addrs, b, "another string that should be hashed since its indexed"); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /src/pwsh_testing/Contracts/MultifileInheritableContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.11; 2 | 3 | contract MultifileInheritableContract { 4 | 5 | address public owner; 6 | 7 | /** 8 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 9 | * account. 10 | */ 11 | function MultifileInheritableContract() { 12 | owner = msg.sender; 13 | } 14 | 15 | 16 | /** 17 | * @dev Throws if called by any account other than the owner. 18 | */ 19 | modifier onlyOwner() { 20 | require(msg.sender == owner); 21 | _; 22 | } 23 | 24 | 25 | /** 26 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 27 | * @param newOwner The address to transfer ownership to. 28 | */ 29 | function transferOwnership(address newOwner) onlyOwner { 30 | require(newOwner != address(0)); 31 | owner = newOwner; 32 | } 33 | 34 | // Test Callstack through multiple contracts and indirect calls. 35 | function testThrowAssert() public { 36 | assert(false); 37 | } 38 | function testAssertIndirect() public { 39 | testThrowAssert(); 40 | } 41 | } -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/UnderlyingTypes/VarBoolean.cs: -------------------------------------------------------------------------------- 1 | using Meadow.CoverageReport.AstTypes; 2 | using Meadow.CoverageReport.Debugging.Variables.Enums; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Meadow.CoverageReport.Debugging.Variables.UnderlyingTypes 8 | { 9 | public class VarBoolean : VarBase 10 | { 11 | #region Constructors 12 | public VarBoolean(string typeString) : base(typeString) 13 | { 14 | // Initialize our bounds 15 | InitializeBounds(1, 1); 16 | } 17 | #endregion 18 | 19 | #region Functions 20 | public override object ParseData(Memory data) 21 | { 22 | // If there is no data, return false 23 | if (data.Length == 0) 24 | { 25 | return false; 26 | } 27 | else 28 | { 29 | // Otherwise the boolean is parsed from the first byte. 30 | return data.Span[data.Length - 1] != 0; 31 | } 32 | } 33 | #endregion 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc.Server/Meadow.JsonRpc.Server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc/JsonConverters/JsonRpcSerializer.cs: -------------------------------------------------------------------------------- 1 | using Meadow.JsonRpc.JsonConverters; 2 | using Newtonsoft.Json; 3 | 4 | namespace Meadow.JsonRpc.JsonConverters 5 | { 6 | public static class JsonRpcSerializer 7 | { 8 | public static readonly JsonSerializerSettings Settings; 9 | public static readonly JsonSerializer Serializer; 10 | public static readonly JsonConverter[] Converters = new JsonConverter[] 11 | { 12 | new AddressHexJsonConverter(), 13 | new DataHexJsonConverter(), 14 | new HashHexJsonConverter(), 15 | new UInt256HexJsonConverter(), 16 | new JsonRpcHexConverter() 17 | }; 18 | 19 | static JsonRpcSerializer() 20 | { 21 | Settings = new JsonSerializerSettings(); 22 | Settings.DefaultValueHandling = DefaultValueHandling.Ignore; 23 | 24 | foreach (var converter in Converters) 25 | { 26 | Settings.Converters.Add(converter); 27 | } 28 | 29 | Serializer = JsonSerializer.CreateDefault(Settings); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.TestNode.Test.App/Contracts/MultifileInheritableContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.11; 2 | 3 | contract MultifileInheritableContract { 4 | 5 | address public owner; 6 | 7 | /** 8 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 9 | * account. 10 | */ 11 | function MultifileInheritableContract() { 12 | owner = msg.sender; 13 | } 14 | 15 | 16 | /** 17 | * @dev Throws if called by any account other than the owner. 18 | */ 19 | modifier onlyOwner() { 20 | require(msg.sender == owner); 21 | _; 22 | } 23 | 24 | 25 | /** 26 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 27 | * @param newOwner The address to transfer ownership to. 28 | */ 29 | function transferOwnership(address newOwner) onlyOwner { 30 | require(newOwner != address(0)); 31 | owner = newOwner; 32 | } 33 | 34 | // Test Callstack through multiple contracts and indirect calls. 35 | function testThrowAssert() public { 36 | assert(false); 37 | } 38 | function testAssertIndirect() public { 39 | testThrowAssert(); 40 | } 41 | } -------------------------------------------------------------------------------- /src/pwsh_testing/Contracts/VarAnalysisContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | /// @title Error Generating Contract (Testing) 4 | /// @author David Pokora 5 | /// @notice This is a contract used to generate errors to test EVM exception tracing, etc. 6 | /// @dev 7 | contract VarAnalysisContract 8 | { 9 | uint globalVal; 10 | 11 | /// @notice Our default contructor 12 | constructor() public 13 | { 14 | } 15 | 16 | enum TestEnum {FIRST,SECOND,THIRD} 17 | 18 | function updateStateValues() 19 | { 20 | uint x = 777; 21 | globalVal++; 22 | } 23 | 24 | function throwWithLocals() 25 | { 26 | address addr1 = 0x345ca3e014aaf5dca488057592ee47305d9b3e10; 27 | address addr2 = 0x7070707070707070707070707070707070707070; 28 | int x = -1; 29 | uint y = 0x1080; 30 | bool b1 = true; 31 | bool b2 = false; 32 | TestEnum enum1 = TestEnum.FIRST; 33 | TestEnum enum2 = TestEnum.SECOND; 34 | TestEnum enum3 = TestEnum.THIRD; 35 | assert(false); 36 | 37 | // This is never hit, these values should not be reflected when checking locals. 38 | TestEnum enum4 = TestEnum.FIRST; 39 | bool b3 = true; 40 | x = 7; 41 | } 42 | } -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Bitwise Logic/InstructionSignedLessThan.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Bitwise_Logic 9 | { 10 | public class InstructionSignedLessThan : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionSignedLessThan(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Checks that the assumed comparison is valid. If it is, return 1, otherwise return 0. 23 | BigInteger a = Stack.Pop(true); 24 | BigInteger b = Stack.Pop(true); 25 | BigInteger result = a < b ? 1 : 0; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Environment/InstructionGasPrice.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.EVM.Execution; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Environment 10 | { 11 | public class InstructionGasPrice : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionGasPrice(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // Push the transaction's current gas price onto the stack. 24 | if (EVM.State.CurrentTransaction != null) 25 | { 26 | Stack.Push(EVM.State.CurrentTransaction.GasPrice); 27 | } 28 | else 29 | { 30 | Stack.Push(0); 31 | } 32 | } 33 | #endregion 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Bitwise Logic/InstructionSignedGreaterThan.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Bitwise_Logic 9 | { 10 | public class InstructionSignedGreaterThan : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionSignedGreaterThan(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Checks that the assumed comparison is valid. If it is, return 1, otherwise return 0. 23 | BigInteger a = Stack.Pop(true); 24 | BigInteger b = Stack.Pop(true); 25 | BigInteger result = a > b ? 1 : 0; 26 | 27 | // Push the result onto the stack. 28 | Stack.Push(result); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Environment/InstructionOrigin.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.EVM.Execution; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Environment 10 | { 11 | public class InstructionOrigin : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionOrigin(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // Push the origin address from the transaction to the stack. 24 | if (EVM.State.CurrentTransaction != null) 25 | { 26 | Stack.Push(EVM.State.CurrentTransaction.GetSenderAddress()); 27 | } 28 | else 29 | { 30 | Stack.Push(0); 31 | } 32 | } 33 | #endregion 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Contracts/FinalizableCrowdsale.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | import "./SafeMath.sol"; 4 | import "./Ownable.sol"; 5 | import "./TimedCrowdsale.sol"; 6 | 7 | 8 | /** 9 | * @title FinalizableCrowdsale 10 | * @dev Extension of Crowdsale where an owner can do extra work 11 | * after finishing. 12 | */ 13 | contract FinalizableCrowdsale is TimedCrowdsale, Ownable { 14 | using SafeMath for uint256; 15 | 16 | bool public isFinalized = false; 17 | 18 | event Finalized(); 19 | 20 | /** 21 | * @dev Must be called after crowdsale ends, to do some extra finalization 22 | * work. Calls the contract's finalization function. 23 | */ 24 | function finalize() onlyOwner public { 25 | require(!isFinalized); 26 | require(hasClosed()); 27 | 28 | finalization(); 29 | emit Finalized(); 30 | 31 | isFinalized = true; 32 | } 33 | 34 | /** 35 | * @dev Can be overridden to add finalization logic. The overriding function 36 | * should call super.finalization() to ensure the chain of finalization is 37 | * executed entirely. 38 | */ 39 | function finalization() internal { 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/Meadow.EVM.Test/TransactionRlpTests.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Core.RlpEncoding; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Numerics; 5 | using System.Text; 6 | using Xunit; 7 | 8 | namespace Meadow.EVM.Test 9 | { 10 | public class TransactionRlpTests 11 | { 12 | [Fact] 13 | public void RLPLogTest() 14 | { 15 | Meadow.EVM.Data_Types.Transactions.Log log = new Meadow.EVM.Data_Types.Transactions.Log((BigInteger)0x11223344, new List() { 3, 2, 1 }, new byte[] { 00, 77, 00, 77 }); 16 | RLPItem item = log.Serialize(); 17 | byte[] data = RLP.Encode(item); 18 | item = RLP.Decode(data); 19 | log.Deserialize(item); 20 | item = log.Serialize(); 21 | byte[] data2 = RLP.Encode(item); 22 | Assert.True(data.ValuesEqual(data2)); 23 | Assert.Equal(0x11223344, (BigInteger)log.Address); 24 | Assert.True(log.Topics.Count == 3 && log.Topics[0] == 3 && log.Topics[1] == 2 && log.Topics[2] == 1); 25 | Assert.True(log.Data.ValuesEqual(new byte[] { 00, 77, 00, 77 })); 26 | } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Environment/InstructionReturnDataSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.Data_Types.Addressing; 8 | using Meadow.EVM.EVM.Execution; 9 | 10 | namespace Meadow.EVM.EVM.Instructions.Environment 11 | { 12 | public class InstructionReturnDataSize : InstructionBase 13 | { 14 | #region Constructors 15 | /// 16 | /// Our default constructor, reads the opcode/operand information from the provided stream. 17 | /// 18 | public InstructionReturnDataSize(MeadowEVM evm) : base(evm) { } 19 | #endregion 20 | 21 | #region Functions 22 | public override void Execute() 23 | { 24 | // Obtain our return data length 25 | int codeLength = ExecutionState.LastCallResult?.ReturnData == null ? 0 : ExecutionState.LastCallResult.ReturnData.Length; 26 | 27 | // Push the return data length to the stack. 28 | Stack.Push(codeLength); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.Networking/Configuration/NetworkConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Networking.Protocol.Addressing; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Net; 5 | using System.Text; 6 | 7 | namespace Meadow.Networking.Configuration 8 | { 9 | public class NetworkConfiguration 10 | { 11 | #region Properties 12 | public bool ListeningEnabled { get; set; } 13 | public IPAddress ListeningHost { get; set; } 14 | public ushort ListeningPort { get; set; } 15 | 16 | public List BootstrapNodes { get; set; } 17 | #endregion 18 | 19 | #region Constructors 20 | public NetworkConfiguration(bool defaultBootstrapServers = true) 21 | { 22 | // Initialize our properties with default values 23 | BootstrapNodes = new List(); 24 | 25 | // Add our default bootstrap nodes 26 | if (defaultBootstrapServers) 27 | { 28 | // Add the bootstrap nodes. 29 | BootstrapNodes.AddRange(DefaultBootstrapNodes.MainNetNodes); 30 | } 31 | } 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Models/SourceFileLine.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | 4 | namespace Meadow.CoverageReport.Models 5 | { 6 | public class SourceFileLine 7 | { 8 | public bool IsActive { get; set; } 9 | public bool IsUnreachable { get; set; } 10 | public int LineNumber { get; set; } 11 | public string LiteralSourceCodeLine { get; set; } 12 | public int ExecutionCount { get; set; } 13 | public bool IsCovered => ExecutionCount > 0; 14 | 15 | [JsonConverter(typeof(StringEnumConverter))] 16 | public BranchCoverageState BranchState { get; set; } 17 | 18 | [JsonConverter(typeof(StringEnumConverter))] 19 | public BranchType? BranchType { get; set; } 20 | 21 | public bool IsBranch { get; set; } 22 | 23 | [JsonIgnore] 24 | public SourceFileMap SourceFileMapParent { get; set; } 25 | 26 | public int Offset { get; set; } 27 | public int OffsetEnd => Offset + Length; 28 | public int Length { get; set; } 29 | 30 | [JsonIgnore] 31 | public AstNode[] CorrelatedAstNodes { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Control Flow and IO/InstructionStorageLoad.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.Data_Types.Accounts; 2 | using Meadow.EVM.Data_Types.Addressing; 3 | using Meadow.EVM.EVM.Execution; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Numerics; 8 | using System.Text; 9 | 10 | namespace Meadow.EVM.EVM.Instructions.Control_Flow_and_IO 11 | { 12 | public class InstructionStorageLoad : InstructionBase 13 | { 14 | #region Constructors 15 | /// 16 | /// Our default constructor, reads the opcode/operand information from the provided stream. 17 | /// 18 | public InstructionStorageLoad(MeadowEVM evm) : base(evm) { } 19 | #endregion 20 | 21 | #region Functions 22 | public override void Execute() 23 | { 24 | // Pop our key off of the stack. 25 | BigInteger key = Stack.Pop(); 26 | 27 | // In our current account, check the storage for this key's value and push it to the stack. 28 | Stack.Push(EVM.State.GetStorageData(Message.To, key)); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/UnderlyingTypes/VarFixedBytes.cs: -------------------------------------------------------------------------------- 1 | using Meadow.CoverageReport.AstTypes; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Meadow.CoverageReport.Debugging.Variables.UnderlyingTypes 7 | { 8 | public class VarFixedBytes : VarBase 9 | { 10 | #region Constructors 11 | public VarFixedBytes(string typeString) : base(typeString) 12 | { 13 | // Determine the size of our fixed array. 14 | int sizeBytes = VarParser.GetFixedArraySizeInBytes(BaseType); 15 | 16 | // Initialize our bounds 17 | InitializeBounds(1, sizeBytes); 18 | } 19 | #endregion 20 | 21 | #region Functions 22 | public override object ParseData(Memory data) 23 | { 24 | // If our data is not the correct size, return an empty array 25 | if (data.Length < SizeBytes) 26 | { 27 | return default(Memory); 28 | } 29 | 30 | // Slice our data off. 31 | return data.Slice(0, SizeBytes); 32 | } 33 | #endregion 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Control Flow and IO/InstructionMemoryStore.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | using System.Text; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Control_Flow_and_IO 9 | { 10 | public class InstructionMemoryStore : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionMemoryStore(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Obtain the address at which to read memory from in our memory segment. 23 | BigInteger address = Stack.Pop(); 24 | 25 | // Obtain our data to store 26 | BigInteger data = Stack.Pop(); 27 | 28 | // Store our data in our memory segment at the given address 29 | Memory.Write((long)address, data); 30 | } 31 | #endregion 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/NestedBranchesTests.cs: -------------------------------------------------------------------------------- 1 | using Meadow.JsonRpc.Types; 2 | using Meadow.EVM.Data_Types; 3 | using Meadow.Core.Utils; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | using System.Numerics; 6 | using System.Threading.Tasks; 7 | using Meadow.Contract; 8 | 9 | namespace Meadow.UnitTestTemplate.Test 10 | { 11 | 12 | [TestClass] 13 | public class NestedBranchesTests : ContractTest 14 | { 15 | NestedBranches _contract; 16 | 17 | protected override async Task BeforeEach() 18 | { 19 | _contract = await NestedBranches.New(RpcClient); 20 | } 21 | 22 | [TestMethod] 23 | public async Task NestedStructBranches() 24 | { 25 | Assert.IsTrue(await _contract.checkStructTree(555).Call()); 26 | Assert.IsFalse(await _contract.checkStructTree(111).Call()); 27 | } 28 | 29 | [TestMethod] 30 | public async Task SimpleIfStatement() 31 | { 32 | Assert.IsTrue(await _contract.simpleIfStatement(true).Call()); 33 | Assert.IsFalse(await _contract.simpleIfStatement(false).Call()); 34 | } 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc/RpcControllerExtensions.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Core.Utils; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | namespace Meadow.JsonRpc 6 | { 7 | public static class RpcControllerExtensions 8 | { 9 | /// 10 | /// Returns a list of rpc methods that are not defined in the interface. 11 | /// 12 | public static RpcApiMethod[] GetUndefinedRpcMethods(this IRpcController controller) 13 | { 14 | var methodAttrs = controller 15 | .GetType() 16 | .GetInterfaces() 17 | .Concat(new[] { controller.GetType() }) 18 | .Distinct() 19 | .SelectMany(t => t.GetMethods(BindingFlags.Public | BindingFlags.Instance)) 20 | .Select(m => m.GetCustomAttribute(inherit: true)) 21 | .Where(a => a != null) 22 | .Select(a => a.Method) 23 | .ToArray(); 24 | 25 | var rpcDefs = EnumExtensions.GetValues(); 26 | var undefined = rpcDefs.Except(methodAttrs).ToArray(); 27 | return undefined; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/AstTypes/AstMappingTypeName.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Meadow.CoverageReport.AstTypes 7 | { 8 | public class AstMappingTypeName : AstElementaryTypeName 9 | { 10 | #region Properties 11 | public AstElementaryTypeName KeyType { get; } 12 | public AstElementaryTypeName ValueType { get; } 13 | #endregion 14 | 15 | #region Constructor 16 | public AstMappingTypeName(JObject node) : base(node) 17 | { 18 | // Set our properties 19 | JToken keyType = node.SelectToken("keyType"); 20 | if (keyType != null) 21 | { 22 | KeyType = Create((JObject)keyType); 23 | } 24 | 25 | JToken valueType = node.SelectToken("valueType"); 26 | if (valueType != null) 27 | { 28 | ValueType = Create((JObject)valueType); 29 | } 30 | } 31 | 32 | public AstMappingTypeName(AstNode node) : this(node.Node) { } 33 | #endregion 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Arithmetic/InstructionAddMod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | using Meadow.Core.Utils; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Arithmetic 10 | { 11 | public class InstructionAddMod : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionAddMod(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // Modulo divide the two added unsigned words off of the top of the stack. 24 | BigInteger a = Stack.Pop(); 25 | BigInteger b = Stack.Pop(); 26 | BigInteger c = Stack.Pop(); 27 | BigInteger result = c == 0 ? 0 : ((a + b) % c).CapOverflow(); 28 | 29 | // Push the result onto the stack. 30 | Stack.Push(result); 31 | } 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/InheritanceTests.cs: -------------------------------------------------------------------------------- 1 | using Meadow.JsonRpc.Types; 2 | using Meadow.EVM.Data_Types; 3 | using Meadow.Core.Utils; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | using System.Numerics; 6 | using System.Threading.Tasks; 7 | using Meadow.Contract; 8 | 9 | namespace Meadow.UnitTestTemplate.Test 10 | { 11 | 12 | [TestClass] 13 | public class InheritanceTests : ContractTest 14 | { 15 | InheritanceChild _contract; 16 | 17 | protected override async Task BeforeEach() 18 | { 19 | _contract = await InheritanceChild.New(RpcClient); 20 | } 21 | 22 | [TestMethod] 23 | public async Task FailModifier() 24 | { 25 | await _contract.testThing(5).ExpectRevertTransaction(); 26 | } 27 | 28 | [TestMethod] 29 | public async Task SuperPass() 30 | { 31 | var num = await _contract.testThing(2).Call(); 32 | Assert.AreEqual(3, num); 33 | } 34 | 35 | [TestMethod] 36 | public async Task SuperFail() 37 | { 38 | await _contract.testThing(0).ExpectRevertTransaction(); 39 | } 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Control Flow and IO/InstructionMemoryLoad.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | using System.Text; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Control_Flow_and_IO 9 | { 10 | public class InstructionMemoryLoad : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionMemoryLoad(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Obtain the address at which to read memory from in our memory segment. 23 | BigInteger address = Stack.Pop(); 24 | 25 | // Read a 256-bit integer from our memory segment and append it to stack 26 | BigInteger value = Memory.ReadBigInteger((long)address); 27 | 28 | // Push our value back onto the stack. 29 | Stack.Push(value); 30 | } 31 | #endregion 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Contracts/OtherContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | contract OtherContract { 5 | 6 | event DataEvent(uint _int1, uint _int2, uint indexed _int3, string _str, uint indexed _int7, address[] _addrs, bytes _bytes, string _mystr); 7 | 8 | event TestEvent(address indexed _addr, uint64 indexed _id, uint _val, uint _timestamp); 9 | 10 | /// @notice The constructor 11 | constructor() public { 12 | 13 | } 14 | 15 | function emitDataEvent(uint _int1, uint _int2, uint _int3) public { 16 | address[] memory addrs = new address[](12); 17 | for (uint i = 0; i < 12; i++) { 18 | addrs[i] = address(i); 19 | } 20 | bytes memory b = new bytes(9); 21 | b[3] = byte(3); 22 | 23 | emit DataEvent(_int1, _int2, _int3, 24 | "All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log. All non-indexed arguments will be stored in the data part of the log.", 25 | 7, addrs, b, "another string that should be hashed since its indexed"); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/Meadow.Core/AccountDerivation/SystemRandomAccountDerivation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Security.Cryptography; 4 | using System.Text; 5 | 6 | namespace Meadow.Core.AccountDerivation 7 | { 8 | public class SystemRandomAccountDerivation : AccountDerivationBase 9 | { 10 | Action _getRandomBytes; 11 | 12 | public SystemRandomAccountDerivation(int? seed = null) 13 | { 14 | if (seed.HasValue) 15 | { 16 | var rnd = new Random(seed.Value); 17 | _getRandomBytes = bytes => 18 | { 19 | rnd.NextBytes(bytes); 20 | }; 21 | } 22 | else 23 | { 24 | var rnd = RandomNumberGenerator.Create(); 25 | _getRandomBytes = bytes => 26 | { 27 | rnd.GetBytes(bytes); 28 | }; 29 | } 30 | } 31 | 32 | public override byte[] GeneratePrivateKey(uint accountIndex) 33 | { 34 | var data = new byte[32]; 35 | _getRandomBytes(data); 36 | return data; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Arithmetic/InstructionMultiplyMod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | using Meadow.Core.Utils; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Arithmetic 10 | { 11 | public class InstructionMultiplyMod : InstructionBase 12 | { 13 | #region Constructors 14 | /// 15 | /// Our default constructor, reads the opcode/operand information from the provided stream. 16 | /// 17 | public InstructionMultiplyMod(MeadowEVM evm) : base(evm) { } 18 | #endregion 19 | 20 | #region Functions 21 | public override void Execute() 22 | { 23 | // Modulo divide the two multiplied unsigned words off of the top of the stack. 24 | BigInteger a = Stack.Pop(); 25 | BigInteger b = Stack.Pop(); 26 | BigInteger c = Stack.Pop(); 27 | BigInteger result = c == 0 ? 0 : ((a * b) % c).CapOverflow(); 28 | 29 | // Push the result onto the stack. 30 | Stack.Push(result); 31 | } 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/System Operations/InstructionRevert.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | using System.Text; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.System_Operations 9 | { 10 | public class InstructionRevert : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionRevert(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Obtain the offset and size of the data to copy from memory as our result. 23 | BigInteger offset = Stack.Pop(); 24 | BigInteger size = Stack.Pop(); 25 | 26 | // We'll want to return with our read memory, our remaining gas, and indicating we wish to revert changes. 27 | Return(new EVMExecutionResult(EVM, Memory.ReadBytes((long)offset, (int)size), GasState.Gas, false)); 28 | } 29 | #endregion 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Models/CoverageStats.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.CoverageReport.Models 6 | { 7 | public class CoverageStats 8 | { 9 | public int LineCount { get; set; } 10 | public int LineCoveredCount { get; set; } 11 | public double LineCoveragePercent => GetPercent(LineCount, LineCoveredCount); 12 | 13 | public int BranchCount { get; set; } 14 | public int BranchCoveredCount { get; set; } 15 | public double BranchCoveragePercent => GetPercent(BranchCount, BranchCoveredCount); 16 | 17 | public int FunctionCount { get; set; } 18 | public int FunctionCoveredCount { get; set; } 19 | public double FunctionCoveragePercent => GetPercent(FunctionCount, FunctionCoveredCount); 20 | 21 | static double GetPercent(int total, int hit) 22 | { 23 | if (total == 0 && hit == 0) 24 | { 25 | return 100; 26 | } 27 | 28 | if (hit == 0) 29 | { 30 | return 0; 31 | } 32 | 33 | return Math.Round((hit / (double)total) * 100, 2); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/System Operations/InstructionReturn.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | using System.Text; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.System_Operations 9 | { 10 | public class InstructionReturn : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionReturn(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Obtain the offset and size of the data to copy from memory as our result. 23 | BigInteger offset = Stack.Pop(); 24 | BigInteger size = Stack.Pop(); 25 | 26 | // We'll want to return with our read memory, our remaining gas, and indicating we don't wish to revert changes. 27 | Return(new EVMExecutionResult(EVM, Memory.ReadBytes((long)offset, (int)size), GasState.Gas, true)); 28 | } 29 | #endregion 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc.Server.Proxy.Test/Meadow.JsonRpc.Server.Proxy.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | false 6 | 7 | 8 | 9 | 10 | all 11 | runtime; build; native; contentfiles; analyzers 12 | 13 | 14 | 15 | 16 | all 17 | runtime; build; native; contentfiles; analyzers 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen/ContractInfo.cs: -------------------------------------------------------------------------------- 1 | using SolcNet.DataDescription.Output; 2 | 3 | namespace Meadow.SolCodeGen 4 | { 5 | class ContractInfo 6 | { 7 | public readonly string SolFile; 8 | public readonly string ContractName; 9 | public readonly SolcNet.DataDescription.Output.Contract ContractOutput; 10 | public readonly byte[] Hash; 11 | public readonly string Bytecode; 12 | 13 | public ContractInfo(string solFile, string contractName, SolcNet.DataDescription.Output.Contract contractOutput, byte[] hash, string bytecode) 14 | { 15 | SolFile = solFile; 16 | ContractName = contractName; 17 | ContractOutput = contractOutput; 18 | Hash = hash; 19 | Bytecode = bytecode; 20 | } 21 | 22 | public void Deconstruct(out string solFile, out string contractName, out SolcNet.DataDescription.Output.Contract contractOuput, out byte[] hash, out string bytecode) 23 | { 24 | solFile = SolFile; 25 | contractName = ContractName; 26 | contractOuput = ContractOutput; 27 | hash = Hash; 28 | bytecode = Bytecode; 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate/InternalTestState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Meadow.UnitTestTemplate 6 | { 7 | /// 8 | /// Provides information regarding the state of a test, as needed by this test framework. 9 | /// 10 | internal class InternalTestState 11 | { 12 | #region Properties 13 | /// 14 | /// Indicates if tests are working on/should be working on an external node. 15 | /// 16 | internal bool InExternalNodeContext { get; set; } 17 | 18 | /// 19 | /// Indicates the test start time. 20 | /// 21 | internal DateTimeOffset StartTime { get; set; } 22 | /// 23 | /// Indicates the test end time. 24 | /// 25 | internal DateTimeOffset EndTime { get; set; } 26 | 27 | /// 28 | /// Indicates whether test initialization occurred without error. 29 | /// 30 | internal bool InitializationSuccess { get; set; } 31 | 32 | internal string CustomDisplayName { get; set; } 33 | #endregion 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.JsonRpc.Server.Proxy/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading.Tasks; 4 | 5 | namespace Meadow.JsonRpc.Server.Proxy 6 | { 7 | class Program 8 | { 9 | static async Task Main(string[] args) 10 | { 11 | // TODO: command line args for port and host 12 | 13 | // Default ganache gui port. 14 | int targetServerPort = 7545; 15 | 16 | // Default to localhost. 17 | string host = IPAddress.Loopback.ToString(); 18 | 19 | int proxyServerPort = 7117; 20 | 21 | string proxyUri = $"http://{IPAddress.Loopback}:{proxyServerPort}"; 22 | string serverUri = $"http://{host}:{targetServerPort}"; 23 | 24 | Console.WriteLine($"Proxying calls to server at {serverUri}"); 25 | 26 | Console.WriteLine($"Launching server proxy, listening at {proxyUri}"); 27 | var rpcServerProxy = new RpcServerProxy(new Uri(serverUri), proxyServerPort); 28 | await rpcServerProxy.StartServerAsync(); 29 | Console.WriteLine("Server started and listening..."); 30 | 31 | await rpcServerProxy.WaitForServerShutdownAsync(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Contracts/Ownable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address public owner; 11 | 12 | 13 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 14 | 15 | 16 | /** 17 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 18 | * account. 19 | */ 20 | function Ownable() public { 21 | owner = msg.sender; 22 | } 23 | 24 | /** 25 | * @dev Throws if called by any account other than the owner. 26 | */ 27 | modifier onlyOwner() { 28 | require(msg.sender == owner); 29 | _; 30 | } 31 | 32 | /** 33 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 34 | * @param newOwner The address to transfer ownership to. 35 | */ 36 | function transferOwnership(address newOwner) public onlyOwner { 37 | require(newOwner != address(0)); 38 | emit OwnershipTransferred(owner, newOwner); 39 | owner = newOwner; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/Meadow.Core/EthTypes/FixedMxN.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | // Disabled, currently unused 7 | 8 | /* 9 | namespace Meadow.Core.EthTypes 10 | { 11 | public interface IFixedN 12 | { 13 | int Decimals { get; } 14 | } 15 | 16 | /// 17 | /// Where M represents the number of bits taken by the type 18 | /// and N represents how many decimal points are available. 19 | /// M must be divisible by 8 and goes from 8 to 256 bits. 20 | /// N must be between 0 and 80, inclusive. ufixed and fixed 21 | /// are aliases for ufixed128x19 and fixed128x19, respectively. 22 | /// 23 | [StructLayout(LayoutKind.Sequential)] 24 | public struct Fixed where M : struct where N : struct, IFixedN 25 | { 26 | readonly M Value; 27 | 28 | public int Decimals => default(N).Decimals; 29 | 30 | 31 | } 32 | 33 | [StructLayout(LayoutKind.Sequential)] 34 | public struct UFixed where M : struct where N : struct, IFixedN 35 | { 36 | readonly M Value; 37 | 38 | public int Decimals => default(N).Decimals; 39 | 40 | 41 | } 42 | } 43 | */ -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Arithmetic/InstructionSignedMod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.EVM.Execution; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Arithmetic 9 | { 10 | public class InstructionSignedMod : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionSignedMod(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Modulo divide the two signed words off of the top of the stack. 23 | BigInteger a = Stack.Pop(true); 24 | BigInteger b = Stack.Pop(true); 25 | BigInteger result = 0; 26 | if (a != 0) 27 | { 28 | result = a.Sign * (BigInteger.Abs(a) % BigInteger.Abs(b)); 29 | } 30 | 31 | // Push the result onto the stack. 32 | Stack.Push(result); 33 | } 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Environment/InstructionExternalCodeSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.Data_Types.Addressing; 8 | using Meadow.EVM.EVM.Execution; 9 | 10 | namespace Meadow.EVM.EVM.Instructions.Environment 11 | { 12 | public class InstructionExternalCodeSize : InstructionBase 13 | { 14 | #region Constructors 15 | /// 16 | /// Our default constructor, reads the opcode/operand information from the provided stream. 17 | /// 18 | public InstructionExternalCodeSize(MeadowEVM evm) : base(evm) { } 19 | #endregion 20 | 21 | #region Functions 22 | public override void Execute() 23 | { 24 | // Obtain our external account address 25 | Address externalCodeAddress = Stack.Pop(); 26 | 27 | // Obtain our code segment 28 | byte[] codeSegment = EVM.State.GetCodeSegment(externalCodeAddress); 29 | 30 | // Push the code size to the stack. 31 | Stack.Push(codeSegment.Length); 32 | } 33 | #endregion 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Control Flow and IO/InstructionMemoryStore8.cs: -------------------------------------------------------------------------------- 1 | using Meadow.EVM.EVM.Execution; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | using System.Text; 7 | 8 | namespace Meadow.EVM.EVM.Instructions.Control_Flow_and_IO 9 | { 10 | public class InstructionMemoryStore8 : InstructionBase 11 | { 12 | #region Constructors 13 | /// 14 | /// Our default constructor, reads the opcode/operand information from the provided stream. 15 | /// 16 | public InstructionMemoryStore8(MeadowEVM evm) : base(evm) { } 17 | #endregion 18 | 19 | #region Functions 20 | public override void Execute() 21 | { 22 | // Obtain the address at which to read memory from in our memory segment. 23 | BigInteger address = Stack.Pop(); 24 | 25 | // Obtain our data to store 26 | BigInteger data = Stack.Pop(); 27 | byte storeData = (byte)(data & 0xFF); 28 | 29 | // Store our data in our memory segment at the given address 30 | Memory.Write((long)address, storeData); 31 | } 32 | #endregion 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.VSCode.Debugger/src/logger.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import * as util from 'util'; 3 | 4 | export class Logger { 5 | 6 | private static outputChannel : vscode.OutputChannel = vscode.window.createOutputChannel("Meadow Solidity Debugger"); 7 | 8 | private static _didShow: boolean = false; 9 | 10 | public static log(message: string, ...params: any[]): void { 11 | if (!this._didShow) { 12 | this._didShow = true; 13 | this.show(); 14 | } 15 | this.outputChannel.appendLine(message); 16 | params.forEach(p => this.outputChannel.appendLine(util.inspect(p))); 17 | 18 | if (this._isDebugging) { 19 | console.log(message); 20 | params.forEach(p => console.log(p)); 21 | } 22 | } 23 | 24 | public static show(): void { 25 | this.outputChannel.show(); 26 | } 27 | 28 | private static _isDebugging: boolean; 29 | 30 | static init() { 31 | try { 32 | const isDebuggingRegex = /^--inspect(-brk)?=?/; 33 | const args = process.execArgv; 34 | this._isDebugging = args ? args.some(arg => isDebuggingRegex.test(arg)) : false; 35 | } catch { } 36 | } 37 | } 38 | 39 | Logger.init(); -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/Pairing/UnderlyingVariableValuePair.cs: -------------------------------------------------------------------------------- 1 | using Meadow.CoverageReport.Debugging.Variables.UnderlyingTypes; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Meadow.CoverageReport.Debugging.Variables.Pairing 7 | { 8 | /// 9 | /// Similar to but instead including the underlying variable object "" instead of a type. 10 | /// 11 | public struct UnderlyingVariableValuePair 12 | { 13 | #region Properties 14 | public readonly VarBase Variable; 15 | public readonly object Value; 16 | #endregion 17 | 18 | #region Constructor 19 | public UnderlyingVariableValuePair(VarBase variable, object value) 20 | { 21 | // Set our properties 22 | Variable = variable; 23 | Value = value; 24 | } 25 | 26 | public UnderlyingVariableValuePair(VariableValuePair variableValuePair) 27 | { 28 | // Set our properties 29 | Variable = variableValuePair.Variable.ValueParser; 30 | Value = variableValuePair.Value; 31 | } 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/Debugging/Variables/UnderlyingTypes/VarAddress.cs: -------------------------------------------------------------------------------- 1 | using Meadow.Core.EthTypes; 2 | using Meadow.CoverageReport.AstTypes; 3 | using Meadow.CoverageReport.Debugging.Variables.Enums; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Meadow.CoverageReport.Debugging.Variables.UnderlyingTypes 9 | { 10 | public class VarAddress : VarBase 11 | { 12 | #region Constructors 13 | public VarAddress(string typeString) : base(typeString) 14 | { 15 | // Initialize our bounds 16 | InitializeBounds(1, Address.SIZE); 17 | } 18 | #endregion 19 | 20 | #region Functions 21 | public override object ParseData(Memory data) 22 | { 23 | // If there is insufficient data, return a zero address. 24 | if (data.Length < Address.SIZE) 25 | { 26 | return new Address(new byte[Address.SIZE]); 27 | } 28 | else 29 | { 30 | // Otherwise the boolean is parsed from the first byte. 31 | return new Address(data.Slice(data.Length - Address.SIZE, Address.SIZE).ToArray()); 32 | } 33 | } 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Meadow.TestNode.Host/ProcessArgs.cs: -------------------------------------------------------------------------------- 1 | using McMaster.Extensions.CommandLineUtils; 2 | 3 | namespace Meadow.TestNode.Host 4 | { 5 | 6 | class ProcessArgs 7 | { 8 | [Option("-p|--port", "TODO.", CommandOptionType.SingleValue)] 9 | public uint Port { get; } = 8747; 10 | 11 | [Option("-h|--host", "TODO", CommandOptionType.SingleValue)] 12 | public string Host { get; } = "127.0.0.1"; 13 | 14 | [Option("-a|--account_count", "TODO", CommandOptionType.SingleValue)] 15 | public uint AccountCount { get; } = 100; 16 | 17 | [Option("-b|--account_balance", "TODO", CommandOptionType.SingleValue)] 18 | public uint AccountBalance { get; } = 1000; 19 | 20 | [Option("-m|--mnemonic", "TODO", CommandOptionType.SingleValue)] 21 | public string Mnemonic { get; } 22 | 23 | [Option("--proxy_node", "TODO", CommandOptionType.SingleValue)] 24 | public string Proxy { get; } 25 | 26 | public static ProcessArgs Parse(string[] args) 27 | { 28 | var app = new CommandLineApplication(throwOnUnexpectedArg: true); 29 | app.Conventions.UseDefaultConventions(); 30 | app.Parse(args); 31 | return app.Model; 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/Meadow.DebugAdapterServer/DebuggerTransport/NamedPipeServerDebuggerTransport.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.IO.Pipes; 3 | 4 | namespace Meadow.DebugAdapterServer.DebuggerTransport 5 | { 6 | public class NamedPipeServerDebuggerTransport : IDebuggerTransport 7 | { 8 | readonly NamedPipeServerStream _pipeServer; 9 | 10 | public Stream InputStream => _pipeServer; 11 | public Stream OutputStream => _pipeServer; 12 | 13 | public void Dispose() 14 | { 15 | try 16 | { 17 | if (_pipeServer.IsConnected) 18 | { 19 | _pipeServer.Disconnect(); 20 | } 21 | } 22 | catch { } 23 | 24 | _pipeServer.Dispose(); 25 | } 26 | 27 | public NamedPipeServerDebuggerTransport() 28 | { 29 | // Setup named pipe server. 30 | var debugSessionID = SolidityDebugger.SolidityDebugSessionID; 31 | _pipeServer = new NamedPipeServerStream(debugSessionID, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); 32 | 33 | // Wait for debug adapter proxy to connect. 34 | _pipeServer.WaitForConnection(); 35 | } 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/Meadow.EVM/EVM/Instructions/Stack/InstructionSwap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | using Meadow.EVM.Data_Types; 7 | using Meadow.EVM.EVM.Execution; 8 | 9 | namespace Meadow.EVM.EVM.Instructions.Stack 10 | { 11 | public class InstructionSwap : InstructionBase 12 | { 13 | #region Properties 14 | public uint SwapIndex { get; } 15 | #endregion 16 | 17 | #region Constructors 18 | /// 19 | /// Our default constructor, reads the opcode/operand information from the provided stream. 20 | /// 21 | public InstructionSwap(MeadowEVM evm) : base(evm) 22 | { 23 | // This class handles multiple swap operations (various indexes). 24 | // The opcodes are linear, so we can calculate the index based off opcode. 25 | SwapIndex = (uint)(Opcode - InstructionOpcode.SWAP1) + 1; 26 | } 27 | #endregion 28 | 29 | #region Functions 30 | public override void Execute() 31 | { 32 | // Swap the top item on the stack with the one at the provided index. 33 | Stack.Swap(SwapIndex); 34 | } 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/Meadow.UnitTestTemplate.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | false 6 | Meadow.UnitTestTemplate.Test.GlobalSetup 7 | 8 | 9 | 10 | 11 | all 12 | runtime; build; native; contentfiles; analyzers 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.TestApp/Contracts/CappedCrowdsale.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | import "./SafeMath.sol"; 4 | import "./Crowdsale.sol"; 5 | 6 | 7 | /** 8 | * @title CappedCrowdsale 9 | * @dev Crowdsale with a limit for total contributions. 10 | */ 11 | contract CappedCrowdsale is Crowdsale { 12 | using SafeMath for uint256; 13 | 14 | uint256 public cap; 15 | 16 | /** 17 | * @dev Constructor, takes maximum amount of wei accepted in the crowdsale. 18 | * @param _cap Max amount of wei to be contributed 19 | */ 20 | function CappedCrowdsale(uint256 _cap) public { 21 | require(_cap > 0); 22 | cap = _cap; 23 | } 24 | 25 | /** 26 | * @dev Checks whether the cap has been reached. 27 | * @return Whether the cap was reached 28 | */ 29 | function capReached() public view returns (bool) { 30 | return weiRaised >= cap; 31 | } 32 | 33 | /** 34 | * @dev Extend parent behavior requiring purchase to respect the funding cap. 35 | * @param _beneficiary Token purchaser 36 | * @param _weiAmount Amount of wei contributed 37 | */ 38 | function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { 39 | super._preValidatePurchase(_beneficiary, _weiAmount); 40 | require(weiRaised.add(_weiAmount) <= cap); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/Meadow.UnitTestTemplate.Test/TestsIgnoredContracts.cs: -------------------------------------------------------------------------------- 1 | using Meadow.JsonRpc.Types; 2 | using Meadow.EVM.Data_Types; 3 | using Meadow.Core.Utils; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | using System.Numerics; 6 | using System.Threading.Tasks; 7 | using Meadow.Contract; 8 | 9 | namespace Meadow.UnitTestTemplate.Test 10 | { 11 | 12 | [TestClass] 13 | public class TestsIgnoredContracts : ContractTest 14 | { 15 | 16 | protected override Task BeforeEach() 17 | { 18 | return Task.CompletedTask; 19 | } 20 | 21 | [TestMethod] 22 | public async Task MockContractFunction() 23 | { 24 | var contract = await MockContract.New(RpcClient); 25 | string testStr = "test string 1234"; 26 | var resultStr = await contract.echoString(testStr).Call(); 27 | Assert.AreEqual(testStr, resultStr); 28 | } 29 | 30 | [TestMethod] 31 | public async Task IgnoreContractFunction() 32 | { 33 | var contract = await IgnoreContract.New(RpcClient); 34 | string testStr = "test string 1234"; 35 | var resultStr = await contract.echoString(testStr).Call(); 36 | Assert.AreEqual(testStr, resultStr); 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/Meadow.Cli/Help/Watch-Solidity.md: -------------------------------------------------------------------------------- 1 | # Watch-Solidity 2 | 3 | ## SYNOPSIS 4 | This Cmdlet lets Meadow.Cli look for active changes in your contracts. 5 | 6 | ## SYNTAX 7 | 8 | ### Watch Solidity Parameters 9 | ``` 10 | Watch-Solidity [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | This Cmdlet allows Meadow.Cli watch for changes in your solidity contracts and respond live. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | Basic use 20 | ```powershell 21 | C:\PS> Watch-Solidity 22 | ``` 23 | 24 | This examples shows how to start the file watcher so that Meadow.Cli can respond to changes in your contracts live. 25 | 26 | ## PARAMETERS 27 | 28 | ### \ 29 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 30 | 31 | ## INPUTS 32 | 33 | ### None 34 | 35 | 36 | ## OUTPUTS 37 | 38 | ### None 39 | 40 | 41 | ## NOTES 42 | 43 | ## RELATED LINKS 44 | 45 | [Meadow Suite site link:](https://meadowsuite.com) 46 | 47 | [Hosho Group site link:](https://hosho.io) 48 | 49 | 50 | *Generated by: PowerShell HelpWriter 2018 v2.2.40* 51 | -------------------------------------------------------------------------------- /src/Meadow.Core/AccountDerivation/AccountDerivationBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Meadow.Core.AccountDerivation 4 | { 5 | public delegate byte[] GenerateAccountKeyDelegate(uint accountIndex); 6 | 7 | public interface IAccountDerivation 8 | { 9 | byte[] GeneratePrivateKey(uint accountIndex); 10 | } 11 | 12 | public abstract class AccountDerivationBase : IAccountDerivation 13 | { 14 | public virtual byte[] Seed { get; set; } 15 | 16 | public abstract byte[] GeneratePrivateKey(uint accountIndex); 17 | 18 | class AccountDerivationFactory : AccountDerivationBase 19 | { 20 | GenerateAccountKeyDelegate _generateAccount; 21 | 22 | public AccountDerivationFactory(GenerateAccountKeyDelegate generateAccount) 23 | { 24 | _generateAccount = generateAccount; 25 | } 26 | 27 | public override byte[] GeneratePrivateKey(uint accountIndex) 28 | { 29 | return _generateAccount(accountIndex); 30 | } 31 | } 32 | 33 | public static IAccountDerivation Create(GenerateAccountKeyDelegate generateAccount) 34 | { 35 | return new AccountDerivationFactory(generateAccount); 36 | } 37 | } 38 | 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/Meadow.SolCodeGen.Test/Util.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Meadow.SolCodeGen.Test 8 | { 9 | public static class Util 10 | { 11 | private static string _solutionDir; 12 | 13 | public static string FindSolutionDirectory() 14 | { 15 | if (_solutionDir != null) 16 | { 17 | return _solutionDir; 18 | } 19 | 20 | const string TEST_PROJ_DIR_NAME = "Meadow.SolCodeGen.Test"; 21 | 22 | // Find the solution directory (start at this assembly directory and move up). 23 | var cwd = typeof(Integration).Assembly.Location; 24 | string checkDir = null; 25 | do 26 | { 27 | cwd = Path.GetDirectoryName(cwd); 28 | var children = Directory.GetDirectories(cwd, TEST_PROJ_DIR_NAME, SearchOption.TopDirectoryOnly); 29 | if (children.Any(p => p.EndsWith(TEST_PROJ_DIR_NAME, StringComparison.Ordinal))) 30 | { 31 | checkDir = cwd; 32 | } 33 | } 34 | while (checkDir == null); 35 | 36 | return _solutionDir = checkDir; 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Meadow.CoverageReport/AnalysisResults.cs: -------------------------------------------------------------------------------- 1 | using SolcNet.DataDescription.Output; 2 | using System.Collections.Generic; 3 | 4 | namespace Meadow.CoverageReport 5 | { 6 | public class AnalysisResults 7 | { 8 | /// 9 | /// All nodes with no filtering. 10 | /// 11 | public AstNode[] FullNodeList { get; set; } 12 | 13 | /// 14 | /// All nodes that have a corresponding sourcemap entry. 15 | /// 16 | public AstNode[] ReachableNodes { get; set; } 17 | 18 | /// 19 | /// All nodes that represent executable source code 20 | /// 21 | public AstNode[] AllActiveNodes { get; set; } 22 | 23 | /// 24 | /// All nodes that have executable source code which are not compiled into the bytecode and thus are 25 | /// unreachable. 26 | /// 27 | public AstNode[] UnreachableNodes { get; set; } 28 | 29 | public AstNode[] FunctionNode { get; set; } 30 | 31 | public (AstNode Node, BranchType BranchType)[] BranchNodes { get; set; } 32 | 33 | public IReadOnlyDictionary<(string FileName, string ContractName, string BytecodeHash), (SourceMapEntry[] NonDeployed, SourceMapEntry[] Deployed)> SourceMaps; 34 | 35 | } 36 | } 37 | --------------------------------------------------------------------------------