drk: added fee call to deployoOor calls

This commit is contained in:
skoupidi
2024-05-17 20:18:04 +03:00
parent 4661d797cd
commit 0243560e1f
5 changed files with 25 additions and 14 deletions

View File

@@ -136,7 +136,7 @@ impl Drk {
Ok(keypair)
}
/// Create a contract deployment transaction
/// Create a feeless contract deployment transaction.
pub async fn deploy_contract(
&self,
deploy_auth: u64,
@@ -157,8 +157,6 @@ impl Drk {
let mut tx_builder =
TransactionBuilder::new(ContractCallLeaf { call, proofs: vec![] }, vec![])?;
// TODO: Tx fees
let mut tx = tx_builder.build()?;
let sigs = tx.create_sigs(&[deploy_keypair.secret])?;
tx.signatures = vec![sigs];
@@ -166,7 +164,7 @@ impl Drk {
Ok(tx)
}
/// Create a contract redeployment lock transaction
/// Create a feeless contract redeployment lock transaction.
pub async fn lock_contract(&self, deploy_auth: u64) -> Result<Transaction> {
// Fetch the keypair
let deploy_keypair = self.get_deploy_auth(deploy_auth).await?;
@@ -182,8 +180,6 @@ impl Drk {
let mut tx_builder =
TransactionBuilder::new(ContractCallLeaf { call, proofs: vec![] }, vec![])?;
// TODO: Tx fees
let mut tx = tx_builder.build()?;
let sigs = tx.create_sigs(&[deploy_keypair.secret])?;
tx.signatures = vec![sigs];

View File

@@ -1295,12 +1295,15 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
};
println!("{}", base64::encode(&serialize_async(&tx).await));
Ok(())
}
Subcmd::Inspect => {
let tx = parse_tx_from_stdin().await?;
println!("{tx:#?}");
Ok(())
}
@@ -1730,7 +1733,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
let drk =
Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
let tx = match drk.deploy_contract(deploy_auth, wasm_bin, deploy_ix).await {
let mut tx = match drk.deploy_contract(deploy_auth, wasm_bin, deploy_ix).await {
Ok(v) => v,
Err(e) => {
eprintln!("Error creating contract deployment tx: {}", e);
@@ -1738,7 +1741,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
}
};
if let Err(e) = drk.attach_fee(&mut tx).await {
eprintln!("Failed to attach the fee call to the transaction: {e:?}");
exit(2);
};
println!("{}", base64::encode(&serialize_async(&tx).await));
Ok(())
}
@@ -1746,7 +1755,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
let drk =
Drk::new(args.wallet_path, args.wallet_pass, Some(args.endpoint), ex).await?;
let tx = match drk.lock_contract(deploy_auth).await {
let mut tx = match drk.lock_contract(deploy_auth).await {
Ok(v) => v,
Err(e) => {
eprintln!("Error creating contract lock tx: {}", e);
@@ -1754,7 +1763,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
}
};
if let Err(e) = drk.attach_fee(&mut tx).await {
eprintln!("Failed to attach the fee call to the transaction: {e:?}");
exit(2);
};
println!("{}", base64::encode(&serialize_async(&tx).await));
Ok(())
}
},

View File

@@ -213,7 +213,7 @@ impl Drk {
// Decode provided amount
let amount = decode_base10(amount, BALANCE_BASE10_DECIMALS, false)?;
// Grab token ID mint authority and attribtes
// Grab token ID mint authority and attributes
let token_mint_authority = self.get_token_mint_authority(&token_id).await?;
let token_attrs =
self.derive_token_attributes(token_mint_authority.1, token_mint_authority.2);
@@ -329,7 +329,7 @@ impl Drk {
/// Create a token freeze transaction. Returns the transaction object on success.
pub async fn freeze_token(&self, token_id: TokenId) -> Result<Transaction> {
// Grab token ID mint authority and attribtes
// Grab token ID mint authority and attributes
let token_mint_authority = self.get_token_mint_authority(&token_id).await?;
let token_attrs =
self.derive_token_attributes(token_mint_authority.1, token_mint_authority.2);

View File

@@ -18,7 +18,7 @@
use darkfi::Result;
use darkfi_sdk::{crypto::Keypair, deploy::DeployParamsV1};
use log::info;
use log::debug;
pub struct DeployCallDebris {
pub params: DeployParamsV1,
@@ -36,7 +36,7 @@ pub struct DeployCallBuilder {
impl DeployCallBuilder {
pub fn build(&self) -> Result<DeployCallDebris> {
info!("Building Deployooor::DeployV1 contract call");
debug!("Building Deployooor::DeployV1 contract call");
assert!(!self.wasm_bincode.is_empty());
let params = DeployParamsV1 {

View File

@@ -18,7 +18,7 @@
use darkfi::Result;
use darkfi_sdk::crypto::Keypair;
use log::info;
use log::debug;
use crate::model::LockParamsV1;
@@ -34,7 +34,7 @@ pub struct LockCallBuilder {
impl LockCallBuilder {
pub fn build(&self) -> Result<LockCallDebris> {
info!("Building Deployooor::LockV1 contract call");
debug!("Building Deployooor::LockV1 contract call");
let params = LockParamsV1 { public_key: self.deploy_keypair.public };
let debris = LockCallDebris { params };