#[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> {
#[serde(with = "jacquard_common::serde_bytes_helper")]
pub address: Bytes,
#[serde(skip_serializing_if = "Option::is_none")]
pub also_on: Option<Vec<i64>>,
#[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> {
#[serde(borrow)]
pub address: CowStr<'a>,
pub chain_id: i64,
#[serde(borrow)]
pub domain: CowStr<'a>,
pub issued_at: Datetime,
#[serde(borrow)]
pub nonce: CowStr<'a>,
#[serde(borrow)]
pub statement: CowStr<'a>,
#[serde(borrow)]
pub uri: UriValue<'a>,
#[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 {}
}
pub trait State: sealed::Sealed {
type Address;
type Signature;
type Siwe;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Address = Unset;
type Signature = Unset;
type Siwe = Unset;
}
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;
}
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;
}
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>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct address(());
pub struct signature(());
pub struct siwe(());
}
}
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> {
pub fn new() -> AddressControlBuilder<'a, address_control_state::Empty> {
AddressControlBuilder::new()
}
}
impl<'a> AddressControlBuilder<'a, address_control_state::Empty> {
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,
{
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> {
pub fn also_on(mut self, value: impl Into<Option<Vec<i64>>>) -> Self {
self._fields.1 = value.into();
self
}
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,
{
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,
{
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,
{
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(),
}
}
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 {}
}
pub trait State: sealed::Sealed {
type ChainId;
type Uri;
type Statement;
type Nonce;
type Domain;
type IssuedAt;
type Version;
type Address;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ChainId = Unset;
type Uri = Unset;
type Statement = Unset;
type Nonce = Unset;
type Domain = Unset;
type IssuedAt = Unset;
type Version = Unset;
type Address = Unset;
}
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 Uri = S::Uri;
type Statement = S::Statement;
type Nonce = S::Nonce;
type Domain = S::Domain;
type IssuedAt = S::IssuedAt;
type Version = S::Version;
type Address = S::Address;
}
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 Uri = Set<members::uri>;
type Statement = S::Statement;
type Nonce = S::Nonce;
type Domain = S::Domain;
type IssuedAt = S::IssuedAt;
type Version = S::Version;
type Address = S::Address;
}
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 Uri = S::Uri;
type Statement = Set<members::statement>;
type Nonce = S::Nonce;
type Domain = S::Domain;
type IssuedAt = S::IssuedAt;
type Version = S::Version;
type Address = S::Address;
}
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 Uri = S::Uri;
type Statement = S::Statement;
type Nonce = Set<members::nonce>;
type Domain = S::Domain;
type IssuedAt = S::IssuedAt;
type Version = S::Version;
type Address = S::Address;
}
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 Uri = S::Uri;
type Statement = S::Statement;
type Nonce = S::Nonce;
type Domain = Set<members::domain>;
type IssuedAt = S::IssuedAt;
type Version = S::Version;
type Address = S::Address;
}
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 Uri = S::Uri;
type Statement = S::Statement;
type Nonce = S::Nonce;
type Domain = S::Domain;
type IssuedAt = Set<members::issued_at>;
type Version = S::Version;
type Address = S::Address;
}
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 Uri = S::Uri;
type Statement = S::Statement;
type Nonce = S::Nonce;
type Domain = S::Domain;
type IssuedAt = S::IssuedAt;
type Version = Set<members::version>;
type Address = S::Address;
}
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 Uri = S::Uri;
type Statement = S::Statement;
type Nonce = S::Nonce;
type Domain = S::Domain;
type IssuedAt = S::IssuedAt;
type Version = S::Version;
type Address = Set<members::address>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct chain_id(());
pub struct uri(());
pub struct statement(());
pub struct nonce(());
pub struct domain(());
pub struct issued_at(());
pub struct version(());
pub struct address(());
}
}
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> {
pub fn new() -> SiweMessageBuilder<'a, siwe_message_state::Empty> {
SiweMessageBuilder::new()
}
}
impl<'a> SiweMessageBuilder<'a, siwe_message_state::Empty> {
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,
{
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,
{
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,
{
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,
{
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,
{
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,
{
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,
{
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,
{
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::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,
S::Version: siwe_message_state::IsSet,
S::Address: siwe_message_state::IsSet,
{
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(),
}
}
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),
}
}
}