pub struct ClientProxy {
    pub chain_id: ChainId,
    pub client: DiemClient,
    pub accounts: Vec<AccountData>,
    pub diem_root_account: Option<AccountData>,
    pub tc_account: Option<AccountData>,
    pub testnet_designated_dealer_account: Option<AccountData>,
    pub quiet_wait: bool,
    pub wallet: WalletLibrary,
    pub url: Url,
    /* private fields */
}
Expand description

Proxy handling CLI commands/inputs.

Fields§

§chain_id: ChainId

chain ID of the Diem network this client is interacting with

§client: DiemClient

client for admission control interface.

§accounts: Vec<AccountData>

Created accounts.

§diem_root_account: Option<AccountData>

Account used for Diem Root operations (e.g., adding a new transaction script)

§tc_account: Option<AccountData>

Account used for Treasury Compliance operations

§testnet_designated_dealer_account: Option<AccountData>

Account used for “minting” operations

§quiet_wait: bool

do not print ‘.’ when waiting for signed transaction

§wallet: WalletLibrary

Wallet library managing user accounts.

§url: Url

Host of the node that client connects to

Implementations§

source§

impl ClientProxy

source

pub fn new( chain_id: ChainId, url: &str, diem_root_account_file: &str, tc_account_file: &str, testnet_designated_dealer_account_file: &str, sync_on_wallet_recovery: bool, faucet_url: Option<String>, mnemonic_file: Option<String>, waypoint: Waypoint, quiet_wait: bool ) -> Result<Self>

Construct a new TestClient.

source

pub async fn streaming_client( &self, config: Option<StreamingClientConfig> ) -> StreamResult<StreamingClient>

Gets a websocket client for the same node DiemClient connects to

source

pub fn get_account(&self, address_num: usize) -> Option<&AccountData>

Gets account data for the indexed address

source

pub fn create_next_account( &mut self, sync_with_validator: bool ) -> Result<AddressAndIndex>

Returns the account index that should be used by user to reference this account

source

pub fn latest_epoch_change_li(&mut self) -> Option<&LedgerInfoWithSignatures>

Returns the ledger info corresonding to the latest epoch change (could further be used for e.g., generating a waypoint)

source

pub fn print_all_accounts(&self)

Print index and address of all accounts.

source

pub fn set_accounts( &mut self, accounts: Vec<AccountData> ) -> Vec<AddressAndIndex>

Set the account of this client instance.

source

pub fn get_balances( &mut self, space_delim_strings: &[&str] ) -> Result<Vec<String>>

Get balance from validator for the account specified.

source

pub fn get_sequence_number( &mut self, space_delim_strings: &[&str] ) -> Result<u64>

Get the latest sequence number from validator for the account specified.

source

pub fn add_currency( &mut self, space_delim_strings: &[&str], is_blocking: bool ) -> Result<()>

Adds a currency to the sending account. Fails if that currency already exists.

source

pub fn mint_coins( &mut self, space_delim_strings: &[&str], is_blocking: bool ) -> Result<()>

Mints coins for the receiver specified.

source

pub fn enable_custom_script( &mut self, space_delim_strings: &[&str], open_module: bool, is_blocking: bool ) -> Result<()>

Allow executing arbitrary script in the network.

source

pub fn change_diem_version( &mut self, space_delim_strings: &[&str], is_blocking: bool ) -> Result<()>

Modify the stored DiemVersion on chain.

source

pub fn upgrade_stdlib( &mut self, space_delim_strings: &[&str], is_blocking: bool ) -> Result<()>

Only allow executing predefined script in the Move standard library in the network.

source

pub fn wait_for_transaction( &self, address: AccountAddress, seq: u64 ) -> Result<()>

Wait for transaction, this function is not safe for waiting for a specific transaction, should use wait_for_signed_transaction instead. TODO: rename to wait_for_account_seq or remove

source

pub fn submit_and_wait( &mut self, txn: &SignedTransaction, is_blocking: bool ) -> Result<()>

Submit transaction and waits for the transaction executed

source

pub fn wait_for_signed_transaction( &mut self, txn: &SignedTransaction ) -> Result<TransactionView>

Waits for the transaction

source

pub fn transfer_coins_int( &mut self, sender_address: &AccountAddress, receiver_address: &AccountAddress, num_coins: u64, coin_currency: String, gas_unit_price: Option<u64>, gas_currency_code: Option<String>, max_gas_amount: Option<u64>, is_blocking: bool ) -> Result<IndexAndSequence>

Transfer num_coins from sender account to receiver. If is_blocking = true, it will keep querying validator till the sequence number is bumped up in validator.

source

pub fn prepare_transfer_coins( &mut self, sender_address: AccountAddress, sender_sequence_number: u64, receiver_address: AccountAddress, num_coins: u64, coin_currency: String, gas_unit_price: Option<u64>, max_gas_amount: Option<u64>, gas_currency_code: Option<String> ) -> Result<RawTransaction>

Prepare a transfer transaction: return the unsigned raw transaction

source

pub fn transfer_coins( &mut self, space_delim_strings: &[&str], is_blocking: bool ) -> Result<IndexAndSequence>

Transfers coins from sender to receiver.

source

pub fn compile_program( &mut self, space_delim_strings: &[&str] ) -> Result<Vec<String>>

Compile Move program

source

pub fn submit_signed_transaction( &mut self, raw_txn: RawTransaction, public_key: Ed25519PublicKey, signature: Ed25519Signature ) -> Result<()>

Submit a transaction to the network given the unsigned raw transaction, sender public key and signature

source

pub fn publish_module(&mut self, space_delim_strings: &[&str]) -> Result<()>

Publish Move module

source

pub fn execute_script(&mut self, space_delim_strings: &[&str]) -> Result<()>

Execute custom script

source

pub fn submit_writeset(&mut self, space_delim_strings: &[&str]) -> Result<()>

Submit a writeset transaction signed by local diem root account.

source

pub fn get_latest_account( &mut self, space_delim_strings: &[&str] ) -> Result<Option<AccountView>>

Get the latest account information from validator.

source

pub fn get_latest_version(&mut self) -> Version

Get the latest version

source

pub fn get_latest_account_resources( &mut self, space_delim_strings: &[&str] ) -> Result<(Option<AnnotatedAccountStateBlob>, Version)>

Get the latest annotated account resources from validator.

source

pub fn get_committed_txn_by_acc_seq( &mut self, space_delim_strings: &[&str] ) -> Result<Option<TransactionView>>

Get committed txn by account and sequence number.

source

pub fn get_committed_txn_by_range( &mut self, space_delim_strings: &[&str] ) -> Result<Vec<TransactionView>>

Get committed txn by account and sequence number

source

pub fn get_account_address_from_parameter( &self, para: &str ) -> Result<(AccountAddress, Option<AuthenticationKey>)>

Get account address and (if applicable) authentication key from parameter. If the parameter is string of address, try to convert it to address, otherwise, try to convert to u64 and looking at TestClient::accounts.

source

pub fn get_events_by_account_and_type( &mut self, space_delim_strings: &[&str] ) -> Result<(Vec<EventView>, AccountView)>

Get events by account and event type with start sequence number and limit.

source

pub fn write_recovery(&self, space_delim_strings: &[&str]) -> Result<()>

Write mnemonic recover to the file specified.

source

pub fn recover_wallet_accounts( &mut self, space_delim_strings: &[&str] ) -> Result<Vec<AddressAndIndex>>

Recover wallet accounts from command ‘recover ’ and return vec<(account_address, index)>.

source

pub fn recover_accounts_in_wallet(&mut self) -> Result<Vec<AddressAndIndex>>

Recover accounts in wallets and sync state if sync_on_wallet_recovery is true.

source

pub fn insert_account_data( &mut self, account_data: AccountData ) -> AddressAndIndex

Insert the account data to Client::accounts and return its address and index.s

source

pub fn test_validator_connection(&mut self) -> Result<MetadataView>

Test JSON RPC client connection with validator.

source

pub fn test_trusted_connection(&mut self) -> Result<()>

Test client’s connection to validator with proof.

source

pub fn association_transaction_with_local_diem_root_account( &mut self, payload: TransactionPayload, is_blocking: bool ) -> Result<()>

Send a transaction signed by the local diem_root credential

source

pub fn convert_to_scaled_representation( input: &str, scaling_factor: i64, fractional_part: i64 ) -> Result<u64>

Scale the number in input based on scaling_factor and ensure the fractional part is no less than fractional_part amount.

source

pub fn convert_to_on_chain_representation( &mut self, input: &str, currency: &str ) -> Result<u64>

convert number of coins (main unit) given as string to its on-chain representation

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

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