RpcSystemAssetTracker/CronContractInvoker.cs
/// <summary>
/// SC parameter helper function.
/// Tries to get SC parameter of given type from raw value
/// </summary>
/// <param name="cp">destination SC parameter</param>
/// <param name="jObj">source JObject value </param>
/// 
SC parameter helper function.
Tries to get SC parameter of given type from raw value
SC parameter helper function . Tries to get SC parameter of given type from raw value
private void SetFromJsonRaw(ContractParameter cp, JObject jObj)
        {
            switch (cp.Type)
            {
                case ContractParameterType.Array:
                    cp.Value = jObj == null ?
                    (new ContractParameter[] { }).ToList() :
                    ((JArray)jObj).Select(p => ContractParameter.FromJson(p)).ToList();
                    break;
                case ContractParameterType.Boolean:
                    cp.Value = bool.Parse(jObj.AsString());
                    break;
                case ContractParameterType.Integer:
                    cp.Value = IntParse(jObj.AsString());
                    break;
                case ContractParameterType.Hash160:
                    cp.Value = UInt160.Parse(jObj.AsString());
                    break;
                case ContractParameterType.Hash256:
                    cp.Value = UInt256.Parse(jObj.AsString());
                    break;
                case ContractParameterType.Signature:
                case ContractParameterType.ByteArray:
                    cp.Value = jObj.AsString().HexToBytes();
                    break;
                case ContractParameterType.PublicKey:
                    cp.Value = ECPoint.Parse(jObj.AsString(), ECCurve.Secp256r1);
                    break;
                case ContractParameterType.String:
                    cp.Value = jObj.AsString();
                    break;
                case ContractParameterType.Map:
                    cp.Value = ((JArray)jObj).Select(p =>
                      new KeyValuePair<ContractParameter, ContractParameter>
                      (ContractParameter.FromJson(p["key"]),
                       ContractParameter.FromJson(p["value"])))
                       .ToList();
                    break;
                case ContractParameterType.InteropInterface:
                    cp.Value = jObj.AsString();
                    break;
                case ContractParameterType.Void:
                    break;
                default:
                    throw new RpcException(-1213, "Wrong parameter type");
            }
        }
private void SetFromJsonRaw ( ContractParameter cp , JObject jObj ) { switch ( cp . Type ) { case ContractParameterType . Array : cp . Value = jObj == null ? ( new ContractParameter [ ] { } ) . ToList ( ) : ( ( JArray ) jObj ) . Select ( p => ContractParameter . FromJson ( p ) ) . ToList ( ) ; break ; case ContractParameterType . Boolean : cp . Value = bool . Parse ( jObj . AsString ( ) ) ; break ; case ContractParameterType . Integer : cp . Value = IntParse ( jObj . AsString ( ) ) ; break ; case ContractParameterType . Hash160 : cp . Value = UInt160 . Parse ( jObj . AsString ( ) ) ; break ; case ContractParameterType . Hash256 : cp . Value = UInt256 . Parse ( jObj . AsString ( ) ) ; break ; case ContractParameterType . Signature : case ContractParameterType . ByteArray : cp . Value = jObj . AsString ( ) . HexToBytes ( ) ; break ; case ContractParameterType . PublicKey : cp . Value = ECPoint . Parse ( jObj . AsString ( ) , ECCurve . Secp256r1 ) ; break ; case ContractParameterType . String : cp . Value = jObj . AsString ( ) ; break ; case ContractParameterType . Map : cp . Value = ( ( JArray ) jObj ) . Select ( p => new KeyValuePair < ContractParameter , ContractParameter > ( ContractParameter . FromJson ( p [ " " ] ) , ContractParameter . FromJson ( p [ " " ] ) ) ) . ToList ( ) ; break ; case ContractParameterType . InteropInterface : cp . Value = jObj . AsString ( ) ; break ; case ContractParameterType . Void : break ; default : throw new RpcException ( - 1213 , " " ) ; } }
SC parameter helper function.
SC parameter helper function .
cp
ContractParameter
destination SC parameter
destination SC parameter
jObj
JObject
source JObject value
source JObject value