SimpleTallyClient

Struct SimpleTallyClient 

Source
pub struct SimpleTallyClient {
    pub rpc_client: RpcClient,
    pub program_id: Pubkey,
}
Expand description

Simple Tally client for basic operations

Fields§

§rpc_client: RpcClient

RPC client for queries

§program_id: Pubkey

Program ID

Implementations§

Source§

impl SimpleTallyClient

Source

pub fn new(cluster_url: &str) -> Result<Self>

Create a new simple Tally client

§Arguments
  • cluster_url - RPC endpoint URL
§Returns
  • Ok(SimpleTallyClient) - The client instance
§Errors

Returns an error if the program ID cannot be parsed or client creation fails

Source

pub fn new_with_program_id(cluster_url: &str, program_id: &str) -> Result<Self>

Create a new simple Tally client with custom program ID

§Arguments
  • cluster_url - RPC endpoint URL
  • program_id - Custom program ID to use
§Returns
  • Ok(SimpleTallyClient) - The client instance
§Errors

Returns an error if the program ID cannot be parsed or client creation fails

Source

pub const fn program_id(&self) -> Pubkey

Get the program ID

Source

pub fn merchant_address(&self, authority: &Pubkey) -> Pubkey

Compute merchant PDA using this client’s program ID

Source

pub const fn rpc(&self) -> &RpcClient

Get the RPC client

Source

pub fn account_exists(&self, address: &Pubkey) -> Result<bool>

Check if an account exists

§Errors

Returns an error if the RPC call to check account existence fails

Source

pub fn get_merchant( &self, merchant_address: &Pubkey, ) -> Result<Option<Merchant>>

Get merchant account data

§Errors

Returns an error if the account doesn’t exist or can’t be deserialized

Source

pub fn get_plan(&self, plan_address: &Pubkey) -> Result<Option<Plan>>

Get plan account data

§Errors

Returns an error if the account doesn’t exist or can’t be deserialized

Source

pub fn list_plans( &self, merchant_address: &Pubkey, ) -> Result<Vec<(Pubkey, Plan)>>

List all plans for a merchant

§Errors

Returns an error if the RPC query fails or accounts can’t be deserialized

Source

pub fn list_subscriptions( &self, plan_address: &Pubkey, ) -> Result<Vec<(Pubkey, Subscription)>>

List all subscriptions for a plan

§Errors

Returns an error if the RPC query fails or accounts can’t be deserialized

Source

pub fn submit_transaction<T: Signer>( &self, transaction: &mut Transaction, signers: &[&T], ) -> Result<String>

Submit and confirm a transaction

§Errors

Returns an error if transaction submission or confirmation fails

Source

pub fn submit_instruction<T: Signer>( &self, instruction: Instruction, signers: &[&T], ) -> Result<String>

Submit instruction with automatic transaction handling

§Errors

Returns an error if transaction submission or confirmation fails

Source

pub fn get_latest_blockhash(&self) -> Result<Hash>

Get latest blockhash

§Errors

Returns an error if RPC call fails

Source

pub fn get_latest_blockhash_with_commitment( &self, commitment: CommitmentConfig, ) -> Result<(Hash, u64)>

Get latest blockhash with commitment

§Errors

Returns an error if RPC call fails

Source

pub fn create_merchant<T: Signer>( &self, authority: &T, usdc_mint: &Pubkey, treasury_ata: &Pubkey, platform_fee_bps: u16, ) -> Result<(Pubkey, String)>

High-level method to create a merchant account

§Errors

Returns an error if merchant creation fails

Source

pub fn initialize_merchant_with_treasury<T: Signer>( &self, authority: &T, usdc_mint: &Pubkey, treasury_ata: &Pubkey, platform_fee_bps: u16, ) -> Result<(Pubkey, String, bool)>

High-level method to initialize merchant with treasury management

This method handles both cases:

  • Treasury ATA exists + Merchant missing → Create merchant only
  • Treasury ATA missing + Merchant missing → Create both ATA and merchant
§Arguments
  • authority - The wallet that will own the merchant account and treasury ATA
  • usdc_mint - The USDC mint address
  • treasury_ata - The expected treasury ATA address
  • platform_fee_bps - Platform fee in basis points
§Returns
  • Ok((merchant_pda, signature, created_ata)) - The merchant PDA, transaction signature, and whether ATA was created
  • Err(TallyError) - If merchant already exists or other validation/execution failures
§Errors

Returns an error if merchant already exists, validation fails, or transaction execution fails

Source

pub fn create_plan<T: Signer>( &self, authority: &T, plan_args: CreatePlanArgs, ) -> Result<(Pubkey, String)>

High-level method to create a subscription plan

§Errors

Returns an error if plan creation fails

Source

pub fn withdraw_platform_fees<T: Signer>( &self, platform_authority: &T, platform_treasury_ata: &Pubkey, destination_ata: &Pubkey, usdc_mint: &Pubkey, amount: u64, ) -> Result<String>

High-level method to withdraw platform fees

§Errors

Returns an error if fee withdrawal fails

Source

pub fn get_confirmed_signatures_for_address( &self, address: &Pubkey, config: Option<GetConfirmedSignaturesForAddress2Config>, ) -> Result<Vec<RpcConfirmedTransactionStatusWithSignature>>

Get confirmed signatures for a program address

§Errors

Returns an error if RPC call fails

Source

pub fn get_transaction(&self, signature: &Signature) -> Result<Value>

Get transaction details

§Errors

Returns an error if RPC call fails or transaction not found

Source

pub fn get_transactions( &self, signatures: &[Signature], ) -> Result<Vec<Option<Value>>>

Get multiple transactions in batch

§Errors

Returns an error if any RPC calls fail

Source

pub fn send_and_confirm_transaction( &self, transaction: &VersionedTransaction, ) -> Result<Signature>

Submit and confirm a pre-signed transaction

§Errors

Returns an error if transaction submission or confirmation fails

Source

pub fn get_slot(&self) -> Result<u64>

Get current slot

§Errors

Returns an error if RPC call fails

Source

pub fn get_health(&self) -> Result<()>

Get health status

§Errors

Returns an error if RPC call fails

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,