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)); }
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 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)); }
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)); }