Struct cli::client_proxy::ClientProxy
source · 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
impl ClientProxy
sourcepub 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>
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.
sourcepub async fn streaming_client(
&self,
config: Option<StreamingClientConfig>
) -> StreamResult<StreamingClient>
pub async fn streaming_client( &self, config: Option<StreamingClientConfig> ) -> StreamResult<StreamingClient>
Gets a websocket client for the same node DiemClient
connects to
sourcepub fn get_account(&self, address_num: usize) -> Option<&AccountData>
pub fn get_account(&self, address_num: usize) -> Option<&AccountData>
Gets account data for the indexed address
sourcepub fn create_next_account(
&mut self,
sync_with_validator: bool
) -> Result<AddressAndIndex>
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
sourcepub fn latest_epoch_change_li(&mut self) -> Option<&LedgerInfoWithSignatures>
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)
sourcepub fn print_all_accounts(&self)
pub fn print_all_accounts(&self)
Print index and address of all accounts.
sourcepub fn set_accounts(
&mut self,
accounts: Vec<AccountData>
) -> Vec<AddressAndIndex> ⓘ
pub fn set_accounts( &mut self, accounts: Vec<AccountData> ) -> Vec<AddressAndIndex> ⓘ
Set the account of this client instance.
sourcepub fn get_balances(
&mut self,
space_delim_strings: &[&str]
) -> Result<Vec<String>>
pub fn get_balances( &mut self, space_delim_strings: &[&str] ) -> Result<Vec<String>>
Get balance from validator for the account specified.
sourcepub fn get_sequence_number(
&mut self,
space_delim_strings: &[&str]
) -> Result<u64>
pub fn get_sequence_number( &mut self, space_delim_strings: &[&str] ) -> Result<u64>
Get the latest sequence number from validator for the account specified.
sourcepub fn add_currency(
&mut self,
space_delim_strings: &[&str],
is_blocking: bool
) -> Result<()>
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.
sourcepub fn mint_coins(
&mut self,
space_delim_strings: &[&str],
is_blocking: bool
) -> Result<()>
pub fn mint_coins( &mut self, space_delim_strings: &[&str], is_blocking: bool ) -> Result<()>
Mints coins for the receiver specified.
sourcepub fn enable_custom_script(
&mut self,
space_delim_strings: &[&str],
open_module: bool,
is_blocking: bool
) -> Result<()>
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.
sourcepub fn change_diem_version(
&mut self,
space_delim_strings: &[&str],
is_blocking: bool
) -> Result<()>
pub fn change_diem_version( &mut self, space_delim_strings: &[&str], is_blocking: bool ) -> Result<()>
Modify the stored DiemVersion on chain.
sourcepub fn upgrade_stdlib(
&mut self,
space_delim_strings: &[&str],
is_blocking: bool
) -> Result<()>
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.
sourcepub fn wait_for_transaction(
&self,
address: AccountAddress,
seq: u64
) -> Result<()>
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
sourcepub fn submit_and_wait(
&mut self,
txn: &SignedTransaction,
is_blocking: bool
) -> Result<()>
pub fn submit_and_wait( &mut self, txn: &SignedTransaction, is_blocking: bool ) -> Result<()>
Submit transaction and waits for the transaction executed
sourcepub fn wait_for_signed_transaction(
&mut self,
txn: &SignedTransaction
) -> Result<TransactionView>
pub fn wait_for_signed_transaction( &mut self, txn: &SignedTransaction ) -> Result<TransactionView>
Waits for the transaction
sourcepub 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>
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.
sourcepub 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>
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
sourcepub fn transfer_coins(
&mut self,
space_delim_strings: &[&str],
is_blocking: bool
) -> Result<IndexAndSequence>
pub fn transfer_coins( &mut self, space_delim_strings: &[&str], is_blocking: bool ) -> Result<IndexAndSequence>
Transfers coins from sender to receiver.
sourcepub fn compile_program(
&mut self,
space_delim_strings: &[&str]
) -> Result<Vec<String>>
pub fn compile_program( &mut self, space_delim_strings: &[&str] ) -> Result<Vec<String>>
Compile Move program
sourcepub fn submit_signed_transaction(
&mut self,
raw_txn: RawTransaction,
public_key: Ed25519PublicKey,
signature: Ed25519Signature
) -> Result<()>
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
sourcepub fn publish_module(&mut self, space_delim_strings: &[&str]) -> Result<()>
pub fn publish_module(&mut self, space_delim_strings: &[&str]) -> Result<()>
Publish Move module
sourcepub fn execute_script(&mut self, space_delim_strings: &[&str]) -> Result<()>
pub fn execute_script(&mut self, space_delim_strings: &[&str]) -> Result<()>
Execute custom script
sourcepub fn submit_writeset(&mut self, space_delim_strings: &[&str]) -> Result<()>
pub fn submit_writeset(&mut self, space_delim_strings: &[&str]) -> Result<()>
Submit a writeset transaction signed by local diem root account.
sourcepub fn get_latest_account(
&mut self,
space_delim_strings: &[&str]
) -> Result<Option<AccountView>>
pub fn get_latest_account( &mut self, space_delim_strings: &[&str] ) -> Result<Option<AccountView>>
Get the latest account information from validator.
sourcepub fn get_latest_version(&mut self) -> Version
pub fn get_latest_version(&mut self) -> Version
Get the latest version
sourcepub fn get_latest_account_resources(
&mut self,
space_delim_strings: &[&str]
) -> Result<(Option<AnnotatedAccountStateBlob>, Version)>
pub fn get_latest_account_resources( &mut self, space_delim_strings: &[&str] ) -> Result<(Option<AnnotatedAccountStateBlob>, Version)>
Get the latest annotated account resources from validator.
sourcepub fn get_committed_txn_by_acc_seq(
&mut self,
space_delim_strings: &[&str]
) -> Result<Option<TransactionView>>
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.
sourcepub fn get_committed_txn_by_range(
&mut self,
space_delim_strings: &[&str]
) -> Result<Vec<TransactionView>>
pub fn get_committed_txn_by_range( &mut self, space_delim_strings: &[&str] ) -> Result<Vec<TransactionView>>
Get committed txn by account and sequence number
sourcepub fn get_account_address_from_parameter(
&self,
para: &str
) -> Result<(AccountAddress, Option<AuthenticationKey>)>
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.
sourcepub fn get_events_by_account_and_type(
&mut self,
space_delim_strings: &[&str]
) -> Result<(Vec<EventView>, AccountView)>
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.
sourcepub fn write_recovery(&self, space_delim_strings: &[&str]) -> Result<()>
pub fn write_recovery(&self, space_delim_strings: &[&str]) -> Result<()>
Write mnemonic recover to the file specified.
sourcepub fn recover_wallet_accounts(
&mut self,
space_delim_strings: &[&str]
) -> Result<Vec<AddressAndIndex>>
pub fn recover_wallet_accounts( &mut self, space_delim_strings: &[&str] ) -> Result<Vec<AddressAndIndex>>
Recover wallet accounts from command ‘recover
sourcepub fn recover_accounts_in_wallet(&mut self) -> Result<Vec<AddressAndIndex>>
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.
sourcepub fn insert_account_data(
&mut self,
account_data: AccountData
) -> AddressAndIndex
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
sourcepub fn test_validator_connection(&mut self) -> Result<MetadataView>
pub fn test_validator_connection(&mut self) -> Result<MetadataView>
Test JSON RPC client connection with validator.
sourcepub fn test_trusted_connection(&mut self) -> Result<()>
pub fn test_trusted_connection(&mut self) -> Result<()>
Test client’s connection to validator with proof.
sourcepub fn association_transaction_with_local_diem_root_account(
&mut self,
payload: TransactionPayload,
is_blocking: bool
) -> Result<()>
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