Skip to content
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
5 changes: 3 additions & 2 deletions src/Plugins/RpcServer/RpcServer.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected internal virtual JToken GetBlock(BlockHashOrIndex blockHashOrIndex, bo
block.NotNull_Or(RpcError.UnknownBlock);
if (verbose)
{
JObject json = Utility.BlockToJson(block, system.Settings);
JObject json = block.ToJson(system.Settings);
json["confirmations"] = NativeContract.Ledger.CurrentIndex(snapshot) - block.Index + 1;
UInt256 hash = NativeContract.Ledger.GetBlockHash(snapshot, block.Index + 1);
if (hash != null)
Expand Down Expand Up @@ -369,7 +369,8 @@ protected internal virtual JToken GetRawTransaction(UInt256 hash, bool verbose =
tx.NotNull_Or(RpcError.UnknownTransaction);

if (!verbose) return Convert.ToBase64String(tx.ToArray());
var json = Utility.TransactionToJson(tx!, system.Settings);

var json = tx!.ToJson(system.Settings);
if (state is not null)
{
var block = NativeContract.Ledger.GetTrimmedBlock(snapshot, NativeContract.Ledger.GetBlockHash(snapshot, state.BlockIndex));
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/RpcServer/RpcServer.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ private JObject SignAndRelay(DataCache snapshot, Transaction tx)
{
tx.Witnesses = context.GetWitnesses();
system.Blockchain.Tell(tx);
return Utility.TransactionToJson(tx, system.Settings);
return tx.ToJson(system.Settings);
}
else
{
Expand Down
35 changes: 0 additions & 35 deletions src/Plugins/RpcServer/Utility.cs

This file was deleted.

7 changes: 5 additions & 2 deletions tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@ public void TestGetRawTransaction()
snapshot.Commit();

var result = _rpcServer.GetRawTransaction(tx.Hash, true);
var json = Utility.TransactionToJson(tx, _neoSystem.Settings);
var json = tx.ToJson(_neoSystem.Settings);
Assert.AreEqual(json.ToString(), result.ToString());
Assert.IsTrue(json.ContainsProperty("sysfee"));
Assert.IsTrue(json.ContainsProperty("netfee"));

result = _rpcServer.GetRawTransaction(tx.Hash, false);
var tx2 = Convert.FromBase64String(result.AsString()).AsSerializable<Transaction>();
Expand All @@ -373,7 +375,8 @@ public void TestGetRawTransaction_Confirmed()

// Test verbose
var resultVerbose = _rpcServer.GetRawTransaction(tx.Hash, true);
var expectedJson = Utility.TransactionToJson(tx, _neoSystem.Settings);
var expectedJson = tx.ToJson(_neoSystem.Settings);

// Add expected block-related fields
expectedJson["blockhash"] = block.Hash.ToString();
expectedJson["confirmations"] = NativeContract.Ledger.CurrentIndex(_neoSystem.StoreView) - block.Index + 1;
Expand Down
Loading