-
Notifications
You must be signed in to change notification settings - Fork 100
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
RpcServer: added GetContractState by contract id support #813
Conversation
public async Task<ContractState> GetContractStateAsync(int id) | ||
{ | ||
var result = await RpcSendAsync(GetRpcName(), id).ConfigureAwait(false); | ||
return ContractStateFromJson((JObject)result); |
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.
Note this doesn't use the "RpcContractState" class which is in the model folder. The function is using the function below it ("ContractStateFromJson", line 257). Should that be changed and updated? To use "RpcContractState" class? As you can see the new function and other one doesn't use the class; nothing does.
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.
Can't use the same method name as GetContractStateAsync(string hash)
, otherwise it will get GetContractStateAsync(string hash)
as default when GetRpcName()
, then id will be an invaild param.
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's just a overload for RcpClient and works fine. That's what we want to do. The method that was changed on RpcServer; GetContractState
to allow contract id to be processed.
Example
var protocolSettings = ProtocolSettings.Load("config.json", true);
RpcClient rpcClient = new(new("http://127.0.0.1:20332"), "admin", "admin", protocolSettings);
var contractstate = await rpcClient.GetContractStateAsync(742).ConfigureAwait(false);
Console.WriteLine("ScriptHash is {0}.", contractstate.Hash);
Console.WriteLine("Press ENTER to exit . . .");
Console.ReadLine();
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.
Sorry, just a fault on my code, it works as the expected!
@superboyiii could you test it? |
* 'wss' of github.com:Liaojinghui/neo-modules: RpcServer: added GetContractState by contract id support (neo-project#813) rpc: add FindStorage (neo-project#805)
closes #788
Also per neo-project/neo#2803 (comment)
Change Log