|
|
@@ -507,14 +507,14 @@ pub struct Drk {
|
|
|
/// Wallet database operations handler
|
|
|
pub wallet: WalletPtr,
|
|
|
/// JSON-RPC client to execute requests to darkfid daemon
|
|
|
- pub rpc_client: RpcClient,
|
|
|
+ pub rpc_client: Option<RpcClient>,
|
|
|
}
|
|
|
|
|
|
impl Drk {
|
|
|
async fn new(
|
|
|
wallet_path: String,
|
|
|
wallet_pass: String,
|
|
|
- endpoint: Url,
|
|
|
+ endpoint: Option<Url>,
|
|
|
ex: Arc<smol::Executor<'static>>,
|
|
|
) -> Result<Self> {
|
|
|
// Script kiddies protection
|
|
|
@@ -539,7 +539,11 @@ impl Drk {
|
|
|
};
|
|
|
|
|
|
// Initialize rpc client
|
|
|
- let rpc_client = RpcClient::new(endpoint, ex).await?;
|
|
|
+ let rpc_client = if let Some(endpoint) = endpoint {
|
|
|
+ Some(RpcClient::new(endpoint, ex).await?)
|
|
|
+ } else {
|
|
|
+ None
|
|
|
+ };
|
|
|
|
|
|
Ok(Self { wallet, rpc_client })
|
|
|
}
|
|
|
@@ -560,7 +564,7 @@ impl Drk {
|
|
|
println!("Executing ping request to darkfid...");
|
|
|
let latency = Instant::now();
|
|
|
let req = JsonRequest::new("ping", JsonValue::Array(vec![]));
|
|
|
- let rep = self.rpc_client.oneshot_request(req).await?;
|
|
|
+ let rep = self.rpc_client.as_ref().unwrap().oneshot_request(req).await?;
|
|
|
let latency = latency.elapsed();
|
|
|
println!("Got reply: {rep:?}");
|
|
|
println!("Latency: {latency:?}");
|
|
|
@@ -577,7 +581,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
Subcmd::Ping => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
drk.ping().await
|
|
|
}
|
|
|
|
|
|
@@ -611,7 +615,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
exit(2);
|
|
|
}
|
|
|
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
|
|
|
if initialize {
|
|
|
drk.initialize_wallet().await?;
|
|
|
@@ -847,7 +851,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
};
|
|
|
|
|
|
let coin = Coin::from(elem);
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
if let Err(e) = drk.unspend_coin(&coin).await {
|
|
|
eprintln!("Failed to mark coin as unspent: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -857,7 +861,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
Subcmd::Transfer { amount, token, recipient } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
|
|
|
if let Err(e) = f64::from_str(&amount) {
|
|
|
eprintln!("Invalid amount: {e:?}");
|
|
|
@@ -893,84 +897,86 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
- Subcmd::Otc { command } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
-
|
|
|
- match command {
|
|
|
- OtcSubcmd::Init { value_pair, token_pair } => {
|
|
|
- let (vp_send, vp_recv) = parse_value_pair(&value_pair)?;
|
|
|
- let (tp_send, tp_recv) = parse_token_pair(&drk, &token_pair).await?;
|
|
|
-
|
|
|
- let half = match drk.init_swap(vp_send, tp_send, vp_recv, tp_recv).await {
|
|
|
- Ok(h) => h,
|
|
|
- Err(e) => {
|
|
|
- eprintln!("Failed to create swap transaction half: {e:?}");
|
|
|
- exit(2);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- println!("{}", base64::encode(&serialize_async(&half).await));
|
|
|
- Ok(())
|
|
|
- }
|
|
|
+ Subcmd::Otc { command } => match command {
|
|
|
+ OtcSubcmd::Init { value_pair, token_pair } => {
|
|
|
+ let drk =
|
|
|
+ Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
+ let (vp_send, vp_recv) = parse_value_pair(&value_pair)?;
|
|
|
+ let (tp_send, tp_recv) = parse_token_pair(&drk, &token_pair).await?;
|
|
|
|
|
|
- OtcSubcmd::Join => {
|
|
|
- let mut buf = String::new();
|
|
|
- stdin().read_to_string(&mut buf)?;
|
|
|
- let Some(bytes) = base64::decode(buf.trim()) else {
|
|
|
- eprintln!("Failed to decode partial swap data");
|
|
|
+ let half = match drk.init_swap(vp_send, tp_send, vp_recv, tp_recv).await {
|
|
|
+ Ok(h) => h,
|
|
|
+ Err(e) => {
|
|
|
+ eprintln!("Failed to create swap transaction half: {e:?}");
|
|
|
exit(2);
|
|
|
- };
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- let partial: PartialSwapData = deserialize_async(&bytes).await?;
|
|
|
+ println!("{}", base64::encode(&serialize_async(&half).await));
|
|
|
+ Ok(())
|
|
|
+ }
|
|
|
|
|
|
- let tx = match drk.join_swap(partial).await {
|
|
|
- Ok(tx) => tx,
|
|
|
- Err(e) => {
|
|
|
- eprintln!("Failed to create a join swap transaction: {e:?}");
|
|
|
- exit(2);
|
|
|
- }
|
|
|
- };
|
|
|
+ OtcSubcmd::Join => {
|
|
|
+ let mut buf = String::new();
|
|
|
+ stdin().read_to_string(&mut buf)?;
|
|
|
+ let Some(bytes) = base64::decode(buf.trim()) else {
|
|
|
+ eprintln!("Failed to decode partial swap data");
|
|
|
+ exit(2);
|
|
|
+ };
|
|
|
|
|
|
- println!("{}", base64::encode(&serialize_async(&tx).await));
|
|
|
- Ok(())
|
|
|
- }
|
|
|
+ let partial: PartialSwapData = deserialize_async(&bytes).await?;
|
|
|
|
|
|
- OtcSubcmd::Inspect => {
|
|
|
- let mut buf = String::new();
|
|
|
- stdin().read_to_string(&mut buf)?;
|
|
|
- let Some(bytes) = base64::decode(buf.trim()) else {
|
|
|
- eprintln!("Failed to decode swap transaction");
|
|
|
+ let drk =
|
|
|
+ Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
+ let tx = match drk.join_swap(partial).await {
|
|
|
+ Ok(tx) => tx,
|
|
|
+ Err(e) => {
|
|
|
+ eprintln!("Failed to create a join swap transaction: {e:?}");
|
|
|
exit(2);
|
|
|
- };
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- if let Err(e) = drk.inspect_swap(bytes).await {
|
|
|
- eprintln!("Failed to inspect swap: {e:?}");
|
|
|
- exit(2);
|
|
|
- };
|
|
|
+ println!("{}", base64::encode(&serialize_async(&tx).await));
|
|
|
+ Ok(())
|
|
|
+ }
|
|
|
|
|
|
- Ok(())
|
|
|
- }
|
|
|
+ OtcSubcmd::Inspect => {
|
|
|
+ let mut buf = String::new();
|
|
|
+ stdin().read_to_string(&mut buf)?;
|
|
|
+ let Some(bytes) = base64::decode(buf.trim()) else {
|
|
|
+ eprintln!("Failed to decode swap transaction");
|
|
|
+ exit(2);
|
|
|
+ };
|
|
|
|
|
|
- OtcSubcmd::Sign => {
|
|
|
- let mut buf = String::new();
|
|
|
- stdin().read_to_string(&mut buf)?;
|
|
|
- let Some(bytes) = base64::decode(buf.trim()) else {
|
|
|
- eprintln!("Failed to decode swap transaction");
|
|
|
- exit(1);
|
|
|
- };
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
+ if let Err(e) = drk.inspect_swap(bytes).await {
|
|
|
+ eprintln!("Failed to inspect swap: {e:?}");
|
|
|
+ exit(2);
|
|
|
+ };
|
|
|
|
|
|
- let mut tx: Transaction = deserialize_async(&bytes).await?;
|
|
|
+ Ok(())
|
|
|
+ }
|
|
|
|
|
|
- if let Err(e) = drk.sign_swap(&mut tx).await {
|
|
|
- eprintln!("Failed to sign joined swap transaction: {e:?}");
|
|
|
- exit(2);
|
|
|
- };
|
|
|
+ OtcSubcmd::Sign => {
|
|
|
+ let mut buf = String::new();
|
|
|
+ stdin().read_to_string(&mut buf)?;
|
|
|
+ let Some(bytes) = base64::decode(buf.trim()) else {
|
|
|
+ eprintln!("Failed to decode swap transaction");
|
|
|
+ exit(1);
|
|
|
+ };
|
|
|
|
|
|
- println!("{}", base64::encode(&serialize_async(&tx).await));
|
|
|
- Ok(())
|
|
|
- }
|
|
|
+ let mut tx: Transaction = deserialize_async(&bytes).await?;
|
|
|
+
|
|
|
+ let drk = Drk::new(args.wallet_path, args.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);
|
|
|
+ };
|
|
|
+
|
|
|
+ println!("{}", base64::encode(&serialize_async(&tx).await));
|
|
|
+ Ok(())
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
|
|
|
Subcmd::Dao { command } => match command {
|
|
|
DaoSubcmd::Create { proposer_limit, quorum, approval_ratio, gov_token_id } => {
|
|
|
@@ -994,7 +1000,7 @@ 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(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
let gov_token_id = match drk.get_token(gov_token_id).await {
|
|
|
Ok(g) => g,
|
|
|
Err(e) => {
|
|
|
@@ -1038,7 +1044,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
let bytes = bs58::decode(&buf.trim()).into_vec()?;
|
|
|
let dao_params: DaoParams = deserialize_async(&bytes).await?;
|
|
|
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
|
|
|
if let Err(e) = drk.import_dao(dao_name, dao_params).await {
|
|
|
eprintln!("Failed to import DAO: {e:?}");
|
|
|
@@ -1049,7 +1055,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::List { dao_alias } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
// We cannot use .map() since get_dao_id() uses ?
|
|
|
let dao_id = match dao_alias {
|
|
|
Some(alias) => Some(drk.get_dao_id(&alias).await?),
|
|
|
@@ -1065,7 +1071,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::Balance { dao_alias } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
let dao_id = drk.get_dao_id(&dao_alias).await?;
|
|
|
|
|
|
let balmap = match drk.dao_balance(dao_id).await {
|
|
|
@@ -1111,7 +1117,8 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::Mint { dao_alias } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk =
|
|
|
+ Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
let dao_id = drk.get_dao_id(&dao_alias).await?;
|
|
|
|
|
|
let tx = match drk.dao_mint(dao_id).await {
|
|
|
@@ -1139,7 +1146,8 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk =
|
|
|
+ Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
let dao_id = drk.get_dao_id(&dao_alias).await?;
|
|
|
let token_id = match drk.get_token(token).await {
|
|
|
Ok(t) => t,
|
|
|
@@ -1161,7 +1169,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::Proposals { dao_alias } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
let dao_id = drk.get_dao_id(&dao_alias).await?;
|
|
|
|
|
|
let proposals = drk.get_dao_proposals(dao_id).await?;
|
|
|
@@ -1174,7 +1182,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::Proposal { dao_alias, proposal_id } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
let dao_id = drk.get_dao_id(&dao_alias).await?;
|
|
|
|
|
|
let proposals = drk.get_dao_proposals(dao_id).await?;
|
|
|
@@ -1196,7 +1204,8 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::Vote { dao_alias, proposal_id, vote, vote_weight } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk =
|
|
|
+ Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
let dao_id = drk.get_dao_id(&dao_alias).await?;
|
|
|
|
|
|
if let Err(e) = f64::from_str(&vote_weight) {
|
|
|
@@ -1227,7 +1236,8 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
DaoSubcmd::Exec { dao_alias, proposal_id } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk =
|
|
|
+ Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
let dao_id = drk.get_dao_id(&dao_alias).await?;
|
|
|
let dao = drk.get_dao_by_id(dao_id).await?;
|
|
|
let proposal = drk.get_dao_proposal_by_id(proposal_id).await?;
|
|
|
@@ -1270,7 +1280,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
|
|
|
let tx = deserialize_async(&bytes).await?;
|
|
|
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
|
|
|
let txid = match drk.broadcast_tx(&tx).await {
|
|
|
Ok(t) => t,
|
|
|
@@ -1286,9 +1296,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
Subcmd::Subscribe => {
|
|
|
- let drk =
|
|
|
- Drk::new(args.wallet_path, args.wallet_pass, args.endpoint.clone(), ex.clone())
|
|
|
- .await?;
|
|
|
+ let drk = Drk::new(
|
|
|
+ args.wallet_path,
|
|
|
+ args.wallet_pass,
|
|
|
+ Some(args.endpoint.clone()),
|
|
|
+ ex.clone(),
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
if let Err(e) = drk.subscribe_blocks(args.endpoint, ex).await {
|
|
|
eprintln!("Block subscription failed: {e:?}");
|
|
|
@@ -1299,9 +1313,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
Subcmd::Scan { reset, list, checkpoint } => {
|
|
|
- let drk =
|
|
|
- Drk::new(args.wallet_path, args.wallet_pass, args.endpoint.clone(), ex.clone())
|
|
|
- .await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
|
|
|
if reset {
|
|
|
println!("Reset requested.");
|
|
|
@@ -1340,8 +1352,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
let tx_hash = TransactionHash(*blake3::Hash::from_hex(&tx_hash)?.as_bytes());
|
|
|
|
|
|
let drk =
|
|
|
- Drk::new(args.wallet_path, args.wallet_pass, args.endpoint.clone(), ex.clone())
|
|
|
- .await?;
|
|
|
+ Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
|
|
|
let tx = match drk.get_tx(&tx_hash).await {
|
|
|
Ok(tx) => tx,
|
|
|
@@ -1384,8 +1395,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
let tx = deserialize_async(&bytes).await?;
|
|
|
|
|
|
let drk =
|
|
|
- Drk::new(args.wallet_path, args.wallet_pass, args.endpoint.clone(), ex.clone())
|
|
|
- .await?;
|
|
|
+ Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
|
|
|
let is_valid = match drk.simulate_tx(&tx).await {
|
|
|
Ok(b) => b,
|
|
|
@@ -1402,9 +1412,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
ExplorerSubcmd::TxsHistory { tx_hash, encode } => {
|
|
|
- let drk =
|
|
|
- Drk::new(args.wallet_path, args.wallet_pass, args.endpoint.clone(), ex.clone())
|
|
|
- .await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
|
|
|
if let Some(c) = tx_hash {
|
|
|
let (tx_hash, status, tx) = drk.get_tx_history_record(&c).await?;
|
|
|
@@ -1462,7 +1470,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
if let Err(e) = drk.add_alias(alias, token_id).await {
|
|
|
eprintln!("Failed to add alias: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -1483,7 +1491,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
None => None,
|
|
|
};
|
|
|
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
let map = drk.get_aliases(alias, token_id).await?;
|
|
|
|
|
|
// Create a prettytable with the new data:
|
|
|
@@ -1504,7 +1512,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
AliasSubcmd::Remove { alias } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
if let Err(e) = drk.remove_alias(alias).await {
|
|
|
eprintln!("Failed to remove alias: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -1526,7 +1534,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
if let Err(e) = drk.import_mint_authority(mint_authority).await {
|
|
|
eprintln!("Importing mint authority failed: {e:?}");
|
|
|
exit(2);
|
|
|
@@ -1541,7 +1549,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
TokenSubcmd::GenerateMint => {
|
|
|
let mint_authority = SecretKey::random(&mut OsRng);
|
|
|
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
|
|
|
if let Err(e) = drk.import_mint_authority(mint_authority).await {
|
|
|
eprintln!("Importing mint authority failed: {e:?}");
|
|
|
@@ -1556,7 +1564,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
TokenSubcmd::List => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
let tokens = drk.list_tokens().await?;
|
|
|
let aliases_map = match drk.get_aliases_mapped_by_token().await {
|
|
|
Ok(map) => map,
|
|
|
@@ -1590,7 +1598,8 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
|
|
|
// TODO: Mint directly into DAO treasury
|
|
|
TokenSubcmd::Mint { token, amount, recipient } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk =
|
|
|
+ Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
|
|
|
if let Err(e) = f64::from_str(&amount) {
|
|
|
eprintln!("Invalid amount: {e:?}");
|
|
|
@@ -1628,7 +1637,8 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
TokenSubcmd::Freeze { token } => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk =
|
|
|
+ Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
|
|
|
let _token_id = match drk.get_token(token).await {
|
|
|
Ok(t) => t,
|
|
|
Err(e) => {
|
|
|
@@ -1654,7 +1664,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
|
|
|
Subcmd::Contract { command } => match command {
|
|
|
ContractSubcmd::GenerateDeploy => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
|
|
|
if let Err(e) = drk.deploy_auth_keygen().await {
|
|
|
eprintln!("Error creating deploy auth keypair: {:?}", e);
|
|
|
@@ -1665,7 +1675,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
ContractSubcmd::List => {
|
|
|
- let drk = Drk::new(args.wallet_path, args.wallet_pass, args.endpoint, ex).await?;
|
|
|
+ let drk = Drk::new(args.wallet_path, args.wallet_pass, None, ex).await?;
|
|
|
let auths = drk.list_deploy_auth().await?;
|
|
|
|
|
|
let mut table = Table::new();
|