EscrowSdk

Struct EscrowSdk 

Source
pub struct EscrowSdk;
Expand description

SDK for interacting with the Escrow program

Implementations§

Source§

impl EscrowSdk

Source

pub fn program_id() -> Pubkey

Get the program ID

Source

pub fn bank_pda() -> (Pubkey, u8)

Get the bank PDA

Source

pub fn config_pda() -> (Pubkey, u8)

Get the config PDA

Source

pub fn escrow_pda(mint: Pubkey) -> (Pubkey, u8)

Get an escrow PDA for a specific mint

Source

pub fn payment_pda(payment_uid: &str, bank: Pubkey) -> (Pubkey, u8)

Get a payment PDA for a specific payment UID

Source

pub fn sol_storage_pda( mint: Pubkey, bank: Pubkey, escrow: Pubkey, ) -> (Pubkey, u8)

Get a SOL storage PDA for a specific escrow

Source

pub fn associated_token_account(wallet: Pubkey, mint: Pubkey) -> Pubkey

Get the associated token account for a wallet and mint

Source

pub fn escrow_token_account(mint: Pubkey) -> Pubkey

Get the associated token account for an escrow

Source

pub fn initialize(signer: Pubkey, fee_bps: Option<u16>) -> Instruction

Create an initialize instruction

Source

pub fn open_escrow( signer: Pubkey, payer: Pubkey, mint: Pubkey, min_payment_amount: u64, max_payment_amount: u64, fee_bps: u16, ) -> Instruction

Create an open escrow instruction signer: bank authority payer: funder mint: token mint min_payment_amount: minimum payment amount max_payment_amount: maximum payment amount fee_bps: fee basis points

Source

pub fn fund_payment( buyer: Pubkey, buyer_tokens: Option<Pubkey>, seller: Pubkey, mint: Pubkey, amount: u64, ttl_seconds: i64, reference: Option<Pubkey>, payment_uid: &str, order_num: &str, ) -> Instruction

Create a fund payment instruction (supports both SOL and SPL tokens) For SOL: mint should be Pubkey::default() For SPL tokens: mint should be the actual token mint

Source

pub fn release_payment( caller: Pubkey, seller_tokens: Option<Pubkey>, seller: Option<Pubkey>, mint: Pubkey, payment_uid: &str, ) -> Instruction

Create a release payment instruction (supports both SOL and SPL tokens) For SOL: mint should be Pubkey::default() For SPL tokens: mint should be the actual token mint

Source

pub fn refund_payment( caller: Pubkey, buyer_tokens: Option<Pubkey>, mint: Pubkey, payment_uid: &str, ) -> Instruction

Create a refund payment instruction (supports both SOL and SPL tokens) For SOL: mint should be Pubkey::default() For SPL tokens: mint should be the actual token mint

Source

pub fn close_payment( buyer: Pubkey, mint: Pubkey, payment_uid: &str, ) -> Instruction

Create a close payment instruction

Source

pub fn withdraw_fees( authority: Pubkey, beneficiary: Pubkey, mint: Pubkey, amount: u64, ) -> Instruction

Create a withdraw fees instruction (supports both SOL and SPL tokens) For SOL: mint should be Pubkey::default() For SPL tokens: mint should be the actual token mint

Source

pub fn confirm_fulfillment( buyer: Pubkey, mint: Pubkey, payment_uid: &str, ) -> Instruction

Source

pub fn dispute_payment( disputer: Pubkey, mint: Pubkey, payment_uid: &str, reason: u8, description: Option<&str>, ) -> Instruction

Create a dispute payment instruction

Source

pub fn arbitrate_payment( arbitrator: Pubkey, mint: Pubkey, payment_uid: &str, decision: u8, buyer_amount: u64, seller_amount: u64, reason: u8, description: Option<&str>, ) -> Instruction

Create an arbitrate payment instruction

Source

pub fn resolve_dispute( resolver: Pubkey, buyer_ata: Option<Pubkey>, seller_ata: Option<Pubkey>, arbitrator: Pubkey, mint: Pubkey, payment_uid: &str, decision: u8, buyer_amount: u64, seller_amount: u64, ) -> Instruction

Create a resolve dispute instruction (supports both SOL and SPL tokens) For SOL: mint should be Pubkey::default() For SPL tokens: mint should be the actual token mint

Source

pub fn extend_payment_ttl( caller: Pubkey, mint: Pubkey, payment_uid: &str, additional_seconds: i64, ) -> Instruction

Create an extend payment TTL instruction

Source

pub fn close_escrow( authority: Pubkey, recipient: Pubkey, mint: Pubkey, ) -> Instruction

Create a close escrow instruction

Source

pub fn update_escrow_settings( authority: Pubkey, escrow: Pubkey, fee_bps: u16, min_payment_amount: u64, max_payment_amount: u64, ) -> Instruction

Create an update escrow settings instruction

Source

pub fn pause_escrow(authority: Pubkey, mint: Pubkey, pause: bool) -> Instruction

Create a pause escrow instruction

Source

pub fn update_authority( current_authority: Pubkey, new_authority: Pubkey, ) -> Instruction

Create an update authority instruction

Source

pub fn appeal_arbitration( appellant: Pubkey, mint: Pubkey, payment_uid: &str, reason: u8, description: Option<&str>, ) -> Instruction

Create an appeal arbitration instruction

Source

pub fn validate_payment_for_funding( payment: &Payment, ) -> Result<(), EscrowError>

Validate that a payment is in the correct state for funding

Source

pub fn validate_payment_for_release( payment: &Payment, ) -> Result<(), EscrowError>

Validate that a payment is in the correct state for release

Source

pub fn validate_payment_for_refund(payment: &Payment) -> Result<(), EscrowError>

Validate that a payment is in the correct state for refund

Source

pub fn validate_payment_for_dispute( payment: &Payment, ) -> Result<(), EscrowError>

Validate that a payment is in the correct state for dispute

Source

pub fn validate_payment_for_arbitration( payment: &Payment, ) -> Result<(), EscrowError>

Validate that a payment is in the correct state for arbitration

Source

pub fn validate_payment_for_resolution( payment: &Payment, ) -> Result<(), EscrowError>

Validate that a payment is in the correct state for resolution

Source

pub fn calculate_fee(amount: u64, fee_bps: u16) -> u64

Calculate fee amount based on payment amount and fee basis points

Source

pub fn calculate_payout(amount: u64, fee_bps: u16) -> u64

Calculate payout amount after deducting fees

Source

pub fn is_payment_expired(payment: &Payment) -> bool

Check if a payment has expired

Source

pub fn get_payment_state_string(state: u8) -> &'static str

Get payment state as string

Source

pub fn get_escrow_state_string(paused: u8) -> &'static str

Get escrow state as string

Source

pub fn get_payment_accounts( buyer: Pubkey, seller: Pubkey, mint: Pubkey, payment_uid: &str, ) -> PaymentAccounts

Get all required accounts for a payment operation

Source

pub fn get_escrow_accounts(mint: Pubkey) -> EscrowAccounts

Get all required accounts for an escrow operation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.