Skip to content

Commit

Permalink
converting deposit args to deposit call
Browse files Browse the repository at this point in the history
  • Loading branch information
hardyjosh committed Jan 8, 2024
1 parent c9ec4e8 commit ddaf4ce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ homepage = "https://github.com/rainprotocol/rain.orderbook"

[dependencies]
rain_orderbook_subgraph_queries = { path = "../subgraph" }
rain_orderbook_bindings = { path = "../bindings" }
anyhow = "1.0.70"
clap = { version = "4.2.5", features = ["cargo", "derive"] }
graphql_client = "0.12.0"
Expand All @@ -21,3 +22,6 @@ serde_bytes = "0.11.9"
tokio = { version = "1.28.0", features = ["full"] }
tracing = "0.1.37"
tracing-subscriber = "0.3.17"
alloy-primitives = "0.5.4"
alloy-sol-types = { version = "0.5.4" }

27 changes: 20 additions & 7 deletions crates/cli/src/commands/deposit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use clap::Parser;
use anyhow::Result;
use clap::Args;
use alloy_primitives::{U256, Address};
use rain_orderbook_bindings::IOrderBookV3::depositCall;
use alloy_sol_types::SolCall;

#[derive(Parser)]
pub struct Deposit {
Expand All @@ -10,12 +13,8 @@ pub struct Deposit {

impl Deposit {
pub async fn execute(self) -> Result<()> {
let DepositArgs {
token,
amount,
vault_id,
} = &self.deposit_args;
println!("Token: {}, Amount: {}, Vault ID: {}", token, amount, vault_id);
let deposit_call = self.deposit_args.to_deposit_call()?;
let call_data = deposit_call.abi_encode();
Ok(())
}
}
Expand All @@ -30,4 +29,18 @@ pub struct DepositArgs {

#[arg(short, long, help = "The ID of the vault")]
vault_id: u64,
}
}

impl DepositArgs {
pub fn to_deposit_call(&self) -> Result<depositCall> {
let token_address = self.token.parse::<Address>()?;
let amount = U256::from(self.amount);
let vault_id = U256::from(self.vault_id);

Ok(depositCall {
token: token_address,
amount,
vaultId: vault_id,
})
}
}

0 comments on commit ddaf4ce

Please sign in to comment.