Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet docs #114

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
18 changes: 18 additions & 0 deletions src/zks_wallet/requests/call_request.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/// Parameters to call a contract's view function i.e.
/// functions which do not alter the net's state.
/// # Example
/// ```compile_fail
/// # let contract_address: zksync_web3_rs::types::Address = Default::default();
/// /// Call request for the greet contract from the [getting started](https://docs.zksync.io/api/sdk/rust/tutorial/) tutorial
/// /// that returns a String.
/// let call_request = CallRequest::new(contract_address, "greet()(string)".to_owned());
/// let greet = ZKSProvider::call(era_provider.as_ref(), &call_request)
/// .await
/// .unwrap();
/// println!("greet: {}", greet[0]);
/// ```
use ethers::{
abi::{encode, Function, HumanReadableParser, ParseError},
types::{Address, Eip1559TransactionRequest},
Expand All @@ -9,10 +22,15 @@ use crate::{
zks_wallet::errors::ZKRequestError,
};

/// Parameters to call a contract's view function i.e.
/// functions which do not alter the net's state.
#[derive(Clone, Debug)]
pub struct CallRequest {
/// The contract's address.
pub to: Address,
/// The function to call, with its signature.
pub function_signature: String,
/// The parameters for the function.
pub function_parameters: Option<Vec<String>>,
}

Expand Down
7 changes: 7 additions & 0 deletions src/zks_wallet/requests/deploy_request.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
use ethers::{abi::Abi, types::Address};
use std::fmt::Debug;

/// Parameters for a contract deployment.
#[derive(Clone, Debug)]
pub struct DeployRequest {
/// The contract's interface.
pub contract_abi: Abi,
/// The compiled contract, as vec of bytes.
pub contract_bytecode: Vec<u8>,
/// The parameters for the contract's constructor
pub constructor_parameters: Vec<String>,
/// The requester of the deploy.
pub from: Address,
/// The list of bytecode hashes that the contract should know
/// in advance, read more about it [here](https://era.zksync.io/docs/reference/architecture/contract-deployment.html#note-on-factory-deps)
pub factory_deps: Option<Vec<Vec<u8>>>,
}

Expand Down
4 changes: 4 additions & 0 deletions src/zks_wallet/requests/transfer_request.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use ethers::types::{Address, Eip1559TransactionRequest, U256};
use std::fmt::Debug;

/// Parameters for a transaction.
#[derive(Clone, Debug)]
pub struct TransferRequest {
/// The amount to transfer
pub amount: U256,
/// The account that sends the funds.
pub to: Address,
/// The receipient of the funds.
pub from: Address,
}

Expand Down
4 changes: 4 additions & 0 deletions src/zks_wallet/requests/withdraw_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ use std::fmt::Debug;

use ethers::types::{Address, U256};

/// Parameters for an L2 -> L1 withdraw.
#[derive(Clone, Debug)]
pub struct WithdrawRequest {
/// The amount to transfer.
pub amount: U256,
/// The L1 recipient address.
pub to: Address,
/// The L2 sender address.
pub from: Address,
}

Expand Down
Loading