// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: club.stellz.evm.addressControl
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_common::deps::bytes::Bytes;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Datetime, UriValue};
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::club_stellz::evm::address_control;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct AddressControl<'a> {
    ///Ethereum address as bytes (20 bytes)
    #[serde(with = "jacquard_common::serde_bytes_helper")]
    pub address: Bytes,
    ///List of all Chain IDs (besides the one in the sign-in message, though you can include it) that the holder of this address is also active on & accepts tokens thru.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub also_on: Option<Vec<i64>>,
    ///Sign in With Ethereum message signature as bytes
    #[serde(with = "jacquard_common::serde_bytes_helper")]
    pub signature: Bytes,
    #[serde(borrow)]
    pub siwe: address_control::SiweMessage<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SiweMessage<'a> {
    ///Ethereum address in 0x-prefixed, checksummed hex format
    #[serde(borrow)]
    pub address: CowStr<'a>,
    ///Chain ID of the Ethereum VM network the address is on
    pub chain_id: i64,
    ///Domain of the application requesting the signature, e.g. 'wallet-link.stellz.club'
    #[serde(borrow)]
    pub domain: CowStr<'a>,
    ///Timestamp when the message was signed
    pub issued_at: Datetime,
    ///Random nonce the message was signed with
    #[serde(borrow)]
    pub nonce: CowStr<'a>,
    ///The message shown to the user in their wallet before signing, which MUST be of the format 'Prove control of ${address} to link it to ${did}', where ${address} is the linked Ethereum address in 0x-prefixed, checksummed hex format, and ${did} is the DID of the user.
    #[serde(borrow)]
    pub statement: CowStr<'a>,
    ///URI of the application requesting the signature, e.g. 'https://wallet-link.stellz.club'
    #[serde(borrow)]
    pub uri: UriValue<'a>,
    ///Sign in With Ethereum message version
    #[serde(borrow)]
    pub version: CowStr<'a>,
}

impl<'a> LexiconSchema for AddressControl<'a> {
    fn nsid() -> &'static str {
        "club.stellz.evm.addressControl"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_club_stellz_evm_addressControl()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for SiweMessage<'a> {
    fn nsid() -> &'static str {
        "club.stellz.evm.addressControl"
    }
    fn def_name() -> &'static str {
        "siweMessage"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_club_stellz_evm_addressControl()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.address;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 42usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("address"),
                    max: 42usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.address;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 42usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("address"),
                    min: 42usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.nonce;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("nonce"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.nonce;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 8usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("nonce"),
                    min: 8usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.statement;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 78usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("statement"),
                    min: 78usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

pub mod address_control_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Address;
        type Signature;
        type Siwe;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Address = Unset;
        type Signature = Unset;
        type Siwe = Unset;
    }
    ///State transition - sets the `address` field to Set
    pub struct SetAddress<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAddress<S> {}
    impl<S: State> State for SetAddress<S> {
        type Address = Set<members::address>;
        type Signature = S::Signature;
        type Siwe = S::Siwe;
    }
    ///State transition - sets the `signature` field to Set
    pub struct SetSignature<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSignature<S> {}
    impl<S: State> State for SetSignature<S> {
        type Address = S::Address;
        type Signature = Set<members::signature>;
        type Siwe = S::Siwe;
    }
    ///State transition - sets the `siwe` field to Set
    pub struct SetSiwe<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSiwe<S> {}
    impl<S: State> State for SetSiwe<S> {
        type Address = S::Address;
        type Signature = S::Signature;
        type Siwe = Set<members::siwe>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `address` field
        pub struct address(());
        ///Marker type for the `signature` field
        pub struct signature(());
        ///Marker type for the `siwe` field
        pub struct siwe(());
    }
}

/// Builder for constructing an instance of this type
pub struct AddressControlBuilder<'a, S: address_control_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Bytes>,
        Option<Vec<i64>>,
        Option<Bytes>,
        Option<address_control::SiweMessage<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> AddressControl<'a> {
    /// Create a new builder for this type
    pub fn new() -> AddressControlBuilder<'a, address_control_state::Empty> {
        AddressControlBuilder::new()
    }
}

impl<'a> AddressControlBuilder<'a, address_control_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        AddressControlBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> AddressControlBuilder<'a, S>
where
    S: address_control_state::State,
    S::Address: address_control_state::IsUnset,
{
    /// Set the `address` field (required)
    pub fn address(
        mut self,
        value: impl Into<Bytes>,
    ) -> AddressControlBuilder<'a, address_control_state::SetAddress<S>> {
        self._fields.0 = Option::Some(value.into());
        AddressControlBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: address_control_state::State> AddressControlBuilder<'a, S> {
    /// Set the `alsoOn` field (optional)
    pub fn also_on(mut self, value: impl Into<Option<Vec<i64>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `alsoOn` field to an Option value (optional)
    pub fn maybe_also_on(mut self, value: Option<Vec<i64>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S> AddressControlBuilder<'a, S>
where
    S: address_control_state::State,
    S::Signature: address_control_state::IsUnset,
{
    /// Set the `signature` field (required)
    pub fn signature(
        mut self,
        value: impl Into<Bytes>,
    ) -> AddressControlBuilder<'a, address_control_state::SetSignature<S>> {
        self._fields.2 = Option::Some(value.into());
        AddressControlBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> AddressControlBuilder<'a, S>
where
    S: address_control_state::State,
    S::Siwe: address_control_state::IsUnset,
{
    /// Set the `siwe` field (required)
    pub fn siwe(
        mut self,
        value: impl Into<address_control::SiweMessage<'a>>,
    ) -> AddressControlBuilder<'a, address_control_state::SetSiwe<S>> {
        self._fields.3 = Option::Some(value.into());
        AddressControlBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> AddressControlBuilder<'a, S>
where
    S: address_control_state::State,
    S::Address: address_control_state::IsSet,
    S::Signature: address_control_state::IsSet,
    S::Siwe: address_control_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> AddressControl<'a> {
        AddressControl {
            address: self._fields.0.unwrap(),
            also_on: self._fields.1,
            signature: self._fields.2.unwrap(),
            siwe: self._fields.3.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> AddressControl<'a> {
        AddressControl {
            address: self._fields.0.unwrap(),
            also_on: self._fields.1,
            signature: self._fields.2.unwrap(),
            siwe: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_club_stellz_evm_addressControl() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("club.stellz.evm.addressControl"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("address"),
                            SmolStr::new_static("signature"), SmolStr::new_static("siwe")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("address"),
                            LexObjectProperty::Bytes(LexBytes { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("alsoOn"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "List of all Chain IDs (besides the one in the sign-in message, though you can include it) that the holder of this address is also active on & accepts tokens thru.",
                                    ),
                                ),
                                items: LexArrayItem::Integer(LexInteger {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("signature"),
                            LexObjectProperty::Bytes(LexBytes { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("siwe"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#siweMessage"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("siweMessage"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("domain"),
                            SmolStr::new_static("address"),
                            SmolStr::new_static("statement"), SmolStr::new_static("uri"),
                            SmolStr::new_static("version"),
                            SmolStr::new_static("chainId"), SmolStr::new_static("nonce"),
                            SmolStr::new_static("issuedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("address"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Ethereum address in 0x-prefixed, checksummed hex format",
                                    ),
                                ),
                                min_length: Some(42usize),
                                max_length: Some(42usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("chainId"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("domain"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Domain of the application requesting the signature, e.g. 'wallet-link.stellz.club'",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("issuedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Timestamp when the message was signed"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("nonce"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Random nonce the message was signed with",
                                    ),
                                ),
                                min_length: Some(8usize),
                                max_length: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("statement"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The message shown to the user in their wallet before signing, which MUST be of the format 'Prove control of ${address} to link it to ${did}', where ${address} is the linked Ethereum address in 0x-prefixed, checksummed hex format, and ${did} is the DID of the user.",
                                    ),
                                ),
                                min_length: Some(78usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "URI of the application requesting the signature, e.g. 'https://wallet-link.stellz.club'",
                                    ),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("version"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Sign in With Ethereum message version"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod siwe_message_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type ChainId;
        type Version;
        type Address;
        type Uri;
        type Statement;
        type Nonce;
        type Domain;
        type IssuedAt;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ChainId = Unset;
        type Version = Unset;
        type Address = Unset;
        type Uri = Unset;
        type Statement = Unset;
        type Nonce = Unset;
        type Domain = Unset;
        type IssuedAt = Unset;
    }
    ///State transition - sets the `chain_id` field to Set
    pub struct SetChainId<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetChainId<S> {}
    impl<S: State> State for SetChainId<S> {
        type ChainId = Set<members::chain_id>;
        type Version = S::Version;
        type Address = S::Address;
        type Uri = S::Uri;
        type Statement = S::Statement;
        type Nonce = S::Nonce;
        type Domain = S::Domain;
        type IssuedAt = S::IssuedAt;
    }
    ///State transition - sets the `version` field to Set
    pub struct SetVersion<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetVersion<S> {}
    impl<S: State> State for SetVersion<S> {
        type ChainId = S::ChainId;
        type Version = Set<members::version>;
        type Address = S::Address;
        type Uri = S::Uri;
        type Statement = S::Statement;
        type Nonce = S::Nonce;
        type Domain = S::Domain;
        type IssuedAt = S::IssuedAt;
    }
    ///State transition - sets the `address` field to Set
    pub struct SetAddress<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAddress<S> {}
    impl<S: State> State for SetAddress<S> {
        type ChainId = S::ChainId;
        type Version = S::Version;
        type Address = Set<members::address>;
        type Uri = S::Uri;
        type Statement = S::Statement;
        type Nonce = S::Nonce;
        type Domain = S::Domain;
        type IssuedAt = S::IssuedAt;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type ChainId = S::ChainId;
        type Version = S::Version;
        type Address = S::Address;
        type Uri = Set<members::uri>;
        type Statement = S::Statement;
        type Nonce = S::Nonce;
        type Domain = S::Domain;
        type IssuedAt = S::IssuedAt;
    }
    ///State transition - sets the `statement` field to Set
    pub struct SetStatement<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetStatement<S> {}
    impl<S: State> State for SetStatement<S> {
        type ChainId = S::ChainId;
        type Version = S::Version;
        type Address = S::Address;
        type Uri = S::Uri;
        type Statement = Set<members::statement>;
        type Nonce = S::Nonce;
        type Domain = S::Domain;
        type IssuedAt = S::IssuedAt;
    }
    ///State transition - sets the `nonce` field to Set
    pub struct SetNonce<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetNonce<S> {}
    impl<S: State> State for SetNonce<S> {
        type ChainId = S::ChainId;
        type Version = S::Version;
        type Address = S::Address;
        type Uri = S::Uri;
        type Statement = S::Statement;
        type Nonce = Set<members::nonce>;
        type Domain = S::Domain;
        type IssuedAt = S::IssuedAt;
    }
    ///State transition - sets the `domain` field to Set
    pub struct SetDomain<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDomain<S> {}
    impl<S: State> State for SetDomain<S> {
        type ChainId = S::ChainId;
        type Version = S::Version;
        type Address = S::Address;
        type Uri = S::Uri;
        type Statement = S::Statement;
        type Nonce = S::Nonce;
        type Domain = Set<members::domain>;
        type IssuedAt = S::IssuedAt;
    }
    ///State transition - sets the `issued_at` field to Set
    pub struct SetIssuedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetIssuedAt<S> {}
    impl<S: State> State for SetIssuedAt<S> {
        type ChainId = S::ChainId;
        type Version = S::Version;
        type Address = S::Address;
        type Uri = S::Uri;
        type Statement = S::Statement;
        type Nonce = S::Nonce;
        type Domain = S::Domain;
        type IssuedAt = Set<members::issued_at>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `chain_id` field
        pub struct chain_id(());
        ///Marker type for the `version` field
        pub struct version(());
        ///Marker type for the `address` field
        pub struct address(());
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `statement` field
        pub struct statement(());
        ///Marker type for the `nonce` field
        pub struct nonce(());
        ///Marker type for the `domain` field
        pub struct domain(());
        ///Marker type for the `issued_at` field
        pub struct issued_at(());
    }
}

/// Builder for constructing an instance of this type
pub struct SiweMessageBuilder<'a, S: siwe_message_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<CowStr<'a>>,
        Option<i64>,
        Option<CowStr<'a>>,
        Option<Datetime>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<UriValue<'a>>,
        Option<CowStr<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> SiweMessage<'a> {
    /// Create a new builder for this type
    pub fn new() -> SiweMessageBuilder<'a, siwe_message_state::Empty> {
        SiweMessageBuilder::new()
    }
}

impl<'a> SiweMessageBuilder<'a, siwe_message_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SiweMessageBuilder<'a, S>
where
    S: siwe_message_state::State,
    S::Address: siwe_message_state::IsUnset,
{
    /// Set the `address` field (required)
    pub fn address(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SiweMessageBuilder<'a, siwe_message_state::SetAddress<S>> {
        self._fields.0 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SiweMessageBuilder<'a, S>
where
    S: siwe_message_state::State,
    S::ChainId: siwe_message_state::IsUnset,
{
    /// Set the `chainId` field (required)
    pub fn chain_id(
        mut self,
        value: impl Into<i64>,
    ) -> SiweMessageBuilder<'a, siwe_message_state::SetChainId<S>> {
        self._fields.1 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SiweMessageBuilder<'a, S>
where
    S: siwe_message_state::State,
    S::Domain: siwe_message_state::IsUnset,
{
    /// Set the `domain` field (required)
    pub fn domain(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SiweMessageBuilder<'a, siwe_message_state::SetDomain<S>> {
        self._fields.2 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SiweMessageBuilder<'a, S>
where
    S: siwe_message_state::State,
    S::IssuedAt: siwe_message_state::IsUnset,
{
    /// Set the `issuedAt` field (required)
    pub fn issued_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> SiweMessageBuilder<'a, siwe_message_state::SetIssuedAt<S>> {
        self._fields.3 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SiweMessageBuilder<'a, S>
where
    S: siwe_message_state::State,
    S::Nonce: siwe_message_state::IsUnset,
{
    /// Set the `nonce` field (required)
    pub fn nonce(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SiweMessageBuilder<'a, siwe_message_state::SetNonce<S>> {
        self._fields.4 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SiweMessageBuilder<'a, S>
where
    S: siwe_message_state::State,
    S::Statement: siwe_message_state::IsUnset,
{
    /// Set the `statement` field (required)
    pub fn statement(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SiweMessageBuilder<'a, siwe_message_state::SetStatement<S>> {
        self._fields.5 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SiweMessageBuilder<'a, S>
where
    S: siwe_message_state::State,
    S::Uri: siwe_message_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<UriValue<'a>>,
    ) -> SiweMessageBuilder<'a, siwe_message_state::SetUri<S>> {
        self._fields.6 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SiweMessageBuilder<'a, S>
where
    S: siwe_message_state::State,
    S::Version: siwe_message_state::IsUnset,
{
    /// Set the `version` field (required)
    pub fn version(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SiweMessageBuilder<'a, siwe_message_state::SetVersion<S>> {
        self._fields.7 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SiweMessageBuilder<'a, S>
where
    S: siwe_message_state::State,
    S::ChainId: siwe_message_state::IsSet,
    S::Version: siwe_message_state::IsSet,
    S::Address: siwe_message_state::IsSet,
    S::Uri: siwe_message_state::IsSet,
    S::Statement: siwe_message_state::IsSet,
    S::Nonce: siwe_message_state::IsSet,
    S::Domain: siwe_message_state::IsSet,
    S::IssuedAt: siwe_message_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SiweMessage<'a> {
        SiweMessage {
            address: self._fields.0.unwrap(),
            chain_id: self._fields.1.unwrap(),
            domain: self._fields.2.unwrap(),
            issued_at: self._fields.3.unwrap(),
            nonce: self._fields.4.unwrap(),
            statement: self._fields.5.unwrap(),
            uri: self._fields.6.unwrap(),
            version: self._fields.7.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SiweMessage<'a> {
        SiweMessage {
            address: self._fields.0.unwrap(),
            chain_id: self._fields.1.unwrap(),
            domain: self._fields.2.unwrap(),
            issued_at: self._fields.3.unwrap(),
            nonce: self._fields.4.unwrap(),
            statement: self._fields.5.unwrap(),
            uri: self._fields.6.unwrap(),
            version: self._fields.7.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}