ows_pay/wallet.rs
1use crate::error::PayError;
2use ows_core::ChainType;
3
4/// An account on any chain.
5#[derive(Debug, Clone)]
6pub struct Account {
7 /// Address in the chain's native format (e.g. "0x..." for EVM, base58 for Solana).
8 pub address: String,
9}
10
11/// Trait abstracting wallet access for payment operations.
12///
13/// Each method takes a CAIP-2 network identifier (e.g. `"eip155:8453"`,
14/// `"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"`) to identify the chain.
15///
16/// The private key NEVER leaves the implementation — all signing happens
17/// inside the wallet.
18pub trait WalletAccess: Send + Sync {
19 /// Chain families this wallet can operate on.
20 fn supported_chains(&self) -> Vec<ChainType>;
21
22 /// Get the account for a CAIP-2 network.
23 fn account(&self, network: &str) -> Result<Account, PayError>;
24
25 /// Sign a payment payload for the given scheme and network.
26 ///
27 /// The payload format depends on the scheme:
28 /// - `"exact"`: EIP-712 typed data JSON (EVM chains)
29 ///
30 /// Returns the signature as a hex string with `0x` prefix.
31 fn sign_payload(&self, scheme: &str, network: &str, payload: &str) -> Result<String, PayError>;
32}