Skip to content

Commit

Permalink
feat(cli): read dotrain from file
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyg committed Jan 24, 2024
1 parent 40c4356 commit 2057a82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ homepage = "https://github.com/rainprotocol/rain.orderbook"
[workspace.dependencies]
alloy-ethers-typecast = { git = "https://github.com/rainlanguage/alloy-ethers-typecast", rev = "eb0e02ee40699808fb984461a920286c19a6c754" }
dotrain = { git = "https://github.com/rainlanguage/dotrain.git", rev = "21663b09177b9ebf00cb43da7233fbdd9b63da3a" }
rain_interpreter_bindings = { git = "https://github.com/rainlanguage/rain.interpreter.git", rev = "4c6b9246020e1ff86888ce85aa892f5cfe123dcb", module = "crates/bindings" }
dotrain_interpreter_dispair = { git = "https://github.com/rainlanguage/rain.interpreter.git", rev = "4c6b9246020e1ff86888ce85aa892f5cfe123dcb", module = "crates/dispair" }
dotrain_interpreter_parser = { git = "https://github.com/rainlanguage/rain.interpreter.git", rev = "4c6b9246020e1ff86888ce85aa892f5cfe123dcb", module = "crates/parser" }
rain_interpreter_bindings = { git = "https://github.com/rainlanguage/rain.interpreter.git", rev = "78d48c989b7cb863e188072dd38e3d7dcf8660fd", module = "crates/bindings" }
dotrain_interpreter_dispair = { git = "https://github.com/rainlanguage/rain.interpreter.git", rev = "78d48c989b7cb863e188072dd38e3d7dcf8660fd", module = "crates/dispair" }
dotrain_interpreter_parser = { git = "https://github.com/rainlanguage/rain.interpreter.git", rev = "78d48c989b7cb863e188072dd38e3d7dcf8660fd", module = "crates/parser" }
alloy-sol-types = { version = "0.5.4" }
alloy-primitives = "0.5.4"
anyhow = "1.0.70"
Expand Down
15 changes: 9 additions & 6 deletions crates/cli/src/commands/order/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ use anyhow::Result;
use clap::Args;
use rain_orderbook_bindings::IOrderBookV3::addOrderCall;
use rain_orderbook_common::add_order::AddOrderArgs;
use std::fs::File;
use std::path::PathBuf;

pub type AddOrder = CliTransactionCommandArgs<CliAddOrderArgs>;

impl Execute for AddOrder {
async fn execute(&self) -> Result<()> {
let add_order_args: AddOrderArgs = self.cmd_args.clone().into();
let add_order_args: AddOrderArgs = self.cmd_args.clone().try_into()?;
let add_order_call: addOrderCall = add_order_args.try_into()?;
let mut execute_tx: ExecuteTransaction = self.clone().into();

Expand All @@ -31,10 +32,12 @@ pub struct CliAddOrderArgs {
dotrain_path: PathBuf,
}

impl From<CliAddOrderArgs> for AddOrderArgs {
fn from(val: CliAddOrderArgs) -> Self {
Self {
dotrain_path: val.dotrain_path,
}
impl TryFrom<CliAddOrderArgs> for AddOrderArgs {
fn try_from(val: CliAddOrderArgs) -> Result<Self> {
let mut file = File::open(val.dotrain_path)?;
let mut text = String::new();
file.read_to_string(&mut text)?;

Self { dotrain: text }
}
}

0 comments on commit 2057a82

Please sign in to comment.