pub struct Operations;Expand description
Factory for creating Soroban operations.
This struct provides methods to create operations for common Soroban tasks, such as uploading contract WASM, deploying contracts, and invoking contract functions. These operations can be added to transactions and submitted to the Stellar network.
Implementations§
Source§impl Operations
impl Operations
Sourcepub fn upload_wasm(wasm_bytes: Vec<u8>) -> Result<Operation, SorobanHelperError>
pub fn upload_wasm(wasm_bytes: Vec<u8>) -> Result<Operation, SorobanHelperError>
Creates an operation to upload contract WASM code to the Stellar network.
§Parameters
wasm_bytes- The raw WASM bytecode to upload
§Returns
An operation that can be added to a transaction to upload the WASM
§Errors
Returns SorobanHelperError::XdrEncodingFailed if the WASM bytes
cannot be encoded into the XDR format
Sourcepub fn create_contract(
contract_id_preimage: ContractIdPreimage,
wasm_hash: Hash,
constructor_args: Option<Vec<ScVal>>,
) -> Result<Operation, SorobanHelperError>
pub fn create_contract( contract_id_preimage: ContractIdPreimage, wasm_hash: Hash, constructor_args: Option<Vec<ScVal>>, ) -> Result<Operation, SorobanHelperError>
Creates an operation to deploy a contract to the Stellar network.
§Parameters
contract_id_preimage- The preimage used to derive the contract IDwasm_hash- The hash of the previously uploaded WASM codeconstructor_args- Optional arguments to pass to the contract constructor
§Returns
An operation that can be added to a transaction to deploy the contract
§Errors
Returns SorobanHelperError::XdrEncodingFailed if any of the arguments
cannot be encoded into the XDR format
Sourcepub fn invoke_contract(
contract_id: &Contract,
function_name: &str,
args: Vec<ScVal>,
) -> Result<Operation, SorobanHelperError>
pub fn invoke_contract( contract_id: &Contract, function_name: &str, args: Vec<ScVal>, ) -> Result<Operation, SorobanHelperError>
Creates an operation to invoke a function on a deployed contract.
§Parameters
contract_id- The ID of the deployed contractfunction_name- The name of the function to invokeargs- Arguments to pass to the function
§Returns
An operation that can be added to a transaction to invoke the contract function
§Errors
Returns:
SorobanHelperError::InvalidArgumentif the function name is invalidSorobanHelperError::XdrEncodingFailedif the arguments cannot be encoded
pub fn send_payment( to: AccountId, amount: i64, asset: Asset, ) -> Result<Operation, SorobanHelperError>
Auto Trait Implementations§
impl Freeze for Operations
impl RefUnwindSafe for Operations
impl Send for Operations
impl Sync for Operations
impl Unpin for Operations
impl UnwindSafe for Operations
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> 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