Skip to content

Commit

Permalink
add serde default for is_promise fields (#11017)
Browse files Browse the repository at this point in the history
  • Loading branch information
saketh-are authored Apr 10, 2024
1 parent 15adc08 commit 31873f1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/primitives/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1935,16 +1935,25 @@ pub enum ReceiptEnumView {
output_data_receivers: Vec<DataReceiverView>,
input_data_ids: Vec<CryptoHash>,
actions: Vec<ActionView>,
#[serde(default = "default_is_promise")]
is_promise_yield: bool,
},
Data {
data_id: CryptoHash,
#[serde_as(as = "Option<Base64>")]
data: Option<Vec<u8>>,
#[serde(default = "default_is_promise")]
is_promise_resume: bool,
},
}

// Default value used when deserializing ReceiptEnumViews which are missing either the
// `is_promise_yield` or `is_promise_resume` fields. Data which is missing this field was
// serialized before the introduction of yield execution.
fn default_is_promise() -> bool {
false
}

impl From<Receipt> for ReceiptView {
fn from(receipt: Receipt) -> Self {
let is_promise_yield = matches!(&receipt.receipt, ReceiptEnum::PromiseYield(_));
Expand Down

0 comments on commit 31873f1

Please sign in to comment.