How to obtain a stable encoding of emitted events from a smart contract?
I have a smart contract which emits events when these events are later fetched from the chain:
#[ink(event)]
pub struct MissionReady {
#[ink(topic)]
owner: AccountId,
#[ink(topic)]
operator: AccountId,
}
#[ink(event)]
/// Mission finished successfully
pub struct MissionAccomplished {}
#[ink(event)]
/// Mission is deployed on the target fleet as claimed by the network operator
pub struct MissionDeployed {}
they are scale encoded respectively as
[0, 178, 156, 14, 4, 92, 150, 156, 193, 7, 172, 3, 90, 148, 68, 118, 151, 188, 182, 196 ...]
[1]
[2]
which looks like they are stored in an enum internally.
This encoding changes if the order in the source code is changed.
The generated metadata in the .contract file can be read with a shell command like this:
cat ./target/ink/$i/$i.contract | jq '{"V3"}[]."spec"."events"'
But this will only detect changes, not prevent them, is there a way to fixate the encoding to keep the binary interface while recompiling the contract?