-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #931 from golemfactory/mwu/withdraw
Add enter / exit / transfer commands to CLI
- Loading branch information
Showing
7 changed files
with
271 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// External crates | ||
use bigdecimal::BigDecimal; | ||
|
||
// Workspace uses | ||
use ya_core_model::driver::{driver_bus_id, Enter, Exit, Transfer}; | ||
use ya_service_bus::typed as bus; | ||
|
||
pub async fn enter( | ||
amount: BigDecimal, | ||
driver: String, | ||
network: Option<String>, | ||
token: Option<String>, | ||
) -> anyhow::Result<String> { | ||
let driver_id = driver_bus_id(driver); | ||
let message = Enter::new(amount, network, token); | ||
let tx_id = bus::service(driver_id).call(message).await??; | ||
Ok(tx_id) | ||
} | ||
|
||
pub async fn exit( | ||
to: Option<String>, | ||
amount: Option<BigDecimal>, | ||
driver: String, | ||
network: Option<String>, | ||
token: Option<String>, | ||
) -> anyhow::Result<String> { | ||
let driver_id = driver_bus_id(driver); | ||
let message = Exit::new(to, amount, network, token); | ||
let tx_id = bus::service(driver_id).call(message).await??; | ||
Ok(tx_id) | ||
} | ||
|
||
pub async fn transfer( | ||
to: String, | ||
amount: BigDecimal, | ||
driver: String, | ||
network: Option<String>, | ||
token: Option<String>, | ||
) -> anyhow::Result<String> { | ||
let driver_id = driver_bus_id(driver); | ||
let message = Transfer::new(to, amount, network, token); | ||
let tx_id = bus::service(driver_id).call(message).await??; | ||
Ok(tx_id) | ||
} |