Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kpinter-iohk committed Dec 12, 2024
1 parent 34df7da commit fab738a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
6 changes: 2 additions & 4 deletions toolkit/offchain/src/init_governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use ogmios_client::{
types::{OgmiosTx, OgmiosUtxo},
};
use partner_chains_plutus_data::version_oracle::VersionOracleDatum;
use sidechain_domain::{MainchainAddressHash, MainchainPrivateKey, McTxHash, UtxoId, UtxoIndex};
use sidechain_domain::{MainchainAddressHash, MainchainPrivateKey, UtxoId};

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -128,9 +128,7 @@ pub async fn run_init_governance<
let result = client.submit_transaction(&signed_transaction.to_bytes()).await?;
let tx_id = result.transaction.id;
log::info!("✅ Transaction submitted. ID: {}", hex::encode(result.transaction.id));
await_tx
.await_tx_output(client, UtxoId { tx_hash: McTxHash(tx_id), index: UtxoIndex(0) })
.await?;
await_tx.await_tx_output(client, UtxoId::new(tx_id, 0)).await?;

Ok((genesis_utxo.to_domain(), result.transaction))
}
Expand Down
22 changes: 10 additions & 12 deletions toolkit/offchain/src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use ogmios_client::{
query_ledger_state::{QueryLedgerState, QueryUtxoByUtxoId},
query_network::QueryNetwork,
transactions::Transactions,
types::{OgmiosTx, OgmiosUtxo},
types::OgmiosUtxo,
};
use partner_chains_plutus_data::registered_candidates::{
candidate_registration_to_plutus_data, RegisterValidatorDatum,
Expand All @@ -32,7 +32,7 @@ pub trait Register {
genesis_utxo: UtxoId,
candidate_registration: &CandidateRegistration,
payment_signing_key: MainchainPrivateKey,
) -> Result<Option<OgmiosTx>, OffchainError>;
) -> Result<Option<McTxHash>, OffchainError>;
}

impl<T> Register for T
Expand All @@ -44,7 +44,7 @@ where
genesis_utxo: UtxoId,
candidate_registration: &CandidateRegistration,
payment_signing_key: MainchainPrivateKey,
) -> Result<Option<OgmiosTx>, OffchainError> {
) -> Result<Option<McTxHash>, OffchainError> {
run_register(
genesis_utxo,
candidate_registration,
Expand All @@ -66,7 +66,7 @@ pub async fn run_register<
payment_signing_key: MainchainPrivateKey,
ogmios_client: &C,
await_tx: A,
) -> anyhow::Result<Option<OgmiosTx>> {
) -> anyhow::Result<Option<McTxHash>> {
let ctx = TransactionContext::for_payment_key(payment_signing_key.0, ogmios_client).await?;
let validator = crate::scripts_data::registered_candidates_scripts(genesis_utxo)?;
let validator_address = validator.address_bech32(ctx.network)?;
Expand Down Expand Up @@ -132,7 +132,7 @@ pub async fn run_register<
log::info!("✅ Transaction submitted. ID: {}", hex::encode(result.transaction.id));
await_tx.await_tx_output(ogmios_client, UtxoId::new(tx_id, 0)).await?;

Ok(Some(result.transaction))
Ok(Some(McTxHash(result.transaction.id)))
}

pub trait Deregister {
Expand All @@ -143,7 +143,7 @@ pub trait Deregister {
payment_signing_key: MainchainPrivateKey,
own_pkh: MainchainAddressHash,
stake_ownership_pub_key: MainchainPublicKey,
) -> Result<Option<OgmiosTx>, OffchainError>;
) -> Result<Option<McTxHash>, OffchainError>;
}

impl<T> Deregister for T
Expand All @@ -156,7 +156,7 @@ where
payment_signing_key: MainchainPrivateKey,
own_pkh: MainchainAddressHash,
stake_ownership_pub_key: MainchainPublicKey,
) -> Result<Option<OgmiosTx>, OffchainError> {
) -> Result<Option<McTxHash>, OffchainError> {
run_deregister(
genesis_utxo,
payment_signing_key,
Expand All @@ -180,7 +180,7 @@ pub async fn run_deregister<
stake_ownership_pub_key: MainchainPublicKey,
ogmios_client: &C,
await_tx: A,
) -> anyhow::Result<Option<OgmiosTx>> {
) -> anyhow::Result<Option<McTxHash>> {
let ctx = TransactionContext::for_payment_key(payment_signing_key.0, ogmios_client).await?;
let validator = crate::scripts_data::registered_candidates_scripts(genesis_utxo)?;
let validator_address = validator.address_bech32(ctx.network)?;
Expand Down Expand Up @@ -217,11 +217,9 @@ pub async fn run_deregister<
})?;
let tx_id = result.transaction.id;
log::info!("✅ Transaction submitted. ID: {}", hex::encode(result.transaction.id));
await_tx
.await_tx_output(ogmios_client, UtxoId { tx_hash: McTxHash(tx_id), index: UtxoIndex(0) })
.await?;
await_tx.await_tx_output(ogmios_client, UtxoId::new(tx_id, 0)).await?;

Ok(Some(result.transaction))
Ok(Some(McTxHash(result.transaction.id)))
}

fn get_own_registrations(
Expand Down

0 comments on commit fab738a

Please sign in to comment.