Enum Account

Source
pub enum Account {
    KeyPair(SingleAccount),
    Multisig(MultisigAccount),
}
Expand description

Represents either a single-signature or multisig account.

This is the main account type used for interacting with the Stellar network. It provides methods for signing transactions, configuring account settings, and managing sequence numbers.

Variants§

§

KeyPair(SingleAccount)

Single-signature account with one key pair

§

Multisig(MultisigAccount)

Multi-signature account

Implementations§

Source§

impl Account

Source

pub fn single(signer: Signer) -> Self

Creates a new single-signature Account instance with the provided signer.

§Parameters
  • signer - The signer for this account
§Returns

A new Account instance with the KeyPair variant

Source

pub fn multisig(account_id: AccountId, signers: Vec<Signer>) -> Self

Creates a new multisig Account instance with the provided account ID and signers.

§Parameters
  • account_id - The identifier for this account
  • signers - A vector of signers for this multi-signature account
§Returns

A new Account instance with the Multisig variant

Source

pub fn account_id(&self) -> AccountId

Returns the account’s identifier.

Source

pub fn signers(&self) -> &[Signer]

Returns a reference to the account’s signers.

Source

pub async fn load(&self, env: &Env) -> Result<AccountEntry, SorobanHelperError>

Loads the account information from the network.

§Parameters
  • env - The environment to use for loading the account
§Returns
  • AccountEntry - The account information
Source

pub async fn get_sequence( &self, env: &Env, ) -> Result<AccountSequence, SorobanHelperError>

Gets the current sequence number for the account.

§Parameters
  • env - The environment to use for fetching the sequence number
§Returns

The current sequence number wrapped in AccountSequence

Source

pub async fn next_sequence( &self, env: &Env, ) -> Result<AccountSequence, SorobanHelperError>

Retrieves the next available sequence number.

This is useful when preparing a new transaction.

§Parameters
  • env - The environment to use for fetching the sequence number
§Returns

The next sequence number (current + 1) wrapped in AccountSequence

Source

pub fn add_guard(&mut self, guard: Guard)

Adds a guard to the account.

Guards are used to control and limit operations that can be performed with this account. Multiple guards can be added to an account, and all guards must pass for operations to proceed.

§Parameters
  • guard - The guard to add to the account
Source

pub fn check_guards(&self, tx: &Transaction) -> Result<bool, SorobanHelperError>

Checks if all guards associated with this account are satisfied.

This method evaluates all guards attached to the account and returns true only if all of them pass their respective checks.

§Returns
  • false - If any guard fails its check
Source

pub fn update_guards( &mut self, tx: &Transaction, ) -> Result<(), SorobanHelperError>

Updates the state of all guards after an operation has been performed.

This method should be called after a successful operation to update the internal state of all guards (e.g., decrement remaining allowed calls).

Source

pub fn sign_transaction( &mut self, tx: &Transaction, network_id: &Hash, ) -> Result<TransactionEnvelope, SorobanHelperError>

Signs a transaction, ensuring the account still has authorized calls.

Decrements the authorized call counter when successful.

§Parameters
  • tx - The transaction to sign
  • network_id - The network ID hash
§Returns

A signed transaction envelope

Source

pub fn sign_transaction_envelope( &mut self, tx_envelope: &TransactionEnvelope, network_id: &Hash, ) -> Result<TransactionEnvelope, SorobanHelperError>

Signs a transaction envelope by appending new signatures.

§Parameters
  • tx_envelope - The transaction envelope to sign
  • network_id - The network ID hash
§Returns

A transaction envelope with the new signatures appended

Source

pub async fn configure( self, env: &Env, config: AccountConfig, ) -> Result<TransactionEnvelope, SorobanHelperError>

Configures the account by building and signing a transaction that sets options.

This can be used to add signers, set thresholds, and modify other account settings.

§Parameters
  • env - The environment to use for transaction building
  • config - The account configuration to apply
§Returns

A signed transaction envelope containing the set options operations

Source

pub fn sign_transaction_unsafe( &self, tx: &Transaction, network_id: &Hash, ) -> Result<TransactionEnvelope, SorobanHelperError>

Signs a transaction without checking or decrementing the authorized_calls counter.

This method bypasses authorization checks and should be used with caution.

§Parameters
  • tx - The transaction to sign
  • network_id - The network ID hash
§Returns

A signed transaction envelope

Source

pub fn sign_with_signers( tx: &Transaction, network_id: &Hash, signers: &[Signer], ) -> Result<VecM<DecoratedSignature, 20>, SorobanHelperError>

Sign a transaction using the account’s signers.

§Parameters
  • tx - The transaction to sign
  • network_id - The network ID hash
  • signers - The signers to use
§Returns

A vector of decorated signatures

Trait Implementations§

Source§

impl Clone for Account

Source§

fn clone(&self) -> Account

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Display for Account

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<MultisigAccount> for Account

Source§

fn from(account: MultisigAccount) -> Self

Converts to this type from the input type.
Source§

impl From<Signer> for Account

Source§

fn from(signer: Signer) -> Self

Converts to this type from the input type.
Source§

impl From<SingleAccount> for Account

Source§

fn from(account: SingleAccount) -> Self

Converts to this type from the input type.

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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,

Source§

impl<T> MaybeSend for T
where T: Send,