Skip to main content

winterwallet_client/
lib.rs

1//! Off-chain client for the WinterWallet program.
2//!
3//! Provides instruction builders, PDA derivation, preimage construction,
4//! CPI payload encoding, and on-chain state deserialization.
5//!
6//! # Example: Build an Advance(Withdraw) plan
7//!
8//! ```ignore
9//! use winterwallet_client::*;
10//! use winterwallet_common::WINTERNITZ_SCALARS;
11//!
12//! // 1. Build a plan. It owns the payload + account order.
13//! let plan = AdvancePlan::withdraw(&wallet_pda, &receiver, lamports, &new_root)?;
14//!
15//! // 2. Compute preimage and sign.
16//! let preimage = plan.preimage(&id, current_root);
17//! let sig = keypair.sign_and_increment::<WINTERNITZ_SCALARS>(&preimage);
18//!
19//! // 3. Build the Advance instruction.
20//! let ix = plan.instruction(sig.as_bytes().try_into().unwrap());
21//! ```
22
23mod error;
24pub mod instruction;
25mod pda;
26mod plan;
27mod preimage;
28mod state;
29pub mod transaction;
30mod wallet;
31
32pub use error::Error;
33pub use instruction::{AdvancePayload, advance, close, encode_advance, initialize, withdraw};
34pub use pda::{find_wallet_address, wallet_id_from_mnemonic};
35pub use plan::AdvancePlan;
36pub use preimage::{advance_preimage, initialize_preimage};
37pub use state::WinterWalletAccount;
38pub use transaction::{
39    AccountEntry, DEFAULT_ADVANCE_COMPUTE_UNIT_LIMIT, LEGACY_TRANSACTION_SIZE_LIMIT,
40    estimate_legacy_transaction_size, set_compute_unit_limit, set_compute_unit_price, upsert,
41    validate_legacy_transaction_size, validate_payer_only_signers, with_compute_budget,
42};
43pub use wallet::{
44    AdvancePersistence, AdvanceSender, PersistedAdvance, SignedAdvance, SigningPosition,
45    UnsignedAdvance, WinterWallet, token_transfer,
46};
47
48// Re-export commonly used items from winterwallet-common for convenience.
49pub use winterwallet_common::{
50    ID, MAX_CPI_INSTRUCTION_ACCOUNTS, MAX_PASSTHROUGH_ACCOUNTS, SIGNATURE_LEN, TOTAL_SCALARS,
51    WALLET_ACCOUNT_LEN, WINTERNITZ_SCALARS, WINTERWALLET_ADVANCE, WINTERWALLET_INITIALIZE,
52    WINTERWALLET_SEED, discriminator,
53};