Struct FlowConnection

Source
pub struct FlowConnection<T> {
    pub client: AccessApiClient<T>,
}
Expand description

The FlowConnection object contains a single API connection. The network transport layer can be optionally substitued by implementing a new FlowConnection

Fields§

§client: AccessApiClient<T>

Implementations§

Source§

impl FlowConnection<Channel>

The default implementation of a FlowConnection, using tonic::transport::Channel

Source

pub async fn new( network_address: &str, ) -> Result<FlowConnection<Channel>, Box<dyn Error>>

Initializes a new connection and checks the availability of the node at the provided address

Source

pub async fn get_account( &mut self, account_address: &str, ) -> Result<AccountResponse, Box<dyn Error>>

get_account will return the flow::AccountResponse of account_address, else an error if it could not be accessed.

Source

pub async fn execute_script( &mut self, script: Vec<u8>, arguments: Vec<Vec<u8>>, block_height: Option<u64>, block_id: Option<Vec<u8>>, ) -> Result<ExecuteScriptResponse, Box<dyn Error>>

execute_script will attempt to run the provided script (as bytes) and return the flow::ExecuteScriptResponse or Error

Source

pub async fn send_transaction( &mut self, transaction: Option<Transaction>, ) -> Result<SendTransactionResponse, Box<dyn Error>>

Sends the transaction to the blockchain. Make sure you signed the transactionsign_transaction first.

Source

pub async fn get_transaction_result( &mut self, id: Vec<u8>, ) -> Result<TransactionResultResponse, Box<dyn Error>>

get transaction result

Source

pub async fn get_block( &mut self, block_id: Option<String>, block_height: Option<u64>, is_sealed: Option<bool>, ) -> Result<BlockResponse, Box<dyn Error>>

get_block accepts either the block_id or block_height. If neither are defined it returns the latest block.

Source

pub async fn get_events_for_height_range( &mut self, event_type: &str, start_height: u64, end_height: u64, ) -> Result<EventsResponse, Box<dyn Error>>

retrieve the specified events by type for the given height range

Source

pub async fn get_events_for_block_ids( &mut self, event_type: &str, ids: Vec<Vec<u8>>, ) -> Result<EventsResponse, Box<dyn Error>>

retrieve the specified events by type for the given blocks

Source

pub async fn get_collection( &mut self, collection_id: Vec<u8>, ) -> Result<CollectionResponse, Box<dyn Error>>

retrieve the specified collections

Source

pub async fn create_account( &mut self, account_keys: Vec<String>, payer: &str, payer_private_key: &str, key_id: u32, ) -> Result<Account, Box<dyn Error>>

Create an account with the given account_keys and payer

Source

pub async fn add_key( &mut self, public_key_to_add: &str, payer: &str, payer_private_key: &str, key_id: u32, ) -> Result<SendTransactionResponse, Box<dyn Error>>

add a key

Source

pub async fn remove_key( &mut self, key_to_remove: u64, payer: &str, payer_private_key: &str, key_id: u32, ) -> Result<SendTransactionResponse, Box<dyn Error>>

remove a key

Source

pub async fn add_contract( &mut self, contract_name: &str, contract_code: &str, payer: &str, payer_private_key: &str, key_id: u32, ) -> Result<SendTransactionResponse, Box<dyn Error>>

add a contract

Source

pub async fn update_contract( &mut self, contract_name: &str, contract_code: &str, payer: &str, payer_private_key: &str, key_id: u32, ) -> Result<SendTransactionResponse, Box<dyn Error>>

update a contract

Source

pub async fn remove_contract( &mut self, contract_name: &str, payer: &str, payer_private_key: &str, key_id: u32, ) -> Result<SendTransactionResponse, Box<dyn Error>>

remove a contract

Auto Trait Implementations§

§

impl<T> Freeze for FlowConnection<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for FlowConnection<T>
where T: RefUnwindSafe,

§

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

§

impl<T> Sync for FlowConnection<T>
where T: Sync,

§

impl<T> Unpin for FlowConnection<T>
where T: Unpin,

§

impl<T> UnwindSafe for FlowConnection<T>
where T: UnwindSafe,

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

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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