pub struct SimpleTallyClient {
pub rpc_client: RpcClient,
pub program_id: Pubkey,
}Expand description
Simple Tally client for basic operations
Fields§
§rpc_client: RpcClientRPC client for queries
program_id: PubkeyProgram ID
Implementations§
Source§impl SimpleTallyClient
impl SimpleTallyClient
Sourcepub fn new_with_program_id(cluster_url: &str, program_id: &str) -> Result<Self>
pub fn new_with_program_id(cluster_url: &str, program_id: &str) -> Result<Self>
Sourcepub const fn program_id(&self) -> Pubkey
pub const fn program_id(&self) -> Pubkey
Get the program ID
Sourcepub fn merchant_address(&self, authority: &Pubkey) -> Pubkey
pub fn merchant_address(&self, authority: &Pubkey) -> Pubkey
Compute merchant PDA using this client’s program ID
Sourcepub fn account_exists(&self, address: &Pubkey) -> Result<bool>
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
Sourcepub fn get_merchant(
&self,
merchant_address: &Pubkey,
) -> Result<Option<Merchant>>
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
Sourcepub fn get_plan(&self, plan_address: &Pubkey) -> Result<Option<Plan>>
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
Sourcepub fn list_plans(
&self,
merchant_address: &Pubkey,
) -> Result<Vec<(Pubkey, Plan)>>
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
Sourcepub fn list_subscriptions(
&self,
plan_address: &Pubkey,
) -> Result<Vec<(Pubkey, Subscription)>>
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
Sourcepub fn submit_transaction<T: Signer>(
&self,
transaction: &mut Transaction,
signers: &[&T],
) -> Result<String>
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
Sourcepub fn submit_instruction<T: Signer>(
&self,
instruction: Instruction,
signers: &[&T],
) -> Result<String>
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
Sourcepub fn get_latest_blockhash(&self) -> Result<Hash>
pub fn get_latest_blockhash(&self) -> Result<Hash>
Sourcepub fn get_latest_blockhash_with_commitment(
&self,
commitment: CommitmentConfig,
) -> Result<(Hash, u64)>
pub fn get_latest_blockhash_with_commitment( &self, commitment: CommitmentConfig, ) -> Result<(Hash, u64)>
Sourcepub fn create_merchant<T: Signer>(
&self,
authority: &T,
usdc_mint: &Pubkey,
treasury_ata: &Pubkey,
platform_fee_bps: u16,
) -> Result<(Pubkey, String)>
pub fn create_merchant<T: Signer>( &self, authority: &T, usdc_mint: &Pubkey, treasury_ata: &Pubkey, platform_fee_bps: u16, ) -> Result<(Pubkey, String)>
Sourcepub fn initialize_merchant_with_treasury<T: Signer>(
&self,
authority: &T,
usdc_mint: &Pubkey,
treasury_ata: &Pubkey,
platform_fee_bps: u16,
) -> Result<(Pubkey, String, bool)>
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 ATAusdc_mint- The USDC mint addresstreasury_ata- The expected treasury ATA addressplatform_fee_bps- Platform fee in basis points
§Returns
Ok((merchant_pda, signature, created_ata))- The merchant PDA, transaction signature, and whether ATA was createdErr(TallyError)- If merchant already exists or other validation/execution failures
§Errors
Returns an error if merchant already exists, validation fails, or transaction execution fails
Sourcepub fn create_plan<T: Signer>(
&self,
authority: &T,
plan_args: CreatePlanArgs,
) -> Result<(Pubkey, String)>
pub fn create_plan<T: Signer>( &self, authority: &T, plan_args: CreatePlanArgs, ) -> Result<(Pubkey, String)>
Sourcepub fn withdraw_platform_fees<T: Signer>(
&self,
platform_authority: &T,
platform_treasury_ata: &Pubkey,
destination_ata: &Pubkey,
usdc_mint: &Pubkey,
amount: u64,
) -> Result<String>
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>
Sourcepub fn get_confirmed_signatures_for_address(
&self,
address: &Pubkey,
config: Option<GetConfirmedSignaturesForAddress2Config>,
) -> Result<Vec<RpcConfirmedTransactionStatusWithSignature>>
pub fn get_confirmed_signatures_for_address( &self, address: &Pubkey, config: Option<GetConfirmedSignaturesForAddress2Config>, ) -> Result<Vec<RpcConfirmedTransactionStatusWithSignature>>
Sourcepub fn get_transaction(&self, signature: &Signature) -> Result<Value>
pub fn get_transaction(&self, signature: &Signature) -> Result<Value>
Sourcepub fn send_and_confirm_transaction(
&self,
transaction: &VersionedTransaction,
) -> Result<Signature>
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
Sourcepub fn get_health(&self) -> Result<()>
pub fn get_health(&self) -> Result<()>
Auto Trait Implementations§
impl !Freeze for SimpleTallyClient
impl !RefUnwindSafe for SimpleTallyClient
impl Send for SimpleTallyClient
impl Sync for SimpleTallyClient
impl Unpin for SimpleTallyClient
impl !UnwindSafe for SimpleTallyClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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