-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add NEO SDK RPC module #850
Conversation
Changed for neo 3.0, not final yet.
sync with neo-project
Codecov Report
@@ Coverage Diff @@
## master #850 +/- ##
==========================================
+ Coverage 52.59% 53.62% +1.03%
==========================================
Files 179 193 +14
Lines 12707 13211 +504
==========================================
+ Hits 6683 7085 +402
- Misses 6024 6126 +102
Continue to review full report at Codecov.
|
We can move most of the classes to the |
Yes, we can inherit from 'Block' to add property "confirmations" and "nextblockhash". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks clear, nice design.
I think @jsolman will like.
What do you think @igormcoelho?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work being done here... SDK is fundamental for any dev platform.
I recommend renaming quite a few things... GetBlock for example could be ModelBlock or SDKBlock, or in the worst case, Block using different namespace.. but it's confusing. This applies to all other classes.
neo.UnitTests/SDK/UT_RpcClient.cs
Outdated
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Neo.UnitTests.SDK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RpcClient
has been moved to Neo.Network.RPC
. So this namespace should be changed too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put it the same place with others
neo/Network/RPC/HttpService.cs
Outdated
|
||
namespace Neo.Network.RPC | ||
{ | ||
public class HttpService : IDisposable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this class, and move HttpClient
into RpcClient
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
neo/Network/RPC/IRpcClient.cs
Outdated
/// <summary> | ||
/// Wrappar of NEO RPC APIs | ||
/// </summary> | ||
public interface IRpcClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this interface?
neo/Network/RPC/Model/RpcBlock.cs
Outdated
using Neo.IO.Json; | ||
using Neo.Network.P2P.Payloads; | ||
|
||
namespace Neo.Network.RPC.Model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace Neo.Network.RPC.Model | |
namespace Neo.Network.RPC.Models |
And many other classes are the same.
neo/Network/RPC/RpcServer.cs
Outdated
@@ -81,7 +81,7 @@ public RpcServer(NeoSystem system, Wallet wallet = null, long maxGasInvoke = def | |||
this.MaxGasInvoke = maxGasInvoke; | |||
} | |||
|
|||
private static JObject CreateErrorResponse(JObject id, int code, string message, JObject data = null) | |||
internal static JObject CreateErrorResponse(JObject id, int code, string message, JObject data = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why internal
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is covered in unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the discussion here, we don't need to test private methods. Testing for public methods can completely cover private methods.
neo.UnitTests/SDK/UT_RpcClient.cs
Outdated
{ | ||
// create block | ||
var block = new Block(); | ||
TestUtils.SetupBlockWithValues(block, UInt256.Zero, out UInt256 merkRootVal, out UInt160 val160, out uint timestampVal, out uint indexVal, out Witness scriptVal, out Transaction[] transactionsVal, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be ulong
now, timestamp is in ms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed👍
@erikzhang should we open a new branch for all NEO3 SDK functions?
|
No. I don't think it's necessary. |
PR correction
No, the REST is more about RpcServer reconstruction, we won't have it in this PR. |
hi, all. |
neo.UnitTests/UT_RpcClient.cs
Outdated
namespace Neo.UnitTests | ||
{ | ||
[TestClass] | ||
public class UT_RpcClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file be moved into a sub folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have moved the file to Network/RPC folder
Codecov Report
@@ Coverage Diff @@
## master #850 +/- ##
==========================================
+ Coverage 52.74% 53.76% +1.02%
==========================================
Files 180 194 +14
Lines 12749 13253 +504
==========================================
+ Hits 6724 7126 +402
- Misses 6025 6127 +102
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For maintenance it looks better. A great job!
Hope it also give all the flexibility you want for the SDK RPC module.
* Add NEO SDK based on RPC client * add rpc interface methods for neo3 * update unit test * add unit test * Update TransactionHelper.cs Changed for neo 3.0, not final yet. * implement sdk rpc client methods * backup files * change class name * remove uncompleted modules for pull request * change json deserialize method with Neo JObject * modified JSON implementation, added FromJson() * more RPC change * PR correction * RPC module fix, remove newton.json * fix * fix getblock issue * PR correction * PR Correction * PR Correction: rename RPC models * PR Correction * resolve conflicts * Clean code * Clean code * Clean code * Clean code * Update RpcValidateAddressResult.cs * Clean code * PR correction * Move test file to the right place
#849 NEO SDK based on RPC interfaces
Add NEO SDK RPC module
This PR contains the rpc client module for neo3 and the unit tests for all the methods