예제 #1
0
 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();
 }
예제 #2
0
        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)));
        }
예제 #3
0
        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;
        }