Beispiel #1
0
        public void TestRpcInvokeResult()
        {
            JObject json = TestUtils.RpcTestCases.Find(p => p.Name == nameof(RpcClient.InvokeFunctionAsync).ToLower()).Response.Result;
            var     item = RpcInvokeResult.FromJson(json);

            Assert.AreEqual(json.ToString(), item.ToJson().ToString());
        }
Beispiel #2
0
        /// <summary>
        /// Returns the result after passing a script through the VM.
        /// This RPC call does not affect the blockchain in any way.
        /// </summary>
        public RpcInvokeResult InvokeScript(byte[] script, params UInt160[] scriptHashesForVerifying)
        {
            List <JObject> parameters = new List <JObject>
            {
                script.ToHexString()
            };

            parameters.AddRange(scriptHashesForVerifying.Select(p => (JObject)p.ToString()));
            return(RpcInvokeResult.FromJson(RpcSend("invokescript", parameters.ToArray())));
        }
Beispiel #3
0
        /// <summary>
        /// Returns the result after passing a script through the VM.
        /// This RPC call does not affect the blockchain in any way.
        /// </summary>
        public async Task <RpcInvokeResult> InvokeScriptAsync(byte[] script, params Signer[] signers)
        {
            List <JObject> parameters = new() { Convert.ToBase64String(script) };

            if (signers.Length > 0)
            {
                parameters.Add(signers.Select(p => p.ToJson()).ToArray());
            }
            var result = await RpcSendAsync(GetRpcName(), parameters.ToArray()).ConfigureAwait(false);

            return(RpcInvokeResult.FromJson(result));
        }
Beispiel #4
0
        /// <summary>
        /// Returns the result after calling a smart contract at scripthash with the given operation and parameters.
        /// This RPC call does not affect the blockchain in any way.
        /// </summary>
        public async Task <RpcInvokeResult> InvokeFunctionAsync(string scriptHash, string operation, RpcStack[] stacks, params Signer[] signer)
        {
            List <JObject> parameters = new() { scriptHash.AsScriptHash(), operation, stacks.Select(p => p.ToJson()).ToArray() };

            if (signer.Length > 0)
            {
                parameters.Add(signer.Select(p => p.ToJson()).ToArray());
            }
            var result = await RpcSendAsync(GetRpcName(), parameters.ToArray()).ConfigureAwait(false);

            return(RpcInvokeResult.FromJson(result));
        }
Beispiel #5
0
        /// <summary>
        /// Returns the result after calling a smart contract at scripthash with the given operation and parameters.
        /// This RPC call does not affect the blockchain in any way.
        /// </summary>
        public RpcInvokeResult InvokeFunction(string scriptHash, string operation, RpcStack[] stacks, params UInt160[] scriptHashesForVerifying)
        {
            List <JObject> parameters = new List <JObject> {
                scriptHash, operation, stacks.Select(p => p.ToJson()).ToArray()
            };

            if (scriptHashesForVerifying.Length > 0)
            {
                parameters.Add(scriptHashesForVerifying.Select(p => (JObject)p.ToString()).ToArray());
            }
            return(RpcInvokeResult.FromJson(RpcSend("invokefunction", parameters.ToArray())));
        }
Beispiel #6
0
        /// <summary>
        /// Returns the result after passing a script through the VM.
        /// This RPC call does not affect the blockchain in any way.
        /// </summary>
        public RpcInvokeResult InvokeScript(byte[] script, params Signer[] signers)
        {
            List <JObject> parameters = new List <JObject> {
                script.ToHexString()
            };

            if (signers.Length > 0)
            {
                parameters.Add(signers.Select(p => p.ToJson()).ToArray());
            }
            return(RpcInvokeResult.FromJson(RpcSend("invokescript", parameters.ToArray())));
        }
Beispiel #7
0
 /// <summary>
 /// Returns the result after calling a smart contract at scripthash with the given operation and parameters.
 /// This RPC call does not affect the blockchain in any way.
 /// </summary>
 public RpcInvokeResult InvokeFunction(string address, string function, RpcStack[] stacks)
 {
     return(RpcInvokeResult.FromJson(RpcSend("invokefunction", address, function, stacks.Select(p => p.ToJson()).ToArray())));
 }
Beispiel #8
0
 /// <summary>
 /// Returns the result after passing a script through the VM.
 /// This RPC call does not affect the blockchain in any way.
 /// </summary>
 public RpcInvokeResult InvokeScript(string script)
 {
     return(RpcInvokeResult.FromJson(RpcSend("invokescript", script)));
 }
Beispiel #9
0
 /// <summary>
 /// Returns the result after passing a script through the VM.
 /// This RPC call does not affect the blockchain in any way.
 /// </summary>
 public RpcInvokeResult InvokeScript(byte[] script)
 {
     return(RpcInvokeResult.FromJson(RpcSend("invokescript", script.ToHexString())));
 }
Beispiel #10
0
 /// <summary>
 /// Returns the result after calling a smart contract at scripthash with the given operation and parameters.
 /// This RPC call does not affect the blockchain in any way.
 /// </summary>
 public RpcInvokeResult InvokeFunction(string scriptHash, string operation, RpcStack[] stacks)
 {
     return(RpcInvokeResult.FromJson(RpcSend("invokefunction", scriptHash, operation, stacks.Select(p => p.ToJson()).ToArray())));
 }