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

Update name nep17 #695

Merged
merged 13 commits into from
Dec 16, 2020
10 changes: 7 additions & 3 deletions neo-cli/CLI/MainService.NEP17.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using System;
using System.Globalization;
using System.Linq;
using Neo.SmartContract;
using Neo.SmartContract.Native;
using Neo.Ledger;

namespace Neo.CLI
{
Expand Down Expand Up @@ -88,9 +91,10 @@ private void OnBalanceOfCommand(UInt160 tokenHash, UInt160 address)
[ConsoleCommand("name", Category = "NEP17 Commands")]
private void OnNameCommand(UInt160 tokenHash)
{
if (!OnInvokeWithResult(tokenHash, "name", out StackItem result, null)) return;

Console.WriteLine($"Result : {((PrimitiveType)result).GetString()}");
var snapshot = Blockchain.Singleton.GetSnapshot();
ContractState contract = NativeContract.Management.GetContract(snapshot, tokenHash);
if (contract == null) Console.WriteLine($"Contract hash not exist: {tokenHash}");
else Console.WriteLine($"Result : {contract.Manifest.Name.ToString()}");
}

/// <summary>
Expand Down