Skip to content

Commit

Permalink
Extent UtxosChangedScope serialization to the Indexes variant
Browse files Browse the repository at this point in the history
  • Loading branch information
tiram88 committed Apr 22, 2024
1 parent 23b5335 commit e9e42ba
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions notify/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,12 @@ where
Self::Addresses(ref addresses) => {
borsh::BorshSerialize::serialize(addresses, writer)?;
}
Self::Indexes(_) => {
todo!("Convert indexes into addresses and serialize");
Self::Indexes(ref indexes) => {
// This variant cannot be serialized as such because indexes are relative to their underlying
// tracker and the relation index->address is specific to the local execution context.
// So we build a temporary vector of addresses and serialize it.
let addresses = indexes.to_addresses();
borsh::BorshSerialize::serialize(&addresses, writer)?;
}
}
Ok(())
Expand Down Expand Up @@ -198,17 +202,20 @@ const _: () = {
where
__S: _serde::Serializer,
{
let mut __serde_state = _serde::Serializer::serialize_struct(__serializer, "UtxosChangedScope", false as usize + 1)?;
match self {
Self::Addresses(ref addresses) => {
let mut __serde_state =
_serde::Serializer::serialize_struct(__serializer, "UtxosChangedScope", false as usize + 1)?;
_serde::ser::SerializeStruct::serialize_field(&mut __serde_state, "addresses", addresses)?;
_serde::ser::SerializeStruct::end(__serde_state)
}
Self::Indexes(_) => {
todo!("Convert indexes into addresses and serialize");
Self::Indexes(ref indexes) => {
// This variant cannot be serialized as such because indexes are relative to their underlying
// tracker and the relation index->address is specific to the local execution context.
// So we build a temporary vector of addresses and serialize it.
let addresses = indexes.to_addresses();
_serde::ser::SerializeStruct::serialize_field(&mut __serde_state, "addresses", &addresses)?;
}
}
_serde::ser::SerializeStruct::end(__serde_state)
}
}
};
Expand Down

0 comments on commit e9e42ba

Please sign in to comment.