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

Commit

Permalink
Optimize code (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
ProDog authored Apr 25, 2021
1 parent f2c96eb commit d1e9648
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions neo-cli/CLI/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,7 @@ private set
/// </summary>
public MainService() : base()
{
RegisterCommandHander<string, UInt160>(false, (str) =>
{
switch (str.ToLowerInvariant())
{
case "neo": return NativeContract.NEO.Hash;
case "gas": return NativeContract.GAS.Hash;
}
// Try to parse as UInt160
if (UInt160.TryParse(str, out var addr))
{
return addr;
}
// Accept wallet format
return str.ToScriptHash(NeoSystem.Settings.AddressVersion);
});

RegisterCommandHander<string, UInt160>(false, (str) => StringToAddress(str, NeoSystem.Settings.AddressVersion));
RegisterCommandHander<string, UInt256>(false, (str) => UInt256.Parse(str));
RegisterCommandHander<string[], UInt256[]>((str) => str.Select(u => UInt256.Parse(u.Trim())).ToArray());
RegisterCommandHander<string[], UInt160[]>((arr) => arr.Select(str => StringToAddress(str, NeoSystem.Settings.AddressVersion)).ToArray());
Expand Down

0 comments on commit d1e9648

Please sign in to comment.