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

fix(wallet): use correct type for contract_id in the contract constitution file format #4179

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use std::convert::{TryFrom, TryInto};

use serde::{Deserialize, Serialize};
use tari_common_types::types::PublicKey;
use tari_common_types::types::{FixedHash, PublicKey};
use tari_core::transactions::transaction_components::{
CheckpointParameters,
ConstitutionChangeFlags,
Expand All @@ -34,11 +34,11 @@ use tari_core::transactions::transaction_components::{
SideChainConsensus,
SideChainFeatures,
};
use tari_utilities::ByteArray;
use tari_utilities::hex::Hex;

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ConstitutionDefinitionFileFormat {
pub contract_id: PublicKey,
pub contract_id: String,
pub validator_committee: Vec<PublicKey>,
pub consensus: SideChainConsensus,
pub initial_reward: u64,
Expand Down Expand Up @@ -66,7 +66,7 @@ impl TryFrom<ConstitutionDefinitionFileFormat> for SideChainFeatures {
type Error = String;

fn try_from(value: ConstitutionDefinitionFileFormat) -> Result<Self, Self::Error> {
let contract_id = value.contract_id.as_bytes().try_into().map_err(|e| format!("{}", e))?;
let contract_id = FixedHash::from_hex(&value.contract_id).map_err(|e| format!("{}", e))?;

Ok(Self::builder(contract_id)
.with_contract_constitution(value.try_into()?)
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/fixtures/contract_constitution.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"contract_id": "ccac168b8edd67b10d152d1ed2337efc65da9fc0b6256dd49b3c559032553d44",
"contract_id": "90b1da4524ea0e9479040d906db9194d8af90f28d05ff2d64c0a82eb93125177",
"validator_committee": [
"ccac168b8edd67b10d152d1ed2337efc65da9fc0b6256dd49b3c559032553d44",
"ccac168b8edd67b10d152d1ed2337efc65da9fc0b6256dd49b3c559032553d44",
Expand Down