Skip to content

Commit

Permalink
store raw metadata only if cip36 data is present
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy committed May 13, 2024
1 parent 9e0783a commit eedb91e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions catalyst-gateway/bin/src/cardano/cip36_registration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ pub(crate) struct Cip36Metadata {
impl Cip36Metadata {
/// Create new `Cip36Registration` from tx metadata
/// Collect secondary errors for granular json error report
#[allow(clippy::too_many_lines)]
pub(crate) fn generate_from_tx_metadata(
tx_metadata: &MultiEraMeta, network: Network,
) -> Option<Self> {
Expand All @@ -120,14 +119,6 @@ impl Cip36Metadata {
/// <https://cips.cardano.org/cips/cip36>
const CIP36_WITNESS_CBOR_KEY: u64 = 61285;

raw_metadata = tx_metadata.encode_fragment().map_or_else(
|err| {
errors_report.push(format!("cannot encode tx metadata into bytes {err}"));
None
},
Some,
);

for (key, metadata) in tx_metadata.iter() {
match *key {
CIP36_REGISTRATION_CBOR_KEY => {
Expand Down Expand Up @@ -160,6 +151,16 @@ impl Cip36Metadata {
_ => continue,
};
}

if signature.is_some() || registration.is_some() {
raw_metadata = tx_metadata.encode_fragment().map_or_else(
|err| {
errors_report.push(format!("cannot encode tx metadata into bytes {err}"));
None
},
Some,
);
}
};

if let Some(raw_61284) = raw_61284 {
Expand Down

0 comments on commit eedb91e

Please sign in to comment.