Skip to content

Commit

Permalink
Add deposit support & enable library usage (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qjawko authored Feb 3, 2025
1 parent 64aa78a commit 034a3d0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ repository = "https://github.com/aurora-is-near/aurora-cli-rs"
description = "Aurora CLI is a command line interface to bootstrap Aurora engine"
readme = "README.md"

[lib]
name = "aurora_cli"
path = "src/lib.rs"

[[bin]]
name = "aurora-cli"
path = "src/main.rs"
Expand Down
18 changes: 16 additions & 2 deletions src/client/near.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,30 @@ impl NearClient {
pub async fn contract_call_batch(
&self,
batch: Vec<(String, Vec<u8>)>,
) -> anyhow::Result<FinalExecutionOutcomeView> {
let batch_with_deposit: Vec<(String, Vec<u8>, u128)> = batch
.into_iter()
.map(|(method_name, args)| (method_name, args, 0u128))
.collect();

self.contract_call_batch_with_deposit(batch_with_deposit)
.await
}

#[allow(dead_code)]
pub async fn contract_call_batch_with_deposit(
&self,
batch: Vec<(String, Vec<u8>, u128)>,
) -> anyhow::Result<FinalExecutionOutcomeView> {
let gas = NEAR_GAS / u64::try_from(batch.len())?;
let actions = batch
.into_iter()
.map(|(method_name, args)| {
.map(|(method_name, args, deposit)| {
Action::FunctionCall(Box::new(near_primitives::transaction::FunctionCallAction {
method_name,
args,
gas,
deposit: 0,
deposit,
}))
})
.collect();
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub mod cli;
pub mod client;
pub mod config;
#[cfg(feature = "advanced")]
pub mod eth_method;
#[cfg(feature = "advanced")]
pub mod transaction_reader;
pub mod utils;

0 comments on commit 034a3d0

Please sign in to comment.