public MetadataBase GetMetadata(GetMetadataParams param)
        {
            JArray prm = new JArray {
            };

            if (param != null)
            {
                prm = new JArray {
                    param.BlockHash
                }
            }
            ;
            JObject query = new JObject {
                { "method", "state_getMetadata" }, { "params", prm }
            };

            JObject response = _jsonRpc.Request(query);

            if (TryDeserialize <MetadataV4, ParseMetadataV4>(response, out MetadataV4 md4))
            {
                return(md4);
            }

            if (TryDeserialize <MetadataV7, ParseMetadataV7>(response, out MetadataV7 md7))
            {
                return(md7);
            }

            if (TryDeserialize <MetadataV8, ParseMetadataV8>(response, out MetadataV8 md8))
            {
                return(md8);
            }

            return(null);
        }
예제 #2
0
        public MetadataBase GetMetadata(GetMetadataParams param, bool force = false)
        {
            if (_metadataCache != null && !force)
            {
                return(_metadataCache);
            }

            JArray prm = new JArray {
            };

            if (param != null)
            {
                prm = new JArray {
                    param.BlockHash
                }
            }
            ;
            JObject query = new JObject {
                { "method", "state_getMetadata" }, { "params", prm }
            };

            JObject response = _jsonRpc.Request(query);

            if (TryDeserialize <MetadataV11, ParseMetadataV11>(response, out MetadataV11 md11))
            {
                _metadataCache = md11;
                return(md11);
            }

            if (TryDeserialize <MetadataV8, ParseMetadataV8>(response, out MetadataV8 md8))
            {
                _metadataCache = md8;
                return(md8);
            }

            if (TryDeserialize <MetadataV7, ParseMetadataV7>(response, out MetadataV7 md7))
            {
                _metadataCache = md7;
                return(md7);
            }

            if (TryDeserialize <MetadataV4, ParseMetadataV4>(response, out MetadataV4 md4))
            {
                _metadataCache = md4;
                return(md4);
            }

            return(null);
        }