void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("signing_payload"); writer.WriteObjectValue(SigningPayload); writer.WritePropertyName("public_key"); writer.WriteObjectValue(PublicKey); writer.WritePropertyName("signature_type"); writer.WriteStringValue(SignatureType.ToString()); writer.WritePropertyName("hex_bytes"); writer.WriteStringValue(HexBytes); writer.WriteEndObject(); }
internal static SigningPayload DeserializeSigningPayload(JsonElement element) { Optional <string> address = default; Optional <AccountIdentifier> accountIdentifier = default; string hexBytes = default; Optional <SignatureType> signatureType = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("address")) { address = property.Value.GetString(); continue; } if (property.NameEquals("account_identifier")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } accountIdentifier = AccountIdentifier.DeserializeAccountIdentifier(property.Value); continue; } if (property.NameEquals("hex_bytes")) { hexBytes = property.Value.GetString(); continue; } if (property.NameEquals("signature_type")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } signatureType = new SignatureType(property.Value.GetString()); continue; } } return(new SigningPayload(address.Value, accountIdentifier.Value, hexBytes, Optional.ToNullable(signatureType))); }
public Signature(SigningPayload signingPayload, PublicKey publicKey, SignatureType signatureType, string hexBytes) { if (signingPayload == null) { throw new ArgumentNullException(nameof(signingPayload)); } if (publicKey == null) { throw new ArgumentNullException(nameof(publicKey)); } if (hexBytes == null) { throw new ArgumentNullException(nameof(hexBytes)); } SigningPayload = signingPayload; PublicKey = publicKey; SignatureType = signatureType; HexBytes = hexBytes; }