use alloy_primitives::{Address, address};
use r402_protocol::scheme::SchemeId;
#[cfg(feature = "client")]
pub mod client;
#[cfg(feature = "facilitator")]
pub mod facilitator;
pub mod payload;
#[cfg(feature = "server")]
pub mod server;
#[cfg(feature = "client")]
pub use client::{
Eip155UptoClient, Eip155UptoClientBuilder, Eip2612SigningParams, sign_eip2612_permit,
};
#[cfg(feature = "facilitator")]
pub use facilitator::Eip155UptoFacilitator;
pub use payload::*;
pub use crate::eip2612::{EIP2612_GAS_SPONSORING_KEY, Eip2612ParseError, Eip2612SignedPermit};
pub const X402_UPTO_PERMIT2_PROXY: Address = address!("0x4020A4f3b7b90ccA423B9fabCc0CE57C6C240002");
#[derive(Debug, Clone, Copy)]
pub struct Eip155Upto;
impl SchemeId for Eip155Upto {
fn namespace(&self) -> &'static str {
"eip155"
}
fn scheme(&self) -> &str {
UptoScheme.as_ref()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn scheme_id_namespace_and_name() {
assert_eq!(Eip155Upto.namespace(), "eip155");
assert_eq!(Eip155Upto.scheme(), "upto");
}
#[test]
fn proxy_address_is_canonical_x402_upto() {
assert_eq!(
X402_UPTO_PERMIT2_PROXY.to_checksum(None),
"0x4020A4f3b7b90ccA423B9fabCc0CE57C6C240002"
);
}
}