Struct web3_rust_wrapper::Web3Manager
source · [−]pub struct Web3Manager {
pub accounts: Vec<H160>,
pub balances: HashMap<H160, U256>,
pub web3http: Web3<Http>,
pub web3web_socket: Web3<WebSocket>,
/* private fields */
}
Fields
accounts: Vec<H160>
balances: HashMap<H160, U256>
web3http: Web3<Http>
web3web_socket: Web3<WebSocket>
Implementations
sourceimpl Web3Manager
impl Web3Manager
pub async fn instance_contract(
&self,
plain_contract_address: &str,
abi_path: &[u8]
) -> Result<Contract<Http>, Box<dyn Error>>
pub fn generate_keypair() -> (SecretKey, PublicKey)
pub fn public_key_address(public_key: &PublicKey) -> Address
pub fn generate_keypairs(n: u8) -> Vec<(SecretKey, PublicKey)>
pub fn wei_to_eth(wei_val: U256) -> f64
pub fn eth_to_wei(eth_val: f64) -> U256
pub fn get_account_balance(&self, account: H160) -> U256
pub fn generate_deadline(&self) -> Result<U256, SystemTimeError>
pub async fn swap_tokens_for_exact_tokens(
&mut self,
account: H160,
contract_instance: &Contract<Http>,
token_amount: &str,
pairs: &[&str],
slippage: usize
) -> Result<H256, Box<dyn Error>>
pub async fn swap_eth_for_exact_tokens(
&mut self,
account: H160,
router_address: &str,
token_amount: &str,
pairs: &[&str],
slippage: usize
) -> Result<H256, Box<dyn Error>>
pub async fn get_out_estimated_tokens_for_tokens(
&self,
contract_instance: &Contract<Http>,
pair_a: &str,
pair_b: &str,
amount: &str
) -> Result<U256, Error>
pub async fn set_token_balances(&mut self)
pub async fn last_nonce(&self) -> Result<U256, Error>
pub async fn load_account(
&mut self,
plain_address: &str,
plain_private_key: &str
) -> &mut Web3Manager
pub async fn new(
http_url: &str,
websocket_url: &str,
u64chain_id: u64
) -> Web3Manager
pub async fn gas_price(&self) -> Result<U256, Error>
pub async fn get_block(&self) -> Result<U64, Error>
pub async fn query_contract<P, T>(
&self,
contract_instance: &Contract<Http>,
func: &str,
params: P
) -> Result<T, Error> where
P: Tokenize,
T: Detokenize,
pub async fn send_raw_transaction(&self, raw_transaction: Bytes) -> H256
pub async fn sign_transaction(
&self,
account: H160,
transact_obj: TransactionParameters
) -> SignedTransaction
pub fn encode_tx_parameters(
&self,
nonce: U256,
to: Address,
value: U256,
gas: U256,
gas_price: U256,
data: Bytes
) -> TransactionParameters
pub fn encode_tx_data<P>(
&self,
contract: &Contract<Http>,
func: &str,
params: P
) -> Bytes where
P: Tokenize,
pub async fn estimate_tx_gas<P>(
&self,
contract: &Contract<Http>,
func: &str,
params: P,
value: &str
) -> U256 where
P: Tokenize,
pub fn first_loaded_account(&self) -> H160
pub async fn approve_erc20_token(
&mut self,
account: H160,
contract_instance: Contract<Http>,
spender: &str,
value: &str
) -> H256
pub async fn sign_and_send_tx<P: Clone>(
&mut self,
account: H160,
contract_instance: &Contract<Http>,
func: &str,
params: &P,
value: &str
) -> H256 where
P: Tokenize,
pub async fn sent_erc20_token(
&mut self,
account: H160,
contract_instance: &Contract<Http>,
to: &str,
token_amount: &str
) -> H256
pub async fn get_latest_price(
&self,
network: impl GetAddress,
pair_address: &str
) -> Int
pub async fn listen_contract_events(&self, contract_address: &str)
pub async fn build_contract_events(
&self,
contract_address: &str
) -> SubscriptionStream<WebSocket, Log>
pub async fn init_pair(&self, lp_address: &str) -> Contract<Http>
pub async fn init_router_factory(&self) -> Contract<Http>
pub async fn init_router(&self) -> Contract<Http>
pub async fn token_has_liquidity(
&self,
lp_pair_factory_instance: Contract<Http>
) -> bool
pub async fn get_token_reserves(
web3m: Web3Manager,
lp_pair_factory_instance: Contract<Http>
) -> (U256, U256, U256)
Trait Implementations
sourceimpl Clone for Web3Manager
impl Clone for Web3Manager
sourcefn clone(&self) -> Web3Manager
fn clone(&self) -> Web3Manager
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Web3Manager
impl Send for Web3Manager
impl Sync for Web3Manager
impl Unpin for Web3Manager
impl !UnwindSafe for Web3Manager
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more