From eed74b9ab406ab7e4786c5102538d960174f658f Mon Sep 17 00:00:00 2001 From: Robert Hambrock Date: Sun, 5 Dec 2021 17:02:56 +0100 Subject: [PATCH 1/2] add strict encoding for PublicOfferId --- src/negotiation.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/negotiation.rs b/src/negotiation.rs index 2de6bb58..164e3491 100644 --- a/src/negotiation.rs +++ b/src/negotiation.rs @@ -485,6 +485,21 @@ impl<'de> Deserialize<'de> for PublicOfferId { } } +impl Encodable for PublicOfferId { + fn consensus_encode(&self, s: &mut W) -> Result { + self.0.consensus_encode(s) + } +} + +impl Decodable for PublicOfferId { + fn consensus_decode(d: &mut D) -> Result { + let bytes: [u8; 32] = Decodable::consensus_decode(d)?; + Ok(Self::from_slice(&bytes)) + } +} + +impl_strict_encoding!(PublicOfferId); + /// A public offer is shared across [`TradeRole::Maker`]'s prefered network to signal is willing of /// trading some assets at some conditions. The assets and condition are defined in the [`Offer`], /// maker peer connection information are contained in the public offer. From f25d5fa435c11c9086261b475fc7df9edb4af03f Mon Sep 17 00:00:00 2001 From: Robert Hambrock Date: Sun, 5 Dec 2021 18:12:08 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16bfb5ea..411ef4fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `strict_encoding` implementation for `PublicOfferId` type ([#195](https://github.com/farcaster-project/farcaster-core/pull/195)) + ## [0.4.2] - 2021-12-05 ### Added