Struct Wallet

Source
pub struct Wallet { /* private fields */ }
Expand description

The wallet provides the main entry point to this crate.

Implementations§

Source§

impl Wallet

Source

pub fn new( config: BlockchainConfig, signer: &Signer, client: Client, ) -> Result<Self>

Creates a new wallet from a config, signer and client.

Source

pub fn config(&self) -> &BlockchainConfig

Returns the blockchain config.

Source

pub fn client(&self) -> &Client

Returns the rosetta client.

Source

pub fn public_key(&self) -> &PublicKey

Returns the public key.

Source

pub fn account(&self) -> &AccountIdentifier

Returns the account identifier.

Source

pub async fn status(&self) -> Result<BlockIdentifier>

Returns the current block identifier.

Source

pub async fn balance(&self) -> Result<Amount>

Returns the balance of the wallet.

Source

pub async fn block(&self, data: PartialBlockIdentifier) -> Result<Block>

Returns block data Takes PartialBlockIdentifier

Source

pub async fn block_transaction( &self, block_identifer: BlockIdentifier, tx_identifier: TransactionIdentifier, ) -> Result<BlockTransactionResponse>

Returns transactions included in a block Parameters:

  1. block_identifier: BlockIdentifier containing block number and hash
  2. tx_identifier: TransactionIdentifier containing hash of transaction
Source

pub async fn call(&self, method: String, params: &Value) -> Result<CallResponse>

Extension of rosetta-api does multiple things

  1. fetching storage
  2. calling extrinsic/contract
Source

pub async fn coins(&self) -> Result<Vec<Coin>>

Returns the coins of the wallet.

Source

pub async fn metadata(&self, metadata_params: Value) -> Result<Value>

Returns the on chain metadata. Parameters:

  • metadata_params: the metadata parameters which we got from transaction builder.
Source

pub async fn submit(&self, transaction: &[u8]) -> Result<TransactionIdentifier>

Submits a transaction and returns the transaction identifier. Parameters:

  • transaction: the transaction bytes to submit
Source

pub async fn construct( &self, metadata_params: Value, ) -> Result<TransactionIdentifier>

Creates, signs and submits a transaction.

Source

pub async fn transfer( &self, account: &AccountIdentifier, amount: u128, ) -> Result<TransactionIdentifier>

Makes a transfer. Parameters:

  • account: the account to transfer to
  • amount: the amount to transfer
Source

pub async fn faucet( &self, faucet_parameter: u128, ) -> Result<TransactionIdentifier>

Uses the faucet on dev chains to seed the account with funds. Parameters:

  • faucet_parameter: the amount to seed the account with
Source

pub async fn transaction( &self, tx: TransactionIdentifier, ) -> Result<BlockTransaction>

Returns the transaction matching the transaction identifier. Parameters:

  • tx: the transaction identifier to search for.
Source

pub fn transactions(&self, limit: u16) -> TransactionStream

Returns a stream of transactions associated with the account.

Trait Implementations§

Source§

impl EthereumExt for Wallet

Source§

fn eth_deploy_contract<'life0, 'async_trait>( &'life0 self, bytecode: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<TransactionIdentifier>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

deploys contract to chain
Source§

fn eth_send_call<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, contract_address: &'life1 str, method_signature: &'life2 str, params: &'life3 [String], amount: u128, ) -> Pin<Box<dyn Future<Output = Result<TransactionIdentifier>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

calls contract send call function
Source§

fn eth_send_call_estimate_gas<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, contract_address: &'life1 str, method_signature: &'life2 str, params: &'life3 [String], amount: u128, ) -> Pin<Box<dyn Future<Output = Result<u128>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

estimates gas of send call
Source§

fn eth_view_call<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, contract_address: &'life1 str, method_signature: &'life2 str, params: &'life3 [String], ) -> Pin<Box<dyn Future<Output = Result<CallResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

calls a contract view call function
Source§

fn eth_storage<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, contract_address: &'life1 str, storage_slot: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<CallResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

gets storage from ethereum contract
Source§

fn eth_storage_proof<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, contract_address: &'life1 str, storage_slot: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<CallResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

gets storage proof from ethereum contract
Source§

fn eth_transaction_receipt<'life0, 'life1, 'async_trait>( &'life0 self, tx_hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<CallResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

gets transaction receipt of specific hash

Auto Trait Implementations§

§

impl Freeze for Wallet

§

impl !RefUnwindSafe for Wallet

§

impl Send for Wallet

§

impl Sync for Wallet

§

impl Unpin for Wallet

§

impl !UnwindSafe for Wallet

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> 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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> JsonSchemaMaybe for T