RpcServer: added GetContractState by contract id support#813
RpcServer: added GetContractState by contract id support#813Jim8y merged 2 commits intoneo-project:masterfrom
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.
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.
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.
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.
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