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
impl Account
Sourcepub fn account_id(&self) -> AccountId
pub fn account_id(&self) -> AccountId
Returns the account’s identifier.
Sourcepub async fn load(&self, env: &Env) -> Result<AccountEntry, SorobanHelperError>
pub async fn load(&self, env: &Env) -> Result<AccountEntry, SorobanHelperError>
Sourcepub async fn get_sequence(
&self,
env: &Env,
) -> Result<AccountSequence, SorobanHelperError>
pub async fn get_sequence( &self, env: &Env, ) -> Result<AccountSequence, SorobanHelperError>
Sourcepub async fn next_sequence(
&self,
env: &Env,
) -> Result<AccountSequence, SorobanHelperError>
pub async fn next_sequence( &self, env: &Env, ) -> Result<AccountSequence, SorobanHelperError>
Sourcepub fn add_guard(&mut self, guard: Guard)
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
Sourcepub fn check_guards(&self, tx: &Transaction) -> Result<bool, SorobanHelperError>
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
Sourcepub fn update_guards(
&mut self,
tx: &Transaction,
) -> Result<(), SorobanHelperError>
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).
Sourcepub fn sign_transaction(
&mut self,
tx: &Transaction,
network_id: &Hash,
) -> Result<TransactionEnvelope, SorobanHelperError>
pub fn sign_transaction( &mut self, tx: &Transaction, network_id: &Hash, ) -> Result<TransactionEnvelope, SorobanHelperError>
Sourcepub fn sign_transaction_envelope(
&mut self,
tx_envelope: &TransactionEnvelope,
network_id: &Hash,
) -> Result<TransactionEnvelope, SorobanHelperError>
pub fn sign_transaction_envelope( &mut self, tx_envelope: &TransactionEnvelope, network_id: &Hash, ) -> Result<TransactionEnvelope, SorobanHelperError>
Sourcepub async fn configure(
self,
env: &Env,
config: AccountConfig,
) -> Result<TransactionEnvelope, SorobanHelperError>
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 buildingconfig
- The account configuration to apply
§Returns
A signed transaction envelope containing the set options operations
Sourcepub fn sign_transaction_unsafe(
&self,
tx: &Transaction,
network_id: &Hash,
) -> Result<TransactionEnvelope, SorobanHelperError>
pub fn sign_transaction_unsafe( &self, tx: &Transaction, network_id: &Hash, ) -> Result<TransactionEnvelope, SorobanHelperError>
Sourcepub fn sign_with_signers(
tx: &Transaction,
network_id: &Hash,
signers: &[Signer],
) -> Result<VecM<DecoratedSignature, 20>, SorobanHelperError>
pub fn sign_with_signers( tx: &Transaction, network_id: &Hash, signers: &[Signer], ) -> Result<VecM<DecoratedSignature, 20>, SorobanHelperError>
Trait Implementations§
Source§impl From<MultisigAccount> for Account
impl From<MultisigAccount> for Account
Source§fn from(account: MultisigAccount) -> Self
fn from(account: MultisigAccount) -> Self
Source§impl From<SingleAccount> for Account
impl From<SingleAccount> for Account
Source§fn from(account: SingleAccount) -> Self
fn from(account: SingleAccount) -> Self
Auto Trait Implementations§
impl Freeze for Account
impl RefUnwindSafe for Account
impl Send for Account
impl Sync for Account
impl Unpin for Account
impl UnwindSafe for Account
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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