Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nugets #233

Merged
merged 11 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion src/LevelDBStore/LevelDBStore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00892" />
<PackageReference Include="Neo" Version="3.0.0-CI00907" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/RocksDBStore/RocksDBStore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00892" />
<PackageReference Include="Neo" Version="3.0.0-CI00907" />
<PackageReference Include="RocksDbNative" Version="6.2.2" />
<PackageReference Include="RocksDbSharp" Version="6.2.2" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/RpcClient/Models/RpcBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public JObject ToJson()
public static RpcBlock FromJson(JObject json)
{
RpcBlock block = new RpcBlock();
block.Block = Block.FromJson(json);
block.Block = Utility.BlockFromJson(json);
block.Confirmations = (uint)json["confirmations"].AsNumber();
block.NextBlockHash = json["nextblockhash"] is null ? null : UInt256.Parse(json["nextblockhash"].AsString());
return block;
Expand Down
2 changes: 1 addition & 1 deletion src/RpcClient/Models/RpcBlockHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public JObject ToJson()
public static RpcBlockHeader FromJson(JObject json)
{
RpcBlockHeader block = new RpcBlockHeader();
block.Header = Header.FromJson(json);
block.Header = Utility.HeaderFromJson(json);
block.Confirmations = (uint)json["confirmations"].AsNumber();
block.NextBlockHash = json["nextblockhash"] is null ? null : UInt256.Parse(json["nextblockhash"].AsString());
return block;
Expand Down
2 changes: 1 addition & 1 deletion src/RpcClient/Models/RpcTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public JObject ToJson()
public static RpcTransaction FromJson(JObject json)
{
RpcTransaction transaction = new RpcTransaction();
transaction.Transaction = Transaction.FromJson(json);
transaction.Transaction = Utility.TransactionFromJson(json);
if (json["confirmations"] != null)
{
transaction.BlockHash = UInt256.Parse(json["blockhash"].AsString());
Expand Down
2 changes: 1 addition & 1 deletion src/RpcClient/RpcClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00892" />
<PackageReference Include="Neo" Version="3.0.0-CI00907" />
</ItemGroup>

</Project>
86 changes: 86 additions & 0 deletions src/RpcClient/Utility.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using Neo.Cryptography.ECC;
using Neo.IO.Json;
using Neo.Network.P2P.Payloads;
using Neo.SmartContract;
using Neo.Wallets;
using System;
using System.Globalization;
using System.Linq;
using System.Numerics;

namespace Neo.Network.RPC
Expand Down Expand Up @@ -88,5 +92,87 @@ public static BigInteger ToBigInteger(this decimal amount, uint decimals)
BigInteger res = factor * numerator / denominator;
return res;
}

public static Block BlockFromJson(JObject json)
{
Block block = new Block();
BlockBase blockBase = block;
blockBase.FromJson(json);
block.ConsensusData = ConsensusDataFromJson(json["consensus_data"]);
block.Transactions = ((JArray)json["tx"]).Select(p => TransactionFromJson(p)).ToArray();
return block;
}

public static void FromJson(this BlockBase block, JObject json)
{
block.Version = (uint)json["version"].AsNumber();
block.PrevHash = UInt256.Parse(json["previousblockhash"].AsString());
block.MerkleRoot = UInt256.Parse(json["merkleroot"].AsString());
block.Timestamp = (ulong)json["time"].AsNumber();
block.Index = (uint)json["index"].AsNumber();
block.NextConsensus = json["nextconsensus"].AsString().ToScriptHash();
block.Witness = ((JArray)json["witnesses"]).Select(p => WitnessFromJson(p)).FirstOrDefault();
}

public static Transaction TransactionFromJson(JObject json)
{
Transaction tx = new Transaction();
tx.Version = byte.Parse(json["version"].AsString());
tx.Nonce = uint.Parse(json["nonce"].AsString());
tx.Sender = json["sender"].AsString().ToScriptHash();
tx.SystemFee = long.Parse(json["sys_fee"].AsString());
tx.NetworkFee = long.Parse(json["net_fee"].AsString());
tx.ValidUntilBlock = uint.Parse(json["valid_until_block"].AsString());
tx.Attributes = ((JArray)json["attributes"]).Select(p => TransactionAttributeFromJson(p)).ToArray();
tx.Cosigners = ((JArray)json["cosigners"]).Select(p => CosignerFromJson(p)).ToArray();
tx.Script = Convert.FromBase64String(json["script"].AsString());
tx.Witnesses = ((JArray)json["witnesses"]).Select(p => WitnessFromJson(p)).ToArray();
return tx;
}

public static Header HeaderFromJson(JObject json)
{
Header header = new Header();
BlockBase blockBase = header;
blockBase.FromJson(json);
return header;
}

public static Cosigner CosignerFromJson(JObject json)
{
return new Cosigner
{
Account = UInt160.Parse(json["account"].AsString()),
Scopes = (WitnessScope)Enum.Parse(typeof(WitnessScope), json["scopes"].AsString()),
AllowedContracts = ((JArray)json["allowedContracts"])?.Select(p => UInt160.Parse(p.AsString())).ToArray(),
AllowedGroups = ((JArray)json["allowedGroups"])?.Select(p => ECPoint.Parse(p.AsString(), ECCurve.Secp256r1)).ToArray()
};
}

public static ConsensusData ConsensusDataFromJson(JObject json)
{
ConsensusData block = new ConsensusData();
block.PrimaryIndex = (uint)json["primary"].AsNumber();
block.Nonce = ulong.Parse(json["nonce"].AsString(), NumberStyles.HexNumber);
return block;
}

public static TransactionAttribute TransactionAttributeFromJson(JObject json)
{
TransactionAttribute transactionAttribute = new TransactionAttribute();
transactionAttribute.Usage = (TransactionAttributeUsage)byte.Parse(json["usage"].AsString());
if (!Enum.IsDefined(typeof(TransactionAttributeUsage), transactionAttribute.Usage))
throw new ArgumentException();
transactionAttribute.Data = Convert.FromBase64String(json["data"].AsString());
return transactionAttribute;
}

public static Witness WitnessFromJson(JObject json)
{
Witness witness = new Witness();
witness.InvocationScript = Convert.FromBase64String(json["invocation"].AsString());
witness.VerificationScript = Convert.FromBase64String(json["verification"].AsString());
return witness;
}
}
}
2 changes: 1 addition & 1 deletion src/RpcServer/RpcServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
<PackageReference Include="Neo" Version="3.0.0-CI00892" />
<PackageReference Include="Neo" Version="3.0.0-CI00907" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/StatesDumper/StatesDumper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00892" />
<PackageReference Include="Neo" Version="3.0.0-CI00907" />
<PackageReference Include="Neo.ConsoleService" Version="1.0.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/SystemLog/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected override void Configure()
Settings.Load(GetConfiguration());
}

void ILogPlugin.Log(string source, LogLevel level, string message)
void ILogPlugin.Log(string source, LogLevel level, object message)
erikzhang marked this conversation as resolved.
Show resolved Hide resolved
{
lock (typeof(Logger))
{
Expand Down
2 changes: 1 addition & 1 deletion src/SystemLog/SystemLog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00892" />
<PackageReference Include="Neo" Version="3.0.0-CI00907" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions tests/Neo.Network.RPC.Tests/UT_TransactionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ public void TestSign()
var tx = txManager.Tx;
byte[] signature = tx.Witnesses[0].InvocationScript.Skip(2).ToArray();

Assert.IsTrue(Crypto.VerifySignature(tx.GetHashData(), signature, keyPair1.PublicKey.EncodePoint(false).Skip(1).ToArray()));
Assert.IsTrue(Crypto.VerifySignature(tx.GetHashData(), signature, keyPair1.PublicKey));
// verify network fee and system fee
long networkFee = tx.Size * (long)1000 + ApplicationEngine.OpCodePrices[OpCode.PUSHDATA1] + ApplicationEngine.OpCodePrices[OpCode.PUSHDATA1] + ApplicationEngine.OpCodePrices[OpCode.PUSHNULL] + InteropService.GetPrice(InteropService.Crypto.ECDsaVerify, null, null);
long networkFee = tx.Size * (long)1000 + ApplicationEngine.OpCodePrices[OpCode.PUSHDATA1] + ApplicationEngine.OpCodePrices[OpCode.PUSHDATA1] + ApplicationEngine.OpCodePrices[OpCode.PUSHNULL] + InteropService.GetPrice(InteropService.Crypto.VerifyWithECDsaSecp256r1, null, null);
Assert.AreEqual(networkFee, tx.NetworkFee);
Assert.AreEqual(100, tx.SystemFee);

Expand Down