Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

update with 2.3 commit from neo-project #25

Merged
12 commits merged into from Oct 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 8 additions & 3 deletions neo-gui/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,20 @@
</runtime>
<userSettings>
<Neo.Properties.Settings>
<setting name="LastWalletPath" serializeAs="String">
<value />
</setting>
<setting name="NeedUpgrade" serializeAs="String">
<value>True</value>
</setting>
<setting name="LastWalletPath" serializeAs="String">
<value />
</setting>
<setting name="InstallCertificate" serializeAs="String">
<value>True</value>
</setting>
<setting name="NEP5Watched" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</value>
</setting>
</Neo.Properties.Settings>
</userSettings>
</configuration>
27 changes: 27 additions & 0 deletions neo-gui/BigDecimal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Numerics;

namespace Neo
{
internal struct BigDecimal
{
private readonly BigInteger value;
private readonly byte decimals;

public BigInteger Value => value;
public byte Decimals => decimals;

public BigDecimal(BigInteger value, byte decimals)
{
this.value = value;
this.decimals = decimals;
}

public override string ToString()
{
BigInteger divisor = BigInteger.Pow(10, decimals);
BigInteger result = BigInteger.DivRem(value, divisor, out BigInteger remainder);
if (remainder == 0) return result.ToString();
return $"{result}.{remainder}".TrimEnd('0');
}
}
}
1 change: 1 addition & 0 deletions neo-gui/Cryptography/CertificateQueryService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Neo.Core;
using Neo.Cryptography.ECC;
using Neo.Properties;
using Neo.SmartContract;
using Neo.Wallets;
using System;
using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static void Main()
XDocument xdoc = null;
try
{
xdoc = XDocument.Load("https://www.antshares.org/client/update.xml");
xdoc = XDocument.Load("https://neo.org/client/update.xml");
}
catch { }
if (xdoc != null)
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("2.2.*")]
[assembly: AssemblyVersion("2.3.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
29 changes: 21 additions & 8 deletions neo-gui/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions neo-gui/Properties/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using System.Linq;

namespace Neo.Properties
{
Expand All @@ -9,6 +10,7 @@ internal sealed partial class Settings
public ushort NodePort { get; }
public ushort WsPort { get; }
public BrowserSettings Urls { get; }
public ContractSettings Contracts { get; }

public Settings()
{
Expand All @@ -24,6 +26,7 @@ public Settings()
this.NodePort = ushort.Parse(section.GetSection("NodePort").Value);
this.WsPort = ushort.Parse(section.GetSection("WsPort").Value);
this.Urls = new BrowserSettings(section.GetSection("Urls"));
this.Contracts = new ContractSettings(section.GetSection("Contracts"));
}
}

Expand All @@ -40,4 +43,14 @@ public BrowserSettings(IConfigurationSection section)
this.TransactionUrl = section.GetSection("TransactionUrl").Value;
}
}

internal class ContractSettings
{
public UInt160[] NEP5 { get; }

public ContractSettings(IConfigurationSection section)
{
this.NEP5 = section.GetSection("NEP5").GetChildren().Select(p => UInt160.Parse(p.Value)).ToArray();
}
}
}
10 changes: 7 additions & 3 deletions neo-gui/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Neo.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="LastWalletPath" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="NeedUpgrade" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="LastWalletPath" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="InstallCertificate" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="NEP5Watched" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /&gt;</Value>
</Setting>
</Settings>
</SettingsFile>
14 changes: 7 additions & 7 deletions neo-gui/Properties/Strings.es-Es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@
<value>Confirmación</value>
</data>
<data name="EnterRemarkMessage" xml:space="preserve">
<value>Introducir aquí la observación que ser grabará en la blockchain</value>
<value>Notas de la transacción que se grabará en la blockchain.</value>
</data>
<data name="EnterRemarkTitle" xml:space="preserve">
<value>Observación de la transacción</value>
<value>Notas de la transacción</value>
</data>
<data name="ExecutionFailed" xml:space="preserve">
<value>La ejecución terminó con un estado de error.</value>
Expand Down Expand Up @@ -233,28 +233,28 @@ Aviso: los ficheros actualizados no podran ser abiertos por clientes de versione
<value>¡Falló la validación! Transacción no válida o blockchain sin sincronizar. Inténtalo de nuevo después de sincronizar.</value>
</data>
<data name="TradeNeedSignatureCaption" xml:space="preserve">
<value>Firma necesaria</value>
<value>Firma necesaria.</value>
</data>
<data name="TradeNeedSignatureMessage" xml:space="preserve">
<value>Transacción generada. Por favor, envia la siguiente información al contratante para su firma:</value>
</data>
<data name="TradeRequestCreatedCaption" xml:space="preserve">
<value>Solicitud de transacción</value>
<value>Solicitud de transacción.</value>
</data>
<data name="TradeRequestCreatedMessage" xml:space="preserve">
<value>Solicitud de transacción generada. Por favor, enviala al contratante o incorporala a la solicitud del contratante.</value>
</data>
<data name="TradeSuccessCaption" xml:space="preserve">
<value>Transacción realizada con éxito</value>
<value>Transacción realizada con éxito.</value>
</data>
<data name="TradeSuccessMessage" xml:space="preserve">
<value>Transacción enviada, este es el TXID:</value>
</data>
<data name="Unconfirmed" xml:space="preserve">
<value>sin confirmar</value>
<value>Sin confirmar.</value>
</data>
<data name="UnknownIssuer" xml:space="preserve">
<value>emisor desconocido</value>
<value>Emisor desconocido.</value>
</data>
<data name="UnsynchronizedBlock" xml:space="preserve">
<value>Blockchain sin sincronizar, la transacción no puede ser enviada.</value>
Expand Down
4 changes: 2 additions & 2 deletions neo-gui/Properties/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<value>Install the certificate</value>
</data>
<data name="InstallCertificateText" xml:space="preserve">
<value>Anthares must install Onchain root certificate to validate assets on the blockchain, install it now?</value>
<value>NEO must install Onchain root certificate to validate assets on the blockchain, install it now?</value>
</data>
<data name="InsufficientFunds" xml:space="preserve">
<value>Insufficient funds, transaction cannot be initiated.</value>
Expand Down Expand Up @@ -271,4 +271,4 @@ Note: updated files cannot be openned by clients in older versions!</value>
<data name="UnsynchronizedBlock" xml:space="preserve">
<value>Blockchain unsynchronized, transaction cannot be sent.</value>
</data>
</root>
</root>
21 changes: 0 additions & 21 deletions neo-gui/SmartContract/CachedScriptTable.cs

This file was deleted.

15 changes: 0 additions & 15 deletions neo-gui/SmartContract/ContractParameter.cs

This file was deleted.

66 changes: 66 additions & 0 deletions neo-gui/UI/AssetDescriptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Neo.Core;
using Neo.SmartContract;
using Neo.VM;
using System;
using System.Linq;
using System.Numerics;

namespace Neo.UI
{
internal class AssetDescriptor
{
public UIntBase AssetId;
public string AssetName;
public byte Precision;

public AssetDescriptor(UInt160 asset_id)
{
byte[] script;
using (ScriptBuilder sb = new ScriptBuilder())
{
sb.EmitAppCall(asset_id, "decimals");
sb.EmitAppCall(asset_id, "name");
script = sb.ToArray();
}
ApplicationEngine engine = ApplicationEngine.Run(script);
if (engine.State.HasFlag(VMState.FAULT)) throw new ArgumentException();
this.AssetId = asset_id;
this.AssetName = engine.EvaluationStack.Pop().GetString();
this.Precision = (byte)engine.EvaluationStack.Pop().GetBigInteger();
}

public AssetDescriptor(AssetState state)
{
this.AssetId = state.AssetId;
this.AssetName = state.GetName();
this.Precision = state.Precision;
}

public BigDecimal GetAvailable()
{
if (AssetId is UInt256 asset_id)
{
return new BigDecimal(Program.CurrentWallet.GetAvailable(asset_id).GetData(), 8);
}
else
{
byte[] script;
using (ScriptBuilder sb = new ScriptBuilder())
{
foreach (UInt160 account in Program.CurrentWallet.GetContracts().Select(p => p.ScriptHash))
sb.EmitAppCall((UInt160)AssetId, "balanceOf", account);
sb.Emit(OpCode.DEPTH, OpCode.PACK);
script = sb.ToArray();
}
ApplicationEngine engine = ApplicationEngine.Run(script);
BigInteger amount = engine.EvaluationStack.Pop().GetArray().Aggregate(BigInteger.Zero, (x, y) => x + y.GetBigInteger());
return new BigDecimal(amount, Precision);
}
}

public override string ToString()
{
return AssetName;
}
}
}
11 changes: 2 additions & 9 deletions neo-gui/UI/AssetRegisterDialog.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Neo.Core;
using Neo.Cryptography.ECC;
using Neo.SmartContract;
using Neo.VM;
using Neo.Wallets;
using System;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Neo.UI
Expand All @@ -28,14 +28,7 @@ public InvocationTransaction GetTransaction()
UInt160 issuer = Wallet.ToScriptHash(comboBox4.Text);
using (ScriptBuilder sb = new ScriptBuilder())
{
sb.EmitPush(issuer.ToArray());
sb.EmitPush(admin.ToArray());
sb.EmitPush(owner.EncodePoint(true));
sb.EmitPush(precision);
sb.EmitPush(amount.GetData());
sb.EmitPush(Encoding.UTF8.GetBytes(name));
sb.EmitPush((byte)asset_type);
sb.EmitSysCall("Neo.Asset.Create");
sb.EmitSysCall("Neo.Asset.Create", asset_type, name, amount, precision, owner, admin, issuer);
return new InvocationTransaction
{
Attributes = new[]
Expand Down
Loading