Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use PascalCase for PolicyIds and remove ValidatorHashes because its unused #323

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions toolkit/offchain/src/plutus_script.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{anyhow, Context};
use cardano_serialization_lib::{Address, LanguageKind, NetworkIdKind, PlutusData, ScriptHash};
use plutus::ToDatum;
use sidechain_domain::{MainchainAddressHash, PolicyId};
use sidechain_domain::PolicyId;
use uplc::ast::{DeBruijn, Program};

use crate::{csl::*, untyped_plutus::*};
Expand Down Expand Up @@ -67,10 +67,6 @@ impl PlutusScript {
ScriptHash::from(self.script_hash())
}

pub fn script_address(&self) -> MainchainAddressHash {
MainchainAddressHash(self.script_hash())
}

pub fn policy_id(&self) -> PolicyId {
PolicyId(self.script_hash())
}
Expand Down
46 changes: 3 additions & 43 deletions toolkit/offchain/src/scripts_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use uplc::PlutusData;
#[serde(rename_all = "camelCase")]
pub struct ScriptsData {
pub addresses: Addresses,
pub validator_hashes: ValidatorHashes,
pub policy_ids: PolicyIds,
}

Expand All @@ -27,19 +26,9 @@ pub struct Addresses {
pub version_oracle_validator: String,
}

/// Hashes of applied validators in partner-chains smart contracts.
#[derive(Clone, Debug, Default, Serialize, PartialEq, Eq)]
pub struct ValidatorHashes {
pub committee_candidate_validator: MainchainAddressHash,
pub d_parameter_validator: MainchainAddressHash,
pub illiquid_circulation_supply_validator: MainchainAddressHash,
pub permissioned_candidates_validator: MainchainAddressHash,
pub reserve_validator: MainchainAddressHash,
pub version_oracle_validator: MainchainAddressHash,
}

/// Policy IDs of applied scripts in partner-chains smart contracts.
#[derive(Clone, Debug, Default, Serialize, PartialEq, Eq)]
#[serde(rename_all = "PascalCase")]
LGLO marked this conversation as resolved.
Show resolved Hide resolved
pub struct PolicyIds {
pub d_parameter: PolicyId,
pub permissioned_candidates: PolicyId,
Expand Down Expand Up @@ -110,15 +99,6 @@ pub fn get_scripts_data(
reserve_validator: reserve_validator.address_bech32(network)?,
version_oracle_validator: version_oracle_validator.address_bech32(network)?,
},
validator_hashes: ValidatorHashes {
committee_candidate_validator: committee_candidate_validator.script_address(),
d_parameter_validator: d_parameter_validator.script_address(),
illiquid_circulation_supply_validator: illiquid_circulation_supply_validator
.script_address(),
permissioned_candidates_validator: permissioned_candidates_validator.script_address(),
reserve_validator: reserve_validator.script_address(),
version_oracle_validator: version_oracle_validator.script_address(),
},
policy_ids: PolicyIds {
d_parameter: d_parameter_policy.policy_id(),
permissioned_candidates: permissioned_candidates_policy.policy_id(),
Expand Down Expand Up @@ -226,11 +206,11 @@ fn multisig_governance_policy_configuration(

#[cfg(test)]
mod tests {
use crate::scripts_data::{Addresses, PolicyIds, ScriptsData, ValidatorHashes};
use crate::scripts_data::{Addresses, PolicyIds, ScriptsData};
use cardano_serialization_lib::NetworkIdKind;
use hex_literal::hex;
use pretty_assertions::assert_eq;
use sidechain_domain::{MainchainAddressHash, McTxHash, PolicyId, UtxoId};
use sidechain_domain::{McTxHash, PolicyId, UtxoId};

pub(crate) const TEST_PARAMS: UtxoId = UtxoId {
tx_hash: McTxHash(hex!("8ea10040249ad3033ae7c4d4b69e0b2e2b50a90741b783491cb5ddf8ced0d861")),
Expand All @@ -253,26 +233,6 @@ mod tests {
version_oracle_validator:
"addr_test1wqxm9e576k5ew7g7ctuqx77p9u7zytesnjsx54q2etck00gqplk0l".into(),
},
validator_hashes: ValidatorHashes {
committee_candidate_validator: MainchainAddressHash(hex!(
"8e2f67bdc3ea30fa9caf980216d1021d831ae552531bc6e151bb9ad9"
)),
d_parameter_validator: MainchainAddressHash(hex!(
"4204f181598111b98a03ad9536d73b1afdef07b547aed6b63e961c5a"
)),
illiquid_circulation_supply_validator: MainchainAddressHash(hex!(
"3d81d83fa6c2dc80ae2008c1ab9e0790b63d419191f8a6e7db283d67"
)),
permissioned_candidates_validator: MainchainAddressHash(hex!(
"3f16086833eed05ccbacd4e630b1dde68f86ff7a7adb35fa1705647f"
)),
reserve_validator: MainchainAddressHash(hex!(
"21427933d4270f33d9c90b5dc94e6f890eb47116e0b92457b3d236ad"
)),
version_oracle_validator: MainchainAddressHash(hex!(
"0db2e69ed5a997791ec2f8037bc12f3c222f309ca06a540acaf167bd"
)),
},
policy_ids: PolicyIds {
d_parameter: PolicyId(hex!(
"f30c3f90c342e61b3f34042bcabd7be8f3ec4b7a6857fdfcdb7b7936"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ mod tests {
use config_fields::CARDANO_PAYMENT_SIGNING_KEY_FILE;
use hex_literal::hex;
use ogmios_client::types::OgmiosTx;
use partner_chains_cardano_offchain::scripts_data::{
Addresses, PolicyIds, ScriptsData, ValidatorHashes,
};
use partner_chains_cardano_offchain::scripts_data::{Addresses, PolicyIds, ScriptsData};
use serde_json::json;
use serde_json::Value;
use sidechain_domain::UtxoId;
Expand Down Expand Up @@ -378,7 +376,6 @@ mod tests {
.to_string(),
..Default::default()
},
validator_hashes: ValidatorHashes::default(),
policy_ids: PolicyIds {
permissioned_candidates: PolicyId::from_hex_unsafe(
TEST_PERMISSIONED_CANDIDATES_POLICY_ID,
Expand Down
Loading