Skip to content

Commit

Permalink
Neo-node Migration (#2990)
Browse files Browse the repository at this point in the history
* Neo Node Migration

* Added blockchain show block/transactions/contracts commands #905 (cschuchardt88)
Added icon to applications #908 (cschuchardt88)

* Update README.md
  • Loading branch information
lock9 authored Dec 7, 2023
1 parent 683af79 commit 40d1086
Show file tree
Hide file tree
Showing 192 changed files with 33,583 additions and 3 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
<a href="https://github.com/neo-project/neo-modules">Neo Modules</a>
·
<a href="https://github.com/neo-project/neo-devpack-dotnet">Neo DevPack</a>
·
<a href="https://github.com/neo-project/neo-node">Neo Node</a>
</p>
<p align="center">
<a href="https://twitter.com/neo_blockchain">
Expand Down Expand Up @@ -128,7 +126,6 @@ An overview of the project folders can be seen below.
Code references are provided for all platform building blocks. That includes the base library, the VM, a command line application and the compiler.

* [neo:](https://github.com/neo-project/neo/) Neo core library, contains base classes, including ledger, p2p and IO modules.
* [neo-node:](https://github.com/neo-project/neo-node/) Executable version of the Neo library, exposing features using a command line application or GUI.
* [neo-modules:](https://github.com/neo-project/neo-modules/) Neo modules include additional tools and plugins to be used with Neo.
* [neo-devpack-dotnet:](https://github.com/neo-project/neo-devpack-dotnet/) These are the official tools used to convert a C# smart-contract into a *neo executable file*.

Expand Down
28 changes: 28 additions & 0 deletions neo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.VM", "src\Neo.VM\Neo.VM
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.VM.Tests", "tests\Neo.VM.Tests\Neo.VM.Tests.csproj", "{005F84EB-EA2E-449F-930A-7B4173DDC7EC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.ConsoleService", "src\Neo.ConsoleService\Neo.ConsoleService.csproj", "{9E886812-7243-48D8-BEAF-47AADC11C054}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.GUI", "src\Neo.GUI\Neo.GUI.csproj", "{02ABDE42-9880-43B4-B6F7-8D618602A277}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.CLI", "src\Neo.CLI\Neo.CLI.csproj", "{BDFBE455-4C1F-4FC4-B5FC-1387B93A8687}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.ConsoleService.Tests", "tests\Neo.ConsoleService.Tests\Neo.ConsoleService.Tests.csproj", "{B40F8584-5AFB-452C-AEFA-009C80CC23A9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -62,6 +70,22 @@ Global
{005F84EB-EA2E-449F-930A-7B4173DDC7EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{005F84EB-EA2E-449F-930A-7B4173DDC7EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{005F84EB-EA2E-449F-930A-7B4173DDC7EC}.Release|Any CPU.Build.0 = Release|Any CPU
{9E886812-7243-48D8-BEAF-47AADC11C054}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E886812-7243-48D8-BEAF-47AADC11C054}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E886812-7243-48D8-BEAF-47AADC11C054}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E886812-7243-48D8-BEAF-47AADC11C054}.Release|Any CPU.Build.0 = Release|Any CPU
{02ABDE42-9880-43B4-B6F7-8D618602A277}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02ABDE42-9880-43B4-B6F7-8D618602A277}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02ABDE42-9880-43B4-B6F7-8D618602A277}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02ABDE42-9880-43B4-B6F7-8D618602A277}.Release|Any CPU.Build.0 = Release|Any CPU
{BDFBE455-4C1F-4FC4-B5FC-1387B93A8687}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDFBE455-4C1F-4FC4-B5FC-1387B93A8687}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDFBE455-4C1F-4FC4-B5FC-1387B93A8687}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDFBE455-4C1F-4FC4-B5FC-1387B93A8687}.Release|Any CPU.Build.0 = Release|Any CPU
{B40F8584-5AFB-452C-AEFA-009C80CC23A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B40F8584-5AFB-452C-AEFA-009C80CC23A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B40F8584-5AFB-452C-AEFA-009C80CC23A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B40F8584-5AFB-452C-AEFA-009C80CC23A9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -75,6 +99,10 @@ Global
{E83633BA-FCF0-4A1A-B5BC-42000E24D437} = {C25EB0B0-0CAC-4CC1-8F36-F9229EFB99EC}
{0603710E-E0BA-494C-AA0F-6FB0C8A8C754} = {B5339DF7-5D1D-43BA-B332-74B825E1770E}
{005F84EB-EA2E-449F-930A-7B4173DDC7EC} = {EDE05FA8-8E73-4924-BC63-DD117127EEE1}
{9E886812-7243-48D8-BEAF-47AADC11C054} = {B5339DF7-5D1D-43BA-B332-74B825E1770E}
{02ABDE42-9880-43B4-B6F7-8D618602A277} = {B5339DF7-5D1D-43BA-B332-74B825E1770E}
{BDFBE455-4C1F-4FC4-B5FC-1387B93A8687} = {B5339DF7-5D1D-43BA-B332-74B825E1770E}
{B40F8584-5AFB-452C-AEFA-009C80CC23A9} = {EDE05FA8-8E73-4924-BC63-DD117127EEE1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BCBA19D9-F868-4C6D-8061-A2B91E06E3EC}
Expand Down
145 changes: 145 additions & 0 deletions src/Neo.CLI/CLI/ConsolePercent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Copyright (C) 2016-2023 The Neo Project.
//
// The neo-cli is free software distributed under the MIT software
// license, see the accompanying file LICENSE in the main directory of
// the project or http://www.opensource.org/licenses/mit-license.php
// for more details.
//
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

using System;

namespace Neo.CLI
{
public class ConsolePercent : IDisposable
{
#region Variables

private readonly long _maxValue;
private long _value;
private decimal _lastFactor;
private string _lastPercent;

private readonly int _x, _y;

private bool _inputRedirected;

#endregion

#region Properties

/// <summary>
/// Value
/// </summary>
public long Value
{
get => _value;
set
{
if (value == _value) return;

_value = Math.Min(value, _maxValue);
Invalidate();
}
}

/// <summary>
/// Maximum value
/// </summary>
public long MaxValue
{
get => _maxValue;
init
{
if (value == _maxValue) return;

_maxValue = value;

if (_value > _maxValue)
_value = _maxValue;

Invalidate();
}
}

/// <summary>
/// Percent
/// </summary>
public decimal Percent
{
get
{
if (_maxValue == 0) return 0;
return (_value * 100M) / _maxValue;
}
}

#endregion

/// <summary>
/// Constructor
/// </summary>
/// <param name="value">Value</param>
/// <param name="maxValue">Maximum value</param>
public ConsolePercent(long value = 0, long maxValue = 100)
{
_inputRedirected = Console.IsInputRedirected;
_lastFactor = -1;
_x = _inputRedirected ? 0 : Console.CursorLeft;
_y = _inputRedirected ? 0 : Console.CursorTop;

MaxValue = maxValue;
Value = value;
Invalidate();
}

/// <summary>
/// Invalidate
/// </summary>
public void Invalidate()
{
var factor = Math.Round((Percent / 100M), 1);
var percent = Percent.ToString("0.0").PadLeft(5, ' ');

if (_lastFactor == factor && _lastPercent == percent)
{
return;
}

_lastFactor = factor;
_lastPercent = percent;

var fill = string.Empty.PadLeft((int)(10 * factor), '■');
var clean = string.Empty.PadLeft(10 - fill.Length, _inputRedirected ? '□' : '■');

if (_inputRedirected)
{
Console.WriteLine("[" + fill + clean + "] (" + percent + "%)");
}
else
{
Console.SetCursorPosition(_x, _y);

var prevColor = Console.ForegroundColor;

Console.ForegroundColor = ConsoleColor.White;
Console.Write("[");
Console.ForegroundColor = Percent > 50 ? ConsoleColor.Green : ConsoleColor.DarkGreen;
Console.Write(fill);
Console.ForegroundColor = ConsoleColor.White;
Console.Write(clean + "] (" + percent + "%)");

Console.ForegroundColor = prevColor;
}
}

/// <summary>
/// Free console
/// </summary>
public void Dispose()
{
Console.WriteLine("");
}
}
}
41 changes: 41 additions & 0 deletions src/Neo.CLI/CLI/Helper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (C) 2016-2023 The Neo Project.
//
// The neo-cli is free software distributed under the MIT software
// license, see the accompanying file LICENSE in the main directory of
// the project or http://www.opensource.org/licenses/mit-license.php
// for more details.
//
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

using System;
using Neo.SmartContract.Manifest;

namespace Neo.CLI
{
internal static class Helper
{
public static bool IsYes(this string input)
{
if (input == null) return false;

input = input.ToLowerInvariant();

return input == "yes" || input == "y";
}

public static string ToBase64String(this byte[] input) => System.Convert.ToBase64String(input);

public static void IsScriptValid(this ReadOnlyMemory<byte> script, ContractAbi abi)
{
try
{
SmartContract.Helper.Check(script.ToArray(), abi);
}
catch (Exception e)
{
throw new FormatException($"Bad Script or Manifest Format: {e.Message}");
}
}
}
}
Loading

0 comments on commit 40d1086

Please sign in to comment.