Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into mode-system
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim8y authored May 25, 2022
2 parents d0c0f30 + 5565c98 commit a89a910
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 50 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: .NET Core Test

on:
push:
branches: [master, develop]
pull_request:
on: pull_request

env:
DOTNET_VERSION: 6.0.x
Expand Down
4 changes: 2 additions & 2 deletions neo-cli/CLI/MainService.Node.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2016-2021 The Neo Project.
// Copyright (C) 2016-2022 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
Expand Down Expand Up @@ -87,7 +87,7 @@ private void OnShowStateCommand()
foreach (RemoteNode node in LocalNode.GetRemoteNodes().OrderByDescending(u => u.LastBlockIndex).Take(Console.WindowHeight - 2).ToArray())
{
ConsoleHelper.Info(" ip: ",
$"{ node.Remote.Address,-15}\t",
$"{node.Remote.Address,-15}\t",
"port: ",
$"{node.Remote.Port,-5}\t",
"listen: ",
Expand Down
56 changes: 13 additions & 43 deletions neo-cli/CLI/MainService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2016-2021 The Neo Project.
// Copyright (C) 2016-2022 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
Expand All @@ -23,8 +23,6 @@
using Neo.VM;
using Neo.VM.Types;
using Neo.Wallets;
using Neo.Wallets.NEP6;
using Neo.Wallets.SQLite;
using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down Expand Up @@ -129,28 +127,21 @@ public override void RunConsole()

public void CreateWallet(string path, string password, bool createDefaultAccount = true)
{
switch (Path.GetExtension(path))
{
case ".db3":
CurrentWallet = UserWallet.Create(path, password, NeoSystem.Settings);
break;
case ".json":
CurrentWallet = new NEP6Wallet(path, NeoSystem.Settings);
((NEP6Wallet)CurrentWallet).Unlock(password);
break;
default:
ConsoleHelper.Warning("Wallet files in that format are not supported, please use a .json or .db3 file extension.");
return;
Wallet wallet = Wallet.Create(null, path, password, NeoSystem.Settings);
if (wallet == null)
{
ConsoleHelper.Warning("Wallet files in that format are not supported, please use a .json or .db3 file extension.");
return;
}
if (createDefaultAccount)
{
WalletAccount account = CurrentWallet.CreateAccount();
WalletAccount account = wallet.CreateAccount();
ConsoleHelper.Info(" Address: ", account.Address);
ConsoleHelper.Info(" Pubkey: ", account.GetKey().PublicKey.EncodePoint(true).ToHexString());
ConsoleHelper.Info("ScriptHash: ", $"{account.ScriptHash}");
}
if (CurrentWallet is NEP6Wallet wallet)
wallet.Save();
wallet.Save();
CurrentWallet = wallet;
}

private IEnumerable<Block> GetBlocks(Stream stream, bool read_start = false)
Expand Down Expand Up @@ -248,10 +239,7 @@ private byte[] LoadDeploymentScript(string nefFilePath, string manifestFilePath,
throw new ArgumentException(nameof(nefFilePath));
}

using (var stream = new BinaryReader(File.OpenRead(nefFilePath), Utility.StrictUTF8, false))
{
nef = stream.ReadSerializable<NefFile>();
}
nef = File.ReadAllBytes(nefFilePath).AsSerializable<NefFile>();

ContractParameter dataParameter = null;
if (data is not null)
Expand Down Expand Up @@ -317,10 +305,7 @@ private byte[] LoadUpdateScript(UInt160 scriptHash, string nefFilePath, string m
throw new ArgumentException(nameof(nefFilePath));
}

using (var stream = new BinaryReader(File.OpenRead(nefFilePath), Utility.StrictUTF8, false))
{
nef = stream.ReadSerializable<NefFile>();
}
nef = File.ReadAllBytes(nefFilePath).AsSerializable<NefFile>();

ContractParameter dataParameter = null;
if (data is not null)
Expand Down Expand Up @@ -379,22 +364,7 @@ public void OpenWallet(string path, string password)
throw new FileNotFoundException();
}

switch (Path.GetExtension(path).ToLowerInvariant())
{
case ".db3":
{
CurrentWallet = UserWallet.Open(path, password, NeoSystem.Settings);
break;
}
case ".json":
{
NEP6Wallet nep6wallet = new NEP6Wallet(path, NeoSystem.Settings);
nep6wallet.Unlock(password);
CurrentWallet = nep6wallet;
break;
}
default: throw new NotSupportedException();
}
CurrentWallet = Wallet.Open(path, password, NeoSystem.Settings) ?? throw new NotSupportedException();
}

public async void Start(string[] args)
Expand Down Expand Up @@ -580,7 +550,7 @@ private void SendTransaction(byte[] script, UInt160 account = null, long gas = T
try
{
Transaction tx = CurrentWallet.MakeTransaction(snapshot, script, account, signers, maxGas: gas);
ConsoleHelper.Info("Invoking script with: ", $"'{tx.Script.ToBase64String()}'");
ConsoleHelper.Info("Invoking script with: ", $"'{Convert.ToBase64String(tx.Script)}'");

using (ApplicationEngine engine = ApplicationEngine.Run(tx.Script, snapshot, container: tx, settings: NeoSystem.Settings, gas: gas))
{
Expand Down
2 changes: 1 addition & 1 deletion neo-cli/neo-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.2.1" />
<PackageReference Include="Neo" Version="3.2.1-CI01355" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit a89a910

Please sign in to comment.