Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ead59ae
Add NNS to UInt160 parameters for neo-cli
cschuchardt88 Dec 17, 2023
b913fa2
Fixed typo
cschuchardt88 Dec 17, 2023
f22224b
Update src/Neo.ConsoleService/ConsoleServiceBase.cs
shargon Dec 19, 2023
e8d9db4
Added NNS hashes to config files.
cschuchardt88 Dec 20, 2023
2d74750
Merge branch 'add-nns' of https://github.com/cschuchardt88/neo into a…
cschuchardt88 Dec 20, 2023
69f1f31
Updated support for neofs
cschuchardt88 Dec 20, 2023
0a5b273
Added ReadOnly Call Flag to the contract call
cschuchardt88 Dec 20, 2023
111ef31
Updated to allow all domains
cschuchardt88 Dec 20, 2023
6c4451f
Merge branch 'master' into add-nns
cschuchardt88 Dec 26, 2023
21f021b
Update src/Neo.CLI/Settings.cs
shargon Dec 27, 2023
5fd63d7
Merge branch 'master' into add-nns
cschuchardt88 Dec 27, 2023
7ce7a3b
null check
cschuchardt88 Dec 29, 2023
b49f449
Update config.testnet.json with contract hash
cschuchardt88 Jan 3, 2024
8f9c0d7
Merge branch 'master' into add-nns
shargon Jan 3, 2024
d95d352
Merge branch 'master' into add-nns
cschuchardt88 Jan 4, 2024
15e014e
Merge branch 'master' into add-nns
cschuchardt88 Jan 5, 2024
57cc30a
Merge branch 'master' into add-nns
cschuchardt88 Jan 9, 2024
6d556ce
Fixes
cschuchardt88 Jan 9, 2024
2e86ad0
Merge branch 'master' into add-nns
shargon Jan 9, 2024
0f3ecc9
Merge branch 'master' into add-nns
cschuchardt88 Jan 10, 2024
be86ed6
fixed wallet
cschuchardt88 Jan 11, 2024
70c40e5
Merge branch 'master' into add-nns
cschuchardt88 Jan 11, 2024
8228472
Merge branch 'master' into add-nns
shargon Jan 11, 2024
138c7b3
Update src/Neo.CLI/Settings.cs
shargon Jan 11, 2024
e6291aa
Update Settings.cs
cschuchardt88 Jan 11, 2024
0dc6229
Update Settings.cs
cschuchardt88 Jan 11, 2024
000ba5c
Refactor NNS definition
shargon Jan 11, 2024
3e6a0cb
clean new
shargon Jan 11, 2024
0430430
Show NNS Fault error
shargon Jan 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Neo.CLI/CLI/MainService.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,9 @@ private void OnSendCommand(UInt160 asset, UInt160 to, string amount, UInt160 fro
ConsoleHelper.Error("Incorrect password");
return;
}

var snapshot = NeoSystem.StoreView;
Transaction tx;
Transaction tx = null;
AssetDescriptor descriptor = new(snapshot, NeoSystem.Settings, asset);
if (!BigDecimal.TryParse(amount, descriptor.Decimals, out BigDecimal decimalAmount) || decimalAmount.Sign <= 0)
{
Expand Down Expand Up @@ -549,10 +550,10 @@ private void OnSendCommand(UInt160 asset, UInt160 to, string amount, UInt160 fro
return;
}

ConsoleHelper.Info("Network fee: ",
$"{new BigDecimal((BigInteger)tx.NetworkFee, NativeContract.GAS.Decimals)}\t",
"Total fee: ",
$"{new BigDecimal((BigInteger)(tx.SystemFee + tx.NetworkFee), NativeContract.GAS.Decimals)} GAS");
ConsoleHelper.Info(
"Send To: ", $"{to.ToAddress(NeoSystem.Settings.AddressVersion)}\n",
"Network fee: ", $"{new BigDecimal((BigInteger)tx.NetworkFee, NativeContract.GAS.Decimals)}\t",
"Total fee: ", $"{new BigDecimal((BigInteger)(tx.SystemFee + tx.NetworkFee), NativeContract.GAS.Decimals)} GAS");
if (!ReadUserInput("Relay tx? (no|yes)").IsYes())
{
return;
Expand Down
39 changes: 38 additions & 1 deletion src/Neo.CLI/CLI/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,24 @@ public MainService() : base()
Initialize_Logger();
}

internal static UInt160 StringToAddress(string input, byte version)
internal UInt160 StringToAddress(string input, byte version)
{
switch (input.ToLowerInvariant())
{
case "neo": return NativeContract.NEO.Hash;
case "gas": return NativeContract.GAS.Hash;
}

if (input.EndsWith(".neo", StringComparison.InvariantCultureIgnoreCase))
{
if (NeoSystem.Settings.Network == mainNet)
return ResolveNeoNameServiceAddress(input);
else
{
throw new Exception("Neo Name Service (NNS): ONLY works on MainNet.");
}
}

// Try to parse as UInt160

if (UInt160.TryParse(input, out var addr))
Expand Down Expand Up @@ -605,5 +615,32 @@ static string GetExceptionMessage(Exception exception)

return exception.Message;
}

static readonly UInt160 nnsHash = UInt160.Parse("0x50ac1c37690cc2cfc594472833cf57505d5f46de");
static readonly uint mainNet = 860833102u;

public UInt160 ResolveNeoNameServiceAddress(string domain)
{
using var sb = new ScriptBuilder();
sb.EmitDynamicCall(nnsHash, "resolve", domain, 16);

using var appEng = ApplicationEngine.Run(sb.ToArray(), NeoSystem.StoreView, settings: NeoSystem.Settings);
if (appEng.State == VMState.HALT)
{
var data = appEng.ResultStack.Pop();
if (data is ByteString)
{
try
{
return data.GetString().ToScriptHash(NeoSystem.Settings.AddressVersion);
}
catch
{
throw new Exception("Neo Name Service (NNS): Record invalid address format.");
}
}
}
throw new Exception($"Neo Name Service (NNS): \"{domain}\" domain not found.");
}
}
}
3 changes: 2 additions & 1 deletion src/Neo.ConsoleService/ConsoleServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ private bool OnCommand(string commandLine)

availableCommands.Add((command, arguments.ToArray()));
}
catch
catch (Exception ex)
{
// Skip parse errors
possibleHelp = command.Key;
ConsoleHelper.Error($"{ex.InnerException?.Message ?? ex.Message}\n");
}
}
}
Expand Down