From bbff6012cd2b73ca6f3c4c236ce974fc10389800 Mon Sep 17 00:00:00 2001 From: Chris Guimaraes Date: Fri, 11 Aug 2023 17:16:16 +0100 Subject: [PATCH] feat: add principal data serializer --- components/clarinet-deployments/src/types.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/components/clarinet-deployments/src/types.rs b/components/clarinet-deployments/src/types.rs index 6c4b537f7..aed19c58e 100644 --- a/components/clarinet-deployments/src/types.rs +++ b/components/clarinet-deployments/src/types.rs @@ -28,6 +28,13 @@ where s.serialize_str(&x.to_address()) } +fn principal_data_serializer(x: &PrincipalData, s: S) -> Result +where + S: Serializer, +{ + s.serialize_str(&x.to_string()) +} + fn source_serializer(x: &str, s: S) -> Result where S: Serializer, @@ -36,7 +43,10 @@ where s.serialize_str(&enc) } -fn qualified_contract_identifier_serializer(x: &QualifiedContractIdentifier, s: S) -> Result +fn qualified_contract_identifier_serializer( + x: &QualifiedContractIdentifier, + s: S, +) -> Result where S: Serializer, { @@ -251,6 +261,7 @@ type MemoArr = [u8; MEMO_BYTE_COUNT]; pub struct StxTransferSpecification { #[serde(serialize_with = "standard_principal_data_serializer")] pub expected_sender: StandardPrincipalData, + #[serde(serialize_with = "principal_data_serializer")] pub recipient: PrincipalData, pub mstx_amount: u64, #[serde_as(as = "Bytes")] @@ -335,6 +346,7 @@ impl BtcTransferSpecification { #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct ContractCallSpecification { + #[serde(serialize_with = "qualified_contract_identifier_serializer")] pub contract_id: QualifiedContractIdentifier, #[serde(serialize_with = "standard_principal_data_serializer")] pub expected_sender: StandardPrincipalData, @@ -1177,4 +1189,4 @@ impl TransactionPlanSpecification { TransactionPlanSpecificationFile { batches } } -} \ No newline at end of file +}