Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions crates/aot/src/auth/auth_id.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{Result, bail};
use snarkvm::{console::types::Field, ledger::block::Transaction};
use snarkvm::ledger::block::Transaction;

use crate::{Authorization, Network};

Expand All @@ -18,20 +18,32 @@ pub fn fee_from_auth<N: Network>(
pub fn auth_tx_id<N: Network>(
auth: &Authorization<N>,
// Left in for backwards compatibility
_fee_auth: Option<&Authorization<N>>,
fee_auth: Option<&Authorization<N>>,
) -> Result<N::TransactionID> {
let field: Field<N> = *Transaction::transitions_tree(auth.transitions().values())?.root();
let execute_tree = Transaction::transitions_tree(auth.transitions().values())?;
let fee = fee_auth.map(fee_from_auth).transpose()?;

Ok(field.into())
let tree = match fee {
Some(fee) => Transaction::transaction_tree(execute_tree, auth.len(), &fee)?,
None => execute_tree,
};

Ok((*tree.root()).into())
}

/// compute the transaction ID for a deployment using the deployment and fee
pub fn deploy_tx_id<N: Network>(
deployment: &snarkvm::ledger::block::Deployment<N>,
// Left in for backwards compatibility
_fee_auth: Option<&Authorization<N>>,
fee_auth: Option<&Authorization<N>>,
) -> Result<N::TransactionID> {
let field: Field<N> = *Transaction::deployment_tree(deployment)?.root();
let deployment_tree = Transaction::deployment_tree(deployment)?;
let fee = fee_auth.map(fee_from_auth).transpose()?;

let tree = match fee {
Some(fee) => Transaction::transaction_tree(deployment_tree, deployment.len(), &fee)?,
None => deployment_tree,
};

Ok(field.into())
Ok((*tree.root()).into())
}
Loading