|
|
@@ -37,7 +37,7 @@ use darkfi::{
|
|
|
path::{expand_path, get_config_path},
|
|
|
},
|
|
|
zk::halo2::Field,
|
|
|
- Result, Error,
|
|
|
+ Error, Result,
|
|
|
};
|
|
|
use darkfi_dao_contract::{blockwindow, model::DaoProposalBulla, DaoFunction};
|
|
|
use darkfi_money_contract::model::{Coin, CoinAttributes, TokenId};
|
|
|
@@ -588,7 +588,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
Subcmd::Ping => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
drk.ping().await?;
|
|
|
drk.stop_rpc_client().await
|
|
|
}
|
|
|
@@ -623,7 +629,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
exit(2);
|
|
|
}
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk =
|
|
|
+ Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex)
|
|
|
+ .await?;
|
|
|
|
|
|
if initialize {
|
|
|
drk.initialize_wallet()?;
|
|
|
@@ -844,7 +852,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
Subcmd::Spend => {
|
|
|
let tx = parse_tx_from_stdin().await?;
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk =
|
|
|
+ Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex)
|
|
|
+ .await?;
|
|
|
|
|
|
if let Err(e) = drk.mark_tx_spend(&tx).await {
|
|
|
eprintln!("Failed to mark transaction coins as spent: {e:?}");
|
|
|
@@ -872,7 +882,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
};
|
|
|
|
|
|
let coin = Coin::from(elem);
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk =
|
|
|
+ Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex)
|
|
|
+ .await?;
|
|
|
if let Err(e) = drk.unspend_coin(&coin).await {
|
|
|
eprintln!("Failed to mark coin as unspent: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -882,7 +894,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
Subcmd::Transfer { amount, token, recipient, spend_hook, user_data, half_split } => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
if let Err(e) = f64::from_str(&amount) {
|
|
|
eprintln!("Invalid amount: {e:?}");
|
|
|
@@ -955,8 +973,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
|
|
|
Subcmd::Otc { command } => match command {
|
|
|
OtcSubcmd::Init { value_pair, token_pair } => {
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let value_pair = parse_value_pair(&value_pair)?;
|
|
|
let token_pair = parse_token_pair(&drk, &token_pair).await?;
|
|
|
|
|
|
@@ -982,8 +1005,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
|
|
|
let partial: PartialSwapData = deserialize_async(&bytes).await?;
|
|
|
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let tx = match drk.join_swap(partial, None, None, None).await {
|
|
|
Ok(tx) => tx,
|
|
|
Err(e) => {
|
|
|
@@ -1004,7 +1032,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
exit(2);
|
|
|
};
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
if let Err(e) = drk.inspect_swap(bytes).await {
|
|
|
eprintln!("Failed to inspect swap: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -1016,7 +1050,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
OtcSubcmd::Sign => {
|
|
|
let mut tx = parse_tx_from_stdin().await?;
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
if let Err(e) = drk.sign_swap(&mut tx).await {
|
|
|
eprintln!("Failed to sign joined swap transaction: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -1049,7 +1089,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
let approval_ratio_base = 100_u64;
|
|
|
let approval_ratio_quot = (approval_ratio * approval_ratio_base as f64) as u64;
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let gov_token_id = match drk.get_token(gov_token_id).await {
|
|
|
Ok(g) => g,
|
|
|
Err(e) => {
|
|
|
@@ -1093,7 +1139,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
let bytes = bs58::decode(&buf.trim()).into_vec()?;
|
|
|
let params: DaoParams = deserialize_async(&bytes).await?;
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
if let Err(e) = drk.import_dao(&name, params).await {
|
|
|
eprintln!("Failed to import DAO: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -1103,7 +1155,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::List { name } => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
if let Err(e) = drk.dao_list(&name).await {
|
|
|
eprintln!("Failed to list DAO: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -1113,7 +1171,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::Balance { name } => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let balmap = match drk.dao_balance(&name).await {
|
|
|
Ok(b) => b,
|
|
|
Err(e) => {
|
|
|
@@ -1157,8 +1221,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::Mint { name } => {
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let tx = match drk.dao_mint(&name).await {
|
|
|
Ok(tx) => tx,
|
|
|
Err(e) => {
|
|
|
@@ -1180,8 +1249,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
spend_hook,
|
|
|
user_data,
|
|
|
} => {
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
if let Err(e) = f64::from_str(&amount) {
|
|
|
eprintln!("Invalid amount: {e:?}");
|
|
|
@@ -1255,7 +1329,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::Proposals { name } => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let proposals = drk.get_dao_proposals(&name).await?;
|
|
|
|
|
|
for (i, proposal) in proposals.iter().enumerate() {
|
|
|
@@ -1274,8 +1354,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let proposal = drk.get_dao_proposal_by_bulla(&bulla).await?;
|
|
|
|
|
|
if export {
|
|
|
@@ -1459,7 +1544,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
};
|
|
|
let encrypted_proposal: AeadEncryptedNote = deserialize_async(&bytes).await?;
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
// Retrieve all DAOs to try to decrypt the proposal
|
|
|
let daos = drk.get_daos().await?;
|
|
|
@@ -1511,8 +1602,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
None => None,
|
|
|
};
|
|
|
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let tx = match drk.dao_vote(&bulla, vote, weight).await {
|
|
|
Ok(tx) => tx,
|
|
|
Err(e) => {
|
|
|
@@ -1534,8 +1630,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let proposal = drk.get_dao_proposal_by_bulla(&bulla).await?;
|
|
|
|
|
|
for call in &proposal.proposal.auth_calls {
|
|
|
@@ -1571,7 +1672,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
Subcmd::AttachFee => {
|
|
|
let mut tx = parse_tx_from_stdin().await?;
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
if let Err(e) = drk.attach_fee(&mut tx).await {
|
|
|
eprintln!("Failed to attach the fee call to the transaction: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -1593,7 +1700,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
Subcmd::Broadcast => {
|
|
|
let tx = parse_tx_from_stdin().await?;
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
if let Err(e) = drk.simulate_tx(&tx).await {
|
|
|
eprintln!("Failed to simulate tx: {e:?}");
|
|
|
@@ -1636,7 +1749,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
Subcmd::Scan { reset } => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
if reset {
|
|
|
println!("Reset requested.");
|
|
|
@@ -1662,8 +1781,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
ExplorerSubcmd::FetchTx { tx_hash, full, encode } => {
|
|
|
let tx_hash = TransactionHash(*blake3::Hash::from_hex(&tx_hash)?.as_bytes());
|
|
|
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
let tx = match drk.get_tx(&tx_hash).await {
|
|
|
Ok(tx) => tx,
|
|
|
@@ -1697,8 +1821,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
ExplorerSubcmd::SimulateTx => {
|
|
|
let tx = parse_tx_from_stdin().await?;
|
|
|
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
let is_valid = match drk.simulate_tx(&tx).await {
|
|
|
Ok(b) => b,
|
|
|
@@ -1715,7 +1844,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
ExplorerSubcmd::TxsHistory { tx_hash, encode } => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
if let Some(c) = tx_hash {
|
|
|
let (tx_hash, status, tx) = drk.get_tx_history_record(&c).await?;
|
|
|
@@ -1773,7 +1908,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
if let Err(e) = drk.add_alias(alias, token_id).await {
|
|
|
eprintln!("Failed to add alias: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -1794,7 +1935,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
None => None,
|
|
|
};
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let map = drk.get_aliases(alias, token_id).await?;
|
|
|
|
|
|
// Create a prettytable with the new data:
|
|
|
@@ -1815,7 +1962,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
AliasSubcmd::Remove { alias } => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
if let Err(e) = drk.remove_alias(alias).await {
|
|
|
eprintln!("Failed to remove alias: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -1843,7 +1996,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let token_id = drk.import_mint_authority(mint_authority, token_blind).await?;
|
|
|
println!("Successfully imported mint authority for token ID: {token_id}");
|
|
|
|
|
|
@@ -1851,7 +2010,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
TokenSubcmd::GenerateMint => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let mint_authority = SecretKey::random(&mut OsRng);
|
|
|
let token_blind = BaseBlind::random(&mut OsRng);
|
|
|
let token_id = drk.import_mint_authority(mint_authority, token_blind).await?;
|
|
|
@@ -1861,7 +2026,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
TokenSubcmd::List => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let tokens = drk.get_mint_authorities().await?;
|
|
|
let aliases_map = match drk.get_aliases_mapped_by_token().await {
|
|
|
Ok(map) => map,
|
|
|
@@ -1900,8 +2071,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
TokenSubcmd::Mint { token, amount, recipient, spend_hook, user_data } => {
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
if let Err(e) = f64::from_str(&amount) {
|
|
|
eprintln!("Invalid amount: {e:?}");
|
|
|
@@ -1971,8 +2147,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
TokenSubcmd::Freeze { token } => {
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let token_id = match drk.get_token(token).await {
|
|
|
Ok(t) => t,
|
|
|
Err(e) => {
|
|
|
@@ -1997,7 +2178,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
|
|
|
Subcmd::Contract { command } => match command {
|
|
|
ContractSubcmd::GenerateDeploy => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
if let Err(e) = drk.deploy_auth_keygen().await {
|
|
|
eprintln!("Error creating deploy auth keypair: {:?}", e);
|
|
|
@@ -2008,7 +2195,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
ContractSubcmd::List => {
|
|
|
- let drk = Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, None, ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ None,
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
let auths = drk.list_deploy_auth().await?;
|
|
|
|
|
|
let mut table = Table::new();
|
|
|
@@ -2033,8 +2226,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
let wasm_bin = smol::fs::read(expand_path(&wasm_path)?).await?;
|
|
|
let deploy_ix = smol::fs::read(expand_path(&deploy_ix)?).await?;
|
|
|
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
let mut tx = match drk.deploy_contract(deploy_auth, wasm_bin, deploy_ix).await {
|
|
|
Ok(v) => v,
|
|
|
@@ -2055,8 +2253,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
ContractSubcmd::Lock { deploy_auth } => {
|
|
|
- let drk =
|
|
|
- Drk::new(blockchain_config.wallet_path, blockchain_config.wallet_pass, Some(blockchain_config.endpoint), ex).await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ blockchain_config.wallet_path,
|
|
|
+ blockchain_config.wallet_pass,
|
|
|
+ Some(blockchain_config.endpoint),
|
|
|
+ ex,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
let mut tx = match drk.lock_contract(deploy_auth).await {
|
|
|
Ok(v) => v,
|