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
impl FlowConnection<Channel>
The default implementation of a FlowConnection, using tonic::transport::Channel
Sourcepub async fn new(
network_address: &str,
) -> Result<FlowConnection<Channel>, Box<dyn Error>>
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
Sourcepub async fn get_account(
&mut self,
account_address: &str,
) -> Result<AccountResponse, Box<dyn Error>>
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.
Sourcepub 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>>
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
Sourcepub async fn send_transaction(
&mut self,
transaction: Option<Transaction>,
) -> Result<SendTransactionResponse, Box<dyn Error>>
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.
Sourcepub async fn get_transaction_result(
&mut self,
id: Vec<u8>,
) -> Result<TransactionResultResponse, Box<dyn Error>>
pub async fn get_transaction_result( &mut self, id: Vec<u8>, ) -> Result<TransactionResultResponse, Box<dyn Error>>
get transaction result
Sourcepub async fn get_block(
&mut self,
block_id: Option<String>,
block_height: Option<u64>,
is_sealed: Option<bool>,
) -> Result<BlockResponse, Box<dyn Error>>
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.
Sourcepub async fn get_events_for_height_range(
&mut self,
event_type: &str,
start_height: u64,
end_height: u64,
) -> Result<EventsResponse, Box<dyn Error>>
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
Sourcepub async fn get_events_for_block_ids(
&mut self,
event_type: &str,
ids: Vec<Vec<u8>>,
) -> Result<EventsResponse, Box<dyn Error>>
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
Sourcepub async fn get_collection(
&mut self,
collection_id: Vec<u8>,
) -> Result<CollectionResponse, Box<dyn Error>>
pub async fn get_collection( &mut self, collection_id: Vec<u8>, ) -> Result<CollectionResponse, Box<dyn Error>>
retrieve the specified collections
Sourcepub async fn create_account(
&mut self,
account_keys: Vec<String>,
payer: &str,
payer_private_key: &str,
key_id: u32,
) -> Result<Account, Box<dyn Error>>
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
Sourcepub 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>>
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
Sourcepub async fn remove_key(
&mut self,
key_to_remove: u64,
payer: &str,
payer_private_key: &str,
key_id: u32,
) -> Result<SendTransactionResponse, Box<dyn Error>>
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
Sourcepub 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>>
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
Sourcepub 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>>
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
Sourcepub async fn remove_contract(
&mut self,
contract_name: &str,
payer: &str,
payer_private_key: &str,
key_id: u32,
) -> Result<SendTransactionResponse, Box<dyn Error>>
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> 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request