Beispiel #1
0
        internal static BlockResponse DeserializeBlockResponse(JsonElement element)
        {
            Optional <Block> block = default;
            Optional <IReadOnlyList <TransactionIdentifier> > otherTransactions = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("block"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    block = Block.DeserializeBlock(property.Value);
                    continue;
                }
                if (property.NameEquals("other_transactions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TransactionIdentifier> array = new List <TransactionIdentifier>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TransactionIdentifier.DeserializeTransactionIdentifier(item));
                    }
                    otherTransactions = array;
                    continue;
                }
            }
            return(new BlockResponse(block.Value, Optional.ToList(otherTransactions)));
        }
        internal static RelatedTransaction DeserializeRelatedTransaction(JsonElement element)
        {
            Optional <NetworkIdentifier> networkIdentifier     = default;
            TransactionIdentifier        transactionIdentifier = default;
            Direction direction = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("network_identifier"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    networkIdentifier = NetworkIdentifier.DeserializeNetworkIdentifier(property.Value);
                    continue;
                }
                if (property.NameEquals("transaction_identifier"))
                {
                    transactionIdentifier = TransactionIdentifier.DeserializeTransactionIdentifier(property.Value);
                    continue;
                }
                if (property.NameEquals("direction"))
                {
                    direction = new Direction(property.Value.GetString());
                    continue;
                }
            }
            return(new RelatedTransaction(networkIdentifier.Value, transactionIdentifier, direction));
        }
Beispiel #3
0
        internal static TransactionIdentifierResponse DeserializeTransactionIdentifierResponse(JsonElement element)
        {
            TransactionIdentifier transactionIdentifier = default;
            Optional <object>     metadata = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("transaction_identifier"))
                {
                    transactionIdentifier = TransactionIdentifier.DeserializeTransactionIdentifier(property.Value);
                    continue;
                }
                if (property.NameEquals("metadata"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    metadata = property.Value.GetObject();
                    continue;
                }
            }
            return(new TransactionIdentifierResponse(transactionIdentifier, metadata.Value));
        }
 internal Transaction(TransactionIdentifier transactionIdentifier, IReadOnlyList <Operation> operations, IReadOnlyList <RelatedTransaction> relatedTransactions, object metadata)
 {
     TransactionIdentifier = transactionIdentifier;
     Operations            = operations;
     RelatedTransactions   = relatedTransactions;
     Metadata = metadata;
 }
        internal TransactionIdentifierResponse(TransactionIdentifier transactionIdentifier)
        {
            if (transactionIdentifier == null)
            {
                throw new ArgumentNullException(nameof(transactionIdentifier));
            }

            TransactionIdentifier = transactionIdentifier;
        }
        internal RelatedTransaction(TransactionIdentifier transactionIdentifier, Direction direction)
        {
            if (transactionIdentifier == null)
            {
                throw new ArgumentNullException(nameof(transactionIdentifier));
            }

            TransactionIdentifier = transactionIdentifier;
            Direction             = direction;
        }
Beispiel #7
0
        internal static Transaction DeserializeTransaction(JsonElement element)
        {
            TransactionIdentifier     transactionIdentifier = default;
            IReadOnlyList <Operation> operations            = default;
            Optional <IReadOnlyList <RelatedTransaction> > relatedTransactions = default;
            Optional <object> metadata = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("transaction_identifier"))
                {
                    transactionIdentifier = TransactionIdentifier.DeserializeTransactionIdentifier(property.Value);
                    continue;
                }
                if (property.NameEquals("operations"))
                {
                    List <Operation> array = new List <Operation>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Operation.DeserializeOperation(item));
                    }
                    operations = array;
                    continue;
                }
                if (property.NameEquals("related_transactions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <RelatedTransaction> array = new List <RelatedTransaction>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(RelatedTransaction.DeserializeRelatedTransaction(item));
                    }
                    relatedTransactions = array;
                    continue;
                }
                if (property.NameEquals("metadata"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    metadata = property.Value.GetObject();
                    continue;
                }
            }
            return(new Transaction(transactionIdentifier, operations, Optional.ToList(relatedTransactions), metadata.Value));
        }
Beispiel #8
0
        public MempoolTransactionRequest(NetworkIdentifier networkIdentifier, TransactionIdentifier transactionIdentifier)
        {
            if (networkIdentifier == null)
            {
                throw new ArgumentNullException(nameof(networkIdentifier));
            }
            if (transactionIdentifier == null)
            {
                throw new ArgumentNullException(nameof(transactionIdentifier));
            }

            NetworkIdentifier     = networkIdentifier;
            TransactionIdentifier = transactionIdentifier;
        }
        internal Transaction(TransactionIdentifier transactionIdentifier, IEnumerable <Operation> operations)
        {
            if (transactionIdentifier == null)
            {
                throw new ArgumentNullException(nameof(transactionIdentifier));
            }
            if (operations == null)
            {
                throw new ArgumentNullException(nameof(operations));
            }

            TransactionIdentifier = transactionIdentifier;
            Operations            = operations.ToList();
            RelatedTransactions   = new ChangeTrackingList <RelatedTransaction>();
        }
        internal static MempoolResponse DeserializeMempoolResponse(JsonElement element)
        {
            IReadOnlyList <TransactionIdentifier> transactionIdentifiers = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("transaction_identifiers"))
                {
                    List <TransactionIdentifier> array = new List <TransactionIdentifier>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TransactionIdentifier.DeserializeTransactionIdentifier(item));
                    }
                    transactionIdentifiers = array;
                    continue;
                }
            }
            return(new MempoolResponse(transactionIdentifiers));
        }
 internal RelatedTransaction(NetworkIdentifier networkIdentifier, TransactionIdentifier transactionIdentifier, Direction direction)
 {
     NetworkIdentifier     = networkIdentifier;
     TransactionIdentifier = transactionIdentifier;
     Direction             = direction;
 }
 internal TransactionIdentifierResponse(TransactionIdentifier transactionIdentifier, object metadata)
 {
     TransactionIdentifier = transactionIdentifier;
     Metadata = metadata;
 }