From 0b9a64ec71c893db937ae3748bc103046b29739a Mon Sep 17 00:00:00 2001 From: glihm Date: Wed, 8 Jan 2025 18:28:24 -0600 Subject: [PATCH 01/15] feat: add the manual registration of messages gated under messaging_test feature --- .tool-versions | 2 +- Scarb.toml | 4 +- bindings/src/bindings.rs | 2 +- src/appchain_test.cairo | 217 ++++++++++++++++++++++++++++++++++ src/lib.cairo | 4 + src/messaging/component.cairo | 28 +++++ src/messaging/interface.cairo | 12 ++ 7 files changed, 266 insertions(+), 3 deletions(-) create mode 100644 src/appchain_test.cairo diff --git a/.tool-versions b/.tool-versions index 4e4d000..8e4fd02 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -scarb 2.8.0 +scarb 2.8.4 starknet-foundry 0.27.0 diff --git a/Scarb.toml b/Scarb.toml index cc33e9c..539aac6 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2023_10" [dependencies] -starknet = "2.8.0" +starknet = "2.8.4" openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.16.0" } [dev-dependencies] @@ -25,3 +25,5 @@ sierra = true [tool.fmt] sort-module-level-items = true +[features] +messaging_test = [] diff --git a/bindings/src/bindings.rs b/bindings/src/bindings.rs index 63674f2..17b5b26 100644 --- a/bindings/src/bindings.rs +++ b/bindings/src/bindings.rs @@ -1 +1 @@ -# [derive (Debug)] pub struct AppChain < A : starknet :: accounts :: ConnectedAccount + Sync > {pub address : starknet :: core :: types :: Felt , pub account : A , pub block_id : starknet :: core :: types :: BlockId ,} impl < A : starknet :: accounts :: ConnectedAccount + Sync > AppChain < A > {pub fn new (address : starknet :: core :: types :: Felt , account : A) -> Self {Self {address , account , block_id : starknet :: core :: types :: BlockId :: Tag (starknet :: core :: types :: BlockTag :: Pending)}} pub fn set_contract_address (& mut self , address : starknet :: core :: types :: Felt) {self . address = address ;} pub fn provider (& self) -> & A :: Provider {self . account . provider ()} pub fn set_block (& mut self , block_id : starknet :: core :: types :: BlockId) {self . block_id = block_id ;} pub fn with_block (self , block_id : starknet :: core :: types :: BlockId) -> Self {Self {block_id , .. self}}} # [derive (Debug)] pub struct AppChainReader < P : starknet :: providers :: Provider + Sync > {pub address : starknet :: core :: types :: Felt , pub provider : P , pub block_id : starknet :: core :: types :: BlockId ,} impl < P : starknet :: providers :: Provider + Sync > AppChainReader < P > {pub fn new (address : starknet :: core :: types :: Felt , provider : P ,) -> Self {Self {address , provider , block_id : starknet :: core :: types :: BlockId :: Tag (starknet :: core :: types :: BlockTag :: Pending)}} pub fn set_contract_address (& mut self , address : starknet :: core :: types :: Felt) {self . address = address ;} pub fn provider (& self) -> & P {& self . provider} pub fn set_block (& mut self , block_id : starknet :: core :: types :: BlockId) {self . block_id = block_id ;} pub fn with_block (self , block_id : starknet :: core :: types :: BlockId) -> Self {Self {block_id , .. self}}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct ContractChanges {pub addr : starknet :: core :: types :: Felt , pub nonce : starknet :: core :: types :: Felt , pub class_hash : Option < starknet :: core :: types :: Felt > , pub storage_changes : Vec < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) >} impl cainome :: cairo_serde :: CairoSerde for ContractChanges {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . addr) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size += Option :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . class_hash) ; __size += Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialized_size (& __rust . storage_changes) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . addr)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out . extend (Option :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . class_hash)) ; __out . extend (Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialize (& __rust . storage_changes)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let addr = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& addr) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let class_hash = Option :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Option :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& class_hash) ; let storage_changes = Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialized_size (& storage_changes) ; Ok (ContractChanges {addr , nonce , class_hash , storage_changes})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct LogStateTransitionFact {pub state_transition_fact : cainome :: cairo_serde :: U256} impl cainome :: cairo_serde :: CairoSerde for LogStateTransitionFact {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: U256 :: cairo_serialized_size (& __rust . state_transition_fact) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: U256 :: cairo_serialize (& __rust . state_transition_fact)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let state_transition_fact = cainome :: cairo_serde :: U256 :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: U256 :: cairo_serialized_size (& state_transition_fact) ; Ok (LogStateTransitionFact {state_transition_fact})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct LogStateUpdate {pub state_root : starknet :: core :: types :: Felt , pub block_number : starknet :: core :: types :: Felt , pub block_hash : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for LogStateUpdate {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . state_root) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . block_number) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . block_hash) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . state_root)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . block_number)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . block_hash)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let state_root = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& state_root) ; let block_number = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_number) ; let block_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_hash) ; Ok (LogStateUpdate {state_root , block_number , block_hash})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageCanceled {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for MessageCanceled {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; Ok (MessageCanceled {message_hash , from , to , selector , payload , nonce})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageCancellationStarted {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for MessageCancellationStarted {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; Ok (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageConsumed {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageConsumed {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageConsumed {message_hash , from , to , payload})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageSent {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub nonce : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageSent {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageSent {message_hash , from , to , selector , nonce , payload})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageToAppchainSealed {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub nonce : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainSealed {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageToStarknetReceived {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageToStarknetReceived {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageToStarknetReceived {message_hash , from , to , payload})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct OwnershipTransferStarted {pub previous_owner : cainome :: cairo_serde :: ContractAddress , pub new_owner : cainome :: cairo_serde :: ContractAddress} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferStarted {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . previous_owner) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . new_owner) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . previous_owner)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . new_owner)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let previous_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; Ok (OwnershipTransferStarted {previous_owner , new_owner})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct OwnershipTransferred {pub previous_owner : cainome :: cairo_serde :: ContractAddress , pub new_owner : cainome :: cairo_serde :: ContractAddress} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferred {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . previous_owner) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . new_owner) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . previous_owner)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . new_owner)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let previous_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; Ok (OwnershipTransferred {previous_owner , new_owner})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct ProgramInfoChanged {pub changed_by : cainome :: cairo_serde :: ContractAddress , pub old_program_hash : starknet :: core :: types :: Felt , pub new_program_hash : starknet :: core :: types :: Felt , pub old_config_hash : starknet :: core :: types :: Felt , pub new_config_hash : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for ProgramInfoChanged {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . changed_by) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . old_program_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . new_program_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . old_config_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . new_config_hash) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . changed_by)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . old_program_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . new_program_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . old_config_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . new_config_hash)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let changed_by = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; Ok (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct StarknetOsOutput {pub initial_root : starknet :: core :: types :: Felt , pub final_root : starknet :: core :: types :: Felt , pub prev_block_number : starknet :: core :: types :: Felt , pub new_block_number : starknet :: core :: types :: Felt , pub prev_block_hash : starknet :: core :: types :: Felt , pub new_block_hash : starknet :: core :: types :: Felt , pub os_program_hash : starknet :: core :: types :: Felt , pub starknet_os_config_hash : starknet :: core :: types :: Felt , pub use_kzg_da : starknet :: core :: types :: Felt , pub full_output : starknet :: core :: types :: Felt , pub messages_to_l1 : Vec < starknet :: core :: types :: Felt > , pub messages_to_l2 : Vec < starknet :: core :: types :: Felt > , pub contracts : Vec < ContractChanges > , pub classes : Vec < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) >} impl cainome :: cairo_serde :: CairoSerde for StarknetOsOutput {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . initial_root) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . final_root) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . prev_block_number) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . new_block_number) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . prev_block_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . new_block_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . os_program_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . starknet_os_config_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . use_kzg_da) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . full_output) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . messages_to_l1) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . messages_to_l2) ; __size += Vec :: < ContractChanges > :: cairo_serialized_size (& __rust . contracts) ; __size += Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialized_size (& __rust . classes) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . initial_root)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . final_root)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . prev_block_number)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . new_block_number)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . prev_block_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . new_block_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . os_program_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . starknet_os_config_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . use_kzg_da)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . full_output)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . messages_to_l1)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . messages_to_l2)) ; __out . extend (Vec :: < ContractChanges > :: cairo_serialize (& __rust . contracts)) ; __out . extend (Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialize (& __rust . classes)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let initial_root = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& initial_root) ; let final_root = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& final_root) ; let prev_block_number = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& prev_block_number) ; let new_block_number = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_block_number) ; let prev_block_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& prev_block_hash) ; let new_block_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_block_hash) ; let os_program_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& os_program_hash) ; let starknet_os_config_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& starknet_os_config_hash) ; let use_kzg_da = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& use_kzg_da) ; let full_output = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& full_output) ; let messages_to_l1 = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& messages_to_l1) ; let messages_to_l2 = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& messages_to_l2) ; let contracts = Vec :: < ContractChanges > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < ContractChanges > :: cairo_serialized_size (& contracts) ; let classes = Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialized_size (& classes) ; Ok (StarknetOsOutput {initial_root , final_root , prev_block_number , new_block_number , prev_block_hash , new_block_hash , os_program_hash , starknet_os_config_hash , use_kzg_da , full_output , messages_to_l1 , messages_to_l2 , contracts , classes})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct Upgraded {pub class_hash : cainome :: cairo_serde :: ClassHash} impl cainome :: cairo_serde :: CairoSerde for Upgraded {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& __rust . class_hash) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ClassHash :: cairo_serialize (& __rust . class_hash)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let class_hash = cainome :: cairo_serde :: ClassHash :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; Ok (Upgraded {class_hash})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {OwnershipTransferred (OwnershipTransferred) , OwnershipTransferStarted (OwnershipTransferStarted)} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {Event :: OwnershipTransferred (val) => OwnershipTransferred :: cairo_serialized_size (val) + 1 , Event :: OwnershipTransferStarted (val) => OwnershipTransferStarted :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {Event :: OwnershipTransferred (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (OwnershipTransferred :: cairo_serialize (val)) ; temp} , Event :: OwnershipTransferStarted (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (OwnershipTransferStarted :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (Event :: OwnershipTransferred (OwnershipTransferred :: cairo_deserialize (__felts , __offset + 1) ?)) , 1usize => Ok (Event :: OwnershipTransferStarted (OwnershipTransferStarted :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferred") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferred")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (Event :: OwnershipTransferred (OwnershipTransferred {previous_owner , new_owner}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (Event :: OwnershipTransferStarted (OwnershipTransferStarted {previous_owner , new_owner}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {ProgramInfoChanged (ProgramInfoChanged)} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {Event :: ProgramInfoChanged (val) => ProgramInfoChanged :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {Event :: ProgramInfoChanged (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (ProgramInfoChanged :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (Event :: ProgramInfoChanged (ProgramInfoChanged :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("ProgramInfoChanged") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "ProgramInfoChanged")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let changed_by = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "changed_by" , "ProgramInfoChanged" , e)) ,} ; data_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; return Ok (Event :: ProgramInfoChanged (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {MessageSent (MessageSent) , MessageConsumed (MessageConsumed) , MessageCancellationStarted (MessageCancellationStarted) , MessageCanceled (MessageCanceled) , MessageToStarknetReceived (MessageToStarknetReceived) , MessageToAppchainSealed (MessageToAppchainSealed)} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {Event :: MessageSent (val) => MessageSent :: cairo_serialized_size (val) + 1 , Event :: MessageConsumed (val) => MessageConsumed :: cairo_serialized_size (val) + 1 , Event :: MessageCancellationStarted (val) => MessageCancellationStarted :: cairo_serialized_size (val) + 1 , Event :: MessageCanceled (val) => MessageCanceled :: cairo_serialized_size (val) + 1 , Event :: MessageToStarknetReceived (val) => MessageToStarknetReceived :: cairo_serialized_size (val) + 1 , Event :: MessageToAppchainSealed (val) => MessageToAppchainSealed :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {Event :: MessageSent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (MessageSent :: cairo_serialize (val)) ; temp} , Event :: MessageConsumed (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (MessageConsumed :: cairo_serialize (val)) ; temp} , Event :: MessageCancellationStarted (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 2usize)) ; temp . extend (MessageCancellationStarted :: cairo_serialize (val)) ; temp} , Event :: MessageCanceled (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 3usize)) ; temp . extend (MessageCanceled :: cairo_serialize (val)) ; temp} , Event :: MessageToStarknetReceived (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 4usize)) ; temp . extend (MessageToStarknetReceived :: cairo_serialize (val)) ; temp} , Event :: MessageToAppchainSealed (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 5usize)) ; temp . extend (MessageToAppchainSealed :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (Event :: MessageSent (MessageSent :: cairo_deserialize (__felts , __offset + 1) ?)) , 1usize => Ok (Event :: MessageConsumed (MessageConsumed :: cairo_deserialize (__felts , __offset + 1) ?)) , 2usize => Ok (Event :: MessageCancellationStarted (MessageCancellationStarted :: cairo_deserialize (__felts , __offset + 1) ?)) , 3usize => Ok (Event :: MessageCanceled (MessageCanceled :: cairo_deserialize (__felts , __offset + 1) ?)) , 4usize => Ok (Event :: MessageToStarknetReceived (MessageToStarknetReceived :: cairo_deserialize (__felts , __offset + 1) ?)) , 5usize => Ok (Event :: MessageToAppchainSealed (MessageToAppchainSealed :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageSent") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageSent")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageSent" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageSent" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessageSent (MessageSent {message_hash , from , to , selector , nonce , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageConsumed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageConsumed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageConsumed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageConsumed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessageConsumed (MessageConsumed {message_hash , from , to , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCancellationStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCancellationStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCancellationStarted" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCancellationStarted" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (Event :: MessageCancellationStarted (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCanceled") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCanceled")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCanceled" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCanceled" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (Event :: MessageCanceled (MessageCanceled {message_hash , from , to , selector , payload , nonce}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToStarknetReceived") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToStarknetReceived")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToStarknetReceived" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToStarknetReceived" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessageToStarknetReceived (MessageToStarknetReceived {message_hash , from , to , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToAppchainSealed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToAppchainSealed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToAppchainSealed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToAppchainSealed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessageToAppchainSealed (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {OwnableEvent (Event) , UpgradeableEvent (Event) , ConfigEvent (Event) , MessagingEvent (Event) , ReentrancyGuardEvent (Event) , StateEvent (Event) , LogStateUpdate (LogStateUpdate) , LogStateTransitionFact (LogStateTransitionFact)} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {Event :: OwnableEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: UpgradeableEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: ConfigEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: MessagingEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: ReentrancyGuardEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: StateEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: LogStateUpdate (val) => LogStateUpdate :: cairo_serialized_size (val) + 1 , Event :: LogStateTransitionFact (val) => LogStateTransitionFact :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {Event :: OwnableEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: UpgradeableEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: ConfigEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 2usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: MessagingEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 3usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: ReentrancyGuardEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 4usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: StateEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 5usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: LogStateUpdate (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 6usize)) ; temp . extend (LogStateUpdate :: cairo_serialize (val)) ; temp} , Event :: LogStateTransitionFact (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 7usize)) ; temp . extend (LogStateTransitionFact :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (Event :: OwnableEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 1usize => Ok (Event :: UpgradeableEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 2usize => Ok (Event :: ConfigEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 3usize => Ok (Event :: MessagingEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 4usize => Ok (Event :: ReentrancyGuardEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 5usize => Ok (Event :: StateEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 6usize => Ok (Event :: LogStateUpdate (LogStateUpdate :: cairo_deserialize (__felts , __offset + 1) ?)) , 7usize => Ok (Event :: LogStateTransitionFact (LogStateTransitionFact :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferred") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferred")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (Event :: OwnableEvent (Event :: OwnershipTransferred (OwnershipTransferred {previous_owner , new_owner})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (Event :: OwnableEvent (Event :: OwnershipTransferStarted (OwnershipTransferStarted {previous_owner , new_owner})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("Upgraded") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "Upgraded")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let class_hash = match cainome :: cairo_serde :: ClassHash :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "class_hash" , "Upgraded" , e)) ,} ; data_offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; return Ok (Event :: UpgradeableEvent (Event :: Upgraded (Upgraded {class_hash})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("ProgramInfoChanged") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "ProgramInfoChanged")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let changed_by = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "changed_by" , "ProgramInfoChanged" , e)) ,} ; data_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; return Ok (Event :: ConfigEvent (Event :: ProgramInfoChanged (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageSent") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageSent")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageSent" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageSent" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessagingEvent (Event :: MessageSent (MessageSent {message_hash , from , to , selector , nonce , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageConsumed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageConsumed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageConsumed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageConsumed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessagingEvent (Event :: MessageConsumed (MessageConsumed {message_hash , from , to , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCancellationStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCancellationStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCancellationStarted" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCancellationStarted" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (Event :: MessagingEvent (Event :: MessageCancellationStarted (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCanceled") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCanceled")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCanceled" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCanceled" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (Event :: MessagingEvent (Event :: MessageCanceled (MessageCanceled {message_hash , from , to , selector , payload , nonce})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToStarknetReceived") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToStarknetReceived")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToStarknetReceived" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToStarknetReceived" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessagingEvent (Event :: MessageToStarknetReceived (MessageToStarknetReceived {message_hash , from , to , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToAppchainSealed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToAppchainSealed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToAppchainSealed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToAppchainSealed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessagingEvent (Event :: MessageToAppchainSealed (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("LogStateUpdate") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "LogStateUpdate")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let state_root = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "state_root" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& state_root) ; let block_number = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "block_number" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_number) ; let block_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "block_hash" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_hash) ; return Ok (Event :: LogStateUpdate (LogStateUpdate {state_root , block_number , block_hash}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("LogStateTransitionFact") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "LogStateTransitionFact")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let state_transition_fact = match cainome :: cairo_serde :: U256 :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "state_transition_fact" , "LogStateTransitionFact" , e)) ,} ; data_offset += cainome :: cairo_serde :: U256 :: cairo_serialized_size (& state_transition_fact) ; return Ok (Event :: LogStateTransitionFact (LogStateTransitionFact {state_transition_fact}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {_ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {_ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {_ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {Upgraded (Upgraded)} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {Event :: Upgraded (val) => Upgraded :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {Event :: Upgraded (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (Upgraded :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (Event :: Upgraded (Upgraded :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("Upgraded") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "Upgraded")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let class_hash = match cainome :: cairo_serde :: ClassHash :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "class_hash" , "Upgraded" , e)) ,} ; data_offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; return Ok (Event :: Upgraded (Upgraded {class_hash}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {_ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {_ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {_ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum MessageToAppchainStatus {SealedOrNotSent , Pending (starknet :: core :: types :: Felt)} impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainStatus {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {MessageToAppchainStatus :: SealedOrNotSent => 1 , MessageToAppchainStatus :: Pending (val) => starknet :: core :: types :: Felt :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {MessageToAppchainStatus :: SealedOrNotSent => usize :: cairo_serialize (& 0usize) , MessageToAppchainStatus :: Pending (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (starknet :: core :: types :: Felt :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (MessageToAppchainStatus :: SealedOrNotSent) , 1usize => Ok (MessageToAppchainStatus :: Pending (starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "MessageToAppchainStatus")))}}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum MessageToStarknetStatus {NothingToConsume , ReadyToConsume (starknet :: core :: types :: Felt)} impl cainome :: cairo_serde :: CairoSerde for MessageToStarknetStatus {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {MessageToStarknetStatus :: NothingToConsume => 1 , MessageToStarknetStatus :: ReadyToConsume (val) => starknet :: core :: types :: Felt :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {MessageToStarknetStatus :: NothingToConsume => usize :: cairo_serialize (& 0usize) , MessageToStarknetStatus :: ReadyToConsume (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (starknet :: core :: types :: Felt :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (MessageToStarknetStatus :: NothingToConsume) , 1usize => Ok (MessageToStarknetStatus :: ReadyToConsume (starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "MessageToStarknetStatus")))}}} impl < A : starknet :: accounts :: ConnectedAccount + Sync > AppChain < A > {# [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn appchain_to_sn_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , MessageToStarknetStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("appchain_to_sn_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_facts_registry (& self ,) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , cainome :: cairo_serde :: ContractAddress > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_facts_registry") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_program_info (& self ,) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_program_info") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_state (& self ,) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_state") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn is_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , bool > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("is_operator") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn sn_to_appchain_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , MessageToAppchainStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("sn_to_appchain_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn cancel_message_getcall (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("cancel_message") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn cancel_message (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("cancel_message") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn consume_message_from_appchain_getcall (& self , from_address : & cainome :: cairo_serde :: ContractAddress , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (from_address)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("consume_message_from_appchain") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn consume_message_from_appchain (& self , from_address : & cainome :: cairo_serde :: ContractAddress , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (from_address)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("consume_message_from_appchain") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn register_operator_getcall (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("register_operator") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn register_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("register_operator") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn send_message_to_appchain_getcall (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("send_message_to_appchain") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn send_message_to_appchain (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("send_message_to_appchain") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_facts_registry_getcall (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_facts_registry") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_facts_registry (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_facts_registry") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_program_info_getcall (& self , program_hash : & starknet :: core :: types :: Felt , config_hash : & starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (program_hash)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (config_hash)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_program_info") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_program_info (& self , program_hash : & starknet :: core :: types :: Felt , config_hash : & starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (program_hash)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (config_hash)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_program_info") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn start_message_cancellation_getcall (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("start_message_cancellation") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn start_message_cancellation (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("start_message_cancellation") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn unregister_operator_getcall (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("unregister_operator") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn unregister_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("unregister_operator") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update_getcall (& self , program_output : & StarknetOsOutput) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (StarknetOsOutput :: cairo_serialize (program_output)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update (& self , program_output : & StarknetOsOutput) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (StarknetOsOutput :: cairo_serialize (program_output)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update_state_getcall (& self , snos_output : & Vec :: < starknet :: core :: types :: Felt > , program_output : & Vec :: < starknet :: core :: types :: Felt > , onchain_data_hash : & starknet :: core :: types :: Felt , onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (snos_output)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (program_output)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (onchain_data_hash)) ; __calldata . extend (cainome :: cairo_serde :: U256 :: cairo_serialize (onchain_data_size)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update_state") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update_state (& self , snos_output : & Vec :: < starknet :: core :: types :: Felt > , program_output : & Vec :: < starknet :: core :: types :: Felt > , onchain_data_hash : & starknet :: core :: types :: Felt , onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (snos_output)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (program_output)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (onchain_data_hash)) ; __calldata . extend (cainome :: cairo_serde :: U256 :: cairo_serialize (onchain_data_size)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update_state") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn upgrade_getcall (& self , new_class_hash : & cainome :: cairo_serde :: ClassHash) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ClassHash :: cairo_serialize (new_class_hash)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("upgrade") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn upgrade (& self , new_class_hash : & cainome :: cairo_serde :: ClassHash) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ClassHash :: cairo_serialize (new_class_hash)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("upgrade") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])}} impl < P : starknet :: providers :: Provider + Sync > AppChainReader < P > {# [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn appchain_to_sn_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < P , MessageToStarknetStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("appchain_to_sn_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_facts_registry (& self ,) -> cainome :: cairo_serde :: call :: FCall < P , cainome :: cairo_serde :: ContractAddress > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_facts_registry") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_program_info (& self ,) -> cainome :: cairo_serde :: call :: FCall < P , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_program_info") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_state (& self ,) -> cainome :: cairo_serde :: call :: FCall < P , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_state") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn is_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> cainome :: cairo_serde :: call :: FCall < P , bool > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("is_operator") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn sn_to_appchain_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < P , MessageToAppchainStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("sn_to_appchain_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)}} \ No newline at end of file +# [derive (Debug)] pub struct AppChain < A : starknet :: accounts :: ConnectedAccount + Sync > {pub address : starknet :: core :: types :: Felt , pub account : A , pub block_id : starknet :: core :: types :: BlockId ,} impl < A : starknet :: accounts :: ConnectedAccount + Sync > AppChain < A > {pub fn new (address : starknet :: core :: types :: Felt , account : A) -> Self {Self {address , account , block_id : starknet :: core :: types :: BlockId :: Tag (starknet :: core :: types :: BlockTag :: Pending)}} pub fn set_contract_address (& mut self , address : starknet :: core :: types :: Felt) {self . address = address ;} pub fn provider (& self) -> & A :: Provider {self . account . provider ()} pub fn set_block (& mut self , block_id : starknet :: core :: types :: BlockId) {self . block_id = block_id ;} pub fn with_block (self , block_id : starknet :: core :: types :: BlockId) -> Self {Self {block_id , .. self}}} # [derive (Debug)] pub struct AppChainReader < P : starknet :: providers :: Provider + Sync > {pub address : starknet :: core :: types :: Felt , pub provider : P , pub block_id : starknet :: core :: types :: BlockId ,} impl < P : starknet :: providers :: Provider + Sync > AppChainReader < P > {pub fn new (address : starknet :: core :: types :: Felt , provider : P ,) -> Self {Self {address , provider , block_id : starknet :: core :: types :: BlockId :: Tag (starknet :: core :: types :: BlockTag :: Pending)}} pub fn set_contract_address (& mut self , address : starknet :: core :: types :: Felt) {self . address = address ;} pub fn provider (& self) -> & P {& self . provider} pub fn set_block (& mut self , block_id : starknet :: core :: types :: BlockId) {self . block_id = block_id ;} pub fn with_block (self , block_id : starknet :: core :: types :: BlockId) -> Self {Self {block_id , .. self}}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct ContractChanges {pub addr : starknet :: core :: types :: Felt , pub nonce : starknet :: core :: types :: Felt , pub class_hash : Option < starknet :: core :: types :: Felt > , pub storage_changes : Vec < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) >} impl cainome :: cairo_serde :: CairoSerde for ContractChanges {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . addr) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size += Option :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . class_hash) ; __size += Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialized_size (& __rust . storage_changes) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . addr)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out . extend (Option :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . class_hash)) ; __out . extend (Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialize (& __rust . storage_changes)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let addr = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& addr) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let class_hash = Option :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Option :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& class_hash) ; let storage_changes = Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialized_size (& storage_changes) ; Ok (ContractChanges {addr , nonce , class_hash , storage_changes})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct LogStateTransitionFact {pub state_transition_fact : cainome :: cairo_serde :: U256} impl cainome :: cairo_serde :: CairoSerde for LogStateTransitionFact {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: U256 :: cairo_serialized_size (& __rust . state_transition_fact) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: U256 :: cairo_serialize (& __rust . state_transition_fact)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let state_transition_fact = cainome :: cairo_serde :: U256 :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: U256 :: cairo_serialized_size (& state_transition_fact) ; Ok (LogStateTransitionFact {state_transition_fact})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct LogStateUpdate {pub state_root : starknet :: core :: types :: Felt , pub block_number : starknet :: core :: types :: Felt , pub block_hash : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for LogStateUpdate {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . state_root) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . block_number) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . block_hash) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . state_root)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . block_number)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . block_hash)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let state_root = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& state_root) ; let block_number = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_number) ; let block_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_hash) ; Ok (LogStateUpdate {state_root , block_number , block_hash})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageCanceled {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for MessageCanceled {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; Ok (MessageCanceled {message_hash , from , to , selector , payload , nonce})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageCancellationStarted {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for MessageCancellationStarted {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; Ok (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageConsumed {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageConsumed {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageConsumed {message_hash , from , to , payload})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageSent {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub nonce : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageSent {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageSent {message_hash , from , to , selector , nonce , payload})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageToAppchainSealed {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub nonce : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainSealed {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct MessageToStarknetReceived {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageToStarknetReceived {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageToStarknetReceived {message_hash , from , to , payload})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct OwnershipTransferStarted {pub previous_owner : cainome :: cairo_serde :: ContractAddress , pub new_owner : cainome :: cairo_serde :: ContractAddress} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferStarted {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . previous_owner) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . new_owner) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . previous_owner)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . new_owner)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let previous_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; Ok (OwnershipTransferStarted {previous_owner , new_owner})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct OwnershipTransferred {pub previous_owner : cainome :: cairo_serde :: ContractAddress , pub new_owner : cainome :: cairo_serde :: ContractAddress} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferred {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . previous_owner) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . new_owner) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . previous_owner)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . new_owner)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let previous_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; Ok (OwnershipTransferred {previous_owner , new_owner})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct ProgramInfoChanged {pub changed_by : cainome :: cairo_serde :: ContractAddress , pub old_program_hash : starknet :: core :: types :: Felt , pub new_program_hash : starknet :: core :: types :: Felt , pub old_config_hash : starknet :: core :: types :: Felt , pub new_config_hash : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for ProgramInfoChanged {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . changed_by) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . old_program_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . new_program_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . old_config_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . new_config_hash) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . changed_by)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . old_program_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . new_program_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . old_config_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . new_config_hash)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let changed_by = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; Ok (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct StarknetOsOutput {pub initial_root : starknet :: core :: types :: Felt , pub final_root : starknet :: core :: types :: Felt , pub prev_block_number : starknet :: core :: types :: Felt , pub new_block_number : starknet :: core :: types :: Felt , pub prev_block_hash : starknet :: core :: types :: Felt , pub new_block_hash : starknet :: core :: types :: Felt , pub os_program_hash : starknet :: core :: types :: Felt , pub starknet_os_config_hash : starknet :: core :: types :: Felt , pub use_kzg_da : starknet :: core :: types :: Felt , pub full_output : starknet :: core :: types :: Felt , pub messages_to_l1 : Vec < starknet :: core :: types :: Felt > , pub messages_to_l2 : Vec < starknet :: core :: types :: Felt > , pub contracts : Vec < ContractChanges > , pub classes : Vec < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) >} impl cainome :: cairo_serde :: CairoSerde for StarknetOsOutput {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . initial_root) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . final_root) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . prev_block_number) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . new_block_number) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . prev_block_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . new_block_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . os_program_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . starknet_os_config_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . use_kzg_da) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . full_output) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . messages_to_l1) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . messages_to_l2) ; __size += Vec :: < ContractChanges > :: cairo_serialized_size (& __rust . contracts) ; __size += Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialized_size (& __rust . classes) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . initial_root)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . final_root)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . prev_block_number)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . new_block_number)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . prev_block_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . new_block_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . os_program_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . starknet_os_config_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . use_kzg_da)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . full_output)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . messages_to_l1)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . messages_to_l2)) ; __out . extend (Vec :: < ContractChanges > :: cairo_serialize (& __rust . contracts)) ; __out . extend (Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialize (& __rust . classes)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let initial_root = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& initial_root) ; let final_root = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& final_root) ; let prev_block_number = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& prev_block_number) ; let new_block_number = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_block_number) ; let prev_block_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& prev_block_hash) ; let new_block_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_block_hash) ; let os_program_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& os_program_hash) ; let starknet_os_config_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& starknet_os_config_hash) ; let use_kzg_da = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& use_kzg_da) ; let full_output = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& full_output) ; let messages_to_l1 = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& messages_to_l1) ; let messages_to_l2 = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& messages_to_l2) ; let contracts = Vec :: < ContractChanges > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < ContractChanges > :: cairo_serialized_size (& contracts) ; let classes = Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > :: cairo_serialized_size (& classes) ; Ok (StarknetOsOutput {initial_root , final_root , prev_block_number , new_block_number , prev_block_hash , new_block_hash , os_program_hash , starknet_os_config_hash , use_kzg_da , full_output , messages_to_l1 , messages_to_l2 , contracts , classes})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub struct Upgraded {pub class_hash : cainome :: cairo_serde :: ClassHash} impl cainome :: cairo_serde :: CairoSerde for Upgraded {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& __rust . class_hash) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ClassHash :: cairo_serialize (& __rust . class_hash)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let class_hash = cainome :: cairo_serde :: ClassHash :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; Ok (Upgraded {class_hash})}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {OwnershipTransferred (OwnershipTransferred) , OwnershipTransferStarted (OwnershipTransferStarted)} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {Event :: OwnershipTransferred (val) => OwnershipTransferred :: cairo_serialized_size (val) + 1 , Event :: OwnershipTransferStarted (val) => OwnershipTransferStarted :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {Event :: OwnershipTransferred (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (OwnershipTransferred :: cairo_serialize (val)) ; temp} , Event :: OwnershipTransferStarted (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (OwnershipTransferStarted :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (Event :: OwnershipTransferred (OwnershipTransferred :: cairo_deserialize (__felts , __offset + 1) ?)) , 1usize => Ok (Event :: OwnershipTransferStarted (OwnershipTransferStarted :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferred") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferred")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (Event :: OwnershipTransferred (OwnershipTransferred {previous_owner , new_owner}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (Event :: OwnershipTransferStarted (OwnershipTransferStarted {previous_owner , new_owner}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {ProgramInfoChanged (ProgramInfoChanged)} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {Event :: ProgramInfoChanged (val) => ProgramInfoChanged :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {Event :: ProgramInfoChanged (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (ProgramInfoChanged :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (Event :: ProgramInfoChanged (ProgramInfoChanged :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("ProgramInfoChanged") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "ProgramInfoChanged")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let changed_by = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "changed_by" , "ProgramInfoChanged" , e)) ,} ; data_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; return Ok (Event :: ProgramInfoChanged (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {MessageSent (MessageSent) , MessageConsumed (MessageConsumed) , MessageCancellationStarted (MessageCancellationStarted) , MessageCanceled (MessageCanceled) , MessageToStarknetReceived (MessageToStarknetReceived) , MessageToAppchainSealed (MessageToAppchainSealed)} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {Event :: MessageSent (val) => MessageSent :: cairo_serialized_size (val) + 1 , Event :: MessageConsumed (val) => MessageConsumed :: cairo_serialized_size (val) + 1 , Event :: MessageCancellationStarted (val) => MessageCancellationStarted :: cairo_serialized_size (val) + 1 , Event :: MessageCanceled (val) => MessageCanceled :: cairo_serialized_size (val) + 1 , Event :: MessageToStarknetReceived (val) => MessageToStarknetReceived :: cairo_serialized_size (val) + 1 , Event :: MessageToAppchainSealed (val) => MessageToAppchainSealed :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {Event :: MessageSent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (MessageSent :: cairo_serialize (val)) ; temp} , Event :: MessageConsumed (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (MessageConsumed :: cairo_serialize (val)) ; temp} , Event :: MessageCancellationStarted (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 2usize)) ; temp . extend (MessageCancellationStarted :: cairo_serialize (val)) ; temp} , Event :: MessageCanceled (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 3usize)) ; temp . extend (MessageCanceled :: cairo_serialize (val)) ; temp} , Event :: MessageToStarknetReceived (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 4usize)) ; temp . extend (MessageToStarknetReceived :: cairo_serialize (val)) ; temp} , Event :: MessageToAppchainSealed (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 5usize)) ; temp . extend (MessageToAppchainSealed :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (Event :: MessageSent (MessageSent :: cairo_deserialize (__felts , __offset + 1) ?)) , 1usize => Ok (Event :: MessageConsumed (MessageConsumed :: cairo_deserialize (__felts , __offset + 1) ?)) , 2usize => Ok (Event :: MessageCancellationStarted (MessageCancellationStarted :: cairo_deserialize (__felts , __offset + 1) ?)) , 3usize => Ok (Event :: MessageCanceled (MessageCanceled :: cairo_deserialize (__felts , __offset + 1) ?)) , 4usize => Ok (Event :: MessageToStarknetReceived (MessageToStarknetReceived :: cairo_deserialize (__felts , __offset + 1) ?)) , 5usize => Ok (Event :: MessageToAppchainSealed (MessageToAppchainSealed :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageSent") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageSent")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageSent" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageSent" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessageSent (MessageSent {message_hash , from , to , selector , nonce , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageConsumed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageConsumed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageConsumed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageConsumed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessageConsumed (MessageConsumed {message_hash , from , to , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCancellationStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCancellationStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCancellationStarted" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCancellationStarted" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (Event :: MessageCancellationStarted (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCanceled") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCanceled")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCanceled" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCanceled" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (Event :: MessageCanceled (MessageCanceled {message_hash , from , to , selector , payload , nonce}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToStarknetReceived") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToStarknetReceived")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToStarknetReceived" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToStarknetReceived" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessageToStarknetReceived (MessageToStarknetReceived {message_hash , from , to , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToAppchainSealed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToAppchainSealed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToAppchainSealed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToAppchainSealed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessageToAppchainSealed (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {OwnableEvent (Event) , UpgradeableEvent (Event) , ConfigEvent (Event) , MessagingEvent (Event) , ReentrancyGuardEvent (Event) , StateEvent (Event) , LogStateUpdate (LogStateUpdate) , LogStateTransitionFact (LogStateTransitionFact)} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {Event :: OwnableEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: UpgradeableEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: ConfigEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: MessagingEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: ReentrancyGuardEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: StateEvent (val) => Event :: cairo_serialized_size (val) + 1 , Event :: LogStateUpdate (val) => LogStateUpdate :: cairo_serialized_size (val) + 1 , Event :: LogStateTransitionFact (val) => LogStateTransitionFact :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {Event :: OwnableEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: UpgradeableEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: ConfigEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 2usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: MessagingEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 3usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: ReentrancyGuardEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 4usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: StateEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 5usize)) ; temp . extend (Event :: cairo_serialize (val)) ; temp} , Event :: LogStateUpdate (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 6usize)) ; temp . extend (LogStateUpdate :: cairo_serialize (val)) ; temp} , Event :: LogStateTransitionFact (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 7usize)) ; temp . extend (LogStateTransitionFact :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (Event :: OwnableEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 1usize => Ok (Event :: UpgradeableEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 2usize => Ok (Event :: ConfigEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 3usize => Ok (Event :: MessagingEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 4usize => Ok (Event :: ReentrancyGuardEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 5usize => Ok (Event :: StateEvent (Event :: cairo_deserialize (__felts , __offset + 1) ?)) , 6usize => Ok (Event :: LogStateUpdate (LogStateUpdate :: cairo_deserialize (__felts , __offset + 1) ?)) , 7usize => Ok (Event :: LogStateTransitionFact (LogStateTransitionFact :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferred") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferred")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (Event :: OwnableEvent (Event :: OwnershipTransferred (OwnershipTransferred {previous_owner , new_owner})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (Event :: OwnableEvent (Event :: OwnershipTransferStarted (OwnershipTransferStarted {previous_owner , new_owner})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("Upgraded") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "Upgraded")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let class_hash = match cainome :: cairo_serde :: ClassHash :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "class_hash" , "Upgraded" , e)) ,} ; data_offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; return Ok (Event :: UpgradeableEvent (Event :: Upgraded (Upgraded {class_hash})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("ProgramInfoChanged") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "ProgramInfoChanged")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let changed_by = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "changed_by" , "ProgramInfoChanged" , e)) ,} ; data_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; return Ok (Event :: ConfigEvent (Event :: ProgramInfoChanged (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageSent") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageSent")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageSent" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageSent" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessagingEvent (Event :: MessageSent (MessageSent {message_hash , from , to , selector , nonce , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageConsumed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageConsumed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageConsumed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageConsumed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessagingEvent (Event :: MessageConsumed (MessageConsumed {message_hash , from , to , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCancellationStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCancellationStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCancellationStarted" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCancellationStarted" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (Event :: MessagingEvent (Event :: MessageCancellationStarted (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCanceled") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCanceled")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCanceled" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCanceled" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (Event :: MessagingEvent (Event :: MessageCanceled (MessageCanceled {message_hash , from , to , selector , payload , nonce})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToStarknetReceived") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToStarknetReceived")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToStarknetReceived" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToStarknetReceived" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessagingEvent (Event :: MessageToStarknetReceived (MessageToStarknetReceived {message_hash , from , to , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToAppchainSealed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToAppchainSealed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToAppchainSealed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToAppchainSealed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (Event :: MessagingEvent (Event :: MessageToAppchainSealed (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("LogStateUpdate") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "LogStateUpdate")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let state_root = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "state_root" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& state_root) ; let block_number = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "block_number" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_number) ; let block_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "block_hash" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_hash) ; return Ok (Event :: LogStateUpdate (LogStateUpdate {state_root , block_number , block_hash}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("LogStateTransitionFact") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "LogStateTransitionFact")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let state_transition_fact = match cainome :: cairo_serde :: U256 :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "state_transition_fact" , "LogStateTransitionFact" , e)) ,} ; data_offset += cainome :: cairo_serde :: U256 :: cairo_serialized_size (& state_transition_fact) ; return Ok (Event :: LogStateTransitionFact (LogStateTransitionFact {state_transition_fact}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {_ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {_ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {_ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {Upgraded (Upgraded)} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {Event :: Upgraded (val) => Upgraded :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {Event :: Upgraded (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (Upgraded :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (Event :: Upgraded (Upgraded :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("Upgraded") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "Upgraded")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let class_hash = match cainome :: cairo_serde :: ClassHash :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "class_hash" , "Upgraded" , e)) ,} ; data_offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; return Ok (Event :: Upgraded (Upgraded {class_hash}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum Event {} impl cainome :: cairo_serde :: CairoSerde for Event {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {_ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {_ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {_ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "Event")))}}} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event {type Error = String ; fn try_from (event : starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum MessageToAppchainStatus {SealedOrNotSent , Pending (starknet :: core :: types :: Felt)} impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainStatus {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {MessageToAppchainStatus :: SealedOrNotSent => 1 , MessageToAppchainStatus :: Pending (val) => starknet :: core :: types :: Felt :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {MessageToAppchainStatus :: SealedOrNotSent => usize :: cairo_serialize (& 0usize) , MessageToAppchainStatus :: Pending (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (starknet :: core :: types :: Felt :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (MessageToAppchainStatus :: SealedOrNotSent) , 1usize => Ok (MessageToAppchainStatus :: Pending (starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "MessageToAppchainStatus")))}}} # [derive (Debug , PartialEq , Eq , Clone , Copy ,)] pub enum MessageToStarknetStatus {NothingToConsume , ReadyToConsume (starknet :: core :: types :: Felt)} impl cainome :: cairo_serde :: CairoSerde for MessageToStarknetStatus {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {MessageToStarknetStatus :: NothingToConsume => 1 , MessageToStarknetStatus :: ReadyToConsume (val) => starknet :: core :: types :: Felt :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {MessageToStarknetStatus :: NothingToConsume => usize :: cairo_serialize (& 0usize) , MessageToStarknetStatus :: ReadyToConsume (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (starknet :: core :: types :: Felt :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (MessageToStarknetStatus :: NothingToConsume) , 1usize => Ok (MessageToStarknetStatus :: ReadyToConsume (starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "MessageToStarknetStatus")))}}} impl < A : starknet :: accounts :: ConnectedAccount + Sync > AppChain < A > {# [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn appchain_to_sn_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , MessageToStarknetStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("appchain_to_sn_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_facts_registry (& self ,) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , cainome :: cairo_serde :: ContractAddress > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_facts_registry") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_program_info (& self ,) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_program_info") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_state (& self ,) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_state") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn is_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , bool > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("is_operator") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn sn_to_appchain_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , MessageToAppchainStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("sn_to_appchain_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn cancel_message_getcall (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("cancel_message") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn cancel_message (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("cancel_message") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn consume_message_from_appchain_getcall (& self , from_address : & cainome :: cairo_serde :: ContractAddress , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (from_address)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("consume_message_from_appchain") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn consume_message_from_appchain (& self , from_address : & cainome :: cairo_serde :: ContractAddress , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (from_address)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("consume_message_from_appchain") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn register_operator_getcall (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("register_operator") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn register_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("register_operator") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn send_message_to_appchain_getcall (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("send_message_to_appchain") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn send_message_to_appchain (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("send_message_to_appchain") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_facts_registry_getcall (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_facts_registry") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_facts_registry (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_facts_registry") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_program_info_getcall (& self , program_hash : & starknet :: core :: types :: Felt , config_hash : & starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (program_hash)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (config_hash)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_program_info") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_program_info (& self , program_hash : & starknet :: core :: types :: Felt , config_hash : & starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (program_hash)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (config_hash)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_program_info") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn start_message_cancellation_getcall (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("start_message_cancellation") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn start_message_cancellation (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("start_message_cancellation") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn unregister_operator_getcall (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("unregister_operator") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn unregister_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("unregister_operator") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update_getcall (& self , program_output : & StarknetOsOutput) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (StarknetOsOutput :: cairo_serialize (program_output)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update (& self , program_output : & StarknetOsOutput) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (StarknetOsOutput :: cairo_serialize (program_output)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update_state_getcall (& self , snos_output : & Vec :: < starknet :: core :: types :: Felt > , program_output : & Vec :: < starknet :: core :: types :: Felt > , onchain_data_hash : & starknet :: core :: types :: Felt , onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (snos_output)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (program_output)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (onchain_data_hash)) ; __calldata . extend (cainome :: cairo_serde :: U256 :: cairo_serialize (onchain_data_size)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update_state") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update_state (& self , snos_output : & Vec :: < starknet :: core :: types :: Felt > , program_output : & Vec :: < starknet :: core :: types :: Felt > , onchain_data_hash : & starknet :: core :: types :: Felt , onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (snos_output)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (program_output)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (onchain_data_hash)) ; __calldata . extend (cainome :: cairo_serde :: U256 :: cairo_serialize (onchain_data_size)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update_state") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn upgrade_getcall (& self , new_class_hash : & cainome :: cairo_serde :: ClassHash) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ClassHash :: cairo_serialize (new_class_hash)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("upgrade") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn upgrade (& self , new_class_hash : & cainome :: cairo_serde :: ClassHash) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ClassHash :: cairo_serialize (new_class_hash)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("upgrade") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])}} impl < P : starknet :: providers :: Provider + Sync > AppChainReader < P > {# [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn appchain_to_sn_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < P , MessageToStarknetStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("appchain_to_sn_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_facts_registry (& self ,) -> cainome :: cairo_serde :: call :: FCall < P , cainome :: cairo_serde :: ContractAddress > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_facts_registry") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_program_info (& self ,) -> cainome :: cairo_serde :: call :: FCall < P , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_program_info") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_state (& self ,) -> cainome :: cairo_serde :: call :: FCall < P , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_state") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn is_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> cainome :: cairo_serde :: call :: FCall < P , bool > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("is_operator") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn sn_to_appchain_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < P , MessageToAppchainStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("sn_to_appchain_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)}} diff --git a/src/appchain_test.cairo b/src/appchain_test.cairo new file mode 100644 index 0000000..2b1d5cf --- /dev/null +++ b/src/appchain_test.cairo @@ -0,0 +1,217 @@ +//! SPDX-License-Identifier: MIT +//! +//! + +mod errors { + const INVALID_ADDRESS: felt252 = 'Config: invalid address'; + const SNOS_INVALID_PROGRAM_OUTPUT_SIZE: felt252 = 'snos: invalid output size'; + const SNOS_INVALID_CONFIG_HASH: felt252 = 'snos: invalid config hash'; + const SNOS_INVALID_MESSAGES_SEGMENTS: felt252 = 'snos: invalid messages segments'; + const NO_STATE_TRANSITION_PROOF: felt252 = 'no state transition proof'; +} + +/// Appchain settlement contract on starknet. +#[starknet::contract] +mod appchain { + use openzeppelin::access::ownable::{ + OwnableComponent as ownable_cpt, OwnableComponent::InternalTrait as OwnableInternal, + interface::IOwnable + }; + use openzeppelin::security::reentrancyguard::{ + ReentrancyGuardComponent, + ReentrancyGuardComponent::InternalTrait as InternalReentrancyGuardImpl + }; + use openzeppelin::upgrades::{ + UpgradeableComponent as upgradeable_cpt, + UpgradeableComponent::InternalTrait as UpgradeableInternal, interface::IUpgradeable + }; + use piltover::components::onchain_data_fact_tree_encoder::{ + encode_fact_with_onchain_data, DataAvailabilityFact + }; + use piltover::config::{config_cpt, config_cpt::InternalTrait as ConfigInternal, IConfig}; + use piltover::interface::IAppchain; + use piltover::messaging::{ + messaging_cpt, messaging_cpt::InternalTrait as MessagingInternal, IMessaging, + output_process, output_process::{MessageToStarknet, MessageToAppchain}, + }; + use piltover::mocks::{ + IFactRegistryMockDispatcher, IFactRegistryMockDispatcherTrait + }; // To change when Herodotus finishes implementing FactRegistry. + use piltover::snos_output::ProgramOutput; + use piltover::snos_output; + use piltover::state::component::state_cpt::HasComponent; + use piltover::state::{state_cpt, state_cpt::InternalTrait as StateInternal, IState}; + use starknet::{ContractAddress, ClassHash}; + use super::errors; + + /// The default cancellation delay of 5 days. + const CANCELLATION_DELAY_SECS: u64 = 432000; + + component!(path: ownable_cpt, storage: ownable, event: OwnableEvent); + component!(path: upgradeable_cpt, storage: upgradeable, event: UpgradeableEvent); + component!(path: config_cpt, storage: config, event: ConfigEvent); + component!(path: messaging_cpt, storage: messaging, event: MessagingEvent); + component!(path: state_cpt, storage: state, event: StateEvent); + component!( + path: ReentrancyGuardComponent, storage: reentrancy_guard, event: ReentrancyGuardEvent + ); + + #[abi(embed_v0)] + impl ConfigImpl = config_cpt::ConfigImpl; + #[abi(embed_v0)] + impl MessagingImpl = messaging_cpt::MessagingImpl; + #[abi(embed_v0)] + impl StateImpl = state_cpt::StateImpl; + + #[storage] + struct Storage { + #[substorage(v0)] + ownable: ownable_cpt::Storage, + #[substorage(v0)] + upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + config: config_cpt::Storage, + #[substorage(v0)] + messaging: messaging_cpt::Storage, + #[substorage(v0)] + reentrancy_guard: ReentrancyGuardComponent::Storage, + #[substorage(v0)] + state: state_cpt::Storage, + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + #[flat] + OwnableEvent: ownable_cpt::Event, + #[flat] + UpgradeableEvent: upgradeable_cpt::Event, + #[flat] + ConfigEvent: config_cpt::Event, + #[flat] + MessagingEvent: messaging_cpt::Event, + #[flat] + ReentrancyGuardEvent: ReentrancyGuardComponent::Event, + #[flat] + StateEvent: state_cpt::Event, + LogStateUpdate: LogStateUpdate, + LogStateTransitionFact: LogStateTransitionFact, + } + + #[derive(Drop, starknet::Event)] + struct LogStateUpdate { + state_root: felt252, + block_number: felt252, + block_hash: felt252, + } + + #[derive(Drop, starknet::Event)] + struct LogStateTransitionFact { + state_transition_fact: u256, + } + + /// Initializes the contract. + /// + /// # Arguments + /// + /// * `address` - The contract address of the owner. + #[constructor] + fn constructor( + ref self: ContractState, + owner: ContractAddress, + state_root: felt252, + block_number: felt252, + block_hash: felt252, + ) { + self.ownable.initializer(owner); + self.messaging.initialize(CANCELLATION_DELAY_SECS); + self.state.initialize(state_root, block_number, block_hash); + } + + + #[abi(embed_v0)] + impl Appchain of IAppchain { + fn update_state( + ref self: ContractState, + program_output: Span, + onchain_data_hash: felt252, + onchain_data_size: u256 + ) { + self.reentrancy_guard.start(); + self.config.assert_only_owner_or_operator(); + + // Header size + 2 messages segments len. + assert( + program_output.len() > snos_output::HEADER_SIZE + 2, + errors::SNOS_INVALID_PROGRAM_OUTPUT_SIZE + ); + + let (current_program_hash, current_config_hash): (felt252, felt252) = self + .config + .program_info + .read(); + + let data_availability_fact: DataAvailabilityFact = DataAvailabilityFact { + onchain_data_hash, onchain_data_size + }; + let state_transition_fact: u256 = encode_fact_with_onchain_data( + program_output, data_availability_fact + ); + + let mut program_output_mut = program_output; + let program_output_struct: ProgramOutput = Serde::deserialize(ref program_output_mut) + .unwrap(); + assert( + program_output_struct.config_hash == current_config_hash, + errors::SNOS_INVALID_CONFIG_HASH + ); + + let sharp_fact: u256 = keccak::keccak_u256s_be_inputs( + array![current_program_hash.into(), state_transition_fact].span() + ); + assert( + IFactRegistryMockDispatcher { contract_address: self.config.get_facts_registry() } + .is_valid(sharp_fact), + errors::NO_STATE_TRANSITION_PROOF + ); + + self.emit(LogStateTransitionFact { state_transition_fact }); + + // Perform state update + self.state.update(program_output); + + let mut offset = snos_output::HEADER_SIZE; + + // TODO(#7): We should update SNOS output to have the messages count + // instead of the messages segment len. + + let mut messages_segments = program_output.slice(offset, program_output.len() - offset); + + let (messages_to_starknet, messages_to_appchain) = + output_process::gather_messages_from_output( + messages_segments + ); + + self.messaging.process_messages_to_starknet(messages_to_starknet); + self.messaging.process_messages_to_appchain(messages_to_appchain); + self.reentrancy_guard.end(); + + self + .emit( + LogStateUpdate { + state_root: self.state.state_root.read(), + block_number: self.state.block_number.read(), + block_hash: self.state.block_hash.read(), + } + ); + } + } + + #[abi(embed_v0)] + impl UpgradeableImpl of IUpgradeable { + fn upgrade(ref self: ContractState, new_class_hash: ClassHash) { + self.ownable.assert_only_owner(); + self.upgradeable.upgrade(new_class_hash); + } + } +} diff --git a/src/lib.cairo b/src/lib.cairo index c91b5ec..b667033 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -1,4 +1,8 @@ mod appchain; +// Since this contract is used for e2e testing, it must be built as appchain.cairo. +// We should evaluate the use of Scarb profile to conditionally compile the appchain_test contract. +mod appchain_test; + mod fact_registry; mod interface; mod snos_output; diff --git a/src/messaging/component.cairo b/src/messaging/component.cairo index 3ffd0ca..d3f0a27 100644 --- a/src/messaging/component.cairo +++ b/src/messaging/component.cairo @@ -295,6 +295,34 @@ mod messaging_cpt { return message_hash; } + + #[cfg(feature: 'messaging_test')] + fn add_messages_hashes_from_appchain( + ref self: ComponentState, messages_hashes: Span + ) { + let mut i = 0_usize; + loop { + if i == messages_hashes.len() { + break; + } + + let msg_hash = *messages_hashes[i]; + + let count = self.appc_to_sn_messages.read(msg_hash); + self.appc_to_sn_messages.write(msg_hash, count + 1); + + // We can't have the detail of the message here, so we emit a dummy event + // with at least the message hash. + self.emit(MessageToStarknetReceived { + message_hash: msg_hash, + from: 0.try_into().unwrap(), + to: 0.try_into().unwrap(), + payload: array![].span() + }); + + i += 1; + }; + } } #[generate_trait] diff --git a/src/messaging/interface.cairo b/src/messaging/interface.cairo index ff8192e..af83f3f 100644 --- a/src/messaging/interface.cairo +++ b/src/messaging/interface.cairo @@ -116,4 +116,16 @@ trait IMessaging { payload: Span, nonce: felt252, ) -> MessageHash; + + /// Manually registers messages hashes as consumable. + /// + /// This function is mostly used to decorrelate the messages registration from the + /// state update step. Since all messages are registered once the proof is verified, + /// and the output of SNOS parsed, this function shortcut this step. + /// + /// The appchain sequencer for testing e2e messaging can then use this function to + /// register messages hashes that are considered as ready to be consumed. This can be done + /// right after the block is produced, for fast and reliable messaging testing. + #[cfg(feature: 'messaging_test')] + fn add_messages_hashes_from_appchain(ref self: T, messages_hashes: Span); } From 4e96d05e0b87e2359c94718142316f22d860afb8 Mon Sep 17 00:00:00 2001 From: glihm Date: Wed, 8 Jan 2025 20:10:35 -0600 Subject: [PATCH 02/15] fix: remove unused files --- src/appchain_test.cairo | 217 ---------------------------------------- 1 file changed, 217 deletions(-) delete mode 100644 src/appchain_test.cairo diff --git a/src/appchain_test.cairo b/src/appchain_test.cairo deleted file mode 100644 index 2b1d5cf..0000000 --- a/src/appchain_test.cairo +++ /dev/null @@ -1,217 +0,0 @@ -//! SPDX-License-Identifier: MIT -//! -//! - -mod errors { - const INVALID_ADDRESS: felt252 = 'Config: invalid address'; - const SNOS_INVALID_PROGRAM_OUTPUT_SIZE: felt252 = 'snos: invalid output size'; - const SNOS_INVALID_CONFIG_HASH: felt252 = 'snos: invalid config hash'; - const SNOS_INVALID_MESSAGES_SEGMENTS: felt252 = 'snos: invalid messages segments'; - const NO_STATE_TRANSITION_PROOF: felt252 = 'no state transition proof'; -} - -/// Appchain settlement contract on starknet. -#[starknet::contract] -mod appchain { - use openzeppelin::access::ownable::{ - OwnableComponent as ownable_cpt, OwnableComponent::InternalTrait as OwnableInternal, - interface::IOwnable - }; - use openzeppelin::security::reentrancyguard::{ - ReentrancyGuardComponent, - ReentrancyGuardComponent::InternalTrait as InternalReentrancyGuardImpl - }; - use openzeppelin::upgrades::{ - UpgradeableComponent as upgradeable_cpt, - UpgradeableComponent::InternalTrait as UpgradeableInternal, interface::IUpgradeable - }; - use piltover::components::onchain_data_fact_tree_encoder::{ - encode_fact_with_onchain_data, DataAvailabilityFact - }; - use piltover::config::{config_cpt, config_cpt::InternalTrait as ConfigInternal, IConfig}; - use piltover::interface::IAppchain; - use piltover::messaging::{ - messaging_cpt, messaging_cpt::InternalTrait as MessagingInternal, IMessaging, - output_process, output_process::{MessageToStarknet, MessageToAppchain}, - }; - use piltover::mocks::{ - IFactRegistryMockDispatcher, IFactRegistryMockDispatcherTrait - }; // To change when Herodotus finishes implementing FactRegistry. - use piltover::snos_output::ProgramOutput; - use piltover::snos_output; - use piltover::state::component::state_cpt::HasComponent; - use piltover::state::{state_cpt, state_cpt::InternalTrait as StateInternal, IState}; - use starknet::{ContractAddress, ClassHash}; - use super::errors; - - /// The default cancellation delay of 5 days. - const CANCELLATION_DELAY_SECS: u64 = 432000; - - component!(path: ownable_cpt, storage: ownable, event: OwnableEvent); - component!(path: upgradeable_cpt, storage: upgradeable, event: UpgradeableEvent); - component!(path: config_cpt, storage: config, event: ConfigEvent); - component!(path: messaging_cpt, storage: messaging, event: MessagingEvent); - component!(path: state_cpt, storage: state, event: StateEvent); - component!( - path: ReentrancyGuardComponent, storage: reentrancy_guard, event: ReentrancyGuardEvent - ); - - #[abi(embed_v0)] - impl ConfigImpl = config_cpt::ConfigImpl; - #[abi(embed_v0)] - impl MessagingImpl = messaging_cpt::MessagingImpl; - #[abi(embed_v0)] - impl StateImpl = state_cpt::StateImpl; - - #[storage] - struct Storage { - #[substorage(v0)] - ownable: ownable_cpt::Storage, - #[substorage(v0)] - upgradeable: upgradeable_cpt::Storage, - #[substorage(v0)] - config: config_cpt::Storage, - #[substorage(v0)] - messaging: messaging_cpt::Storage, - #[substorage(v0)] - reentrancy_guard: ReentrancyGuardComponent::Storage, - #[substorage(v0)] - state: state_cpt::Storage, - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - #[flat] - OwnableEvent: ownable_cpt::Event, - #[flat] - UpgradeableEvent: upgradeable_cpt::Event, - #[flat] - ConfigEvent: config_cpt::Event, - #[flat] - MessagingEvent: messaging_cpt::Event, - #[flat] - ReentrancyGuardEvent: ReentrancyGuardComponent::Event, - #[flat] - StateEvent: state_cpt::Event, - LogStateUpdate: LogStateUpdate, - LogStateTransitionFact: LogStateTransitionFact, - } - - #[derive(Drop, starknet::Event)] - struct LogStateUpdate { - state_root: felt252, - block_number: felt252, - block_hash: felt252, - } - - #[derive(Drop, starknet::Event)] - struct LogStateTransitionFact { - state_transition_fact: u256, - } - - /// Initializes the contract. - /// - /// # Arguments - /// - /// * `address` - The contract address of the owner. - #[constructor] - fn constructor( - ref self: ContractState, - owner: ContractAddress, - state_root: felt252, - block_number: felt252, - block_hash: felt252, - ) { - self.ownable.initializer(owner); - self.messaging.initialize(CANCELLATION_DELAY_SECS); - self.state.initialize(state_root, block_number, block_hash); - } - - - #[abi(embed_v0)] - impl Appchain of IAppchain { - fn update_state( - ref self: ContractState, - program_output: Span, - onchain_data_hash: felt252, - onchain_data_size: u256 - ) { - self.reentrancy_guard.start(); - self.config.assert_only_owner_or_operator(); - - // Header size + 2 messages segments len. - assert( - program_output.len() > snos_output::HEADER_SIZE + 2, - errors::SNOS_INVALID_PROGRAM_OUTPUT_SIZE - ); - - let (current_program_hash, current_config_hash): (felt252, felt252) = self - .config - .program_info - .read(); - - let data_availability_fact: DataAvailabilityFact = DataAvailabilityFact { - onchain_data_hash, onchain_data_size - }; - let state_transition_fact: u256 = encode_fact_with_onchain_data( - program_output, data_availability_fact - ); - - let mut program_output_mut = program_output; - let program_output_struct: ProgramOutput = Serde::deserialize(ref program_output_mut) - .unwrap(); - assert( - program_output_struct.config_hash == current_config_hash, - errors::SNOS_INVALID_CONFIG_HASH - ); - - let sharp_fact: u256 = keccak::keccak_u256s_be_inputs( - array![current_program_hash.into(), state_transition_fact].span() - ); - assert( - IFactRegistryMockDispatcher { contract_address: self.config.get_facts_registry() } - .is_valid(sharp_fact), - errors::NO_STATE_TRANSITION_PROOF - ); - - self.emit(LogStateTransitionFact { state_transition_fact }); - - // Perform state update - self.state.update(program_output); - - let mut offset = snos_output::HEADER_SIZE; - - // TODO(#7): We should update SNOS output to have the messages count - // instead of the messages segment len. - - let mut messages_segments = program_output.slice(offset, program_output.len() - offset); - - let (messages_to_starknet, messages_to_appchain) = - output_process::gather_messages_from_output( - messages_segments - ); - - self.messaging.process_messages_to_starknet(messages_to_starknet); - self.messaging.process_messages_to_appchain(messages_to_appchain); - self.reentrancy_guard.end(); - - self - .emit( - LogStateUpdate { - state_root: self.state.state_root.read(), - block_number: self.state.block_number.read(), - block_hash: self.state.block_hash.read(), - } - ); - } - } - - #[abi(embed_v0)] - impl UpgradeableImpl of IUpgradeable { - fn upgrade(ref self: ContractState, new_class_hash: ClassHash) { - self.ownable.assert_only_owner(); - self.upgradeable.upgrade(new_class_hash); - } - } -} From 0fd80c2e323bd8f4980fc50ba66088862312be5e Mon Sep 17 00:00:00 2001 From: glihm Date: Wed, 8 Jan 2025 22:17:59 -0600 Subject: [PATCH 03/15] fix: ensure the first nonce is 0 and use other value for sealed messages --- src/messaging/component.cairo | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/messaging/component.cairo b/src/messaging/component.cairo index d3f0a27..49c56b4 100644 --- a/src/messaging/component.cairo +++ b/src/messaging/component.cairo @@ -55,6 +55,9 @@ mod messaging_cpt { use starknet::storage::Map; use super::errors; + // Max felt252 value to indicate that the message is sealed. + const SEALED_MESSAGE: felt252 = 0x800000000000011000000000000000000000000000000000000000000000000; + #[storage] struct Storage { /// Cancellation delay in seconds for message from Starknet to Appchain. @@ -165,9 +168,14 @@ mod messaging_cpt { selector: felt252, payload: Span ) -> (MessageHash, Nonce) { - // Starts by +1 to avoid 0 as a valid nonce. - let nonce = self.sn_to_appc_nonce.read() + 1; - self.sn_to_appc_nonce.write(nonce); + // From the what's done from L1 to L2, the first nonce must be 0: + // + // The value is read from the storage, and then incremented but the read + // value is used at the tx nonce. + let mut nonce = self.sn_to_appc_nonce.read(); + + // Increment the nonce, but the read value is used at the tx nonce. + self.sn_to_appc_nonce.write(nonce + 1); let from = starknet::get_caller_address(); let message_hash = hash::compute_message_hash_sn_to_appc( @@ -392,11 +400,14 @@ mod messaging_cpt { from, to, selector, payload, nonce ); assert( - self.sn_to_appc_messages.read(message_hash).is_non_zero(), + self.sn_to_appc_messages.read(message_hash) != SEALED_MESSAGE, errors::INVALID_MESSAGE_TO_SEAL ); - self.sn_to_appc_messages.write(message_hash, 0); + // On the L1, they use the Fee in front of the message hash, not the nonce. + // Since the nonce 0 is a valid nonce, the max value of the felt is used + // instead to indicate that the message is sealed. + self.sn_to_appc_messages.write(message_hash, SEALED_MESSAGE); self .emit( From 4e1da98bea1034553c8757dcbd6b2dc983d0046b Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 9 Jan 2025 00:12:27 -0600 Subject: [PATCH 04/15] fix: directly use the appchain message type instead of nonce magic value --- src/messaging/component.cairo | 44 ++++++++++-------------- src/messaging/tests/test_messaging.cairo | 14 ++++---- src/messaging/types.cairo | 7 ++-- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/src/messaging/component.cairo b/src/messaging/component.cairo index 49c56b4..d8f8997 100644 --- a/src/messaging/component.cairo +++ b/src/messaging/component.cairo @@ -26,7 +26,6 @@ /// Errors. mod errors { - const INVALID_NONCE: felt252 = 'INVALID_NONCE'; const INVALID_MESSAGE_TO_CONSUME: felt252 = 'INVALID_MESSAGE_TO_CONSUME'; const INVALID_MESSAGE_TO_SEAL: felt252 = 'INVALID_MESSAGE_TO_SEAL'; const NO_MESSAGE_TO_CANCEL: felt252 = 'NO_MESSAGE_TO_CANCEL'; @@ -55,9 +54,6 @@ mod messaging_cpt { use starknet::storage::Map; use super::errors; - // Max felt252 value to indicate that the message is sealed. - const SEALED_MESSAGE: felt252 = 0x800000000000011000000000000000000000000000000000000000000000000; - #[storage] struct Storage { /// Cancellation delay in seconds for message from Starknet to Appchain. @@ -66,8 +62,8 @@ mod messaging_cpt { sn_to_appc_cancellations: Map::, /// The nonce for messages sent to the Appchain from Starknet. sn_to_appc_nonce: Nonce, - /// Ledger of messages hashes sent from Starknet to the appchain. - sn_to_appc_messages: Map::, + /// Ledger of messages hashes sent from Starknet to the appchain and their status. + sn_to_appc_messages: Map::, /// Ledger of messages hashes registered from the Appchain and a refcount /// associated to it to control messages consumption. appc_to_sn_messages: Map::, @@ -187,21 +183,16 @@ mod messaging_cpt { MessageSent { message_hash, from, to: to_address, selector, nonce, payload, } ); - self.sn_to_appc_messages.write(message_hash, nonce); + self.sn_to_appc_messages.write(message_hash, MessageToAppchainStatus::Pending(nonce)); (message_hash, nonce) } fn sn_to_appchain_messages( self: @ComponentState, message_hash: MessageHash ) -> MessageToAppchainStatus { - let nonce = self.sn_to_appc_messages.read(message_hash); - if nonce == 0 { - return MessageToAppchainStatus::SealedOrNotSent; - } - return MessageToAppchainStatus::Pending(nonce); + self.sn_to_appc_messages.read(message_hash) } - fn appchain_to_sn_messages( self: @ComponentState, message_hash: MessageHash ) -> MessageToStarknetStatus { @@ -243,16 +234,16 @@ mod messaging_cpt { payload: Span, nonce: Nonce, ) -> MessageHash { - assert(nonce.is_non_zero(), errors::INVALID_NONCE); let from = starknet::get_caller_address(); let message_hash = hash::compute_message_hash_sn_to_appc( from, to_address, selector, payload, nonce ); - assert( - self.sn_to_appc_messages.read(message_hash) == nonce, errors::NO_MESSAGE_TO_CANCEL - ); + match self.sn_to_appc_messages.read(message_hash) { + MessageToAppchainStatus::Pending(_) => {}, + _ => assert(false, errors::NO_MESSAGE_TO_CANCEL), + }; self.sn_to_appc_cancellations.write(message_hash, starknet::get_block_timestamp()); @@ -280,7 +271,8 @@ mod messaging_cpt { ); assert( - self.sn_to_appc_messages.read(message_hash) == nonce, errors::NO_MESSAGE_TO_CANCEL + self.sn_to_appc_messages.read(message_hash) == MessageToAppchainStatus::Pending(nonce), + errors::NO_MESSAGE_TO_CANCEL ); let request_time = self.sn_to_appc_cancellations.read(message_hash); @@ -299,7 +291,7 @@ mod messaging_cpt { ); // Once canceled, no more operation can be done on this message. - self.sn_to_appc_messages.write(message_hash, 0); + self.sn_to_appc_messages.write(message_hash, MessageToAppchainStatus::Cancelled); return message_hash; } @@ -399,15 +391,15 @@ mod messaging_cpt { let message_hash = hash::compute_message_hash_sn_to_appc( from, to, selector, payload, nonce ); - assert( - self.sn_to_appc_messages.read(message_hash) != SEALED_MESSAGE, - errors::INVALID_MESSAGE_TO_SEAL - ); + + match self.sn_to_appc_messages.read(message_hash) { + MessageToAppchainStatus::Pending(_) => {}, + _ => assert(false, errors::INVALID_MESSAGE_TO_SEAL), + }; // On the L1, they use the Fee in front of the message hash, not the nonce. - // Since the nonce 0 is a valid nonce, the max value of the felt is used - // instead to indicate that the message is sealed. - self.sn_to_appc_messages.write(message_hash, SEALED_MESSAGE); + // Here, we have an enum to explicitly indicate that the message is sealed. + self.sn_to_appc_messages.write(message_hash, MessageToAppchainStatus::Sealed); self .emit( diff --git a/src/messaging/tests/test_messaging.cairo b/src/messaging/tests/test_messaging.cairo index 1198869..3ff140f 100644 --- a/src/messaging/tests/test_messaging.cairo +++ b/src/messaging/tests/test_messaging.cairo @@ -168,7 +168,7 @@ fn send_message_ok() { let (message_hash, nonce) = mock.send_message_to_appchain(to, selector, payload.span()); assert(message_hash.is_non_zero(), 'invalid message hash'); - assert(nonce == 1, 'invalid nonce'); + assert(nonce == 0, 'invalid nonce'); let expected_event = MessageSent { message_hash, from, to, selector, nonce: nonce, payload: payload.span(), @@ -190,11 +190,11 @@ fn sn_to_appchain_messages_ok() { // Calculate the message_hash let message_hash = hash::compute_message_hash_sn_to_appc( - from_address: from, to_address: to, :selector, payload: payload.span(), nonce: 1 + from_address: from, to_address: to, :selector, payload: payload.span(), nonce: 0 ); let is_pending_before = mock.sn_to_appchain_messages(message_hash); assert( - is_pending_before == MessageToAppchainStatus::SealedOrNotSent, + is_pending_before == MessageToAppchainStatus::NotSent, 'Should not be pending before' ); @@ -248,14 +248,14 @@ fn start_cancellation_ok() { } #[test] -#[should_panic(expected: ('INVALID_NONCE',))] +#[should_panic(expected: ('NO_MESSAGE_TO_CANCEL',))] fn start_cancellation_invalid_nonce() { let (mock, _) = deploy_mock(); let to = c::RECIPIENT(); let selector = selector!("func1"); let payload = array![1, 2, 3]; - let nonce = 0; + let nonce = 0x800000000000011000000000000000000000000000000000000000000000000; mock.start_message_cancellation(to, selector, payload.span(), nonce); } @@ -325,7 +325,7 @@ fn cancel_message_no_message_to_cancel() { let to = c::RECIPIENT(); let selector = selector!("func1"); let payload = array![1, 2, 3]; - let nonce = 1; + let nonce = 0; mock.cancel_message(to, selector, payload.span(), nonce + 1000); } @@ -407,7 +407,7 @@ fn process_messages_to_appchain_ok() { let (_message_hash, _nonce) = mock.send_message_to_appchain(to, selector, payload.span()); let m = MessageToAppchain { - from_address: from, to_address: to, nonce: 1, selector, payload: payload.span(), + from_address: from, to_address: to, nonce: 0, selector, payload: payload.span(), }; let _message_hash = hash::compute_message_hash_sn_to_appc( diff --git a/src/messaging/types.cairo b/src/messaging/types.cairo index 2e7382d..debf98f 100644 --- a/src/messaging/types.cairo +++ b/src/messaging/types.cairo @@ -1,9 +1,12 @@ pub type MessageHash = felt252; pub type Nonce = felt252; -#[derive(Serde, Drop, PartialEq)] +#[derive(Serde, Drop, PartialEq, starknet::Store, Default)] pub enum MessageToAppchainStatus { - SealedOrNotSent, // sn->appc: The nonce is 0 for the message hash. + #[default] + NotSent, + Sealed, + Cancelled, Pending: Nonce, // sn->appc: The nonce > 0. } From e395ea1642de178b088accfcf4c3841e3c9552a4 Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 9 Jan 2025 00:26:33 -0600 Subject: [PATCH 05/15] tests: add messaging-test test --- .github/workflows/build.yml | 2 +- .github/workflows/check.yml | 2 +- src/messaging/tests/test_messaging.cairo | 22 +++++++++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a46b060..dae7b6e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,4 +15,4 @@ jobs: - uses: actions/checkout@v4 - uses: asdf-vm/actions/install@v3 - run: scarb fmt --check - - run: scarb build + - run: scarb build --all-features diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index adac1ce..3f05879 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -24,4 +24,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: asdf-vm/actions/install@v3 - - run: snforge test + - run: snforge test --all-features diff --git a/src/messaging/tests/test_messaging.cairo b/src/messaging/tests/test_messaging.cairo index 3ff140f..6d317ad 100644 --- a/src/messaging/tests/test_messaging.cairo +++ b/src/messaging/tests/test_messaging.cairo @@ -470,7 +470,27 @@ fn appchain_to_sn_messages_ok() { // Ensure that message is available to consume let count_after = mock.appchain_to_sn_messages(message_hash); - assert(count_after == MessageToStarknetStatus::ReadyToConsume(1), 'message not be present'); + assert(count_after == MessageToStarknetStatus::ReadyToConsume(1), 'message not present'); +} + +#[test] +fn appchain_to_sn_messages_hashes_test() { + let mut mock = mock_state_testing(); + + let from = c::SPENDER(); + let to = starknet::get_contract_address(); + let payload = array![1, 2, 3].span(); + + let message_hash = hash::compute_message_hash_appc_to_sn(from, to, payload); + + let previous_status = mock.appchain_to_sn_messages(message_hash); + assert(previous_status == MessageToStarknetStatus::NothingToConsume, 'message already present'); + + mock.add_messages_hashes_from_appchain(array![message_hash].span()); + + // Ensure that message is available to consume. + let count_after = mock.appchain_to_sn_messages(message_hash); + assert(count_after == MessageToStarknetStatus::ReadyToConsume(1), 'message not present'); } #[test] From 02f5aa833abd650ce3cadbb232f7727b09b6cfe0 Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 9 Jan 2025 00:27:05 -0600 Subject: [PATCH 06/15] fix: run scarb fmt --- src/messaging/component.cairo | 23 +++++++++++++++-------- src/messaging/tests/test_messaging.cairo | 5 +---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/messaging/component.cairo b/src/messaging/component.cairo index d8f8997..1854091 100644 --- a/src/messaging/component.cairo +++ b/src/messaging/component.cairo @@ -271,7 +271,9 @@ mod messaging_cpt { ); assert( - self.sn_to_appc_messages.read(message_hash) == MessageToAppchainStatus::Pending(nonce), + self + .sn_to_appc_messages + .read(message_hash) == MessageToAppchainStatus::Pending(nonce), errors::NO_MESSAGE_TO_CANCEL ); @@ -313,12 +315,15 @@ mod messaging_cpt { // We can't have the detail of the message here, so we emit a dummy event // with at least the message hash. - self.emit(MessageToStarknetReceived { - message_hash: msg_hash, - from: 0.try_into().unwrap(), - to: 0.try_into().unwrap(), - payload: array![].span() - }); + self + .emit( + MessageToStarknetReceived { + message_hash: msg_hash, + from: 0.try_into().unwrap(), + to: 0.try_into().unwrap(), + payload: array![].span() + } + ); i += 1; }; @@ -399,7 +404,9 @@ mod messaging_cpt { // On the L1, they use the Fee in front of the message hash, not the nonce. // Here, we have an enum to explicitly indicate that the message is sealed. - self.sn_to_appc_messages.write(message_hash, MessageToAppchainStatus::Sealed); + self + .sn_to_appc_messages + .write(message_hash, MessageToAppchainStatus::Sealed); self .emit( diff --git a/src/messaging/tests/test_messaging.cairo b/src/messaging/tests/test_messaging.cairo index 6d317ad..d106a1f 100644 --- a/src/messaging/tests/test_messaging.cairo +++ b/src/messaging/tests/test_messaging.cairo @@ -193,10 +193,7 @@ fn sn_to_appchain_messages_ok() { from_address: from, to_address: to, :selector, payload: payload.span(), nonce: 0 ); let is_pending_before = mock.sn_to_appchain_messages(message_hash); - assert( - is_pending_before == MessageToAppchainStatus::NotSent, - 'Should not be pending before' - ); + assert(is_pending_before == MessageToAppchainStatus::NotSent, 'Should not be pending before'); snf::start_cheat_caller_address(from, from); let (message_hash, nonce) = mock.send_message_to_appchain(to, selector, payload.span()); From 69a814c3efe0b09121420dc2cd500b085bb661b2 Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 9 Jan 2025 01:00:07 -0600 Subject: [PATCH 07/15] ci: call snforge using scarb interface --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 3f05879..1cac1ef 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -24,4 +24,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: asdf-vm/actions/install@v3 - - run: snforge test --all-features + - run: scarb test --all-features From 4c6e2de9559775e4685e2745f1ac1189fe9eac79 Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 9 Jan 2025 01:07:27 -0600 Subject: [PATCH 08/15] tests: fix nonce since it starts to 0 now --- tests/test_appchain.cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_appchain.cairo b/tests/test_appchain.cairo index dd9c26f..ba31af3 100644 --- a/tests/test_appchain.cairo +++ b/tests/test_appchain.cairo @@ -228,7 +228,7 @@ fn update_state_ok() { // being sealed, it must be sent first. // The nonce must be adjusted to ensure the correct message to be sent. snf::store( - appchain.contract_address, selector!("sn_to_appc_nonce"), array![1629170 - 1].span() + appchain.contract_address, selector!("sn_to_appc_nonce"), array![1629170].span() ); snf::start_cheat_caller_address(appchain.contract_address, contract_sn); From 520d23bac66e1efec3afde8d45bd6e099aa732c7 Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 9 Jan 2025 01:09:04 -0600 Subject: [PATCH 09/15] fix: run scarb fmt --- tests/test_appchain.cairo | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_appchain.cairo b/tests/test_appchain.cairo index ba31af3..1fa1854 100644 --- a/tests/test_appchain.cairo +++ b/tests/test_appchain.cairo @@ -227,9 +227,7 @@ fn update_state_ok() { // The state update contains a message to appchain, therefore, before // being sealed, it must be sent first. // The nonce must be adjusted to ensure the correct message to be sent. - snf::store( - appchain.contract_address, selector!("sn_to_appc_nonce"), array![1629170].span() - ); + snf::store(appchain.contract_address, selector!("sn_to_appc_nonce"), array![1629170].span()); snf::start_cheat_caller_address(appchain.contract_address, contract_sn); imsg.send_message_to_appchain(contract_appc, selector_appc, payload_sn_to_appc); From 1e50f0ff8e782cab098763ff14255eb461a8657b Mon Sep 17 00:00:00 2001 From: glihm Date: Fri, 29 Nov 2024 10:11:34 -0600 Subject: [PATCH 10/15] feat: import chudas code --- src/appchain.cairo | 4 ++++ src/lib.cairo | 7 ++----- src/state/tests/test_state.cairo | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/appchain.cairo b/src/appchain.cairo index f3a99a8..8d85740 100644 --- a/src/appchain.cairo +++ b/src/appchain.cairo @@ -42,6 +42,8 @@ mod appchain { use piltover::state::{state_cpt, state_cpt::InternalTrait as StateInternal, IState}; use starknet::{ContractAddress, ClassHash}; use super::errors; + use piltover::fact_registry::{IFactRegistryDispatcher, IFactRegistryDispatcherTrait}; + use core::poseidon::{Poseidon, PoseidonImpl, HashStateImpl, poseidon_hash_span}; /// The default cancellation delay of 5 days. const CANCELLATION_DELAY_SECS: u64 = 432000; @@ -133,6 +135,7 @@ mod appchain { fn update_state( ref self: ContractState, snos_output: Array, + snos_output: Array, program_output: Span, onchain_data_hash: felt252, onchain_data_size: u256 @@ -161,6 +164,7 @@ mod appchain { program_output, data_availability_fact ); + assert( program_output_struct.starknet_os_config_hash == current_config_hash, errors::SNOS_INVALID_CONFIG_HASH diff --git a/src/lib.cairo b/src/lib.cairo index b667033..1da3392 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -1,11 +1,8 @@ mod appchain; -// Since this contract is used for e2e testing, it must be built as appchain.cairo. -// We should evaluate the use of Scarb profile to conditionally compile the appchain_test contract. -mod appchain_test; - -mod fact_registry; mod interface; +mod fact_registry; mod snos_output; +mod mocks; // Components mod config { mod component; diff --git a/src/state/tests/test_state.cairo b/src/state/tests/test_state.cairo index 4ed74a4..4d66c9b 100644 --- a/src/state/tests/test_state.cairo +++ b/src/state/tests/test_state.cairo @@ -4,6 +4,7 @@ use piltover::state::{ state_cpt, state_cpt::InternalTrait as StateInternal, IState, IStateDispatcher, IStateDispatcherTrait, state_mock, }; +use piltover::snos_output::StarknetOsOutput; use snforge_std as snf; use snforge_std::ContractClassTrait; @@ -68,6 +69,7 @@ fn state_update_invalid_block_number() { }; mock.update(os_output); + mock.update(os_output); } #[test] From e27155718d72e5a61aafe2ff6d077c3cf0e9cbe7 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Fri, 10 Jan 2025 12:07:26 +0100 Subject: [PATCH 11/15] post rebase fix --- src/appchain.cairo | 4 ---- src/lib.cairo | 3 +-- src/messaging/tests/test_messaging.cairo | 1 + src/state/tests/test_state.cairo | 2 -- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/appchain.cairo b/src/appchain.cairo index 8d85740..f3a99a8 100644 --- a/src/appchain.cairo +++ b/src/appchain.cairo @@ -42,8 +42,6 @@ mod appchain { use piltover::state::{state_cpt, state_cpt::InternalTrait as StateInternal, IState}; use starknet::{ContractAddress, ClassHash}; use super::errors; - use piltover::fact_registry::{IFactRegistryDispatcher, IFactRegistryDispatcherTrait}; - use core::poseidon::{Poseidon, PoseidonImpl, HashStateImpl, poseidon_hash_span}; /// The default cancellation delay of 5 days. const CANCELLATION_DELAY_SECS: u64 = 432000; @@ -135,7 +133,6 @@ mod appchain { fn update_state( ref self: ContractState, snos_output: Array, - snos_output: Array, program_output: Span, onchain_data_hash: felt252, onchain_data_size: u256 @@ -164,7 +161,6 @@ mod appchain { program_output, data_availability_fact ); - assert( program_output_struct.starknet_os_config_hash == current_config_hash, errors::SNOS_INVALID_CONFIG_HASH diff --git a/src/lib.cairo b/src/lib.cairo index 1da3392..c91b5ec 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -1,8 +1,7 @@ mod appchain; -mod interface; mod fact_registry; +mod interface; mod snos_output; -mod mocks; // Components mod config { mod component; diff --git a/src/messaging/tests/test_messaging.cairo b/src/messaging/tests/test_messaging.cairo index d106a1f..f33bb56 100644 --- a/src/messaging/tests/test_messaging.cairo +++ b/src/messaging/tests/test_messaging.cairo @@ -470,6 +470,7 @@ fn appchain_to_sn_messages_ok() { assert(count_after == MessageToStarknetStatus::ReadyToConsume(1), 'message not present'); } +#[cfg(feature: 'messaging_test')] #[test] fn appchain_to_sn_messages_hashes_test() { let mut mock = mock_state_testing(); diff --git a/src/state/tests/test_state.cairo b/src/state/tests/test_state.cairo index 4d66c9b..4ed74a4 100644 --- a/src/state/tests/test_state.cairo +++ b/src/state/tests/test_state.cairo @@ -4,7 +4,6 @@ use piltover::state::{ state_cpt, state_cpt::InternalTrait as StateInternal, IState, IStateDispatcher, IStateDispatcherTrait, state_mock, }; -use piltover::snos_output::StarknetOsOutput; use snforge_std as snf; use snforge_std::ContractClassTrait; @@ -69,7 +68,6 @@ fn state_update_invalid_block_number() { }; mock.update(os_output); - mock.update(os_output); } #[test] From 2ec433bdbbd22c0a4783421bd6eacb8be7cfdc95 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Fri, 10 Jan 2025 12:19:49 +0100 Subject: [PATCH 12/15] comments --- src/appchain.cairo | 12 ++++++++---- src/snos_output.cairo | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/appchain.cairo b/src/appchain.cairo index f3a99a8..e7b7ec9 100644 --- a/src/appchain.cairo +++ b/src/appchain.cairo @@ -127,9 +127,12 @@ mod appchain { self.state.initialize(state_root, block_number, block_hash); } - + #[abi(embed_v0)] impl Appchain of IAppchain { + /// This function accepts two outputs due to the dynamic nature of the layout, which prevents direct verification of the snos proof. + /// To ensure the correctness of `snos_output`, we compare its hash with the corresponding hash in `program_output`, + /// which serves as a layout bridge proof. fn update_state( ref self: ContractState, snos_output: Array, @@ -142,12 +145,13 @@ mod appchain { let snos_output_span = snos_output.span(); let snos_output_hash = poseidon_hash_span(snos_output_span); - let snos_output_hash_in_bridge_output = program_output.at(4); - assert!(snos_output_hash == *snos_output_hash_in_bridge_output); + let snos_output_hash_in_bridge_output = program_output.at(4); + assert!(snos_output_hash == *snos_output_hash_in_bridge_output); let output_hash = poseidon_hash_span(program_output); let mut snos_output_iter = snos_output.into_iter(); - let program_output_struct = deserialize_os_output(ref snos_output_iter); + let program_output_struct = deserialize_os_output(ref snos_output_iter); //Custom deserialization function, inspired by + //https://github.com/starkware-libs/cairo-lang/blob/8e11b8cc65ae1d0959328b1b4a40b92df8b58595/src/starkware/starknet/core/aggregator/output_parser.py let (current_program_hash, current_config_hash): (felt252, felt252) = self .config diff --git a/src/snos_output.cairo b/src/snos_output.cairo index 262257a..3b20576 100644 --- a/src/snos_output.cairo +++ b/src/snos_output.cairo @@ -89,6 +89,8 @@ fn read_segment(ref input_iter: ArrayIter, segment_length: usize) -> Ar }; return segment; } +/// Custom deserialization function, inspired by +///https://github.com/starkware-libs/cairo-lang/blob/8e11b8cc65ae1d0959328b1b4a40b92df8b58595/src/starkware/starknet/core/aggregator/output_parser.py fn deserialize_os_output(ref input_iter: ArrayIter) -> StarknetOsOutput { let _ = read_segment(ref input_iter, 3); let header = read_segment(ref input_iter, HEADER_SIZE); From 408fa58b985a180fc810f77dbfeb3d6fddf09f40 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Fri, 10 Jan 2025 12:26:20 +0100 Subject: [PATCH 13/15] fmt --- src/appchain.cairo | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/appchain.cairo b/src/appchain.cairo index e7b7ec9..f57cdb6 100644 --- a/src/appchain.cairo +++ b/src/appchain.cairo @@ -127,12 +127,13 @@ mod appchain { self.state.initialize(state_root, block_number, block_hash); } - + #[abi(embed_v0)] impl Appchain of IAppchain { - /// This function accepts two outputs due to the dynamic nature of the layout, which prevents direct verification of the snos proof. - /// To ensure the correctness of `snos_output`, we compare its hash with the corresponding hash in `program_output`, - /// which serves as a layout bridge proof. + /// This function accepts two outputs due to the dynamic nature of the layout, which + /// prevents direct verification of the snos proof. + /// To ensure the correctness of `snos_output`, we compare its hash with the corresponding + /// hash in `program_output`, which serves as a layout bridge proof. fn update_state( ref self: ContractState, snos_output: Array, @@ -145,12 +146,14 @@ mod appchain { let snos_output_span = snos_output.span(); let snos_output_hash = poseidon_hash_span(snos_output_span); - let snos_output_hash_in_bridge_output = program_output.at(4); - assert!(snos_output_hash == *snos_output_hash_in_bridge_output); + let snos_output_hash_in_bridge_output = program_output.at(4); + assert!(snos_output_hash == *snos_output_hash_in_bridge_output); let output_hash = poseidon_hash_span(program_output); let mut snos_output_iter = snos_output.into_iter(); - let program_output_struct = deserialize_os_output(ref snos_output_iter); //Custom deserialization function, inspired by + let program_output_struct = deserialize_os_output( + ref snos_output_iter + ); //Custom deserialization function, inspired by //https://github.com/starkware-libs/cairo-lang/blob/8e11b8cc65ae1d0959328b1b4a40b92df8b58595/src/starkware/starknet/core/aggregator/output_parser.py let (current_program_hash, current_config_hash): (felt252, felt252) = self From a5a9a79fcee1ef891cdccb3620c06369b1b43119 Mon Sep 17 00:00:00 2001 From: glihm Date: Tue, 28 Jan 2025 12:28:49 -0600 Subject: [PATCH 14/15] fix: adjust messaging messages status + add testing feature (#44) * feat: add the manual registration of messages gated under messaging_test feature * fix: remove unused files * fix: ensure the first nonce is 0 and use other value for sealed messages * fix: directly use the appchain message type instead of nonce magic value * tests: add messaging-test test * fix: run scarb fmt * ci: call snforge using scarb interface * tests: fix nonce since it starts to 0 now * fix: run scarb fmt * fix(bindings): regenerate bindings with latest version --- .github/workflows/build.yml | 2 +- .github/workflows/check.yml | 2 +- .tool-versions | 2 +- README.md | 9 +- Scarb.toml | 4 +- bindings/Cargo.lock | 181 +- bindings/Cargo.toml | 15 +- bindings/src/bin.rs | 18 + bindings/src/bindings.rs | 2720 --------------- bindings/src/lib.rs | 3893 +++++++++++++++++++++- src/messaging/component.cairo | 86 +- src/messaging/interface.cairo | 12 + src/messaging/tests/test_messaging.cairo | 39 +- src/messaging/types.cairo | 7 +- tests/test_appchain.cairo | 4 +- 15 files changed, 4146 insertions(+), 2848 deletions(-) create mode 100644 bindings/src/bin.rs delete mode 100644 bindings/src/bindings.rs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a46b060..dae7b6e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,4 +15,4 @@ jobs: - uses: actions/checkout@v4 - uses: asdf-vm/actions/install@v3 - run: scarb fmt --check - - run: scarb build + - run: scarb build --all-features diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index adac1ce..1cac1ef 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -24,4 +24,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: asdf-vm/actions/install@v3 - - run: snforge test + - run: scarb test --all-features diff --git a/.tool-versions b/.tool-versions index 4e4d000..8e4fd02 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -scarb 2.8.0 +scarb 2.8.4 starknet-foundry 0.27.0 diff --git a/README.md b/README.md index 81855c1..a8b6128 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,12 @@ To build/update the bindings, first build the contract with `scarb`. Then, within the Rust project `bindings/` run: -````bash -cargo build -```` +```bash +cargo build --bin generator +``` + +This will generate the bindings into `src/lib.rs`, which can be imported in other Rust project. +Currently some warnings are displayed, will be fixed in a future version of `cainome`. ## Test diff --git a/Scarb.toml b/Scarb.toml index cc33e9c..539aac6 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2023_10" [dependencies] -starknet = "2.8.0" +starknet = "2.8.4" openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.16.0" } [dev-dependencies] @@ -25,3 +25,5 @@ sierra = true [tool.fmt] sort-module-level-items = true +[features] +messaging_test = [] diff --git a/bindings/Cargo.lock b/bindings/Cargo.lock index 7782bed..a58d9e0 100644 --- a/bindings/Cargo.lock +++ b/bindings/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -174,13 +174,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "bindings" -version = "0.1.0" -dependencies = [ - "cainome", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -234,12 +227,13 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cainome" -version = "0.2.3" -source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.0#0d29bb06b3f7cb7fcb8f0749c3b2ad105a5551dd" +version = "0.4.11" +source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.11#355b88b7b808656d729e9dfd16f81d80c5c30fbf" dependencies = [ "anyhow", "async-trait", "cainome-cairo-serde", + "cainome-cairo-serde-derive", "cainome-parser", "cainome-rs", "cainome-rs-macro", @@ -250,7 +244,7 @@ dependencies = [ "serde", "serde_json", "starknet", - "starknet-types-core 0.1.5 (git+https://github.com/starknet-io/types-rs?rev=f98f048)", + "starknet-types-core", "thiserror", "tracing", "tracing-subscriber", @@ -260,17 +254,30 @@ dependencies = [ [[package]] name = "cainome-cairo-serde" version = "0.1.0" -source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.0#0d29bb06b3f7cb7fcb8f0749c3b2ad105a5551dd" +source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.11#355b88b7b808656d729e9dfd16f81d80c5c30fbf" dependencies = [ + "num-bigint", "serde", + "serde_with", "starknet", "thiserror", ] +[[package]] +name = "cainome-cairo-serde-derive" +version = "0.1.0" +source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.11#355b88b7b808656d729e9dfd16f81d80c5c30fbf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", + "unzip-n", +] + [[package]] name = "cainome-parser" version = "0.1.0" -source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.0#0d29bb06b3f7cb7fcb8f0749c3b2ad105a5551dd" +source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.11#355b88b7b808656d729e9dfd16f81d80c5c30fbf" dependencies = [ "convert_case", "quote", @@ -283,7 +290,7 @@ dependencies = [ [[package]] name = "cainome-rs" version = "0.1.0" -source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.0#0d29bb06b3f7cb7fcb8f0749c3b2ad105a5551dd" +source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.11#355b88b7b808656d729e9dfd16f81d80c5c30fbf" dependencies = [ "anyhow", "cainome-cairo-serde", @@ -301,7 +308,7 @@ dependencies = [ [[package]] name = "cainome-rs-macro" version = "0.1.0" -source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.0#0d29bb06b3f7cb7fcb8f0749c3b2ad105a5551dd" +source = "git+https://github.com/cartridge-gg/cainome?rev=v0.4.11#355b88b7b808656d729e9dfd16f81d80c5c30fbf" dependencies = [ "anyhow", "cainome-cairo-serde", @@ -645,6 +652,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -740,7 +753,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.5.0", + "indexmap 2.7.1", "slab", "tokio", "tokio-util", @@ -755,9 +768,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -948,12 +961,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.2", "serde", ] @@ -1004,9 +1017,9 @@ dependencies = [ [[package]] name = "lambdaworks-crypto" -version = "0.7.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb5d4f22241504f7c7b8d2c3a7d7835d7c07117f10bff2a7d96a9ef6ef217c3" +checksum = "bbc2a4da0d9e52ccfe6306801a112e81a8fc0c76aa3e4449fefeda7fef72bb34" dependencies = [ "lambdaworks-math", "serde", @@ -1016,9 +1029,9 @@ dependencies = [ [[package]] name = "lambdaworks-math" -version = "0.7.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "358e172628e713b80a530a59654154bfc45783a6ed70ea284839800cebdf8f97" +checksum = "d1bd2632acbd9957afc5aeec07ad39f078ae38656654043bf16e046fa2730e23" dependencies = [ "serde", "serde_json", @@ -1199,6 +1212,14 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "piltover" +version = "0.1.0" +dependencies = [ + "cainome", + "starknet", +] + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -1284,9 +1305,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -1593,15 +1614,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.9.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.5.0", + "indexmap 2.7.1", "serde", "serde_derive", "serde_json", @@ -1611,9 +1632,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.9.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" dependencies = [ "darling", "proc-macro2", @@ -1690,8 +1711,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "starknet" -version = "0.11.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694#2ddc69479d326ed154df438d22f2d720fbba746e" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0c9ac3809cc7630784e8c8565fa3013af819d83c97aa2720d566016d439011" dependencies = [ "starknet-accounts", "starknet-contract", @@ -1704,8 +1726,9 @@ dependencies = [ [[package]] name = "starknet-accounts" -version = "0.10.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694#2ddc69479d326ed154df438d22f2d720fbba746e" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee27ded58ade61da410fccafd57ed5429b0e79a9d62a4ae8b65818cb9d6f400" dependencies = [ "async-trait", "auto_impl", @@ -1718,8 +1741,9 @@ dependencies = [ [[package]] name = "starknet-contract" -version = "0.10.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694#2ddc69479d326ed154df438d22f2d720fbba746e" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6ee5762d24c4f06ab7e9406550925df406712e73719bd2de905c879c674a87" dependencies = [ "serde", "serde_json", @@ -1732,26 +1756,43 @@ dependencies = [ [[package]] name = "starknet-core" -version = "0.11.1" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694#2ddc69479d326ed154df438d22f2d720fbba746e" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37abf0af45a3b866dd108880ace9949ae7830f6830adb8963024302ae9e82c24" dependencies = [ "base64 0.21.7", "crypto-bigint", "flate2", + "foldhash", "hex", + "indexmap 2.7.1", + "num-traits", "serde", "serde_json", "serde_json_pythonic", "serde_with", "sha3", + "starknet-core-derive", "starknet-crypto", - "starknet-types-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "starknet-types-core", +] + +[[package]] +name = "starknet-core-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b08520b7d80eda7bf1a223e8db4f9bb5779a12846f15ebf8f8d76667eca7f5ad" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", ] [[package]] name = "starknet-crypto" -version = "0.7.1" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694#2ddc69479d326ed154df438d22f2d720fbba746e" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "039a3bad70806b494c9e6b21c5238a6c8a373d66a26071859deb0ccca6f93634" dependencies = [ "crypto-bigint", "hex", @@ -1762,22 +1803,24 @@ dependencies = [ "rfc6979", "sha2", "starknet-curve", - "starknet-types-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "starknet-types-core", "zeroize", ] [[package]] name = "starknet-curve" -version = "0.5.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694#2ddc69479d326ed154df438d22f2d720fbba746e" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcde6bd74269b8161948190ace6cf069ef20ac6e79cd2ba09b320efa7500b6de" dependencies = [ - "starknet-types-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "starknet-types-core", ] [[package]] name = "starknet-macros" -version = "0.2.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694#2ddc69479d326ed154df438d22f2d720fbba746e" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8986a940af916fc0a034f4e42c6ba76d94f1e97216d75447693dfd7aefaf3ef2" dependencies = [ "starknet-core", "syn 2.0.77", @@ -1785,8 +1828,9 @@ dependencies = [ [[package]] name = "starknet-providers" -version = "0.11.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694#2ddc69479d326ed154df438d22f2d720fbba746e" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9256247f718564b3e4c73cc941735012691c14903fbc25cea306745bcbfa384" dependencies = [ "async-trait", "auto_impl", @@ -1805,8 +1849,9 @@ dependencies = [ [[package]] name = "starknet-signers" -version = "0.9.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694#2ddc69479d326ed154df438d22f2d720fbba746e" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b9cbae629e277fba372b5f22f52aa5dd1dd40c61924bb18bf901d4d830edd1" dependencies = [ "async-trait", "auto_impl", @@ -1821,22 +1866,9 @@ dependencies = [ [[package]] name = "starknet-types-core" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6bacf0ba19bc721e518bc4bf389ff13daa8a7c5db5fd320600473b8aa9fcbd" -dependencies = [ - "lambdaworks-crypto", - "lambdaworks-math", - "num-bigint", - "num-integer", - "num-traits", - "serde", -] - -[[package]] -name = "starknet-types-core" -version = "0.1.5" -source = "git+https://github.com/starknet-io/types-rs?rev=f98f048#f98f048efa776f1f8da81a19f337a9b8c2f4b8f7" +checksum = "fa1b9e01ccb217ab6d475c5cda05dbb22c30029f7bb52b192a010a00d77a3d74" dependencies = [ "lambdaworks-crypto", "lambdaworks-math", @@ -2054,7 +2086,7 @@ version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.7.1", "toml_datetime", "winnow", ] @@ -2196,6 +2228,17 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "unzip-n" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e7e85a0596447f0f2ac090e16bc4c516c6fe91771fb0c0ccf7fa3dae896b9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "url" version = "2.5.2" diff --git a/bindings/Cargo.toml b/bindings/Cargo.toml index 30bc133..58455ae 100644 --- a/bindings/Cargo.toml +++ b/bindings/Cargo.toml @@ -1,9 +1,16 @@ [package] -name = "bindings" +name = "piltover" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -cainome = { git = "https://github.com/cartridge-gg/cainome", rev = "v0.4.0", features = ["abigen-rs"] } +cainome = { git = "https://github.com/cartridge-gg/cainome", rev = "v0.4.11", features = ["abigen-rs"] } +starknet = "0.12" + +[lib] +name = "piltover_bindings" +path = "src/lib.rs" + +[[bin]] +name = "generator" +path = "src/bin.rs" diff --git a/bindings/src/bin.rs b/bindings/src/bin.rs new file mode 100644 index 0000000..73c1367 --- /dev/null +++ b/bindings/src/bin.rs @@ -0,0 +1,18 @@ +use cainome::rs::abigen; + +abigen!( + Appchain, + "../target/dev/piltover_appchain.contract_class.json", + output_path("src/lib.rs"), + type_aliases { + piltover::messaging::component::messaging_cpt::Event as MessagingEvent; + piltover::state::component::state_cpt::Event as StateEvent; + piltover::config::component::config_cpt::Event as ConfigEvent; + openzeppelin_security::reentrancyguard::ReentrancyGuardComponent::Event as ReentrancyguardEvent; + openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event as UpgradeableEvent; + openzeppelin_access::ownable::ownable::OwnableComponent::Event as OwnableEvent; + piltover::appchain::appchain::Event as AppchainEvent; + } +); + +fn main() {} diff --git a/bindings/src/bindings.rs b/bindings/src/bindings.rs deleted file mode 100644 index dff3c53..0000000 --- a/bindings/src/bindings.rs +++ /dev/null @@ -1,2720 +0,0 @@ -#[derive(Debug)] pub struct AppChain < A : starknet :: accounts :: -ConnectedAccount + Sync > -{ - pub address : starknet :: core :: types :: Felt, pub account : A, pub - block_id : starknet :: core :: types :: BlockId, -} impl < A : starknet :: accounts :: ConnectedAccount + Sync > AppChain < A > -{ - pub fn new(address : starknet :: core :: types :: Felt, account : A) -> - Self - { - Self - { - address, account, block_id : starknet :: core :: types :: BlockId - :: Tag(starknet :: core :: types :: BlockTag :: Pending) - } - } pub fn - set_contract_address(& mut self, address : starknet :: core :: types :: - Felt) { self.address = address; } pub fn provider(& self) -> & A :: - Provider { self.account.provider() } pub fn - set_block(& mut self, block_id : starknet :: core :: types :: BlockId) - { self.block_id = block_id; } pub fn - with_block(self, block_id : starknet :: core :: types :: BlockId) -> Self - { Self { block_id, .. self } } -} #[derive(Debug)] pub struct AppChainReader < P : starknet :: providers :: -Provider + Sync > -{ - pub address : starknet :: core :: types :: Felt, pub provider : P, pub - block_id : starknet :: core :: types :: BlockId, -} impl < P : starknet :: providers :: Provider + Sync > AppChainReader < P > -{ - pub fn new(address : starknet :: core :: types :: Felt, provider : P,) -> - Self - { - Self - { - address, provider, block_id : starknet :: core :: types :: BlockId - :: Tag(starknet :: core :: types :: BlockTag :: Pending) - } - } pub fn - set_contract_address(& mut self, address : starknet :: core :: types :: - Felt) { self.address = address; } pub fn provider(& self) -> & P - { & self.provider } pub fn - set_block(& mut self, block_id : starknet :: core :: types :: BlockId) - { self.block_id = block_id; } pub fn - with_block(self, block_id : starknet :: core :: types :: BlockId) -> Self - { Self { block_id, .. self } } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct -LogStateTransitionFact -{ pub state_transition_fact : cainome :: cairo_serde :: U256 } impl cainome :: -cairo_serde :: CairoSerde for LogStateTransitionFact -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += cainome :: cairo_serde :: U256 :: - cairo_serialized_size(& __rust.state_transition_fact); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(cainome :: cairo_serde :: U256 :: - cairo_serialize(& __rust.state_transition_fact)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let state_transition_fact = cainome :: - cairo_serde :: U256 :: cairo_deserialize(__felts, __offset) ? ; - __offset += cainome :: cairo_serde :: U256 :: - cairo_serialized_size(& state_transition_fact); - Ok(LogStateTransitionFact { state_transition_fact }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct LogStateUpdate -{ - pub state_root : starknet :: core :: types :: Felt, pub block_number : - starknet :: core :: types :: Felt, pub block_hash : starknet :: core :: - types :: Felt -} impl cainome :: cairo_serde :: CairoSerde for LogStateUpdate -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.state_root); __size += starknet :: core - :: types :: Felt :: cairo_serialized_size(& __rust.block_number); - __size += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.block_hash); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.state_root)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.block_number)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.block_hash)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let state_root = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& state_root); let block_number = starknet :: - core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; - __offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& block_number); let block_hash = starknet :: - core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; - __offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& block_hash); - Ok(LogStateUpdate { state_root, block_number, block_hash }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct MessageCanceled -{ - pub message_hash : starknet :: core :: types :: Felt, pub from : cainome - :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: - ContractAddress, pub selector : starknet :: core :: types :: Felt, pub - payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet - :: core :: types :: Felt -} impl cainome :: cairo_serde :: CairoSerde for MessageCanceled -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.message_hash); __size += cainome :: - cairo_serde :: ContractAddress :: - cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde - :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.selector); __size += Vec :: < starknet - :: core :: types :: Felt > :: cairo_serialized_size(& __rust.payload); - __size += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.nonce); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.message_hash)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.from)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.to)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.selector)); - __out.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(& __rust.payload)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.nonce)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let message_hash = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = cainome :: - cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) - ? ; __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = cainome :: cairo_serde :: - ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset - += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = starknet :: core :: types - :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let payload = Vec :: < starknet :: - core :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; - __offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); let nonce = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); - Ok(MessageCanceled - { message_hash, from, to, selector, payload, nonce }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct -MessageCancellationStarted -{ - pub message_hash : starknet :: core :: types :: Felt, pub from : cainome - :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: - ContractAddress, pub selector : starknet :: core :: types :: Felt, pub - payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet - :: core :: types :: Felt -} impl cainome :: cairo_serde :: CairoSerde for MessageCancellationStarted -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.message_hash); __size += cainome :: - cairo_serde :: ContractAddress :: - cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde - :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.selector); __size += Vec :: < starknet - :: core :: types :: Felt > :: cairo_serialized_size(& __rust.payload); - __size += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.nonce); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.message_hash)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.from)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.to)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.selector)); - __out.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(& __rust.payload)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.nonce)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let message_hash = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = cainome :: - cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) - ? ; __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = cainome :: cairo_serde :: - ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset - += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = starknet :: core :: types - :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let payload = Vec :: < starknet :: - core :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; - __offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); let nonce = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); - Ok(MessageCancellationStarted - { message_hash, from, to, selector, payload, nonce }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct MessageConsumed -{ - pub message_hash : starknet :: core :: types :: Felt, pub from : cainome - :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: - ContractAddress, pub payload : Vec < starknet :: core :: types :: Felt > -} impl cainome :: cairo_serde :: CairoSerde for MessageConsumed -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.message_hash); __size += cainome :: - cairo_serde :: ContractAddress :: - cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde - :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += - Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& __rust.payload); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.message_hash)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.from)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.to)); - __out.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(& __rust.payload)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let message_hash = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = cainome :: - cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) - ? ; __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = cainome :: cairo_serde :: - ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset - += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let payload = Vec :: < starknet :: core - :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; - __offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); - Ok(MessageConsumed { message_hash, from, to, payload }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct MessageSent -{ - pub message_hash : starknet :: core :: types :: Felt, pub from : cainome - :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: - ContractAddress, pub selector : starknet :: core :: types :: Felt, pub - nonce : starknet :: core :: types :: Felt, pub payload : Vec < starknet :: - core :: types :: Felt > -} impl cainome :: cairo_serde :: CairoSerde for MessageSent -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.message_hash); __size += cainome :: - cairo_serde :: ContractAddress :: - cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde - :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.selector); __size += starknet :: core - :: types :: Felt :: cairo_serialized_size(& __rust.nonce); __size += - Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& __rust.payload); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.message_hash)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.from)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.to)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.selector)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.nonce)); - __out.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(& __rust.payload)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let message_hash = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = cainome :: - cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) - ? ; __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = cainome :: cairo_serde :: - ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset - += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = starknet :: core :: types - :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let nonce = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); - let payload = Vec :: < starknet :: core :: types :: Felt > :: - cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < starknet - :: core :: types :: Felt > :: cairo_serialized_size(& payload); - Ok(MessageSent { message_hash, from, to, selector, nonce, payload }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct -MessageToAppchainSealed -{ - pub message_hash : starknet :: core :: types :: Felt, pub from : cainome - :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: - ContractAddress, pub selector : starknet :: core :: types :: Felt, pub - nonce : starknet :: core :: types :: Felt, pub payload : Vec < starknet :: - core :: types :: Felt > -} impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainSealed -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.message_hash); __size += cainome :: - cairo_serde :: ContractAddress :: - cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde - :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.selector); __size += starknet :: core - :: types :: Felt :: cairo_serialized_size(& __rust.nonce); __size += - Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& __rust.payload); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.message_hash)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.from)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.to)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.selector)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.nonce)); - __out.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(& __rust.payload)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let message_hash = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = cainome :: - cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) - ? ; __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = cainome :: cairo_serde :: - ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset - += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = starknet :: core :: types - :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let nonce = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); - let payload = Vec :: < starknet :: core :: types :: Felt > :: - cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < starknet - :: core :: types :: Felt > :: cairo_serialized_size(& payload); - Ok(MessageToAppchainSealed - { message_hash, from, to, selector, nonce, payload }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct -MessageToStarknetReceived -{ - pub message_hash : starknet :: core :: types :: Felt, pub from : cainome - :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: - ContractAddress, pub payload : Vec < starknet :: core :: types :: Felt > -} impl cainome :: cairo_serde :: CairoSerde for MessageToStarknetReceived -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.message_hash); __size += cainome :: - cairo_serde :: ContractAddress :: - cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde - :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += - Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& __rust.payload); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.message_hash)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.from)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.to)); - __out.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(& __rust.payload)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let message_hash = starknet :: core :: - types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += - starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = cainome :: - cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) - ? ; __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = cainome :: cairo_serde :: - ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset - += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let payload = Vec :: < starknet :: core - :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; - __offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); - Ok(MessageToStarknetReceived { message_hash, from, to, payload }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct -OwnershipTransferStarted -{ - pub previous_owner : cainome :: cairo_serde :: ContractAddress, pub - new_owner : cainome :: cairo_serde :: ContractAddress -} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferStarted -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += cainome :: cairo_serde :: - ContractAddress :: cairo_serialized_size(& __rust.previous_owner); - __size += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& __rust.new_owner); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.previous_owner)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.new_owner)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let previous_owner = cainome :: - cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) - ? ; __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& previous_owner); let new_owner = cainome :: - cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) - ? ; __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& new_owner); - Ok(OwnershipTransferStarted { previous_owner, new_owner }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct -OwnershipTransferred -{ - pub previous_owner : cainome :: cairo_serde :: ContractAddress, pub - new_owner : cainome :: cairo_serde :: ContractAddress -} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferred -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += cainome :: cairo_serde :: - ContractAddress :: cairo_serialized_size(& __rust.previous_owner); - __size += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& __rust.new_owner); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.previous_owner)); - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.new_owner)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let previous_owner = cainome :: - cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) - ? ; __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& previous_owner); let new_owner = cainome :: - cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) - ? ; __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& new_owner); - Ok(OwnershipTransferred { previous_owner, new_owner }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct ProgramInfoChanged -{ - pub changed_by : cainome :: cairo_serde :: ContractAddress, pub - old_program_hash : starknet :: core :: types :: Felt, pub new_program_hash - : starknet :: core :: types :: Felt, pub old_config_hash : starknet :: - core :: types :: Felt, pub new_config_hash : starknet :: core :: types :: - Felt -} impl cainome :: cairo_serde :: CairoSerde for ProgramInfoChanged -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += cainome :: cairo_serde :: - ContractAddress :: cairo_serialized_size(& __rust.changed_by); __size - += starknet :: core :: types :: Felt :: - cairo_serialized_size(& __rust.old_program_hash); __size += starknet - :: core :: types :: Felt :: - cairo_serialized_size(& __rust.new_program_hash); __size += starknet - :: core :: types :: Felt :: - cairo_serialized_size(& __rust.old_config_hash); __size += starknet :: - core :: types :: Felt :: - cairo_serialized_size(& __rust.new_config_hash); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(& __rust.changed_by)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.old_program_hash)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.new_program_hash)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.old_config_hash)); - __out.extend(starknet :: core :: types :: Felt :: - cairo_serialize(& __rust.new_config_hash)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let changed_by = cainome :: cairo_serde - :: ContractAddress :: cairo_deserialize(__felts, __offset) ? ; - __offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& changed_by); let old_program_hash = starknet - :: core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; - __offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& old_program_hash); let new_program_hash = - starknet :: core :: types :: Felt :: - cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core - :: types :: Felt :: cairo_serialized_size(& new_program_hash); let - old_config_hash = starknet :: core :: types :: Felt :: - cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core - :: types :: Felt :: cairo_serialized_size(& old_config_hash); let - new_config_hash = starknet :: core :: types :: Felt :: - cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core - :: types :: Felt :: cairo_serialized_size(& new_config_hash); - Ok(ProgramInfoChanged - { - changed_by, old_program_hash, new_program_hash, old_config_hash, - new_config_hash - }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub struct Upgraded -{ pub class_hash : cainome :: cairo_serde :: ClassHash } impl cainome :: -cairo_serde :: CairoSerde for Upgraded -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - let mut __size = 0; __size += cainome :: cairo_serde :: ClassHash :: - cairo_serialized_size(& __rust.class_hash); __size - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; - __out.extend(cainome :: cairo_serde :: ClassHash :: - cairo_serialize(& __rust.class_hash)); __out - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let mut __offset = __offset; let class_hash = cainome :: cairo_serde - :: ClassHash :: cairo_deserialize(__felts, __offset) ? ; __offset += - cainome :: cairo_serde :: ClassHash :: - cairo_serialized_size(& class_hash); Ok(Upgraded { class_hash }) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub enum Event -{ Upgraded(Upgraded) } impl cainome :: cairo_serde :: CairoSerde for Event -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = std :: option :: Option :: None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - match __rust - { - Event :: Upgraded(val) => Upgraded :: cairo_serialized_size(val) + - 1, _ => 0 - } - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - match __rust - { - Event :: Upgraded(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 0usize)); - temp.extend(Upgraded :: cairo_serialize(val)); temp - }, _ => vec! [] - } - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let __f = __felts [__offset]; let __index = u128 :: - from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match - __index as usize - { - 0usize => - Ok(Event :: - Upgraded(Upgraded :: cairo_deserialize(__felts, __offset + 1) ?)), - _ => return - Err(cainome :: cairo_serde :: Error :: - Deserialize(format! ("Index not handle for enum {}", "Event"))) - } - } -} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event -{ - type Error = String; fn - try_from(event : starknet :: core :: types :: EmittedEvent) -> Result < - Self, Self :: Error > - { - use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() - { return Err("Event has no key".to_string()); } let selector = - event.keys [0]; if selector == starknet :: core :: utils :: - get_selector_from_name("Upgraded").unwrap_or_else(| _ | panic! - ("Invalid selector for {}", "Upgraded")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - class_hash = match cainome :: cairo_serde :: ClassHash :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "class_hash", - "Upgraded", e)), - }; data_offset += cainome :: cairo_serde :: ClassHash :: - cairo_serialized_size(& class_hash); return - Ok(Event :: Upgraded(Upgraded { class_hash })) - }; - Err(format! ("Could not match any event from keys {:?}", event.keys)) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub enum Event -{ - OwnableEvent(Event), UpgradeableEvent(Event), ConfigEvent(Event), - MessagingEvent(Event), ReentrancyGuardEvent(Event), StateEvent(Event), - LogStateUpdate(LogStateUpdate), - LogStateTransitionFact(LogStateTransitionFact) -} impl cainome :: cairo_serde :: CairoSerde for Event -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = std :: option :: Option :: None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - match __rust - { - Event :: OwnableEvent(val) => Event :: cairo_serialized_size(val) - + 1, Event :: UpgradeableEvent(val) => Event :: - cairo_serialized_size(val) + 1, Event :: ConfigEvent(val) => Event - :: cairo_serialized_size(val) + 1, Event :: MessagingEvent(val) => - Event :: cairo_serialized_size(val) + 1, Event :: - ReentrancyGuardEvent(val) => Event :: cairo_serialized_size(val) + - 1, Event :: StateEvent(val) => Event :: cairo_serialized_size(val) - + 1, Event :: LogStateUpdate(val) => LogStateUpdate :: - cairo_serialized_size(val) + 1, Event :: - LogStateTransitionFact(val) => LogStateTransitionFact :: - cairo_serialized_size(val) + 1, _ => 0 - } - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - match __rust - { - Event :: OwnableEvent(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 0usize)); - temp.extend(Event :: cairo_serialize(val)); temp - }, Event :: UpgradeableEvent(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 1usize)); - temp.extend(Event :: cairo_serialize(val)); temp - }, Event :: ConfigEvent(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 2usize)); - temp.extend(Event :: cairo_serialize(val)); temp - }, Event :: MessagingEvent(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 3usize)); - temp.extend(Event :: cairo_serialize(val)); temp - }, Event :: ReentrancyGuardEvent(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 4usize)); - temp.extend(Event :: cairo_serialize(val)); temp - }, Event :: StateEvent(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 5usize)); - temp.extend(Event :: cairo_serialize(val)); temp - }, Event :: LogStateUpdate(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 6usize)); - temp.extend(LogStateUpdate :: cairo_serialize(val)); temp - }, Event :: LogStateTransitionFact(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 7usize)); - temp.extend(LogStateTransitionFact :: cairo_serialize(val)); - temp - }, _ => vec! [] - } - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let __f = __felts [__offset]; let __index = u128 :: - from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match - __index as usize - { - 0usize => - Ok(Event :: - OwnableEvent(Event :: cairo_deserialize(__felts, __offset + 1) - ?)), 1usize => - Ok(Event :: - UpgradeableEvent(Event :: cairo_deserialize(__felts, __offset + 1) - ?)), 2usize => - Ok(Event :: - ConfigEvent(Event :: cairo_deserialize(__felts, __offset + 1) ?)), - 3usize => - Ok(Event :: - MessagingEvent(Event :: cairo_deserialize(__felts, __offset + 1) - ?)), 4usize => - Ok(Event :: - ReentrancyGuardEvent(Event :: - cairo_deserialize(__felts, __offset + 1) ?)), 5usize => - Ok(Event :: - StateEvent(Event :: cairo_deserialize(__felts, __offset + 1) ?)), - 6usize => - Ok(Event :: - LogStateUpdate(LogStateUpdate :: - cairo_deserialize(__felts, __offset + 1) ?)), 7usize => - Ok(Event :: - LogStateTransitionFact(LogStateTransitionFact :: - cairo_deserialize(__felts, __offset + 1) ?)), _ => return - Err(cainome :: cairo_serde :: Error :: - Deserialize(format! ("Index not handle for enum {}", "Event"))) - } - } -} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event -{ - type Error = String; fn - try_from(event : starknet :: core :: types :: EmittedEvent) -> Result < - Self, Self :: Error > - { - use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() - { return Err("Event has no key".to_string()); } let selector = - event.keys [0]; if selector == starknet :: core :: utils :: - get_selector_from_name("OwnershipTransferred").unwrap_or_else(| _ | - panic! ("Invalid selector for {}", "OwnershipTransferred")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - previous_owner = match cainome :: cairo_serde :: ContractAddress - :: cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "previous_owner", "OwnershipTransferred", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& previous_owner); let new_owner = match - cainome :: cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "new_owner", - "OwnershipTransferred", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& new_owner); return - Ok(Event :: - OwnableEvent(Event :: - OwnershipTransferred(OwnershipTransferred - { previous_owner, new_owner }))) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("OwnershipTransferStarted").unwrap_or_else(| _ - | panic! ("Invalid selector for {}", "OwnershipTransferStarted")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - previous_owner = match cainome :: cairo_serde :: ContractAddress - :: cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "previous_owner", "OwnershipTransferStarted", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& previous_owner); let new_owner = match - cainome :: cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "new_owner", - "OwnershipTransferStarted", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& new_owner); return - Ok(Event :: - OwnableEvent(Event :: - OwnershipTransferStarted(OwnershipTransferStarted - { previous_owner, new_owner }))) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("Upgraded").unwrap_or_else(| _ | panic! - ("Invalid selector for {}", "Upgraded")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - class_hash = match cainome :: cairo_serde :: ClassHash :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "class_hash", - "Upgraded", e)), - }; data_offset += cainome :: cairo_serde :: ClassHash :: - cairo_serialized_size(& class_hash); return - Ok(Event :: - UpgradeableEvent(Event :: Upgraded(Upgraded { class_hash }))) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("ProgramInfoChanged").unwrap_or_else(| _ | - panic! ("Invalid selector for {}", "ProgramInfoChanged")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - changed_by = match cainome :: cairo_serde :: ContractAddress :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "changed_by", - "ProgramInfoChanged", e)), - }; data_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& changed_by); let old_program_hash = match - starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "old_program_hash", "ProgramInfoChanged", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& old_program_hash); let new_program_hash = - match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "new_program_hash", "ProgramInfoChanged", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& new_program_hash); let old_config_hash = - match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "old_config_hash", "ProgramInfoChanged", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& old_config_hash); let new_config_hash = - match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "new_config_hash", "ProgramInfoChanged", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& new_config_hash); return - Ok(Event :: - ConfigEvent(Event :: - ProgramInfoChanged(ProgramInfoChanged - { - changed_by, old_program_hash, new_program_hash, - old_config_hash, new_config_hash - }))) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageSent").unwrap_or_else(| _ | panic! - ("Invalid selector for {}", "MessageSent")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageSent", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageSent", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageSent", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = match starknet :: core - :: types :: Felt :: cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "selector", - "MessageSent", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let nonce = match starknet :: - core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "nonce", - "MessageSent", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& nonce); let payload = match Vec :: < - starknet :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageSent", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); return - Ok(Event :: - MessagingEvent(Event :: - MessageSent(MessageSent - { message_hash, from, to, selector, nonce, payload }))) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageConsumed").unwrap_or_else(| _ | panic! - ("Invalid selector for {}", "MessageConsumed")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageConsumed", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageConsumed", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageConsumed", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let payload = match Vec :: < starknet - :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageConsumed", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); return - Ok(Event :: - MessagingEvent(Event :: - MessageConsumed(MessageConsumed - { message_hash, from, to, payload }))) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageCancellationStarted").unwrap_or_else(| - _ | panic! ("Invalid selector for {}", "MessageCancellationStarted")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageCancellationStarted", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageCancellationStarted", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageCancellationStarted", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = match starknet :: core - :: types :: Felt :: cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "selector", - "MessageCancellationStarted", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let payload = match Vec :: < - starknet :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageCancellationStarted", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); let nonce = match starknet :: - core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "nonce", - "MessageCancellationStarted", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& nonce); return - Ok(Event :: - MessagingEvent(Event :: - MessageCancellationStarted(MessageCancellationStarted - { message_hash, from, to, selector, payload, nonce }))) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageCanceled").unwrap_or_else(| _ | panic! - ("Invalid selector for {}", "MessageCanceled")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageCanceled", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageCanceled", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageCanceled", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = match starknet :: core - :: types :: Felt :: cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "selector", - "MessageCanceled", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let payload = match Vec :: < - starknet :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageCanceled", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); let nonce = match starknet :: - core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "nonce", - "MessageCanceled", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& nonce); return - Ok(Event :: - MessagingEvent(Event :: - MessageCanceled(MessageCanceled - { message_hash, from, to, selector, payload, nonce }))) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageToStarknetReceived").unwrap_or_else(| _ - | panic! ("Invalid selector for {}", "MessageToStarknetReceived")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageToStarknetReceived", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageToStarknetReceived", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageToStarknetReceived", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let payload = match Vec :: < starknet - :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageToStarknetReceived", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); return - Ok(Event :: - MessagingEvent(Event :: - MessageToStarknetReceived(MessageToStarknetReceived - { message_hash, from, to, payload }))) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageToAppchainSealed").unwrap_or_else(| _ | - panic! ("Invalid selector for {}", "MessageToAppchainSealed")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageToAppchainSealed", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageToAppchainSealed", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageToAppchainSealed", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = match starknet :: core - :: types :: Felt :: cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "selector", - "MessageToAppchainSealed", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let nonce = match starknet :: - core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "nonce", - "MessageToAppchainSealed", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& nonce); let payload = match Vec :: < - starknet :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageToAppchainSealed", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); return - Ok(Event :: - MessagingEvent(Event :: - MessageToAppchainSealed(MessageToAppchainSealed - { message_hash, from, to, selector, nonce, payload }))) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("LogStateUpdate").unwrap_or_else(| _ | panic! - ("Invalid selector for {}", "LogStateUpdate")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - state_root = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "state_root", - "LogStateUpdate", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& state_root); let block_number = match - starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "block_number", "LogStateUpdate", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& block_number); let block_hash = match - starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "block_hash", - "LogStateUpdate", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& block_hash); return - Ok(Event :: - LogStateUpdate(LogStateUpdate - { state_root, block_number, block_hash })) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("LogStateTransitionFact").unwrap_or_else(| _ | - panic! ("Invalid selector for {}", "LogStateTransitionFact")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - state_transition_fact = match cainome :: cairo_serde :: U256 :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "state_transition_fact", "LogStateTransitionFact", e)), - }; data_offset += cainome :: cairo_serde :: U256 :: - cairo_serialized_size(& state_transition_fact); return - Ok(Event :: - LogStateTransitionFact(LogStateTransitionFact - { state_transition_fact })) - }; - Err(format! ("Could not match any event from keys {:?}", event.keys)) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub enum Event -{ ProgramInfoChanged(ProgramInfoChanged) } impl cainome :: cairo_serde :: -CairoSerde for Event -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = std :: option :: Option :: None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - match __rust - { - Event :: ProgramInfoChanged(val) => ProgramInfoChanged :: - cairo_serialized_size(val) + 1, _ => 0 - } - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - match __rust - { - Event :: ProgramInfoChanged(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 0usize)); - temp.extend(ProgramInfoChanged :: cairo_serialize(val)); temp - }, _ => vec! [] - } - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let __f = __felts [__offset]; let __index = u128 :: - from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match - __index as usize - { - 0usize => - Ok(Event :: - ProgramInfoChanged(ProgramInfoChanged :: - cairo_deserialize(__felts, __offset + 1) ?)), _ => return - Err(cainome :: cairo_serde :: Error :: - Deserialize(format! ("Index not handle for enum {}", "Event"))) - } - } -} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event -{ - type Error = String; fn - try_from(event : starknet :: core :: types :: EmittedEvent) -> Result < - Self, Self :: Error > - { - use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() - { return Err("Event has no key".to_string()); } let selector = - event.keys [0]; if selector == starknet :: core :: utils :: - get_selector_from_name("ProgramInfoChanged").unwrap_or_else(| _ | - panic! ("Invalid selector for {}", "ProgramInfoChanged")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - changed_by = match cainome :: cairo_serde :: ContractAddress :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "changed_by", - "ProgramInfoChanged", e)), - }; data_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& changed_by); let old_program_hash = match - starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "old_program_hash", "ProgramInfoChanged", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& old_program_hash); let new_program_hash = - match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "new_program_hash", "ProgramInfoChanged", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& new_program_hash); let old_config_hash = - match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "old_config_hash", "ProgramInfoChanged", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& old_config_hash); let new_config_hash = - match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "new_config_hash", "ProgramInfoChanged", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& new_config_hash); return - Ok(Event :: - ProgramInfoChanged(ProgramInfoChanged - { - changed_by, old_program_hash, new_program_hash, - old_config_hash, new_config_hash - })) - }; - Err(format! ("Could not match any event from keys {:?}", event.keys)) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub enum Event -{ - OwnershipTransferred(OwnershipTransferred), - OwnershipTransferStarted(OwnershipTransferStarted) -} impl cainome :: cairo_serde :: CairoSerde for Event -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = std :: option :: Option :: None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - match __rust - { - Event :: OwnershipTransferred(val) => OwnershipTransferred :: - cairo_serialized_size(val) + 1, Event :: - OwnershipTransferStarted(val) => OwnershipTransferStarted :: - cairo_serialized_size(val) + 1, _ => 0 - } - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - match __rust - { - Event :: OwnershipTransferred(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 0usize)); - temp.extend(OwnershipTransferred :: cairo_serialize(val)); - temp - }, Event :: OwnershipTransferStarted(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 1usize)); - temp.extend(OwnershipTransferStarted :: cairo_serialize(val)); - temp - }, _ => vec! [] - } - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let __f = __felts [__offset]; let __index = u128 :: - from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match - __index as usize - { - 0usize => - Ok(Event :: - OwnershipTransferred(OwnershipTransferred :: - cairo_deserialize(__felts, __offset + 1) ?)), 1usize => - Ok(Event :: - OwnershipTransferStarted(OwnershipTransferStarted :: - cairo_deserialize(__felts, __offset + 1) ?)), _ => return - Err(cainome :: cairo_serde :: Error :: - Deserialize(format! ("Index not handle for enum {}", "Event"))) - } - } -} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event -{ - type Error = String; fn - try_from(event : starknet :: core :: types :: EmittedEvent) -> Result < - Self, Self :: Error > - { - use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() - { return Err("Event has no key".to_string()); } let selector = - event.keys [0]; if selector == starknet :: core :: utils :: - get_selector_from_name("OwnershipTransferred").unwrap_or_else(| _ | - panic! ("Invalid selector for {}", "OwnershipTransferred")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - previous_owner = match cainome :: cairo_serde :: ContractAddress - :: cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "previous_owner", "OwnershipTransferred", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& previous_owner); let new_owner = match - cainome :: cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "new_owner", - "OwnershipTransferred", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& new_owner); return - Ok(Event :: - OwnershipTransferred(OwnershipTransferred - { previous_owner, new_owner })) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("OwnershipTransferStarted").unwrap_or_else(| _ - | panic! ("Invalid selector for {}", "OwnershipTransferStarted")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - previous_owner = match cainome :: cairo_serde :: ContractAddress - :: cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "previous_owner", "OwnershipTransferStarted", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& previous_owner); let new_owner = match - cainome :: cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "new_owner", - "OwnershipTransferStarted", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& new_owner); return - Ok(Event :: - OwnershipTransferStarted(OwnershipTransferStarted - { previous_owner, new_owner })) - }; - Err(format! ("Could not match any event from keys {:?}", event.keys)) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub enum Event -{ - MessageSent(MessageSent), MessageConsumed(MessageConsumed), - MessageCancellationStarted(MessageCancellationStarted), - MessageCanceled(MessageCanceled), - MessageToStarknetReceived(MessageToStarknetReceived), - MessageToAppchainSealed(MessageToAppchainSealed) -} impl cainome :: cairo_serde :: CairoSerde for Event -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = std :: option :: Option :: None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - match __rust - { - Event :: MessageSent(val) => MessageSent :: - cairo_serialized_size(val) + 1, Event :: MessageConsumed(val) => - MessageConsumed :: cairo_serialized_size(val) + 1, Event :: - MessageCancellationStarted(val) => MessageCancellationStarted :: - cairo_serialized_size(val) + 1, Event :: MessageCanceled(val) => - MessageCanceled :: cairo_serialized_size(val) + 1, Event :: - MessageToStarknetReceived(val) => MessageToStarknetReceived :: - cairo_serialized_size(val) + 1, Event :: - MessageToAppchainSealed(val) => MessageToAppchainSealed :: - cairo_serialized_size(val) + 1, _ => 0 - } - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - match __rust - { - Event :: MessageSent(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 0usize)); - temp.extend(MessageSent :: cairo_serialize(val)); temp - }, Event :: MessageConsumed(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 1usize)); - temp.extend(MessageConsumed :: cairo_serialize(val)); temp - }, Event :: MessageCancellationStarted(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 2usize)); - temp.extend(MessageCancellationStarted :: - cairo_serialize(val)); temp - }, Event :: MessageCanceled(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 3usize)); - temp.extend(MessageCanceled :: cairo_serialize(val)); temp - }, Event :: MessageToStarknetReceived(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 4usize)); - temp.extend(MessageToStarknetReceived :: - cairo_serialize(val)); temp - }, Event :: MessageToAppchainSealed(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 5usize)); - temp.extend(MessageToAppchainSealed :: cairo_serialize(val)); - temp - }, _ => vec! [] - } - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let __f = __felts [__offset]; let __index = u128 :: - from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match - __index as usize - { - 0usize => - Ok(Event :: - MessageSent(MessageSent :: - cairo_deserialize(__felts, __offset + 1) ?)), 1usize => - Ok(Event :: - MessageConsumed(MessageConsumed :: - cairo_deserialize(__felts, __offset + 1) ?)), 2usize => - Ok(Event :: - MessageCancellationStarted(MessageCancellationStarted :: - cairo_deserialize(__felts, __offset + 1) ?)), 3usize => - Ok(Event :: - MessageCanceled(MessageCanceled :: - cairo_deserialize(__felts, __offset + 1) ?)), 4usize => - Ok(Event :: - MessageToStarknetReceived(MessageToStarknetReceived :: - cairo_deserialize(__felts, __offset + 1) ?)), 5usize => - Ok(Event :: - MessageToAppchainSealed(MessageToAppchainSealed :: - cairo_deserialize(__felts, __offset + 1) ?)), _ => return - Err(cainome :: cairo_serde :: Error :: - Deserialize(format! ("Index not handle for enum {}", "Event"))) - } - } -} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event -{ - type Error = String; fn - try_from(event : starknet :: core :: types :: EmittedEvent) -> Result < - Self, Self :: Error > - { - use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() - { return Err("Event has no key".to_string()); } let selector = - event.keys [0]; if selector == starknet :: core :: utils :: - get_selector_from_name("MessageSent").unwrap_or_else(| _ | panic! - ("Invalid selector for {}", "MessageSent")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageSent", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageSent", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageSent", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = match starknet :: core - :: types :: Felt :: cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "selector", - "MessageSent", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let nonce = match starknet :: - core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "nonce", - "MessageSent", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& nonce); let payload = match Vec :: < - starknet :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageSent", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); return - Ok(Event :: - MessageSent(MessageSent - { message_hash, from, to, selector, nonce, payload })) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageConsumed").unwrap_or_else(| _ | panic! - ("Invalid selector for {}", "MessageConsumed")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageConsumed", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageConsumed", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageConsumed", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let payload = match Vec :: < starknet - :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageConsumed", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); return - Ok(Event :: - MessageConsumed(MessageConsumed - { message_hash, from, to, payload })) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageCancellationStarted").unwrap_or_else(| - _ | panic! ("Invalid selector for {}", "MessageCancellationStarted")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageCancellationStarted", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageCancellationStarted", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageCancellationStarted", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = match starknet :: core - :: types :: Felt :: cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "selector", - "MessageCancellationStarted", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let payload = match Vec :: < - starknet :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageCancellationStarted", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); let nonce = match starknet :: - core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "nonce", - "MessageCancellationStarted", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& nonce); return - Ok(Event :: - MessageCancellationStarted(MessageCancellationStarted - { message_hash, from, to, selector, payload, nonce })) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageCanceled").unwrap_or_else(| _ | panic! - ("Invalid selector for {}", "MessageCanceled")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageCanceled", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageCanceled", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageCanceled", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = match starknet :: core - :: types :: Felt :: cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "selector", - "MessageCanceled", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let payload = match Vec :: < - starknet :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageCanceled", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); let nonce = match starknet :: - core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "nonce", - "MessageCanceled", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& nonce); return - Ok(Event :: - MessageCanceled(MessageCanceled - { message_hash, from, to, selector, payload, nonce })) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageToStarknetReceived").unwrap_or_else(| _ - | panic! ("Invalid selector for {}", "MessageToStarknetReceived")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageToStarknetReceived", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageToStarknetReceived", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageToStarknetReceived", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let payload = match Vec :: < starknet - :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageToStarknetReceived", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); return - Ok(Event :: - MessageToStarknetReceived(MessageToStarknetReceived - { message_hash, from, to, payload })) - }; let selector = event.keys [0]; if selector == starknet :: core :: - utils :: - get_selector_from_name("MessageToAppchainSealed").unwrap_or_else(| _ | - panic! ("Invalid selector for {}", "MessageToAppchainSealed")) - { - let mut key_offset = 0 + 1; let mut data_offset = 0; let - message_hash = match starknet :: core :: types :: Felt :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", - "message_hash", "MessageToAppchainSealed", e)), - }; key_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& message_hash); let from = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "from", - "MessageToAppchainSealed", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& from); let to = match cainome :: - cairo_serde :: ContractAddress :: - cairo_deserialize(& event.keys, key_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "to", - "MessageToAppchainSealed", e)), - }; key_offset += cainome :: cairo_serde :: ContractAddress :: - cairo_serialized_size(& to); let selector = match starknet :: core - :: types :: Felt :: cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "selector", - "MessageToAppchainSealed", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& selector); let nonce = match starknet :: - core :: types :: Felt :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "nonce", - "MessageToAppchainSealed", e)), - }; data_offset += starknet :: core :: types :: Felt :: - cairo_serialized_size(& nonce); let payload = match Vec :: < - starknet :: core :: types :: Felt > :: - cairo_deserialize(& event.data, data_offset) - { - Ok(v) => v, Err(e) => return - Err(format! - ("Could not deserialize field {} for {}: {:?}", "payload", - "MessageToAppchainSealed", e)), - }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialized_size(& payload); return - Ok(Event :: - MessageToAppchainSealed(MessageToAppchainSealed - { message_hash, from, to, selector, nonce, payload })) - }; - Err(format! ("Could not match any event from keys {:?}", event.keys)) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub enum Event {} impl cainome -:: cairo_serde :: CairoSerde for Event -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = std :: option :: Option :: None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { match __rust { _ => 0 } } fn - cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: core :: - types :: Felt > { match __rust { _ => vec! [] } } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let __f = __felts [__offset]; let __index = u128 :: - from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match - __index as usize - { - _ => return - Err(cainome :: cairo_serde :: Error :: - Deserialize(format! ("Index not handle for enum {}", "Event"))) - } - } -} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event -{ - type Error = String; fn - try_from(event : starknet :: core :: types :: EmittedEvent) -> Result < - Self, Self :: Error > - { - use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() - { return Err("Event has no key".to_string()); } - Err(format! ("Could not match any event from keys {:?}", event.keys)) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub enum Event {} impl cainome -:: cairo_serde :: CairoSerde for Event -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = std :: option :: Option :: None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { match __rust { _ => 0 } } fn - cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: core :: - types :: Felt > { match __rust { _ => vec! [] } } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let __f = __felts [__offset]; let __index = u128 :: - from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match - __index as usize - { - _ => return - Err(cainome :: cairo_serde :: Error :: - Deserialize(format! ("Index not handle for enum {}", "Event"))) - } - } -} impl TryFrom < starknet :: core :: types :: EmittedEvent > for Event -{ - type Error = String; fn - try_from(event : starknet :: core :: types :: EmittedEvent) -> Result < - Self, Self :: Error > - { - use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() - { return Err("Event has no key".to_string()); } - Err(format! ("Could not match any event from keys {:?}", event.keys)) - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub enum -MessageToAppchainStatus -{ SealedOrNotSent, Pending(starknet :: core :: types :: Felt) } impl cainome -:: cairo_serde :: CairoSerde for MessageToAppchainStatus -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = std :: option :: Option :: None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - match __rust - { - MessageToAppchainStatus :: SealedOrNotSent => 1, - MessageToAppchainStatus :: Pending(val) => starknet :: core :: - types :: Felt :: cairo_serialized_size(val) + 1, _ => 0 - } - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - match __rust - { - MessageToAppchainStatus :: SealedOrNotSent => usize :: - cairo_serialize(& 0usize), MessageToAppchainStatus :: Pending(val) - => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 1usize)); - temp.extend(starknet :: core :: types :: Felt :: - cairo_serialize(val)); temp - }, _ => vec! [] - } - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let __f = __felts [__offset]; let __index = u128 :: - from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match - __index as usize - { - 0usize => Ok(MessageToAppchainStatus :: SealedOrNotSent), 1usize - => - Ok(MessageToAppchainStatus :: - Pending(starknet :: core :: types :: Felt :: - cairo_deserialize(__felts, __offset + 1) ?)), _ => return - Err(cainome :: cairo_serde :: Error :: - Deserialize(format! - ("Index not handle for enum {}", "MessageToAppchainStatus"))) - } - } -} #[derive(Debug, PartialEq, Eq, Clone, Copy,)] pub enum -MessageToStarknetStatus -{ NothingToConsume, ReadyToConsume(starknet :: core :: types :: Felt) } impl -cainome :: cairo_serde :: CairoSerde for MessageToStarknetStatus -{ - type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < - usize > = std :: option :: Option :: None; #[inline] fn - cairo_serialized_size(__rust : & Self :: RustType) -> usize - { - match __rust - { - MessageToStarknetStatus :: NothingToConsume => 1, - MessageToStarknetStatus :: ReadyToConsume(val) => starknet :: core - :: types :: Felt :: cairo_serialized_size(val) + 1, _ => 0 - } - } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: - core :: types :: Felt > - { - match __rust - { - MessageToStarknetStatus :: NothingToConsume => usize :: - cairo_serialize(& 0usize), MessageToStarknetStatus :: - ReadyToConsume(val) => - { - let mut temp = vec! []; - temp.extend(usize :: cairo_serialize(& 1usize)); - temp.extend(starknet :: core :: types :: Felt :: - cairo_serialize(val)); temp - }, _ => vec! [] - } - } fn - cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], - __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > - { - let __f = __felts [__offset]; let __index = u128 :: - from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match - __index as usize - { - 0usize => Ok(MessageToStarknetStatus :: NothingToConsume), 1usize - => - Ok(MessageToStarknetStatus :: - ReadyToConsume(starknet :: core :: types :: Felt :: - cairo_deserialize(__felts, __offset + 1) ?)), _ => return - Err(cainome :: cairo_serde :: Error :: - Deserialize(format! - ("Index not handle for enum {}", "MessageToStarknetStatus"))) - } - } -} impl < A : starknet :: accounts :: ConnectedAccount + Sync > AppChain < A > -{ - #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub fn - appchain_to_sn_messages(& self, message_hash : & starknet :: core :: types - :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider, - MessageToStarknetStatus > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(message_hash)); let __call = starknet :: core :: types - :: FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("appchain_to_sn_messages"), calldata : - __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn get_facts_registry(& self,) -> cainome :: cairo_serde :: call :: FCall - < A :: Provider, cainome :: cairo_serde :: ContractAddress > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; let __call = starknet :: core :: types :: FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("get_facts_registry"), calldata : - __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn get_program_info(& self,) -> cainome :: cairo_serde :: call :: FCall < - A :: Provider, - (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; let __call = starknet :: core :: types :: FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("get_program_info"), calldata : - __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn get_state(& self,) -> cainome :: cairo_serde :: call :: FCall < A :: - Provider, - (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt, - starknet :: core :: types :: Felt) > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; let __call = starknet :: core :: types :: FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("get_state"), calldata : __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - is_operator(& self, address : & cainome :: cairo_serde :: ContractAddress) - -> cainome :: cairo_serde :: call :: FCall < A :: Provider, bool > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(address)); let __call = starknet :: core :: types :: - FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("is_operator"), calldata : __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - sn_to_appchain_messages(& self, message_hash : & starknet :: core :: types - :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider, - MessageToAppchainStatus > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(message_hash)); let __call = starknet :: core :: types - :: FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("sn_to_appchain_messages"), calldata : - __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - cancel_message_getcall(& self, to_address : & cainome :: cairo_serde :: - ContractAddress, selector : & starknet :: core :: types :: Felt, payload : - & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: - core :: types :: Felt) -> starknet :: core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(to_address)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(selector)); - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(payload)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(nonce)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("cancel_message"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - cancel_message(& self, to_address : & cainome :: cairo_serde :: - ContractAddress, selector : & starknet :: core :: types :: Felt, payload : - & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: - core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(to_address)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(selector)); - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(payload)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(nonce)); let __call = starknet :: core :: types :: - Call - { - to : self.address, selector : starknet :: macros :: selector! - ("cancel_message"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - consume_message_from_appchain_getcall(& self, from_address : & cainome :: - cairo_serde :: ContractAddress, payload : & Vec :: < starknet :: core :: - types :: Felt >) -> starknet :: core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(from_address)); - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(payload)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("consume_message_from_appchain"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - consume_message_from_appchain(& self, from_address : & cainome :: - cairo_serde :: ContractAddress, payload : & Vec :: < starknet :: core :: - types :: Felt >) -> starknet :: accounts :: ExecutionV1 < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(from_address)); - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(payload)); let __call = starknet :: core :: types :: - Call - { - to : self.address, selector : starknet :: macros :: selector! - ("consume_message_from_appchain"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - register_operator_getcall(& self, address : & cainome :: cairo_serde :: - ContractAddress) -> starknet :: core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(address)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("register_operator"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - register_operator(& self, address : & cainome :: cairo_serde :: - ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(address)); let __call = starknet :: core :: types :: - Call - { - to : self.address, selector : starknet :: macros :: selector! - ("register_operator"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - send_message_to_appchain_getcall(& self, to_address : & cainome :: - cairo_serde :: ContractAddress, selector : & starknet :: core :: types :: - Felt, payload : & Vec :: < starknet :: core :: types :: Felt >) -> - starknet :: core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(to_address)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(selector)); - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(payload)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("send_message_to_appchain"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - send_message_to_appchain(& self, to_address : & cainome :: cairo_serde :: - ContractAddress, selector : & starknet :: core :: types :: Felt, payload : - & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: accounts :: - ExecutionV1 < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(to_address)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(selector)); - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(payload)); let __call = starknet :: core :: types :: - Call - { - to : self.address, selector : starknet :: macros :: selector! - ("send_message_to_appchain"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - set_facts_registry_getcall(& self, address : & cainome :: cairo_serde :: - ContractAddress) -> starknet :: core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(address)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("set_facts_registry"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - set_facts_registry(& self, address : & cainome :: cairo_serde :: - ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(address)); let __call = starknet :: core :: types :: - Call - { - to : self.address, selector : starknet :: macros :: selector! - ("set_facts_registry"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - set_program_info_getcall(& self, program_hash : & starknet :: core :: - types :: Felt, config_hash : & starknet :: core :: types :: Felt) -> - starknet :: core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(program_hash)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(config_hash)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("set_program_info"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - set_program_info(& self, program_hash : & starknet :: core :: types :: - Felt, config_hash : & starknet :: core :: types :: Felt) -> starknet :: - accounts :: ExecutionV1 < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(program_hash)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(config_hash)); let __call = starknet :: core :: types - :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("set_program_info"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - start_message_cancellation_getcall(& self, to_address : & cainome :: - cairo_serde :: ContractAddress, selector : & starknet :: core :: types :: - Felt, payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & - starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(to_address)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(selector)); - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(payload)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(nonce)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("start_message_cancellation"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - start_message_cancellation(& self, to_address : & cainome :: cairo_serde - :: ContractAddress, selector : & starknet :: core :: types :: Felt, - payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & - starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 - < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(to_address)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(selector)); - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(payload)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(nonce)); let __call = starknet :: core :: types :: - Call - { - to : self.address, selector : starknet :: macros :: selector! - ("start_message_cancellation"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - unregister_operator_getcall(& self, address : & cainome :: cairo_serde :: - ContractAddress) -> starknet :: core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(address)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("unregister_operator"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - unregister_operator(& self, address : & cainome :: cairo_serde :: - ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(address)); let __call = starknet :: core :: types :: - Call - { - to : self.address, selector : starknet :: macros :: selector! - ("unregister_operator"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - update_getcall(& self, program_output : & Vec :: < starknet :: core :: - types :: Felt >) -> starknet :: core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(program_output)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("update"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - update(& self, program_output : & Vec :: < starknet :: core :: types :: - Felt >) -> starknet :: accounts :: ExecutionV1 < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(program_output)); let __call = starknet :: core :: - types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("update"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - update_state_getcall(& self, program_output : & Vec :: < starknet :: core - :: types :: Felt > , onchain_data_hash : & starknet :: core :: types :: - Felt, onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: - core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(program_output)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(onchain_data_hash)); - __calldata.extend(cainome :: cairo_serde :: U256 :: - cairo_serialize(onchain_data_size)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("update_state"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - update_state(& self, program_output : & Vec :: < starknet :: core :: types - :: Felt > , onchain_data_hash : & starknet :: core :: types :: Felt, - onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: - accounts :: ExecutionV1 < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: - cairo_serialize(program_output)); - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(onchain_data_hash)); - __calldata.extend(cainome :: cairo_serde :: U256 :: - cairo_serialize(onchain_data_size)); let __call = starknet :: core :: - types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("update_state"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - upgrade_getcall(& self, new_class_hash : & cainome :: cairo_serde :: - ClassHash) -> starknet :: core :: types :: Call - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ClassHash :: - cairo_serialize(new_class_hash)); starknet :: core :: types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("upgrade"), calldata : __calldata, - } - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn upgrade(& self, new_class_hash : & cainome :: cairo_serde :: ClassHash) - -> starknet :: accounts :: ExecutionV1 < A > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ClassHash :: - cairo_serialize(new_class_hash)); let __call = starknet :: core :: - types :: Call - { - to : self.address, selector : starknet :: macros :: selector! - ("upgrade"), calldata : __calldata, - }; self.account.execute_v1(vec! [__call]) - } -} impl < P : starknet :: providers :: Provider + Sync > AppChainReader < P > -{ - #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub fn - appchain_to_sn_messages(& self, message_hash : & starknet :: core :: types - :: Felt) -> cainome :: cairo_serde :: call :: FCall < P, - MessageToStarknetStatus > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(message_hash)); let __call = starknet :: core :: types - :: FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("appchain_to_sn_messages"), calldata : - __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn get_facts_registry(& self,) -> cainome :: cairo_serde :: call :: FCall - < P, cainome :: cairo_serde :: ContractAddress > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; let __call = starknet :: core :: types :: FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("get_facts_registry"), calldata : - __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn get_program_info(& self,) -> cainome :: cairo_serde :: call :: FCall < - P, (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) - > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; let __call = starknet :: core :: types :: FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("get_program_info"), calldata : - __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn get_state(& self,) -> cainome :: cairo_serde :: call :: FCall < P, - (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt, - starknet :: core :: types :: Felt) > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; let __call = starknet :: core :: types :: FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("get_state"), calldata : __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - is_operator(& self, address : & cainome :: cairo_serde :: ContractAddress) - -> cainome :: cairo_serde :: call :: FCall < P, bool > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(cainome :: cairo_serde :: ContractAddress :: - cairo_serialize(address)); let __call = starknet :: core :: types :: - FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("is_operator"), calldata : __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub - fn - sn_to_appchain_messages(& self, message_hash : & starknet :: core :: types - :: Felt) -> cainome :: cairo_serde :: call :: FCall < P, - MessageToAppchainStatus > - { - use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! - []; - __calldata.extend(starknet :: core :: types :: Felt :: - cairo_serialize(message_hash)); let __call = starknet :: core :: types - :: FunctionCall - { - contract_address : self.address, entry_point_selector : starknet - :: macros :: selector! ("sn_to_appchain_messages"), calldata : - __calldata, - }; cainome :: cairo_serde :: call :: FCall :: - new(__call, self.provider(),) - } -} \ No newline at end of file diff --git a/bindings/src/lib.rs b/bindings/src/lib.rs index 89070d6..ff8d401 100644 --- a/bindings/src/lib.rs +++ b/bindings/src/lib.rs @@ -1,8 +1,3885 @@ -use cainome::rs::abigen; - -abigen!( - AppChain, - "../target/dev/piltover_appchain.contract_class.json", - output_path("src/bindings.rs"), - derives(Debug, PartialEq, Eq, Clone, Copy) -); +#[derive()] pub struct Appchain < A : starknet :: accounts :: ConnectedAccount ++ Sync > +{ + pub address : starknet :: core :: types :: Felt, pub account : A, pub + block_id : starknet :: core :: types :: BlockId, +} impl < A : starknet :: accounts :: ConnectedAccount + Sync > Appchain < A > +{ + pub fn new(address : starknet :: core :: types :: Felt, account : A) -> + Self + { + Self + { + address, account, block_id : starknet :: core :: types :: BlockId + :: Tag(starknet :: core :: types :: BlockTag :: Pending) + } + } pub fn + set_contract_address(& mut self, address : starknet :: core :: types :: + Felt) { self.address = address; } pub fn provider(& self) -> & A :: + Provider { self.account.provider() } pub fn + set_block(& mut self, block_id : starknet :: core :: types :: BlockId) + { self.block_id = block_id; } pub fn + with_block(self, block_id : starknet :: core :: types :: BlockId) -> Self + { Self { block_id, .. self } } +} #[derive()] pub struct AppchainReader < P : starknet :: providers :: +Provider + Sync > +{ + pub address : starknet :: core :: types :: Felt, pub provider : P, pub + block_id : starknet :: core :: types :: BlockId, +} impl < P : starknet :: providers :: Provider + Sync > AppchainReader < P > +{ + pub fn new(address : starknet :: core :: types :: Felt, provider : P,) -> + Self + { + Self + { + address, provider, block_id : starknet :: core :: types :: BlockId + :: Tag(starknet :: core :: types :: BlockTag :: Pending) + } + } pub fn + set_contract_address(& mut self, address : starknet :: core :: types :: + Felt) { self.address = address; } pub fn provider(& self) -> & P + { & self.provider } pub fn + set_block(& mut self, block_id : starknet :: core :: types :: BlockId) + { self.block_id = block_id; } pub fn + with_block(self, block_id : starknet :: core :: types :: BlockId) -> Self + { Self { block_id, .. self } } +} #[derive()] pub struct LogStateTransitionFact +{ pub state_transition_fact : cainome :: cairo_serde :: U256 } impl cainome :: +cairo_serde :: CairoSerde for LogStateTransitionFact +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: U256 :: + cairo_serialized_size(& __rust.state_transition_fact); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: U256 :: + cairo_serialize(& __rust.state_transition_fact)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let state_transition_fact = cainome :: + cairo_serde :: U256 :: cairo_deserialize(__felts, __offset) ? ; + __offset += cainome :: cairo_serde :: U256 :: + cairo_serialized_size(& state_transition_fact); + Ok(LogStateTransitionFact { state_transition_fact }) + } +} impl LogStateTransitionFact +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("LogStateTransitionFact").unwrap() + } pub fn event_name() -> & 'static str { "LogStateTransitionFact" } +} #[derive()] pub struct LogStateUpdate +{ + pub state_root : starknet :: core :: types :: Felt, pub block_number : + starknet :: core :: types :: Felt, pub block_hash : starknet :: core :: + types :: Felt +} impl cainome :: cairo_serde :: CairoSerde for LogStateUpdate +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.state_root); __size += starknet :: core + :: types :: Felt :: cairo_serialized_size(& __rust.block_number); + __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.block_hash); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.state_root)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.block_number)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.block_hash)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let state_root = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& state_root); let block_number = starknet :: + core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; + __offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_number); let block_hash = starknet :: + core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; + __offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_hash); + Ok(LogStateUpdate { state_root, block_number, block_hash }) + } +} impl LogStateUpdate +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("LogStateUpdate").unwrap() + } pub fn event_name() -> & 'static str { "LogStateUpdate" } +} #[derive()] pub struct MessageCanceled +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub selector : starknet :: core :: types :: Felt, pub + payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet + :: core :: types :: Felt +} impl cainome :: cairo_serde :: CairoSerde for MessageCanceled +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.selector); __size += Vec :: < starknet + :: core :: types :: Felt > :: cairo_serialized_size(& __rust.payload); + __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.nonce); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.selector)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.nonce)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = starknet :: core :: types + :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = Vec :: < starknet :: + core :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; + __offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); + Ok(MessageCanceled + { message_hash, from, to, selector, payload, nonce }) + } +} impl MessageCanceled +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageCanceled").unwrap() + } pub fn event_name() -> & 'static str { "MessageCanceled" } +} #[derive()] pub struct MessageCancellationStarted +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub selector : starknet :: core :: types :: Felt, pub + payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet + :: core :: types :: Felt +} impl cainome :: cairo_serde :: CairoSerde for MessageCancellationStarted +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.selector); __size += Vec :: < starknet + :: core :: types :: Felt > :: cairo_serialized_size(& __rust.payload); + __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.nonce); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.selector)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.nonce)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = starknet :: core :: types + :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = Vec :: < starknet :: + core :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; + __offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); + Ok(MessageCancellationStarted + { message_hash, from, to, selector, payload, nonce }) + } +} impl MessageCancellationStarted +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageCancellationStarted").unwrap() + } pub fn event_name() -> & 'static str { "MessageCancellationStarted" } +} #[derive()] pub struct MessageConsumed +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub payload : Vec < starknet :: core :: types :: Felt > +} impl cainome :: cairo_serde :: CairoSerde for MessageConsumed +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& __rust.payload); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = Vec :: < starknet :: core + :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; + __offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); + Ok(MessageConsumed { message_hash, from, to, payload }) + } +} impl MessageConsumed +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageConsumed").unwrap() + } pub fn event_name() -> & 'static str { "MessageConsumed" } +} #[derive()] pub struct MessageSent +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub selector : starknet :: core :: types :: Felt, pub + nonce : starknet :: core :: types :: Felt, pub payload : Vec < starknet :: + core :: types :: Felt > +} impl cainome :: cairo_serde :: CairoSerde for MessageSent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.selector); __size += starknet :: core + :: types :: Felt :: cairo_serialized_size(& __rust.nonce); __size += + Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& __rust.payload); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.selector)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.nonce)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = starknet :: core :: types + :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); + let payload = Vec :: < starknet :: core :: types :: Felt > :: + cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < starknet + :: core :: types :: Felt > :: cairo_serialized_size(& payload); + Ok(MessageSent { message_hash, from, to, selector, nonce, payload }) + } +} impl MessageSent +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageSent").unwrap() + } pub fn event_name() -> & 'static str { "MessageSent" } +} #[derive()] pub struct MessageToAppchainSealed +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub selector : starknet :: core :: types :: Felt, pub + nonce : starknet :: core :: types :: Felt, pub payload : Vec < starknet :: + core :: types :: Felt > +} impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainSealed +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.selector); __size += starknet :: core + :: types :: Felt :: cairo_serialized_size(& __rust.nonce); __size += + Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& __rust.payload); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.selector)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.nonce)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = starknet :: core :: types + :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); + let payload = Vec :: < starknet :: core :: types :: Felt > :: + cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < starknet + :: core :: types :: Felt > :: cairo_serialized_size(& payload); + Ok(MessageToAppchainSealed + { message_hash, from, to, selector, nonce, payload }) + } +} impl MessageToAppchainSealed +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageToAppchainSealed").unwrap() + } pub fn event_name() -> & 'static str { "MessageToAppchainSealed" } +} #[derive()] pub struct MessageToStarknetReceived +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub payload : Vec < starknet :: core :: types :: Felt > +} impl cainome :: cairo_serde :: CairoSerde for MessageToStarknetReceived +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& __rust.payload); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = Vec :: < starknet :: core + :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; + __offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); + Ok(MessageToStarknetReceived { message_hash, from, to, payload }) + } +} impl MessageToStarknetReceived +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageToStarknetReceived").unwrap() + } pub fn event_name() -> & 'static str { "MessageToStarknetReceived" } +} #[derive()] pub struct OwnershipTransferStarted +{ + pub previous_owner : cainome :: cairo_serde :: ContractAddress, pub + new_owner : cainome :: cairo_serde :: ContractAddress +} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferStarted +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: + ContractAddress :: cairo_serialized_size(& __rust.previous_owner); + __size += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.new_owner); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.previous_owner)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.new_owner)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let previous_owner = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); + Ok(OwnershipTransferStarted { previous_owner, new_owner }) + } +} impl OwnershipTransferStarted +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferStarted").unwrap() + } pub fn event_name() -> & 'static str { "OwnershipTransferStarted" } +} #[derive()] pub struct OwnershipTransferred +{ + pub previous_owner : cainome :: cairo_serde :: ContractAddress, pub + new_owner : cainome :: cairo_serde :: ContractAddress +} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferred +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: + ContractAddress :: cairo_serialized_size(& __rust.previous_owner); + __size += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.new_owner); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.previous_owner)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.new_owner)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let previous_owner = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); + Ok(OwnershipTransferred { previous_owner, new_owner }) + } +} impl OwnershipTransferred +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferred").unwrap() + } pub fn event_name() -> & 'static str { "OwnershipTransferred" } +} #[derive()] pub struct ProgramInfoChanged +{ + pub changed_by : cainome :: cairo_serde :: ContractAddress, pub + old_program_hash : starknet :: core :: types :: Felt, pub new_program_hash + : starknet :: core :: types :: Felt, pub old_config_hash : starknet :: + core :: types :: Felt, pub new_config_hash : starknet :: core :: types :: + Felt +} impl cainome :: cairo_serde :: CairoSerde for ProgramInfoChanged +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: + ContractAddress :: cairo_serialized_size(& __rust.changed_by); __size + += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.old_program_hash); __size += starknet + :: core :: types :: Felt :: + cairo_serialized_size(& __rust.new_program_hash); __size += starknet + :: core :: types :: Felt :: + cairo_serialized_size(& __rust.old_config_hash); __size += starknet :: + core :: types :: Felt :: + cairo_serialized_size(& __rust.new_config_hash); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.changed_by)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.old_program_hash)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.new_program_hash)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.old_config_hash)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.new_config_hash)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let changed_by = cainome :: cairo_serde + :: ContractAddress :: cairo_deserialize(__felts, __offset) ? ; + __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& changed_by); let old_program_hash = starknet + :: core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; + __offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_program_hash); let new_program_hash = + starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& new_program_hash); let + old_config_hash = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& old_config_hash); let + new_config_hash = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& new_config_hash); + Ok(ProgramInfoChanged + { + changed_by, old_program_hash, new_program_hash, old_config_hash, + new_config_hash + }) + } +} impl ProgramInfoChanged +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("ProgramInfoChanged").unwrap() + } pub fn event_name() -> & 'static str { "ProgramInfoChanged" } +} #[derive()] pub struct Upgraded +{ pub class_hash : cainome :: cairo_serde :: ClassHash } impl cainome :: +cairo_serde :: CairoSerde for Upgraded +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& __rust.class_hash); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: ClassHash :: + cairo_serialize(& __rust.class_hash)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let class_hash = cainome :: cairo_serde + :: ClassHash :: cairo_deserialize(__felts, __offset) ? ; __offset += + cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& class_hash); Ok(Upgraded { class_hash }) + } +} impl Upgraded +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("Upgraded").unwrap() + } pub fn event_name() -> & 'static str { "Upgraded" } +} #[derive()] pub enum AppchainEvent +{ + OwnableEvent(OwnableEvent), UpgradeableEvent(UpgradeableEvent), + ConfigEvent(ConfigEvent), MessagingEvent(MessagingEvent), + ReentrancyGuardEvent(ReentrancyguardEvent), StateEvent(StateEvent), + LogStateUpdate(LogStateUpdate), + LogStateTransitionFact(LogStateTransitionFact) +} impl cainome :: cairo_serde :: CairoSerde for AppchainEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + AppchainEvent :: OwnableEvent(val) => OwnableEvent :: + cairo_serialized_size(val) + 1, AppchainEvent :: + UpgradeableEvent(val) => UpgradeableEvent :: + cairo_serialized_size(val) + 1, AppchainEvent :: ConfigEvent(val) + => ConfigEvent :: cairo_serialized_size(val) + 1, AppchainEvent :: + MessagingEvent(val) => MessagingEvent :: + cairo_serialized_size(val) + 1, AppchainEvent :: + ReentrancyGuardEvent(val) => ReentrancyguardEvent :: + cairo_serialized_size(val) + 1, AppchainEvent :: StateEvent(val) + => StateEvent :: cairo_serialized_size(val) + 1, AppchainEvent :: + LogStateUpdate(val) => LogStateUpdate :: + cairo_serialized_size(val) + 1, AppchainEvent :: + LogStateTransitionFact(val) => LogStateTransitionFact :: + cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + AppchainEvent :: OwnableEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 0usize)); + temp.extend(OwnableEvent :: cairo_serialize(val)); temp + }, AppchainEvent :: UpgradeableEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 1usize)); + temp.extend(UpgradeableEvent :: cairo_serialize(val)); temp + }, AppchainEvent :: ConfigEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 2usize)); + temp.extend(ConfigEvent :: cairo_serialize(val)); temp + }, AppchainEvent :: MessagingEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 3usize)); + temp.extend(MessagingEvent :: cairo_serialize(val)); temp + }, AppchainEvent :: ReentrancyGuardEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 4usize)); + temp.extend(ReentrancyguardEvent :: cairo_serialize(val)); + temp + }, AppchainEvent :: StateEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 5usize)); + temp.extend(StateEvent :: cairo_serialize(val)); temp + }, AppchainEvent :: LogStateUpdate(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 6usize)); + temp.extend(LogStateUpdate :: cairo_serialize(val)); temp + }, AppchainEvent :: LogStateTransitionFact(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 7usize)); + temp.extend(LogStateTransitionFact :: cairo_serialize(val)); + temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => + Ok(AppchainEvent :: + OwnableEvent(OwnableEvent :: + cairo_deserialize(__felts, __offset + 1) ?)), 1usize => + Ok(AppchainEvent :: + UpgradeableEvent(UpgradeableEvent :: + cairo_deserialize(__felts, __offset + 1) ?)), 2usize => + Ok(AppchainEvent :: + ConfigEvent(ConfigEvent :: + cairo_deserialize(__felts, __offset + 1) ?)), 3usize => + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + cairo_deserialize(__felts, __offset + 1) ?)), 4usize => + Ok(AppchainEvent :: + ReentrancyGuardEvent(ReentrancyguardEvent :: + cairo_deserialize(__felts, __offset + 1) ?)), 5usize => + Ok(AppchainEvent :: + StateEvent(StateEvent :: cairo_deserialize(__felts, __offset + 1) + ?)), 6usize => + Ok(AppchainEvent :: + LogStateUpdate(LogStateUpdate :: + cairo_deserialize(__felts, __offset + 1) ?)), 7usize => + Ok(AppchainEvent :: + LogStateTransitionFact(LogStateTransitionFact :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "AppchainEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for +AppchainEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferred").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "OwnershipTransferred")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(AppchainEvent :: + OwnableEvent(OwnableEvent :: + OwnershipTransferred(OwnershipTransferred + { previous_owner, new_owner }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("OwnershipTransferStarted").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "OwnershipTransferStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(AppchainEvent :: + OwnableEvent(OwnableEvent :: + OwnershipTransferStarted(OwnershipTransferStarted + { previous_owner, new_owner }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("Upgraded").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "Upgraded")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + class_hash = match cainome :: cairo_serde :: ClassHash :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "class_hash", + "Upgraded", e)), + }; data_offset += cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& class_hash); return + Ok(AppchainEvent :: + UpgradeableEvent(UpgradeableEvent :: + Upgraded(Upgraded { class_hash }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("ProgramInfoChanged").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "ProgramInfoChanged")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + changed_by = match cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "changed_by", + "ProgramInfoChanged", e)), + }; data_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& changed_by); let old_program_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_program_hash); let new_program_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_program_hash); let old_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_config_hash); let new_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_config_hash); return + Ok(AppchainEvent :: + ConfigEvent(ConfigEvent :: + ProgramInfoChanged(ProgramInfoChanged + { + changed_by, old_program_hash, new_program_hash, + old_config_hash, new_config_hash + }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageSent").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageSent")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageSent", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageSent", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageSent(MessageSent + { message_hash, from, to, selector, nonce, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageConsumed").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageConsumed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageConsumed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageConsumed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageConsumed(MessageConsumed + { message_hash, from, to, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCancellationStarted").unwrap_or_else(| + _ | panic! ("Invalid selector for {}", "MessageCancellationStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCancellationStarted", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCancellationStarted", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageCancellationStarted(MessageCancellationStarted + { message_hash, from, to, selector, payload, nonce }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCanceled").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageCanceled")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCanceled", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCanceled", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageCanceled(MessageCanceled + { message_hash, from, to, selector, payload, nonce }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToStarknetReceived").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "MessageToStarknetReceived")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToStarknetReceived", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToStarknetReceived", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageToStarknetReceived(MessageToStarknetReceived + { message_hash, from, to, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToAppchainSealed").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "MessageToAppchainSealed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToAppchainSealed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToAppchainSealed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageToAppchainSealed(MessageToAppchainSealed + { message_hash, from, to, selector, nonce, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("LogStateUpdate").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "LogStateUpdate")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + state_root = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "state_root", + "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& state_root); let block_number = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "block_number", "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_number); let block_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "block_hash", + "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_hash); return + Ok(AppchainEvent :: + LogStateUpdate(LogStateUpdate + { state_root, block_number, block_hash })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("LogStateTransitionFact").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "LogStateTransitionFact")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + state_transition_fact = match cainome :: cairo_serde :: U256 :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "state_transition_fact", "LogStateTransitionFact", e)), + }; data_offset += cainome :: cairo_serde :: U256 :: + cairo_serialized_size(& state_transition_fact); return + Ok(AppchainEvent :: + LogStateTransitionFact(LogStateTransitionFact + { state_transition_fact })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for AppchainEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferred").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "OwnershipTransferred")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(AppchainEvent :: + OwnableEvent(OwnableEvent :: + OwnershipTransferred(OwnershipTransferred + { previous_owner, new_owner }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("OwnershipTransferStarted").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "OwnershipTransferStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(AppchainEvent :: + OwnableEvent(OwnableEvent :: + OwnershipTransferStarted(OwnershipTransferStarted + { previous_owner, new_owner }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("Upgraded").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "Upgraded")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + class_hash = match cainome :: cairo_serde :: ClassHash :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "class_hash", + "Upgraded", e)), + }; data_offset += cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& class_hash); return + Ok(AppchainEvent :: + UpgradeableEvent(UpgradeableEvent :: + Upgraded(Upgraded { class_hash }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("ProgramInfoChanged").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "ProgramInfoChanged")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + changed_by = match cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "changed_by", + "ProgramInfoChanged", e)), + }; data_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& changed_by); let old_program_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_program_hash); let new_program_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_program_hash); let old_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_config_hash); let new_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_config_hash); return + Ok(AppchainEvent :: + ConfigEvent(ConfigEvent :: + ProgramInfoChanged(ProgramInfoChanged + { + changed_by, old_program_hash, new_program_hash, + old_config_hash, new_config_hash + }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageSent").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageSent")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageSent", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageSent", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageSent(MessageSent + { message_hash, from, to, selector, nonce, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageConsumed").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageConsumed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageConsumed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageConsumed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageConsumed(MessageConsumed + { message_hash, from, to, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCancellationStarted").unwrap_or_else(| + _ | panic! ("Invalid selector for {}", "MessageCancellationStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCancellationStarted", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCancellationStarted", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageCancellationStarted(MessageCancellationStarted + { message_hash, from, to, selector, payload, nonce }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCanceled").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageCanceled")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCanceled", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCanceled", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageCanceled(MessageCanceled + { message_hash, from, to, selector, payload, nonce }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToStarknetReceived").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "MessageToStarknetReceived")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToStarknetReceived", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToStarknetReceived", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageToStarknetReceived(MessageToStarknetReceived + { message_hash, from, to, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToAppchainSealed").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "MessageToAppchainSealed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToAppchainSealed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToAppchainSealed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageToAppchainSealed(MessageToAppchainSealed + { message_hash, from, to, selector, nonce, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("LogStateUpdate").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "LogStateUpdate")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + state_root = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "state_root", + "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& state_root); let block_number = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "block_number", "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_number); let block_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "block_hash", + "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_hash); return + Ok(AppchainEvent :: + LogStateUpdate(LogStateUpdate + { state_root, block_number, block_hash })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("LogStateTransitionFact").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "LogStateTransitionFact")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + state_transition_fact = match cainome :: cairo_serde :: U256 :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "state_transition_fact", "LogStateTransitionFact", e)), + }; data_offset += cainome :: cairo_serde :: U256 :: + cairo_serialized_size(& state_transition_fact); return + Ok(AppchainEvent :: + LogStateTransitionFact(LogStateTransitionFact + { state_transition_fact })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum ConfigEvent { ProgramInfoChanged(ProgramInfoChanged) } +impl cainome :: cairo_serde :: CairoSerde for ConfigEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + ConfigEvent :: ProgramInfoChanged(val) => ProgramInfoChanged :: + cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + ConfigEvent :: ProgramInfoChanged(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 0usize)); + temp.extend(ProgramInfoChanged :: cairo_serialize(val)); temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => + Ok(ConfigEvent :: + ProgramInfoChanged(ProgramInfoChanged :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "ConfigEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for ConfigEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("ProgramInfoChanged").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "ProgramInfoChanged")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + changed_by = match cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "changed_by", + "ProgramInfoChanged", e)), + }; data_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& changed_by); let old_program_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_program_hash); let new_program_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_program_hash); let old_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_config_hash); let new_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_config_hash); return + Ok(ConfigEvent :: + ProgramInfoChanged(ProgramInfoChanged + { + changed_by, old_program_hash, new_program_hash, + old_config_hash, new_config_hash + })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for ConfigEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("ProgramInfoChanged").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "ProgramInfoChanged")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + changed_by = match cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "changed_by", + "ProgramInfoChanged", e)), + }; data_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& changed_by); let old_program_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_program_hash); let new_program_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_program_hash); let old_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_config_hash); let new_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_config_hash); return + Ok(ConfigEvent :: + ProgramInfoChanged(ProgramInfoChanged + { + changed_by, old_program_hash, new_program_hash, + old_config_hash, new_config_hash + })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum MessageToAppchainStatus +{ NotSent, Sealed, Cancelled, Pending(starknet :: core :: types :: Felt) } +impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainStatus +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + MessageToAppchainStatus :: NotSent => 1, MessageToAppchainStatus + :: Sealed => 1, MessageToAppchainStatus :: Cancelled => 1, + MessageToAppchainStatus :: Pending(val) => starknet :: core :: + types :: Felt :: cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + MessageToAppchainStatus :: NotSent => usize :: + cairo_serialize(& 0usize), MessageToAppchainStatus :: Sealed => + usize :: cairo_serialize(& 1usize), MessageToAppchainStatus :: + Cancelled => usize :: cairo_serialize(& 2usize), + MessageToAppchainStatus :: Pending(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 3usize)); + temp.extend(starknet :: core :: types :: Felt :: + cairo_serialize(val)); temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => Ok(MessageToAppchainStatus :: NotSent), 1usize => + Ok(MessageToAppchainStatus :: Sealed), 2usize => + Ok(MessageToAppchainStatus :: Cancelled), 3usize => + Ok(MessageToAppchainStatus :: + Pending(starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "MessageToAppchainStatus"))) + } + } +} #[derive()] pub enum MessageToStarknetStatus +{ NothingToConsume, ReadyToConsume(starknet :: core :: types :: Felt) } impl +cainome :: cairo_serde :: CairoSerde for MessageToStarknetStatus +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + MessageToStarknetStatus :: NothingToConsume => 1, + MessageToStarknetStatus :: ReadyToConsume(val) => starknet :: core + :: types :: Felt :: cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + MessageToStarknetStatus :: NothingToConsume => usize :: + cairo_serialize(& 0usize), MessageToStarknetStatus :: + ReadyToConsume(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 1usize)); + temp.extend(starknet :: core :: types :: Felt :: + cairo_serialize(val)); temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => Ok(MessageToStarknetStatus :: NothingToConsume), 1usize + => + Ok(MessageToStarknetStatus :: + ReadyToConsume(starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "MessageToStarknetStatus"))) + } + } +} #[derive()] pub enum MessagingEvent +{ + MessageSent(MessageSent), MessageConsumed(MessageConsumed), + MessageCancellationStarted(MessageCancellationStarted), + MessageCanceled(MessageCanceled), + MessageToStarknetReceived(MessageToStarknetReceived), + MessageToAppchainSealed(MessageToAppchainSealed) +} impl cainome :: cairo_serde :: CairoSerde for MessagingEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + MessagingEvent :: MessageSent(val) => MessageSent :: + cairo_serialized_size(val) + 1, MessagingEvent :: + MessageConsumed(val) => MessageConsumed :: + cairo_serialized_size(val) + 1, MessagingEvent :: + MessageCancellationStarted(val) => MessageCancellationStarted :: + cairo_serialized_size(val) + 1, MessagingEvent :: + MessageCanceled(val) => MessageCanceled :: + cairo_serialized_size(val) + 1, MessagingEvent :: + MessageToStarknetReceived(val) => MessageToStarknetReceived :: + cairo_serialized_size(val) + 1, MessagingEvent :: + MessageToAppchainSealed(val) => MessageToAppchainSealed :: + cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + MessagingEvent :: MessageSent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 0usize)); + temp.extend(MessageSent :: cairo_serialize(val)); temp + }, MessagingEvent :: MessageConsumed(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 1usize)); + temp.extend(MessageConsumed :: cairo_serialize(val)); temp + }, MessagingEvent :: MessageCancellationStarted(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 2usize)); + temp.extend(MessageCancellationStarted :: + cairo_serialize(val)); temp + }, MessagingEvent :: MessageCanceled(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 3usize)); + temp.extend(MessageCanceled :: cairo_serialize(val)); temp + }, MessagingEvent :: MessageToStarknetReceived(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 4usize)); + temp.extend(MessageToStarknetReceived :: + cairo_serialize(val)); temp + }, MessagingEvent :: MessageToAppchainSealed(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 5usize)); + temp.extend(MessageToAppchainSealed :: cairo_serialize(val)); + temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => + Ok(MessagingEvent :: + MessageSent(MessageSent :: + cairo_deserialize(__felts, __offset + 1) ?)), 1usize => + Ok(MessagingEvent :: + MessageConsumed(MessageConsumed :: + cairo_deserialize(__felts, __offset + 1) ?)), 2usize => + Ok(MessagingEvent :: + MessageCancellationStarted(MessageCancellationStarted :: + cairo_deserialize(__felts, __offset + 1) ?)), 3usize => + Ok(MessagingEvent :: + MessageCanceled(MessageCanceled :: + cairo_deserialize(__felts, __offset + 1) ?)), 4usize => + Ok(MessagingEvent :: + MessageToStarknetReceived(MessageToStarknetReceived :: + cairo_deserialize(__felts, __offset + 1) ?)), 5usize => + Ok(MessagingEvent :: + MessageToAppchainSealed(MessageToAppchainSealed :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "MessagingEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for +MessagingEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("MessageSent").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageSent")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageSent", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageSent", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageSent(MessageSent + { message_hash, from, to, selector, nonce, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageConsumed").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageConsumed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageConsumed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageConsumed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageConsumed(MessageConsumed + { message_hash, from, to, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCancellationStarted").unwrap_or_else(| + _ | panic! ("Invalid selector for {}", "MessageCancellationStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCancellationStarted", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCancellationStarted", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(MessagingEvent :: + MessageCancellationStarted(MessageCancellationStarted + { message_hash, from, to, selector, payload, nonce })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCanceled").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageCanceled")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCanceled", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCanceled", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(MessagingEvent :: + MessageCanceled(MessageCanceled + { message_hash, from, to, selector, payload, nonce })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToStarknetReceived").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "MessageToStarknetReceived")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToStarknetReceived", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToStarknetReceived", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageToStarknetReceived(MessageToStarknetReceived + { message_hash, from, to, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToAppchainSealed").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "MessageToAppchainSealed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToAppchainSealed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToAppchainSealed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageToAppchainSealed(MessageToAppchainSealed + { message_hash, from, to, selector, nonce, payload })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for MessagingEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("MessageSent").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageSent")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageSent", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageSent", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageSent(MessageSent + { message_hash, from, to, selector, nonce, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageConsumed").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageConsumed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageConsumed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageConsumed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageConsumed(MessageConsumed + { message_hash, from, to, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCancellationStarted").unwrap_or_else(| + _ | panic! ("Invalid selector for {}", "MessageCancellationStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCancellationStarted", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCancellationStarted", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(MessagingEvent :: + MessageCancellationStarted(MessageCancellationStarted + { message_hash, from, to, selector, payload, nonce })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCanceled").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageCanceled")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCanceled", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCanceled", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(MessagingEvent :: + MessageCanceled(MessageCanceled + { message_hash, from, to, selector, payload, nonce })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToStarknetReceived").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "MessageToStarknetReceived")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToStarknetReceived", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToStarknetReceived", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageToStarknetReceived(MessageToStarknetReceived + { message_hash, from, to, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToAppchainSealed").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "MessageToAppchainSealed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToAppchainSealed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToAppchainSealed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageToAppchainSealed(MessageToAppchainSealed + { message_hash, from, to, selector, nonce, payload })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum OwnableEvent +{ + OwnershipTransferred(OwnershipTransferred), + OwnershipTransferStarted(OwnershipTransferStarted) +} impl cainome :: cairo_serde :: CairoSerde for OwnableEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + OwnableEvent :: OwnershipTransferred(val) => OwnershipTransferred + :: cairo_serialized_size(val) + 1, OwnableEvent :: + OwnershipTransferStarted(val) => OwnershipTransferStarted :: + cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + OwnableEvent :: OwnershipTransferred(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 0usize)); + temp.extend(OwnershipTransferred :: cairo_serialize(val)); + temp + }, OwnableEvent :: OwnershipTransferStarted(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 1usize)); + temp.extend(OwnershipTransferStarted :: cairo_serialize(val)); + temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => + Ok(OwnableEvent :: + OwnershipTransferred(OwnershipTransferred :: + cairo_deserialize(__felts, __offset + 1) ?)), 1usize => + Ok(OwnableEvent :: + OwnershipTransferStarted(OwnershipTransferStarted :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "OwnableEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for +OwnableEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferred").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "OwnershipTransferred")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(OwnableEvent :: + OwnershipTransferred(OwnershipTransferred + { previous_owner, new_owner })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("OwnershipTransferStarted").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "OwnershipTransferStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(OwnableEvent :: + OwnershipTransferStarted(OwnershipTransferStarted + { previous_owner, new_owner })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for OwnableEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferred").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "OwnershipTransferred")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(OwnableEvent :: + OwnershipTransferred(OwnershipTransferred + { previous_owner, new_owner })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("OwnershipTransferStarted").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "OwnershipTransferStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(OwnableEvent :: + OwnershipTransferStarted(OwnershipTransferStarted + { previous_owner, new_owner })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum ReentrancyguardEvent {} impl cainome :: cairo_serde :: +CairoSerde for ReentrancyguardEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { match __rust { _ => 0 } } fn + cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: core :: + types :: Felt > { match __rust { _ => vec! [] } } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "ReentrancyguardEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for +ReentrancyguardEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for +ReentrancyguardEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum StateEvent {} impl cainome :: cairo_serde :: CairoSerde +for StateEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { match __rust { _ => 0 } } fn + cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: core :: + types :: Felt > { match __rust { _ => vec! [] } } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "StateEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for StateEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for StateEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum UpgradeableEvent { Upgraded(Upgraded) } impl cainome :: +cairo_serde :: CairoSerde for UpgradeableEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + UpgradeableEvent :: Upgraded(val) => Upgraded :: + cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + UpgradeableEvent :: Upgraded(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 0usize)); + temp.extend(Upgraded :: cairo_serialize(val)); temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => + Ok(UpgradeableEvent :: + Upgraded(Upgraded :: cairo_deserialize(__felts, __offset + 1) ?)), + _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "UpgradeableEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for +UpgradeableEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("Upgraded").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "Upgraded")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + class_hash = match cainome :: cairo_serde :: ClassHash :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "class_hash", + "Upgraded", e)), + }; data_offset += cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& class_hash); return + Ok(UpgradeableEvent :: Upgraded(Upgraded { class_hash })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for UpgradeableEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("Upgraded").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "Upgraded")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + class_hash = match cainome :: cairo_serde :: ClassHash :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "class_hash", + "Upgraded", e)), + }; data_offset += cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& class_hash); return + Ok(UpgradeableEvent :: Upgraded(Upgraded { class_hash })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl < A : starknet :: accounts :: ConnectedAccount + Sync > Appchain < A > +{ + #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub fn + appchain_to_sn_messages(& self, message_hash : & starknet :: core :: types + :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider, + MessageToStarknetStatus > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(message_hash)); let __call = starknet :: core :: types + :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("appchain_to_sn_messages"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_facts_registry(& self,) -> cainome :: cairo_serde :: call :: FCall + < A :: Provider, cainome :: cairo_serde :: ContractAddress > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_facts_registry"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_program_info(& self,) -> cainome :: cairo_serde :: call :: FCall < + A :: Provider, + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_program_info"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_state(& self,) -> cainome :: cairo_serde :: call :: FCall < A :: + Provider, + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt, + starknet :: core :: types :: Felt) > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_state"), calldata : __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + is_operator(& self, address : & cainome :: cairo_serde :: ContractAddress) + -> cainome :: cairo_serde :: call :: FCall < A :: Provider, bool > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); let __call = starknet :: core :: types :: + FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("is_operator"), calldata : __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + sn_to_appchain_messages(& self, message_hash : & starknet :: core :: types + :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider, + MessageToAppchainStatus > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(message_hash)); let __call = starknet :: core :: types + :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("sn_to_appchain_messages"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + cancel_message_getcall(& self, to_address : & cainome :: cairo_serde :: + ContractAddress, selector : & starknet :: core :: types :: Felt, payload : + & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: + core :: types :: Felt) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(nonce)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("cancel_message"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + cancel_message(& self, to_address : & cainome :: cairo_serde :: + ContractAddress, selector : & starknet :: core :: types :: Felt, payload : + & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: + core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(nonce)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("cancel_message"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + consume_message_from_appchain_getcall(& self, from_address : & cainome :: + cairo_serde :: ContractAddress, payload : & Vec :: < starknet :: core :: + types :: Felt >) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(from_address)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("consume_message_from_appchain"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + consume_message_from_appchain(& self, from_address : & cainome :: + cairo_serde :: ContractAddress, payload : & Vec :: < starknet :: core :: + types :: Felt >) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(from_address)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("consume_message_from_appchain"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + register_operator_getcall(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("register_operator"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + register_operator(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("register_operator"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + send_message_to_appchain_getcall(& self, to_address : & cainome :: + cairo_serde :: ContractAddress, selector : & starknet :: core :: types :: + Felt, payload : & Vec :: < starknet :: core :: types :: Felt >) -> + starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("send_message_to_appchain"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + send_message_to_appchain(& self, to_address : & cainome :: cairo_serde :: + ContractAddress, selector : & starknet :: core :: types :: Felt, payload : + & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: accounts :: + ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("send_message_to_appchain"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + set_facts_registry_getcall(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("set_facts_registry"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + set_facts_registry(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("set_facts_registry"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + set_program_info_getcall(& self, program_hash : & starknet :: core :: + types :: Felt, config_hash : & starknet :: core :: types :: Felt) -> + starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(program_hash)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(config_hash)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("set_program_info"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + set_program_info(& self, program_hash : & starknet :: core :: types :: + Felt, config_hash : & starknet :: core :: types :: Felt) -> starknet :: + accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(program_hash)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(config_hash)); let __call = starknet :: core :: types + :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("set_program_info"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + start_message_cancellation_getcall(& self, to_address : & cainome :: + cairo_serde :: ContractAddress, selector : & starknet :: core :: types :: + Felt, payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & + starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(nonce)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("start_message_cancellation"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + start_message_cancellation(& self, to_address : & cainome :: cairo_serde + :: ContractAddress, selector : & starknet :: core :: types :: Felt, + payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & + starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 + < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(nonce)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("start_message_cancellation"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + unregister_operator_getcall(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("unregister_operator"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + unregister_operator(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("unregister_operator"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + update_getcall(& self, program_output : & Vec :: < starknet :: core :: + types :: Felt >) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(program_output)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("update"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + update(& self, program_output : & Vec :: < starknet :: core :: types :: + Felt >) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(program_output)); let __call = starknet :: core :: + types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("update"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + update_state_getcall(& self, program_output : & Vec :: < starknet :: core + :: types :: Felt > , onchain_data_hash : & starknet :: core :: types :: + Felt, onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: + core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(program_output)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(onchain_data_hash)); + __calldata.extend(cainome :: cairo_serde :: U256 :: + cairo_serialize(onchain_data_size)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("update_state"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + update_state(& self, program_output : & Vec :: < starknet :: core :: types + :: Felt > , onchain_data_hash : & starknet :: core :: types :: Felt, + onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: + accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(program_output)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(onchain_data_hash)); + __calldata.extend(cainome :: cairo_serde :: U256 :: + cairo_serialize(onchain_data_size)); let __call = starknet :: core :: + types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("update_state"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + upgrade_getcall(& self, new_class_hash : & cainome :: cairo_serde :: + ClassHash) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ClassHash :: + cairo_serialize(new_class_hash)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("upgrade"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn upgrade(& self, new_class_hash : & cainome :: cairo_serde :: ClassHash) + -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ClassHash :: + cairo_serialize(new_class_hash)); let __call = starknet :: core :: + types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("upgrade"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } +} impl < P : starknet :: providers :: Provider + Sync > AppchainReader < P > +{ + #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub fn + appchain_to_sn_messages(& self, message_hash : & starknet :: core :: types + :: Felt) -> cainome :: cairo_serde :: call :: FCall < P, + MessageToStarknetStatus > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(message_hash)); let __call = starknet :: core :: types + :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("appchain_to_sn_messages"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_facts_registry(& self,) -> cainome :: cairo_serde :: call :: FCall + < P, cainome :: cairo_serde :: ContractAddress > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_facts_registry"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_program_info(& self,) -> cainome :: cairo_serde :: call :: FCall < + P, (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) + > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_program_info"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_state(& self,) -> cainome :: cairo_serde :: call :: FCall < P, + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt, + starknet :: core :: types :: Felt) > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_state"), calldata : __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + is_operator(& self, address : & cainome :: cairo_serde :: ContractAddress) + -> cainome :: cairo_serde :: call :: FCall < P, bool > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); let __call = starknet :: core :: types :: + FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("is_operator"), calldata : __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + sn_to_appchain_messages(& self, message_hash : & starknet :: core :: types + :: Felt) -> cainome :: cairo_serde :: call :: FCall < P, + MessageToAppchainStatus > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(message_hash)); let __call = starknet :: core :: types + :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("sn_to_appchain_messages"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } +} \ No newline at end of file diff --git a/src/messaging/component.cairo b/src/messaging/component.cairo index 29f18c5..136067c 100644 --- a/src/messaging/component.cairo +++ b/src/messaging/component.cairo @@ -26,7 +26,6 @@ /// Errors. mod errors { - const INVALID_NONCE: felt252 = 'INVALID_NONCE'; const INVALID_MESSAGE_TO_CONSUME: felt252 = 'INVALID_MESSAGE_TO_CONSUME'; const INVALID_MESSAGE_TO_SEAL: felt252 = 'INVALID_MESSAGE_TO_SEAL'; const NO_MESSAGE_TO_CANCEL: felt252 = 'NO_MESSAGE_TO_CANCEL'; @@ -62,8 +61,8 @@ mod messaging_cpt { sn_to_appc_cancellations: Map::, /// The nonce for messages sent to the Appchain from Starknet. sn_to_appc_nonce: Nonce, - /// Ledger of messages hashes sent from Starknet to the appchain. - sn_to_appc_messages: Map::, + /// Ledger of messages hashes sent from Starknet to the appchain and their status. + sn_to_appc_messages: Map::, /// Ledger of messages hashes registered from the Appchain and a refcount /// associated to it to control messages consumption. appc_to_sn_messages: Map::, @@ -164,9 +163,14 @@ mod messaging_cpt { selector: felt252, payload: Span ) -> (MessageHash, Nonce) { - // Starts by +1 to avoid 0 as a valid nonce. - let nonce = self.sn_to_appc_nonce.read() + 1; - self.sn_to_appc_nonce.write(nonce); + // From the what's done from L1 to L2, the first nonce must be 0: + // + // The value is read from the storage, and then incremented but the read + // value is used at the tx nonce. + let mut nonce = self.sn_to_appc_nonce.read(); + + // Increment the nonce, but the read value is used at the tx nonce. + self.sn_to_appc_nonce.write(nonce + 1); let from = starknet::get_caller_address(); let message_hash = hash::compute_message_hash_sn_to_appc( @@ -178,21 +182,16 @@ mod messaging_cpt { MessageSent { message_hash, from, to: to_address, selector, nonce, payload, } ); - self.sn_to_appc_messages.write(message_hash, nonce); + self.sn_to_appc_messages.write(message_hash, MessageToAppchainStatus::Pending(nonce)); (message_hash, nonce) } fn sn_to_appchain_messages( self: @ComponentState, message_hash: MessageHash ) -> MessageToAppchainStatus { - let nonce = self.sn_to_appc_messages.read(message_hash); - if nonce == 0 { - return MessageToAppchainStatus::SealedOrNotSent; - } - return MessageToAppchainStatus::Pending(nonce); + self.sn_to_appc_messages.read(message_hash) } - fn appchain_to_sn_messages( self: @ComponentState, message_hash: MessageHash ) -> MessageToStarknetStatus { @@ -234,16 +233,16 @@ mod messaging_cpt { payload: Span, nonce: Nonce, ) -> MessageHash { - assert(nonce.is_non_zero(), errors::INVALID_NONCE); let from = starknet::get_caller_address(); let message_hash = hash::compute_message_hash_sn_to_appc( from, to_address, selector, payload, nonce ); - assert( - self.sn_to_appc_messages.read(message_hash) == nonce, errors::NO_MESSAGE_TO_CANCEL - ); + match self.sn_to_appc_messages.read(message_hash) { + MessageToAppchainStatus::Pending(_) => {}, + _ => assert(false, errors::NO_MESSAGE_TO_CANCEL), + }; self.sn_to_appc_cancellations.write(message_hash, starknet::get_block_timestamp()); @@ -271,7 +270,10 @@ mod messaging_cpt { ); assert( - self.sn_to_appc_messages.read(message_hash) == nonce, errors::NO_MESSAGE_TO_CANCEL + self + .sn_to_appc_messages + .read(message_hash) == MessageToAppchainStatus::Pending(nonce), + errors::NO_MESSAGE_TO_CANCEL ); let request_time = self.sn_to_appc_cancellations.read(message_hash); @@ -290,10 +292,41 @@ mod messaging_cpt { ); // Once canceled, no more operation can be done on this message. - self.sn_to_appc_messages.write(message_hash, 0); + self.sn_to_appc_messages.write(message_hash, MessageToAppchainStatus::Cancelled); return message_hash; } + + #[cfg(feature: 'messaging_test')] + fn add_messages_hashes_from_appchain( + ref self: ComponentState, messages_hashes: Span + ) { + let mut i = 0_usize; + loop { + if i == messages_hashes.len() { + break; + } + + let msg_hash = *messages_hashes[i]; + + let count = self.appc_to_sn_messages.read(msg_hash); + self.appc_to_sn_messages.write(msg_hash, count + 1); + + // We can't have the detail of the message here, so we emit a dummy event + // with at least the message hash. + self + .emit( + MessageToStarknetReceived { + message_hash: msg_hash, + from: 0.try_into().unwrap(), + to: 0.try_into().unwrap(), + payload: array![].span() + } + ); + + i += 1; + }; + } } #[generate_trait] @@ -362,12 +395,17 @@ mod messaging_cpt { let message_hash = hash::compute_message_hash_sn_to_appc( from, to, selector, payload, nonce ); - assert( - self.sn_to_appc_messages.read(message_hash).is_non_zero(), - errors::INVALID_MESSAGE_TO_SEAL - ); - self.sn_to_appc_messages.write(message_hash, 0); + match self.sn_to_appc_messages.read(message_hash) { + MessageToAppchainStatus::Pending(_) => {}, + _ => assert(false, errors::INVALID_MESSAGE_TO_SEAL), + }; + + // On the L1, they use the Fee in front of the message hash, not the nonce. + // Here, we have an enum to explicitly indicate that the message is sealed. + self + .sn_to_appc_messages + .write(message_hash, MessageToAppchainStatus::Sealed); self .emit( diff --git a/src/messaging/interface.cairo b/src/messaging/interface.cairo index ff8192e..af83f3f 100644 --- a/src/messaging/interface.cairo +++ b/src/messaging/interface.cairo @@ -116,4 +116,16 @@ trait IMessaging { payload: Span, nonce: felt252, ) -> MessageHash; + + /// Manually registers messages hashes as consumable. + /// + /// This function is mostly used to decorrelate the messages registration from the + /// state update step. Since all messages are registered once the proof is verified, + /// and the output of SNOS parsed, this function shortcut this step. + /// + /// The appchain sequencer for testing e2e messaging can then use this function to + /// register messages hashes that are considered as ready to be consumed. This can be done + /// right after the block is produced, for fast and reliable messaging testing. + #[cfg(feature: 'messaging_test')] + fn add_messages_hashes_from_appchain(ref self: T, messages_hashes: Span); } diff --git a/src/messaging/tests/test_messaging.cairo b/src/messaging/tests/test_messaging.cairo index 2a9ef68..ca7707e 100644 --- a/src/messaging/tests/test_messaging.cairo +++ b/src/messaging/tests/test_messaging.cairo @@ -168,7 +168,7 @@ fn send_message_ok() { let (message_hash, nonce) = mock.send_message_to_appchain(to, selector, payload.span()); assert(message_hash.is_non_zero(), 'invalid message hash'); - assert(nonce == 1, 'invalid nonce'); + assert(nonce == 0, 'invalid nonce'); let expected_event = MessageSent { message_hash, from, to, selector, nonce: nonce, payload: payload.span(), @@ -190,13 +190,10 @@ fn sn_to_appchain_messages_ok() { // Calculate the message_hash let message_hash = hash::compute_message_hash_sn_to_appc( - from_address: from, to_address: to, :selector, payload: payload.span(), nonce: 1 + from_address: from, to_address: to, :selector, payload: payload.span(), nonce: 0 ); let is_pending_before = mock.sn_to_appchain_messages(message_hash); - assert( - is_pending_before == MessageToAppchainStatus::SealedOrNotSent, - 'Should not be pending before' - ); + assert(is_pending_before == MessageToAppchainStatus::NotSent, 'Should not be pending before'); snf::start_cheat_caller_address(from, from); let (message_hash, nonce) = mock.send_message_to_appchain(to, selector, payload.span()); @@ -248,14 +245,14 @@ fn start_cancellation_ok() { } #[test] -#[should_panic(expected: ('INVALID_NONCE',))] +#[should_panic(expected: ('NO_MESSAGE_TO_CANCEL',))] fn start_cancellation_invalid_nonce() { let (mock, _) = deploy_mock(); let to = c::RECIPIENT(); let selector = selector!("func1"); let payload = array![1, 2, 3]; - let nonce = 0; + let nonce = 0x800000000000011000000000000000000000000000000000000000000000000; mock.start_message_cancellation(to, selector, payload.span(), nonce); } @@ -325,7 +322,7 @@ fn cancel_message_no_message_to_cancel() { let to = c::RECIPIENT(); let selector = selector!("func1"); let payload = array![1, 2, 3]; - let nonce = 1; + let nonce = 0; mock.cancel_message(to, selector, payload.span(), nonce + 1000); } @@ -409,7 +406,7 @@ fn process_messages_to_appchain_ok() { let (_message_hash, _nonce) = mock.send_message_to_appchain(to, selector, payload.span()); let m = MessageToAppchain { - from_address: from, to_address: to, nonce: 1, selector, payload: payload.span(), + from_address: from, to_address: to, nonce: 0, selector, payload: payload.span(), }; let _message_hash = hash::compute_message_hash_sn_to_appc( @@ -472,7 +469,27 @@ fn appchain_to_sn_messages_ok() { // Ensure that message is available to consume let count_after = mock.appchain_to_sn_messages(message_hash); - assert(count_after == MessageToStarknetStatus::ReadyToConsume(1), 'message not be present'); + assert(count_after == MessageToStarknetStatus::ReadyToConsume(1), 'message not present'); +} + +#[test] +fn appchain_to_sn_messages_hashes_test() { + let mut mock = mock_state_testing(); + + let from = c::SPENDER(); + let to = starknet::get_contract_address(); + let payload = array![1, 2, 3].span(); + + let message_hash = hash::compute_message_hash_appc_to_sn(from, to, payload); + + let previous_status = mock.appchain_to_sn_messages(message_hash); + assert(previous_status == MessageToStarknetStatus::NothingToConsume, 'message already present'); + + mock.add_messages_hashes_from_appchain(array![message_hash].span()); + + // Ensure that message is available to consume. + let count_after = mock.appchain_to_sn_messages(message_hash); + assert(count_after == MessageToStarknetStatus::ReadyToConsume(1), 'message not present'); } #[test] diff --git a/src/messaging/types.cairo b/src/messaging/types.cairo index 2e7382d..debf98f 100644 --- a/src/messaging/types.cairo +++ b/src/messaging/types.cairo @@ -1,9 +1,12 @@ pub type MessageHash = felt252; pub type Nonce = felt252; -#[derive(Serde, Drop, PartialEq)] +#[derive(Serde, Drop, PartialEq, starknet::Store, Default)] pub enum MessageToAppchainStatus { - SealedOrNotSent, // sn->appc: The nonce is 0 for the message hash. + #[default] + NotSent, + Sealed, + Cancelled, Pending: Nonce, // sn->appc: The nonce > 0. } diff --git a/tests/test_appchain.cairo b/tests/test_appchain.cairo index 9d86212..e6d88f8 100644 --- a/tests/test_appchain.cairo +++ b/tests/test_appchain.cairo @@ -179,9 +179,7 @@ fn update_state_ok() { // The state update contains a message to appchain, therefore, before // being sealed, it must be sent first. // The nonce must be adjusted to ensure the correct message to be sent. - snf::store( - appchain.contract_address, selector!("sn_to_appc_nonce"), array![1629170 - 1].span() - ); + snf::store(appchain.contract_address, selector!("sn_to_appc_nonce"), array![1629170].span()); snf::start_cheat_caller_address(appchain.contract_address, contract_sn); imsg.send_message_to_appchain(contract_appc, selector_appc, payload_sn_to_appc); From bc36b5fa222b7904be035643a458e13b36484995 Mon Sep 17 00:00:00 2001 From: glihm Date: Tue, 28 Jan 2025 16:11:21 -0600 Subject: [PATCH 15/15] fix: use SpanIter instead of ArrayIter It's a better convention to use Span when accepting inputs from an external call (contract entrypoint), since the memory is not accessible, hence the array can't be modify anyway. --- README.md | 14 +- bindings/src/lib.rs | 4177 +++++++++++++++++++++- scripts/cairo_fmt.sh | 9 + scripts/test_all_features.sh | 3 + src/appchain.cairo | 15 +- src/interface.cairo | 14 +- src/messaging/tests/test_messaging.cairo | 2 +- src/snos_output.cairo | 73 +- tests/test_appchain.cairo | 4 +- 9 files changed, 4253 insertions(+), 58 deletions(-) create mode 100755 scripts/cairo_fmt.sh create mode 100644 scripts/test_all_features.sh diff --git a/README.md b/README.md index a8b6128..ea6174e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,13 @@ Currently some warnings are displayed, will be fixed in a future version of `cai To test the project, run: ```bash -snforge test +scarb test --all-features +``` + +Or using the script (where further tests may be added in the future): + +```bash +bash scripts/test_all_features.sh ``` ## Code style (cairo) @@ -71,3 +77,9 @@ let addr = contract_address_const::<0>(); ``` - Document functions inside the trait, and add details if needed in the implementation. + +To enforce the cairo linter, please use: + +```bash +bash scripts/cairo_fmt.sh --fix +``` diff --git a/bindings/src/lib.rs b/bindings/src/lib.rs index 838de1f..fa297a5 100644 --- a/bindings/src/lib.rs +++ b/bindings/src/lib.rs @@ -1 +1,4176 @@ -# [derive ()] pub struct Appchain < A : starknet :: accounts :: ConnectedAccount + Sync > {pub address : starknet :: core :: types :: Felt , pub account : A , pub block_id : starknet :: core :: types :: BlockId ,} impl < A : starknet :: accounts :: ConnectedAccount + Sync > Appchain < A > {pub fn new (address : starknet :: core :: types :: Felt , account : A) -> Self {Self {address , account , block_id : starknet :: core :: types :: BlockId :: Tag (starknet :: core :: types :: BlockTag :: Pending)}} pub fn set_contract_address (& mut self , address : starknet :: core :: types :: Felt) {self . address = address ;} pub fn provider (& self) -> & A :: Provider {self . account . provider ()} pub fn set_block (& mut self , block_id : starknet :: core :: types :: BlockId) {self . block_id = block_id ;} pub fn with_block (self , block_id : starknet :: core :: types :: BlockId) -> Self {Self {block_id , .. self}}} # [derive ()] pub struct AppchainReader < P : starknet :: providers :: Provider + Sync > {pub address : starknet :: core :: types :: Felt , pub provider : P , pub block_id : starknet :: core :: types :: BlockId ,} impl < P : starknet :: providers :: Provider + Sync > AppchainReader < P > {pub fn new (address : starknet :: core :: types :: Felt , provider : P ,) -> Self {Self {address , provider , block_id : starknet :: core :: types :: BlockId :: Tag (starknet :: core :: types :: BlockTag :: Pending)}} pub fn set_contract_address (& mut self , address : starknet :: core :: types :: Felt) {self . address = address ;} pub fn provider (& self) -> & P {& self . provider} pub fn set_block (& mut self , block_id : starknet :: core :: types :: BlockId) {self . block_id = block_id ;} pub fn with_block (self , block_id : starknet :: core :: types :: BlockId) -> Self {Self {block_id , .. self}}} # [derive ()] pub struct LogStateTransitionFact {pub state_transition_fact : cainome :: cairo_serde :: U256} impl cainome :: cairo_serde :: CairoSerde for LogStateTransitionFact {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: U256 :: cairo_serialized_size (& __rust . state_transition_fact) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: U256 :: cairo_serialize (& __rust . state_transition_fact)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let state_transition_fact = cainome :: cairo_serde :: U256 :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: U256 :: cairo_serialized_size (& state_transition_fact) ; Ok (LogStateTransitionFact {state_transition_fact})}} impl LogStateTransitionFact {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("LogStateTransitionFact") . unwrap ()} pub fn event_name () -> & 'static str {"LogStateTransitionFact"}} # [derive ()] pub struct LogStateUpdate {pub state_root : starknet :: core :: types :: Felt , pub block_number : starknet :: core :: types :: Felt , pub block_hash : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for LogStateUpdate {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . state_root) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . block_number) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . block_hash) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . state_root)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . block_number)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . block_hash)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let state_root = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& state_root) ; let block_number = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_number) ; let block_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_hash) ; Ok (LogStateUpdate {state_root , block_number , block_hash})}} impl LogStateUpdate {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("LogStateUpdate") . unwrap ()} pub fn event_name () -> & 'static str {"LogStateUpdate"}} # [derive ()] pub struct MessageCanceled {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for MessageCanceled {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; Ok (MessageCanceled {message_hash , from , to , selector , payload , nonce})}} impl MessageCanceled {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("MessageCanceled") . unwrap ()} pub fn event_name () -> & 'static str {"MessageCanceled"}} # [derive ()] pub struct MessageCancellationStarted {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for MessageCancellationStarted {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; Ok (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce})}} impl MessageCancellationStarted {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("MessageCancellationStarted") . unwrap ()} pub fn event_name () -> & 'static str {"MessageCancellationStarted"}} # [derive ()] pub struct MessageConsumed {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageConsumed {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageConsumed {message_hash , from , to , payload})}} impl MessageConsumed {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("MessageConsumed") . unwrap ()} pub fn event_name () -> & 'static str {"MessageConsumed"}} # [derive ()] pub struct MessageSent {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub nonce : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageSent {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageSent {message_hash , from , to , selector , nonce , payload})}} impl MessageSent {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("MessageSent") . unwrap ()} pub fn event_name () -> & 'static str {"MessageSent"}} # [derive ()] pub struct MessageToAppchainSealed {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub selector : starknet :: core :: types :: Felt , pub nonce : starknet :: core :: types :: Felt , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainSealed {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . selector) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . nonce) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . selector)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . nonce)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload})}} impl MessageToAppchainSealed {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("MessageToAppchainSealed") . unwrap ()} pub fn event_name () -> & 'static str {"MessageToAppchainSealed"}} # [derive ()] pub struct MessageToStarknetReceived {pub message_hash : starknet :: core :: types :: Felt , pub from : cainome :: cairo_serde :: ContractAddress , pub to : cainome :: cairo_serde :: ContractAddress , pub payload : Vec < starknet :: core :: types :: Felt >} impl cainome :: cairo_serde :: CairoSerde for MessageToStarknetReceived {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . message_hash) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . from) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . to) ; __size += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& __rust . payload) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . message_hash)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . from)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . to)) ; __out . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (& __rust . payload)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let message_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (__felts , __offset) ? ; __offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; Ok (MessageToStarknetReceived {message_hash , from , to , payload})}} impl MessageToStarknetReceived {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("MessageToStarknetReceived") . unwrap ()} pub fn event_name () -> & 'static str {"MessageToStarknetReceived"}} # [derive ()] pub struct OwnershipTransferStarted {pub previous_owner : cainome :: cairo_serde :: ContractAddress , pub new_owner : cainome :: cairo_serde :: ContractAddress} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferStarted {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . previous_owner) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . new_owner) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . previous_owner)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . new_owner)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let previous_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; Ok (OwnershipTransferStarted {previous_owner , new_owner})}} impl OwnershipTransferStarted {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferStarted") . unwrap ()} pub fn event_name () -> & 'static str {"OwnershipTransferStarted"}} # [derive ()] pub struct OwnershipTransferred {pub previous_owner : cainome :: cairo_serde :: ContractAddress , pub new_owner : cainome :: cairo_serde :: ContractAddress} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferred {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . previous_owner) ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . new_owner) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . previous_owner)) ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . new_owner)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let previous_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; Ok (OwnershipTransferred {previous_owner , new_owner})}} impl OwnershipTransferred {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferred") . unwrap ()} pub fn event_name () -> & 'static str {"OwnershipTransferred"}} # [derive ()] pub struct ProgramInfoChanged {pub changed_by : cainome :: cairo_serde :: ContractAddress , pub old_program_hash : starknet :: core :: types :: Felt , pub new_program_hash : starknet :: core :: types :: Felt , pub old_config_hash : starknet :: core :: types :: Felt , pub new_config_hash : starknet :: core :: types :: Felt} impl cainome :: cairo_serde :: CairoSerde for ProgramInfoChanged {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& __rust . changed_by) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . old_program_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . new_program_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . old_config_hash) ; __size += starknet :: core :: types :: Felt :: cairo_serialized_size (& __rust . new_config_hash) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (& __rust . changed_by)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . old_program_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . new_program_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . old_config_hash)) ; __out . extend (starknet :: core :: types :: Felt :: cairo_serialize (& __rust . new_config_hash)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let changed_by = cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset) ? ; __offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; Ok (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash})}} impl ProgramInfoChanged {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("ProgramInfoChanged") . unwrap ()} pub fn event_name () -> & 'static str {"ProgramInfoChanged"}} # [derive ()] pub struct Upgraded {pub class_hash : cainome :: cairo_serde :: ClassHash} impl cainome :: cairo_serde :: CairoSerde for Upgraded {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {let mut __size = 0 ; __size += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& __rust . class_hash) ; __size} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {let mut __out : Vec < starknet :: core :: types :: Felt > = vec ! [] ; __out . extend (cainome :: cairo_serde :: ClassHash :: cairo_serialize (& __rust . class_hash)) ; __out} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let mut __offset = __offset ; let class_hash = cainome :: cairo_serde :: ClassHash :: cairo_deserialize (__felts , __offset) ? ; __offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; Ok (Upgraded {class_hash})}} impl Upgraded {pub fn event_selector () -> starknet :: core :: types :: Felt {starknet :: core :: utils :: get_selector_from_name ("Upgraded") . unwrap ()} pub fn event_name () -> & 'static str {"Upgraded"}} # [derive ()] pub enum AppchainEvent {OwnableEvent (OwnableEvent) , UpgradeableEvent (UpgradeableEvent) , ConfigEvent (ConfigEvent) , MessagingEvent (MessagingEvent) , ReentrancyGuardEvent (ReentrancyguardEvent) , StateEvent (StateEvent) , LogStateUpdate (LogStateUpdate) , LogStateTransitionFact (LogStateTransitionFact)} impl cainome :: cairo_serde :: CairoSerde for AppchainEvent {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {AppchainEvent :: OwnableEvent (val) => OwnableEvent :: cairo_serialized_size (val) + 1 , AppchainEvent :: UpgradeableEvent (val) => UpgradeableEvent :: cairo_serialized_size (val) + 1 , AppchainEvent :: ConfigEvent (val) => ConfigEvent :: cairo_serialized_size (val) + 1 , AppchainEvent :: MessagingEvent (val) => MessagingEvent :: cairo_serialized_size (val) + 1 , AppchainEvent :: ReentrancyGuardEvent (val) => ReentrancyguardEvent :: cairo_serialized_size (val) + 1 , AppchainEvent :: StateEvent (val) => StateEvent :: cairo_serialized_size (val) + 1 , AppchainEvent :: LogStateUpdate (val) => LogStateUpdate :: cairo_serialized_size (val) + 1 , AppchainEvent :: LogStateTransitionFact (val) => LogStateTransitionFact :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {AppchainEvent :: OwnableEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (OwnableEvent :: cairo_serialize (val)) ; temp} , AppchainEvent :: UpgradeableEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (UpgradeableEvent :: cairo_serialize (val)) ; temp} , AppchainEvent :: ConfigEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 2usize)) ; temp . extend (ConfigEvent :: cairo_serialize (val)) ; temp} , AppchainEvent :: MessagingEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 3usize)) ; temp . extend (MessagingEvent :: cairo_serialize (val)) ; temp} , AppchainEvent :: ReentrancyGuardEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 4usize)) ; temp . extend (ReentrancyguardEvent :: cairo_serialize (val)) ; temp} , AppchainEvent :: StateEvent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 5usize)) ; temp . extend (StateEvent :: cairo_serialize (val)) ; temp} , AppchainEvent :: LogStateUpdate (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 6usize)) ; temp . extend (LogStateUpdate :: cairo_serialize (val)) ; temp} , AppchainEvent :: LogStateTransitionFact (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 7usize)) ; temp . extend (LogStateTransitionFact :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (AppchainEvent :: OwnableEvent (OwnableEvent :: cairo_deserialize (__felts , __offset + 1) ?)) , 1usize => Ok (AppchainEvent :: UpgradeableEvent (UpgradeableEvent :: cairo_deserialize (__felts , __offset + 1) ?)) , 2usize => Ok (AppchainEvent :: ConfigEvent (ConfigEvent :: cairo_deserialize (__felts , __offset + 1) ?)) , 3usize => Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: cairo_deserialize (__felts , __offset + 1) ?)) , 4usize => Ok (AppchainEvent :: ReentrancyGuardEvent (ReentrancyguardEvent :: cairo_deserialize (__felts , __offset + 1) ?)) , 5usize => Ok (AppchainEvent :: StateEvent (StateEvent :: cairo_deserialize (__felts , __offset + 1) ?)) , 6usize => Ok (AppchainEvent :: LogStateUpdate (LogStateUpdate :: cairo_deserialize (__felts , __offset + 1) ?)) , 7usize => Ok (AppchainEvent :: LogStateTransitionFact (LogStateTransitionFact :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "AppchainEvent")))}}} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for AppchainEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferred") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferred")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (AppchainEvent :: OwnableEvent (OwnableEvent :: OwnershipTransferred (OwnershipTransferred {previous_owner , new_owner})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (AppchainEvent :: OwnableEvent (OwnableEvent :: OwnershipTransferStarted (OwnershipTransferStarted {previous_owner , new_owner})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("Upgraded") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "Upgraded")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let class_hash = match cainome :: cairo_serde :: ClassHash :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "class_hash" , "Upgraded" , e)) ,} ; data_offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; return Ok (AppchainEvent :: UpgradeableEvent (UpgradeableEvent :: Upgraded (Upgraded {class_hash})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("ProgramInfoChanged") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "ProgramInfoChanged")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let changed_by = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "changed_by" , "ProgramInfoChanged" , e)) ,} ; data_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; return Ok (AppchainEvent :: ConfigEvent (ConfigEvent :: ProgramInfoChanged (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageSent") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageSent")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageSent" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageSent" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageSent (MessageSent {message_hash , from , to , selector , nonce , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageConsumed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageConsumed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageConsumed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageConsumed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageConsumed (MessageConsumed {message_hash , from , to , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCancellationStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCancellationStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCancellationStarted" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCancellationStarted" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageCancellationStarted (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCanceled") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCanceled")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCanceled" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCanceled" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageCanceled (MessageCanceled {message_hash , from , to , selector , payload , nonce})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToStarknetReceived") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToStarknetReceived")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToStarknetReceived" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToStarknetReceived" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageToStarknetReceived (MessageToStarknetReceived {message_hash , from , to , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToAppchainSealed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToAppchainSealed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToAppchainSealed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToAppchainSealed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageToAppchainSealed (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("LogStateUpdate") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "LogStateUpdate")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let state_root = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "state_root" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& state_root) ; let block_number = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "block_number" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_number) ; let block_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "block_hash" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_hash) ; return Ok (AppchainEvent :: LogStateUpdate (LogStateUpdate {state_root , block_number , block_hash}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("LogStateTransitionFact") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "LogStateTransitionFact")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let state_transition_fact = match cainome :: cairo_serde :: U256 :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "state_transition_fact" , "LogStateTransitionFact" , e)) ,} ; data_offset += cainome :: cairo_serde :: U256 :: cairo_serialized_size (& state_transition_fact) ; return Ok (AppchainEvent :: LogStateTransitionFact (LogStateTransitionFact {state_transition_fact}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} impl TryFrom < & starknet :: core :: types :: Event > for AppchainEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: Event) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferred") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferred")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (AppchainEvent :: OwnableEvent (OwnableEvent :: OwnershipTransferred (OwnershipTransferred {previous_owner , new_owner})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (AppchainEvent :: OwnableEvent (OwnableEvent :: OwnershipTransferStarted (OwnershipTransferStarted {previous_owner , new_owner})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("Upgraded") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "Upgraded")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let class_hash = match cainome :: cairo_serde :: ClassHash :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "class_hash" , "Upgraded" , e)) ,} ; data_offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; return Ok (AppchainEvent :: UpgradeableEvent (UpgradeableEvent :: Upgraded (Upgraded {class_hash})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("ProgramInfoChanged") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "ProgramInfoChanged")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let changed_by = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "changed_by" , "ProgramInfoChanged" , e)) ,} ; data_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; return Ok (AppchainEvent :: ConfigEvent (ConfigEvent :: ProgramInfoChanged (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageSent") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageSent")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageSent" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageSent" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageSent (MessageSent {message_hash , from , to , selector , nonce , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageConsumed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageConsumed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageConsumed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageConsumed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageConsumed (MessageConsumed {message_hash , from , to , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCancellationStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCancellationStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCancellationStarted" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCancellationStarted" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageCancellationStarted (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCanceled") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCanceled")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCanceled" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCanceled" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageCanceled (MessageCanceled {message_hash , from , to , selector , payload , nonce})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToStarknetReceived") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToStarknetReceived")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToStarknetReceived" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToStarknetReceived" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageToStarknetReceived (MessageToStarknetReceived {message_hash , from , to , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToAppchainSealed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToAppchainSealed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToAppchainSealed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToAppchainSealed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (AppchainEvent :: MessagingEvent (MessagingEvent :: MessageToAppchainSealed (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload})))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("LogStateUpdate") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "LogStateUpdate")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let state_root = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "state_root" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& state_root) ; let block_number = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "block_number" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_number) ; let block_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "block_hash" , "LogStateUpdate" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& block_hash) ; return Ok (AppchainEvent :: LogStateUpdate (LogStateUpdate {state_root , block_number , block_hash}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("LogStateTransitionFact") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "LogStateTransitionFact")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let state_transition_fact = match cainome :: cairo_serde :: U256 :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "state_transition_fact" , "LogStateTransitionFact" , e)) ,} ; data_offset += cainome :: cairo_serde :: U256 :: cairo_serialized_size (& state_transition_fact) ; return Ok (AppchainEvent :: LogStateTransitionFact (LogStateTransitionFact {state_transition_fact}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive ()] pub enum ConfigEvent {ProgramInfoChanged (ProgramInfoChanged)} impl cainome :: cairo_serde :: CairoSerde for ConfigEvent {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {ConfigEvent :: ProgramInfoChanged (val) => ProgramInfoChanged :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {ConfigEvent :: ProgramInfoChanged (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (ProgramInfoChanged :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (ConfigEvent :: ProgramInfoChanged (ProgramInfoChanged :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "ConfigEvent")))}}} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for ConfigEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("ProgramInfoChanged") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "ProgramInfoChanged")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let changed_by = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "changed_by" , "ProgramInfoChanged" , e)) ,} ; data_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; return Ok (ConfigEvent :: ProgramInfoChanged (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} impl TryFrom < & starknet :: core :: types :: Event > for ConfigEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: Event) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("ProgramInfoChanged") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "ProgramInfoChanged")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let changed_by = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "changed_by" , "ProgramInfoChanged" , e)) ,} ; data_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& changed_by) ; let old_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_program_hash) ; let new_program_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_program_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_program_hash) ; let old_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "old_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& old_config_hash) ; let new_config_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_config_hash" , "ProgramInfoChanged" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& new_config_hash) ; return Ok (ConfigEvent :: ProgramInfoChanged (ProgramInfoChanged {changed_by , old_program_hash , new_program_hash , old_config_hash , new_config_hash}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive ()] pub enum MessageToAppchainStatus {NotSent , Sealed , Cancelled , Pending (starknet :: core :: types :: Felt)} impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainStatus {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {MessageToAppchainStatus :: NotSent => 1 , MessageToAppchainStatus :: Sealed => 1 , MessageToAppchainStatus :: Cancelled => 1 , MessageToAppchainStatus :: Pending (val) => starknet :: core :: types :: Felt :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {MessageToAppchainStatus :: NotSent => usize :: cairo_serialize (& 0usize) , MessageToAppchainStatus :: Sealed => usize :: cairo_serialize (& 1usize) , MessageToAppchainStatus :: Cancelled => usize :: cairo_serialize (& 2usize) , MessageToAppchainStatus :: Pending (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 3usize)) ; temp . extend (starknet :: core :: types :: Felt :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (MessageToAppchainStatus :: NotSent) , 1usize => Ok (MessageToAppchainStatus :: Sealed) , 2usize => Ok (MessageToAppchainStatus :: Cancelled) , 3usize => Ok (MessageToAppchainStatus :: Pending (starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "MessageToAppchainStatus")))}}} # [derive ()] pub enum MessageToStarknetStatus {NothingToConsume , ReadyToConsume (starknet :: core :: types :: Felt)} impl cainome :: cairo_serde :: CairoSerde for MessageToStarknetStatus {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {MessageToStarknetStatus :: NothingToConsume => 1 , MessageToStarknetStatus :: ReadyToConsume (val) => starknet :: core :: types :: Felt :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {MessageToStarknetStatus :: NothingToConsume => usize :: cairo_serialize (& 0usize) , MessageToStarknetStatus :: ReadyToConsume (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (starknet :: core :: types :: Felt :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (MessageToStarknetStatus :: NothingToConsume) , 1usize => Ok (MessageToStarknetStatus :: ReadyToConsume (starknet :: core :: types :: Felt :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "MessageToStarknetStatus")))}}} # [derive ()] pub enum MessagingEvent {MessageSent (MessageSent) , MessageConsumed (MessageConsumed) , MessageCancellationStarted (MessageCancellationStarted) , MessageCanceled (MessageCanceled) , MessageToStarknetReceived (MessageToStarknetReceived) , MessageToAppchainSealed (MessageToAppchainSealed)} impl cainome :: cairo_serde :: CairoSerde for MessagingEvent {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {MessagingEvent :: MessageSent (val) => MessageSent :: cairo_serialized_size (val) + 1 , MessagingEvent :: MessageConsumed (val) => MessageConsumed :: cairo_serialized_size (val) + 1 , MessagingEvent :: MessageCancellationStarted (val) => MessageCancellationStarted :: cairo_serialized_size (val) + 1 , MessagingEvent :: MessageCanceled (val) => MessageCanceled :: cairo_serialized_size (val) + 1 , MessagingEvent :: MessageToStarknetReceived (val) => MessageToStarknetReceived :: cairo_serialized_size (val) + 1 , MessagingEvent :: MessageToAppchainSealed (val) => MessageToAppchainSealed :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {MessagingEvent :: MessageSent (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (MessageSent :: cairo_serialize (val)) ; temp} , MessagingEvent :: MessageConsumed (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (MessageConsumed :: cairo_serialize (val)) ; temp} , MessagingEvent :: MessageCancellationStarted (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 2usize)) ; temp . extend (MessageCancellationStarted :: cairo_serialize (val)) ; temp} , MessagingEvent :: MessageCanceled (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 3usize)) ; temp . extend (MessageCanceled :: cairo_serialize (val)) ; temp} , MessagingEvent :: MessageToStarknetReceived (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 4usize)) ; temp . extend (MessageToStarknetReceived :: cairo_serialize (val)) ; temp} , MessagingEvent :: MessageToAppchainSealed (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 5usize)) ; temp . extend (MessageToAppchainSealed :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (MessagingEvent :: MessageSent (MessageSent :: cairo_deserialize (__felts , __offset + 1) ?)) , 1usize => Ok (MessagingEvent :: MessageConsumed (MessageConsumed :: cairo_deserialize (__felts , __offset + 1) ?)) , 2usize => Ok (MessagingEvent :: MessageCancellationStarted (MessageCancellationStarted :: cairo_deserialize (__felts , __offset + 1) ?)) , 3usize => Ok (MessagingEvent :: MessageCanceled (MessageCanceled :: cairo_deserialize (__felts , __offset + 1) ?)) , 4usize => Ok (MessagingEvent :: MessageToStarknetReceived (MessageToStarknetReceived :: cairo_deserialize (__felts , __offset + 1) ?)) , 5usize => Ok (MessagingEvent :: MessageToAppchainSealed (MessageToAppchainSealed :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "MessagingEvent")))}}} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for MessagingEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageSent") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageSent")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageSent" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageSent" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (MessagingEvent :: MessageSent (MessageSent {message_hash , from , to , selector , nonce , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageConsumed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageConsumed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageConsumed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageConsumed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (MessagingEvent :: MessageConsumed (MessageConsumed {message_hash , from , to , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCancellationStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCancellationStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCancellationStarted" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCancellationStarted" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (MessagingEvent :: MessageCancellationStarted (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCanceled") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCanceled")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCanceled" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCanceled" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (MessagingEvent :: MessageCanceled (MessageCanceled {message_hash , from , to , selector , payload , nonce}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToStarknetReceived") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToStarknetReceived")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToStarknetReceived" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToStarknetReceived" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (MessagingEvent :: MessageToStarknetReceived (MessageToStarknetReceived {message_hash , from , to , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToAppchainSealed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToAppchainSealed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToAppchainSealed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToAppchainSealed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (MessagingEvent :: MessageToAppchainSealed (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} impl TryFrom < & starknet :: core :: types :: Event > for MessagingEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: Event) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageSent") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageSent")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageSent" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageSent" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageSent" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageSent" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (MessagingEvent :: MessageSent (MessageSent {message_hash , from , to , selector , nonce , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageConsumed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageConsumed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageConsumed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageConsumed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageConsumed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (MessagingEvent :: MessageConsumed (MessageConsumed {message_hash , from , to , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCancellationStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCancellationStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCancellationStarted" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCancellationStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCancellationStarted" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCancellationStarted" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (MessagingEvent :: MessageCancellationStarted (MessageCancellationStarted {message_hash , from , to , selector , payload , nonce}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageCanceled") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageCanceled")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageCanceled" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageCanceled" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageCanceled" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageCanceled" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; return Ok (MessagingEvent :: MessageCanceled (MessageCanceled {message_hash , from , to , selector , payload , nonce}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToStarknetReceived") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToStarknetReceived")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToStarknetReceived" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToStarknetReceived" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToStarknetReceived" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (MessagingEvent :: MessageToStarknetReceived (MessageToStarknetReceived {message_hash , from , to , payload}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("MessageToAppchainSealed") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "MessageToAppchainSealed")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let message_hash = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "message_hash" , "MessageToAppchainSealed" , e)) ,} ; key_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& message_hash) ; let from = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "from" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& from) ; let to = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "to" , "MessageToAppchainSealed" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& to) ; let selector = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "selector" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& selector) ; let nonce = match starknet :: core :: types :: Felt :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "nonce" , "MessageToAppchainSealed" , e)) ,} ; data_offset += starknet :: core :: types :: Felt :: cairo_serialized_size (& nonce) ; let payload = match Vec :: < starknet :: core :: types :: Felt > :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "payload" , "MessageToAppchainSealed" , e)) ,} ; data_offset += Vec :: < starknet :: core :: types :: Felt > :: cairo_serialized_size (& payload) ; return Ok (MessagingEvent :: MessageToAppchainSealed (MessageToAppchainSealed {message_hash , from , to , selector , nonce , payload}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive ()] pub enum OwnableEvent {OwnershipTransferred (OwnershipTransferred) , OwnershipTransferStarted (OwnershipTransferStarted)} impl cainome :: cairo_serde :: CairoSerde for OwnableEvent {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {OwnableEvent :: OwnershipTransferred (val) => OwnershipTransferred :: cairo_serialized_size (val) + 1 , OwnableEvent :: OwnershipTransferStarted (val) => OwnershipTransferStarted :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {OwnableEvent :: OwnershipTransferred (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (OwnershipTransferred :: cairo_serialize (val)) ; temp} , OwnableEvent :: OwnershipTransferStarted (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 1usize)) ; temp . extend (OwnershipTransferStarted :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (OwnableEvent :: OwnershipTransferred (OwnershipTransferred :: cairo_deserialize (__felts , __offset + 1) ?)) , 1usize => Ok (OwnableEvent :: OwnershipTransferStarted (OwnershipTransferStarted :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "OwnableEvent")))}}} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for OwnableEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferred") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferred")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (OwnableEvent :: OwnershipTransferred (OwnershipTransferred {previous_owner , new_owner}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (OwnableEvent :: OwnershipTransferStarted (OwnershipTransferStarted {previous_owner , new_owner}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} impl TryFrom < & starknet :: core :: types :: Event > for OwnableEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: Event) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferred") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferred")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferred" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (OwnableEvent :: OwnershipTransferred (OwnershipTransferred {previous_owner , new_owner}))} ; let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("OwnershipTransferStarted") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "OwnershipTransferStarted")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let previous_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "previous_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& previous_owner) ; let new_owner = match cainome :: cairo_serde :: ContractAddress :: cairo_deserialize (& event . keys , key_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "new_owner" , "OwnershipTransferStarted" , e)) ,} ; key_offset += cainome :: cairo_serde :: ContractAddress :: cairo_serialized_size (& new_owner) ; return Ok (OwnableEvent :: OwnershipTransferStarted (OwnershipTransferStarted {previous_owner , new_owner}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive ()] pub enum ReentrancyguardEvent {} impl cainome :: cairo_serde :: CairoSerde for ReentrancyguardEvent {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {_ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {_ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {_ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "ReentrancyguardEvent")))}}} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for ReentrancyguardEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} impl TryFrom < & starknet :: core :: types :: Event > for ReentrancyguardEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: Event) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive ()] pub enum StateEvent {} impl cainome :: cairo_serde :: CairoSerde for StateEvent {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {_ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {_ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {_ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "StateEvent")))}}} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for StateEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} impl TryFrom < & starknet :: core :: types :: Event > for StateEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: Event) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} # [derive ()] pub enum UpgradeableEvent {Upgraded (Upgraded)} impl cainome :: cairo_serde :: CairoSerde for UpgradeableEvent {type RustType = Self ; const SERIALIZED_SIZE : std :: option :: Option < usize > = std :: option :: Option :: None ; # [inline] fn cairo_serialized_size (__rust : & Self :: RustType) -> usize {match __rust {UpgradeableEvent :: Upgraded (val) => Upgraded :: cairo_serialized_size (val) + 1 , _ => 0}} fn cairo_serialize (__rust : & Self :: RustType) -> Vec < starknet :: core :: types :: Felt > {match __rust {UpgradeableEvent :: Upgraded (val) => {let mut temp = vec ! [] ; temp . extend (usize :: cairo_serialize (& 0usize)) ; temp . extend (Upgraded :: cairo_serialize (val)) ; temp} , _ => vec ! []}} fn cairo_deserialize (__felts : & [starknet :: core :: types :: Felt] , __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > {let __f = __felts [__offset] ; let __index = u128 :: from_be_bytes (__f . to_bytes_be () [16 ..] . try_into () . unwrap ()) ; match __index as usize {0usize => Ok (UpgradeableEvent :: Upgraded (Upgraded :: cairo_deserialize (__felts , __offset + 1) ?)) , _ => return Err (cainome :: cairo_serde :: Error :: Deserialize (format ! ("Index not handle for enum {}" , "UpgradeableEvent")))}}} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for UpgradeableEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: EmittedEvent) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("Upgraded") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "Upgraded")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let class_hash = match cainome :: cairo_serde :: ClassHash :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "class_hash" , "Upgraded" , e)) ,} ; data_offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; return Ok (UpgradeableEvent :: Upgraded (Upgraded {class_hash}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} impl TryFrom < & starknet :: core :: types :: Event > for UpgradeableEvent {type Error = String ; fn try_from (event : & starknet :: core :: types :: Event) -> Result < Self , Self :: Error > {use cainome :: cairo_serde :: CairoSerde ; if event . keys . is_empty () {return Err ("Event has no key" . to_string ()) ;} let selector = event . keys [0] ; if selector == starknet :: core :: utils :: get_selector_from_name ("Upgraded") . unwrap_or_else (| _ | panic ! ("Invalid selector for {}" , "Upgraded")) {let mut key_offset = 0 + 1 ; let mut data_offset = 0 ; let class_hash = match cainome :: cairo_serde :: ClassHash :: cairo_deserialize (& event . data , data_offset) {Ok (v) => v , Err (e) => return Err (format ! ("Could not deserialize field {} for {}: {:?}" , "class_hash" , "Upgraded" , e)) ,} ; data_offset += cainome :: cairo_serde :: ClassHash :: cairo_serialized_size (& class_hash) ; return Ok (UpgradeableEvent :: Upgraded (Upgraded {class_hash}))} ; Err (format ! ("Could not match any event from keys {:?}" , event . keys))}} impl < A : starknet :: accounts :: ConnectedAccount + Sync > Appchain < A > {# [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn appchain_to_sn_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , MessageToStarknetStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("appchain_to_sn_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_facts_registry (& self ,) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , cainome :: cairo_serde :: ContractAddress > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_facts_registry") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_program_info (& self ,) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_program_info") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_state (& self ,) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_state") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn is_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , bool > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("is_operator") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn sn_to_appchain_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider , MessageToAppchainStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("sn_to_appchain_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn cancel_message_getcall (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("cancel_message") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn cancel_message (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("cancel_message") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn consume_message_from_appchain_getcall (& self , from_address : & cainome :: cairo_serde :: ContractAddress , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (from_address)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("consume_message_from_appchain") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn consume_message_from_appchain (& self , from_address : & cainome :: cairo_serde :: ContractAddress , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (from_address)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("consume_message_from_appchain") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn register_operator_getcall (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("register_operator") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn register_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("register_operator") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn send_message_to_appchain_getcall (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("send_message_to_appchain") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn send_message_to_appchain (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("send_message_to_appchain") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_facts_registry_getcall (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_facts_registry") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_facts_registry (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_facts_registry") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_program_info_getcall (& self , program_hash : & starknet :: core :: types :: Felt , config_hash : & starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (program_hash)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (config_hash)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_program_info") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn set_program_info (& self , program_hash : & starknet :: core :: types :: Felt , config_hash : & starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (program_hash)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (config_hash)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("set_program_info") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn start_message_cancellation_getcall (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("start_message_cancellation") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn start_message_cancellation (& self , to_address : & cainome :: cairo_serde :: ContractAddress , selector : & starknet :: core :: types :: Felt , payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (to_address)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (selector)) ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (payload)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (nonce)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("start_message_cancellation") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn unregister_operator_getcall (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("unregister_operator") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn unregister_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("unregister_operator") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update_getcall (& self , program_output : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (program_output)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update (& self , program_output : & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (program_output)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update_state_getcall (& self , program_output : & Vec :: < starknet :: core :: types :: Felt > , onchain_data_hash : & starknet :: core :: types :: Felt , onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (program_output)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (onchain_data_hash)) ; __calldata . extend (cainome :: cairo_serde :: U256 :: cairo_serialize (onchain_data_size)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update_state") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn update_state (& self , program_output : & Vec :: < starknet :: core :: types :: Felt > , onchain_data_hash : & starknet :: core :: types :: Felt , onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (Vec :: < starknet :: core :: types :: Felt > :: cairo_serialize (program_output)) ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (onchain_data_hash)) ; __calldata . extend (cainome :: cairo_serde :: U256 :: cairo_serialize (onchain_data_size)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("update_state") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn upgrade_getcall (& self , new_class_hash : & cainome :: cairo_serde :: ClassHash) -> starknet :: core :: types :: Call {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ClassHash :: cairo_serialize (new_class_hash)) ; starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("upgrade") , calldata : __calldata ,}} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn upgrade (& self , new_class_hash : & cainome :: cairo_serde :: ClassHash) -> starknet :: accounts :: ExecutionV1 < A > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ClassHash :: cairo_serialize (new_class_hash)) ; let __call = starknet :: core :: types :: Call {to : self . address , selector : starknet :: macros :: selector ! ("upgrade") , calldata : __calldata ,} ; self . account . execute_v1 (vec ! [__call])}} impl < P : starknet :: providers :: Provider + Sync > AppchainReader < P > {# [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn appchain_to_sn_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < P , MessageToStarknetStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("appchain_to_sn_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_facts_registry (& self ,) -> cainome :: cairo_serde :: call :: FCall < P , cainome :: cairo_serde :: ContractAddress > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_facts_registry") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_program_info (& self ,) -> cainome :: cairo_serde :: call :: FCall < P , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_program_info") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn get_state (& self ,) -> cainome :: cairo_serde :: call :: FCall < P , (starknet :: core :: types :: Felt , starknet :: core :: types :: Felt , starknet :: core :: types :: Felt) > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("get_state") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn is_operator (& self , address : & cainome :: cairo_serde :: ContractAddress) -> cainome :: cairo_serde :: call :: FCall < P , bool > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (cainome :: cairo_serde :: ContractAddress :: cairo_serialize (address)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("is_operator") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)} # [allow (clippy :: ptr_arg)] # [allow (clippy :: too_many_arguments)] pub fn sn_to_appchain_messages (& self , message_hash : & starknet :: core :: types :: Felt) -> cainome :: cairo_serde :: call :: FCall < P , MessageToAppchainStatus > {use cainome :: cairo_serde :: CairoSerde ; let mut __calldata = vec ! [] ; __calldata . extend (starknet :: core :: types :: Felt :: cairo_serialize (message_hash)) ; let __call = starknet :: core :: types :: FunctionCall {contract_address : self . address , entry_point_selector : starknet :: macros :: selector ! ("sn_to_appchain_messages") , calldata : __calldata ,} ; cainome :: cairo_serde :: call :: FCall :: new (__call , self . provider () ,)}} \ No newline at end of file +#[derive()] pub struct Appchain < A : starknet :: accounts :: ConnectedAccount ++ Sync > +{ + pub address : starknet :: core :: types :: Felt, pub account : A, pub + block_id : starknet :: core :: types :: BlockId, +} impl < A : starknet :: accounts :: ConnectedAccount + Sync > Appchain < A > +{ + pub fn new(address : starknet :: core :: types :: Felt, account : A) -> + Self + { + Self + { + address, account, block_id : starknet :: core :: types :: BlockId + :: Tag(starknet :: core :: types :: BlockTag :: Pending) + } + } pub fn + set_contract_address(& mut self, address : starknet :: core :: types :: + Felt) { self.address = address; } pub fn provider(& self) -> & A :: + Provider { self.account.provider() } pub fn + set_block(& mut self, block_id : starknet :: core :: types :: BlockId) + { self.block_id = block_id; } pub fn + with_block(self, block_id : starknet :: core :: types :: BlockId) -> Self + { Self { block_id, .. self } } +} #[derive()] pub struct AppchainReader < P : starknet :: providers :: +Provider + Sync > +{ + pub address : starknet :: core :: types :: Felt, pub provider : P, pub + block_id : starknet :: core :: types :: BlockId, +} impl < P : starknet :: providers :: Provider + Sync > AppchainReader < P > +{ + pub fn new(address : starknet :: core :: types :: Felt, provider : P,) -> + Self + { + Self + { + address, provider, block_id : starknet :: core :: types :: BlockId + :: Tag(starknet :: core :: types :: BlockTag :: Pending) + } + } pub fn + set_contract_address(& mut self, address : starknet :: core :: types :: + Felt) { self.address = address; } pub fn provider(& self) -> & P + { & self.provider } pub fn + set_block(& mut self, block_id : starknet :: core :: types :: BlockId) + { self.block_id = block_id; } pub fn + with_block(self, block_id : starknet :: core :: types :: BlockId) -> Self + { Self { block_id, .. self } } +} #[derive()] pub struct ContractChanges +{ + pub addr : starknet :: core :: types :: Felt, pub nonce : starknet :: core + :: types :: Felt, pub class_hash : Option < starknet :: core :: types :: + Felt > , pub storage_changes : Vec < + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) > +} impl cainome :: cairo_serde :: CairoSerde for ContractChanges +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.addr); __size += starknet :: core :: + types :: Felt :: cairo_serialized_size(& __rust.nonce); __size += + Option :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& __rust.class_hash); __size += Vec :: < + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) + > :: cairo_serialized_size(& __rust.storage_changes); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.addr)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.nonce)); + __out.extend(Option :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.class_hash)); + __out.extend(Vec :: < + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) + > :: cairo_serialize(& __rust.storage_changes)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let addr = starknet :: core :: types :: + Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += starknet + :: core :: types :: Felt :: cairo_serialized_size(& addr); let nonce = + starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& nonce); let class_hash = + Option :: < starknet :: core :: types :: Felt > :: + cairo_deserialize(__felts, __offset) ? ; __offset += Option :: < + starknet :: core :: types :: Felt > :: + cairo_serialized_size(& class_hash); let storage_changes = Vec :: < + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) + > :: cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) + > :: cairo_serialized_size(& storage_changes); + Ok(ContractChanges { addr, nonce, class_hash, storage_changes }) + } +} #[derive()] pub struct LogStateTransitionFact +{ pub state_transition_fact : cainome :: cairo_serde :: U256 } impl cainome :: +cairo_serde :: CairoSerde for LogStateTransitionFact +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: U256 :: + cairo_serialized_size(& __rust.state_transition_fact); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: U256 :: + cairo_serialize(& __rust.state_transition_fact)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let state_transition_fact = cainome :: + cairo_serde :: U256 :: cairo_deserialize(__felts, __offset) ? ; + __offset += cainome :: cairo_serde :: U256 :: + cairo_serialized_size(& state_transition_fact); + Ok(LogStateTransitionFact { state_transition_fact }) + } +} impl LogStateTransitionFact +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("LogStateTransitionFact").unwrap() + } pub fn event_name() -> & 'static str { "LogStateTransitionFact" } +} #[derive()] pub struct LogStateUpdate +{ + pub state_root : starknet :: core :: types :: Felt, pub block_number : + starknet :: core :: types :: Felt, pub block_hash : starknet :: core :: + types :: Felt +} impl cainome :: cairo_serde :: CairoSerde for LogStateUpdate +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.state_root); __size += starknet :: core + :: types :: Felt :: cairo_serialized_size(& __rust.block_number); + __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.block_hash); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.state_root)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.block_number)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.block_hash)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let state_root = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& state_root); let block_number = starknet :: + core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; + __offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_number); let block_hash = starknet :: + core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; + __offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_hash); + Ok(LogStateUpdate { state_root, block_number, block_hash }) + } +} impl LogStateUpdate +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("LogStateUpdate").unwrap() + } pub fn event_name() -> & 'static str { "LogStateUpdate" } +} #[derive()] pub struct MessageCanceled +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub selector : starknet :: core :: types :: Felt, pub + payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet + :: core :: types :: Felt +} impl cainome :: cairo_serde :: CairoSerde for MessageCanceled +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.selector); __size += Vec :: < starknet + :: core :: types :: Felt > :: cairo_serialized_size(& __rust.payload); + __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.nonce); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.selector)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.nonce)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = starknet :: core :: types + :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = Vec :: < starknet :: + core :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; + __offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); + Ok(MessageCanceled + { message_hash, from, to, selector, payload, nonce }) + } +} impl MessageCanceled +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageCanceled").unwrap() + } pub fn event_name() -> & 'static str { "MessageCanceled" } +} #[derive()] pub struct MessageCancellationStarted +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub selector : starknet :: core :: types :: Felt, pub + payload : Vec < starknet :: core :: types :: Felt > , pub nonce : starknet + :: core :: types :: Felt +} impl cainome :: cairo_serde :: CairoSerde for MessageCancellationStarted +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.selector); __size += Vec :: < starknet + :: core :: types :: Felt > :: cairo_serialized_size(& __rust.payload); + __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.nonce); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.selector)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.nonce)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = starknet :: core :: types + :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = Vec :: < starknet :: + core :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; + __offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); + Ok(MessageCancellationStarted + { message_hash, from, to, selector, payload, nonce }) + } +} impl MessageCancellationStarted +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageCancellationStarted").unwrap() + } pub fn event_name() -> & 'static str { "MessageCancellationStarted" } +} #[derive()] pub struct MessageConsumed +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub payload : Vec < starknet :: core :: types :: Felt > +} impl cainome :: cairo_serde :: CairoSerde for MessageConsumed +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& __rust.payload); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = Vec :: < starknet :: core + :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; + __offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); + Ok(MessageConsumed { message_hash, from, to, payload }) + } +} impl MessageConsumed +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageConsumed").unwrap() + } pub fn event_name() -> & 'static str { "MessageConsumed" } +} #[derive()] pub struct MessageSent +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub selector : starknet :: core :: types :: Felt, pub + nonce : starknet :: core :: types :: Felt, pub payload : Vec < starknet :: + core :: types :: Felt > +} impl cainome :: cairo_serde :: CairoSerde for MessageSent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.selector); __size += starknet :: core + :: types :: Felt :: cairo_serialized_size(& __rust.nonce); __size += + Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& __rust.payload); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.selector)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.nonce)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = starknet :: core :: types + :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); + let payload = Vec :: < starknet :: core :: types :: Felt > :: + cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < starknet + :: core :: types :: Felt > :: cairo_serialized_size(& payload); + Ok(MessageSent { message_hash, from, to, selector, nonce, payload }) + } +} impl MessageSent +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageSent").unwrap() + } pub fn event_name() -> & 'static str { "MessageSent" } +} #[derive()] pub struct MessageToAppchain +{ + pub from_address : cainome :: cairo_serde :: ContractAddress, pub + to_address : cainome :: cairo_serde :: ContractAddress, pub nonce : + starknet :: core :: types :: Felt, pub selector : starknet :: core :: + types :: Felt, pub payload : Vec < starknet :: core :: types :: Felt > +} impl cainome :: cairo_serde :: CairoSerde for MessageToAppchain +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: + ContractAddress :: cairo_serialized_size(& __rust.from_address); + __size += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.to_address); __size += starknet :: core + :: types :: Felt :: cairo_serialized_size(& __rust.nonce); __size += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.selector); __size += Vec :: < starknet + :: core :: types :: Felt > :: cairo_serialized_size(& __rust.payload); + __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from_address)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to_address)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.nonce)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.selector)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let from_address = cainome :: cairo_serde + :: ContractAddress :: cairo_deserialize(__felts, __offset) ? ; + __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from_address); let to_address = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to_address); let nonce = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); + let selector = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& selector); let payload = + Vec :: < starknet :: core :: types :: Felt > :: + cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < starknet + :: core :: types :: Felt > :: cairo_serialized_size(& payload); + Ok(MessageToAppchain + { from_address, to_address, nonce, selector, payload }) + } +} #[derive()] pub struct MessageToAppchainSealed +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub selector : starknet :: core :: types :: Felt, pub + nonce : starknet :: core :: types :: Felt, pub payload : Vec < starknet :: + core :: types :: Felt > +} impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainSealed +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.selector); __size += starknet :: core + :: types :: Felt :: cairo_serialized_size(& __rust.nonce); __size += + Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& __rust.payload); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.selector)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.nonce)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = starknet :: core :: types + :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: cairo_serialized_size(& nonce); + let payload = Vec :: < starknet :: core :: types :: Felt > :: + cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < starknet + :: core :: types :: Felt > :: cairo_serialized_size(& payload); + Ok(MessageToAppchainSealed + { message_hash, from, to, selector, nonce, payload }) + } +} impl MessageToAppchainSealed +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageToAppchainSealed").unwrap() + } pub fn event_name() -> & 'static str { "MessageToAppchainSealed" } +} #[derive()] pub struct MessageToStarknet +{ + pub from_address : cainome :: cairo_serde :: ContractAddress, pub + to_address : cainome :: cairo_serde :: ContractAddress, pub payload : Vec + < starknet :: core :: types :: Felt > +} impl cainome :: cairo_serde :: CairoSerde for MessageToStarknet +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: + ContractAddress :: cairo_serialized_size(& __rust.from_address); + __size += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.to_address); __size += Vec :: < + starknet :: core :: types :: Felt > :: + cairo_serialized_size(& __rust.payload); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from_address)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to_address)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let from_address = cainome :: cairo_serde + :: ContractAddress :: cairo_deserialize(__felts, __offset) ? ; + __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from_address); let to_address = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to_address); let payload = Vec :: < starknet + :: core :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; + __offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); + Ok(MessageToStarknet { from_address, to_address, payload }) + } +} #[derive()] pub struct MessageToStarknetReceived +{ + pub message_hash : starknet :: core :: types :: Felt, pub from : cainome + :: cairo_serde :: ContractAddress, pub to : cainome :: cairo_serde :: + ContractAddress, pub payload : Vec < starknet :: core :: types :: Felt > +} impl cainome :: cairo_serde :: CairoSerde for MessageToStarknetReceived +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.message_hash); __size += cainome :: + cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.from); __size += cainome :: cairo_serde + :: ContractAddress :: cairo_serialized_size(& __rust.to); __size += + Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& __rust.payload); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.message_hash)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.from)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.to)); + __out.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(& __rust.payload)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let message_hash = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = cainome :: cairo_serde :: + ContractAddress :: cairo_deserialize(__felts, __offset) ? ; __offset + += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = Vec :: < starknet :: core + :: types :: Felt > :: cairo_deserialize(__felts, __offset) ? ; + __offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); + Ok(MessageToStarknetReceived { message_hash, from, to, payload }) + } +} impl MessageToStarknetReceived +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("MessageToStarknetReceived").unwrap() + } pub fn event_name() -> & 'static str { "MessageToStarknetReceived" } +} #[derive()] pub struct OwnershipTransferStarted +{ + pub previous_owner : cainome :: cairo_serde :: ContractAddress, pub + new_owner : cainome :: cairo_serde :: ContractAddress +} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferStarted +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: + ContractAddress :: cairo_serialized_size(& __rust.previous_owner); + __size += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.new_owner); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.previous_owner)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.new_owner)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let previous_owner = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); + Ok(OwnershipTransferStarted { previous_owner, new_owner }) + } +} impl OwnershipTransferStarted +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferStarted").unwrap() + } pub fn event_name() -> & 'static str { "OwnershipTransferStarted" } +} #[derive()] pub struct OwnershipTransferred +{ + pub previous_owner : cainome :: cairo_serde :: ContractAddress, pub + new_owner : cainome :: cairo_serde :: ContractAddress +} impl cainome :: cairo_serde :: CairoSerde for OwnershipTransferred +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: + ContractAddress :: cairo_serialized_size(& __rust.previous_owner); + __size += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& __rust.new_owner); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.previous_owner)); + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.new_owner)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let previous_owner = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = cainome :: + cairo_serde :: ContractAddress :: cairo_deserialize(__felts, __offset) + ? ; __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); + Ok(OwnershipTransferred { previous_owner, new_owner }) + } +} impl OwnershipTransferred +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferred").unwrap() + } pub fn event_name() -> & 'static str { "OwnershipTransferred" } +} #[derive()] pub struct ProgramInfoChanged +{ + pub changed_by : cainome :: cairo_serde :: ContractAddress, pub + old_program_hash : starknet :: core :: types :: Felt, pub new_program_hash + : starknet :: core :: types :: Felt, pub old_config_hash : starknet :: + core :: types :: Felt, pub new_config_hash : starknet :: core :: types :: + Felt +} impl cainome :: cairo_serde :: CairoSerde for ProgramInfoChanged +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: + ContractAddress :: cairo_serialized_size(& __rust.changed_by); __size + += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.old_program_hash); __size += starknet + :: core :: types :: Felt :: + cairo_serialized_size(& __rust.new_program_hash); __size += starknet + :: core :: types :: Felt :: + cairo_serialized_size(& __rust.old_config_hash); __size += starknet :: + core :: types :: Felt :: + cairo_serialized_size(& __rust.new_config_hash); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(& __rust.changed_by)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.old_program_hash)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.new_program_hash)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.old_config_hash)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.new_config_hash)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let changed_by = cainome :: cairo_serde + :: ContractAddress :: cairo_deserialize(__felts, __offset) ? ; + __offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& changed_by); let old_program_hash = starknet + :: core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; + __offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_program_hash); let new_program_hash = + starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& new_program_hash); let + old_config_hash = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& old_config_hash); let + new_config_hash = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& new_config_hash); + Ok(ProgramInfoChanged + { + changed_by, old_program_hash, new_program_hash, old_config_hash, + new_config_hash + }) + } +} impl ProgramInfoChanged +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("ProgramInfoChanged").unwrap() + } pub fn event_name() -> & 'static str { "ProgramInfoChanged" } +} #[derive()] pub struct StarknetOsOutput +{ + pub initial_root : starknet :: core :: types :: Felt, pub final_root : + starknet :: core :: types :: Felt, pub prev_block_number : starknet :: + core :: types :: Felt, pub new_block_number : starknet :: core :: types :: + Felt, pub prev_block_hash : starknet :: core :: types :: Felt, pub + new_block_hash : starknet :: core :: types :: Felt, pub os_program_hash : + starknet :: core :: types :: Felt, pub starknet_os_config_hash : starknet + :: core :: types :: Felt, pub use_kzg_da : starknet :: core :: types :: + Felt, pub full_output : starknet :: core :: types :: Felt, pub + messages_to_l1 : Vec < MessageToStarknet > , pub messages_to_l2 : Vec < + MessageToAppchain > , pub contracts : Vec < ContractChanges > , pub + classes : Vec < + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) > +} impl cainome :: cairo_serde :: CairoSerde for StarknetOsOutput +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.initial_root); __size += starknet :: + core :: types :: Felt :: cairo_serialized_size(& __rust.final_root); + __size += starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.prev_block_number); __size += starknet + :: core :: types :: Felt :: + cairo_serialized_size(& __rust.new_block_number); __size += starknet + :: core :: types :: Felt :: + cairo_serialized_size(& __rust.prev_block_hash); __size += starknet :: + core :: types :: Felt :: + cairo_serialized_size(& __rust.new_block_hash); __size += starknet :: + core :: types :: Felt :: + cairo_serialized_size(& __rust.os_program_hash); __size += starknet :: + core :: types :: Felt :: + cairo_serialized_size(& __rust.starknet_os_config_hash); __size += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& __rust.use_kzg_da); __size += starknet :: core + :: types :: Felt :: cairo_serialized_size(& __rust.full_output); + __size += Vec :: < MessageToStarknet > :: + cairo_serialized_size(& __rust.messages_to_l1); __size += Vec :: < + MessageToAppchain > :: cairo_serialized_size(& __rust.messages_to_l2); + __size += Vec :: < ContractChanges > :: + cairo_serialized_size(& __rust.contracts); __size += Vec :: < + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) + > :: cairo_serialized_size(& __rust.classes); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.initial_root)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.final_root)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.prev_block_number)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.new_block_number)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.prev_block_hash)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.new_block_hash)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.os_program_hash)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.starknet_os_config_hash)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.use_kzg_da)); + __out.extend(starknet :: core :: types :: Felt :: + cairo_serialize(& __rust.full_output)); + __out.extend(Vec :: < MessageToStarknet > :: + cairo_serialize(& __rust.messages_to_l1)); + __out.extend(Vec :: < MessageToAppchain > :: + cairo_serialize(& __rust.messages_to_l2)); + __out.extend(Vec :: < ContractChanges > :: + cairo_serialize(& __rust.contracts)); + __out.extend(Vec :: < + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) + > :: cairo_serialize(& __rust.classes)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let initial_root = starknet :: core :: + types :: Felt :: cairo_deserialize(__felts, __offset) ? ; __offset += + starknet :: core :: types :: Felt :: + cairo_serialized_size(& initial_root); let final_root = starknet :: + core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; + __offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& final_root); let prev_block_number = starknet + :: core :: types :: Felt :: cairo_deserialize(__felts, __offset) ? ; + __offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& prev_block_number); let new_block_number = + starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& new_block_number); let + prev_block_hash = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& prev_block_hash); let + new_block_hash = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& new_block_hash); let + os_program_hash = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& os_program_hash); let + starknet_os_config_hash = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& starknet_os_config_hash); + let use_kzg_da = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& use_kzg_da); let + full_output = starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset) ? ; __offset += starknet :: core + :: types :: Felt :: cairo_serialized_size(& full_output); let + messages_to_l1 = Vec :: < MessageToStarknet > :: + cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < + MessageToStarknet > :: cairo_serialized_size(& messages_to_l1); let + messages_to_l2 = Vec :: < MessageToAppchain > :: + cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < + MessageToAppchain > :: cairo_serialized_size(& messages_to_l2); let + contracts = Vec :: < ContractChanges > :: + cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < + ContractChanges > :: cairo_serialized_size(& contracts); let classes = + Vec :: < + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) + > :: cairo_deserialize(__felts, __offset) ? ; __offset += Vec :: < + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) + > :: cairo_serialized_size(& classes); + Ok(StarknetOsOutput + { + initial_root, final_root, prev_block_number, new_block_number, + prev_block_hash, new_block_hash, os_program_hash, + starknet_os_config_hash, use_kzg_da, full_output, messages_to_l1, + messages_to_l2, contracts, classes + }) + } +} #[derive()] pub struct Upgraded +{ pub class_hash : cainome :: cairo_serde :: ClassHash } impl cainome :: +cairo_serde :: CairoSerde for Upgraded +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + let mut __size = 0; __size += cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& __rust.class_hash); __size + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + let mut __out : Vec < starknet :: core :: types :: Felt > = vec! []; + __out.extend(cainome :: cairo_serde :: ClassHash :: + cairo_serialize(& __rust.class_hash)); __out + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let mut __offset = __offset; let class_hash = cainome :: cairo_serde + :: ClassHash :: cairo_deserialize(__felts, __offset) ? ; __offset += + cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& class_hash); Ok(Upgraded { class_hash }) + } +} impl Upgraded +{ + pub fn event_selector() -> starknet :: core :: types :: Felt + { + starknet :: core :: utils :: + get_selector_from_name("Upgraded").unwrap() + } pub fn event_name() -> & 'static str { "Upgraded" } +} #[derive()] pub enum AppchainEvent +{ + OwnableEvent(OwnableEvent), UpgradeableEvent(UpgradeableEvent), + ConfigEvent(ConfigEvent), MessagingEvent(MessagingEvent), + ReentrancyGuardEvent(ReentrancyguardEvent), StateEvent(StateEvent), + LogStateUpdate(LogStateUpdate), + LogStateTransitionFact(LogStateTransitionFact) +} impl cainome :: cairo_serde :: CairoSerde for AppchainEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + AppchainEvent :: OwnableEvent(val) => OwnableEvent :: + cairo_serialized_size(val) + 1, AppchainEvent :: + UpgradeableEvent(val) => UpgradeableEvent :: + cairo_serialized_size(val) + 1, AppchainEvent :: ConfigEvent(val) + => ConfigEvent :: cairo_serialized_size(val) + 1, AppchainEvent :: + MessagingEvent(val) => MessagingEvent :: + cairo_serialized_size(val) + 1, AppchainEvent :: + ReentrancyGuardEvent(val) => ReentrancyguardEvent :: + cairo_serialized_size(val) + 1, AppchainEvent :: StateEvent(val) + => StateEvent :: cairo_serialized_size(val) + 1, AppchainEvent :: + LogStateUpdate(val) => LogStateUpdate :: + cairo_serialized_size(val) + 1, AppchainEvent :: + LogStateTransitionFact(val) => LogStateTransitionFact :: + cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + AppchainEvent :: OwnableEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 0usize)); + temp.extend(OwnableEvent :: cairo_serialize(val)); temp + }, AppchainEvent :: UpgradeableEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 1usize)); + temp.extend(UpgradeableEvent :: cairo_serialize(val)); temp + }, AppchainEvent :: ConfigEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 2usize)); + temp.extend(ConfigEvent :: cairo_serialize(val)); temp + }, AppchainEvent :: MessagingEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 3usize)); + temp.extend(MessagingEvent :: cairo_serialize(val)); temp + }, AppchainEvent :: ReentrancyGuardEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 4usize)); + temp.extend(ReentrancyguardEvent :: cairo_serialize(val)); + temp + }, AppchainEvent :: StateEvent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 5usize)); + temp.extend(StateEvent :: cairo_serialize(val)); temp + }, AppchainEvent :: LogStateUpdate(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 6usize)); + temp.extend(LogStateUpdate :: cairo_serialize(val)); temp + }, AppchainEvent :: LogStateTransitionFact(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 7usize)); + temp.extend(LogStateTransitionFact :: cairo_serialize(val)); + temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => + Ok(AppchainEvent :: + OwnableEvent(OwnableEvent :: + cairo_deserialize(__felts, __offset + 1) ?)), 1usize => + Ok(AppchainEvent :: + UpgradeableEvent(UpgradeableEvent :: + cairo_deserialize(__felts, __offset + 1) ?)), 2usize => + Ok(AppchainEvent :: + ConfigEvent(ConfigEvent :: + cairo_deserialize(__felts, __offset + 1) ?)), 3usize => + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + cairo_deserialize(__felts, __offset + 1) ?)), 4usize => + Ok(AppchainEvent :: + ReentrancyGuardEvent(ReentrancyguardEvent :: + cairo_deserialize(__felts, __offset + 1) ?)), 5usize => + Ok(AppchainEvent :: + StateEvent(StateEvent :: cairo_deserialize(__felts, __offset + 1) + ?)), 6usize => + Ok(AppchainEvent :: + LogStateUpdate(LogStateUpdate :: + cairo_deserialize(__felts, __offset + 1) ?)), 7usize => + Ok(AppchainEvent :: + LogStateTransitionFact(LogStateTransitionFact :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "AppchainEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for +AppchainEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferred").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "OwnershipTransferred")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(AppchainEvent :: + OwnableEvent(OwnableEvent :: + OwnershipTransferred(OwnershipTransferred + { previous_owner, new_owner }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("OwnershipTransferStarted").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "OwnershipTransferStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(AppchainEvent :: + OwnableEvent(OwnableEvent :: + OwnershipTransferStarted(OwnershipTransferStarted + { previous_owner, new_owner }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("Upgraded").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "Upgraded")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + class_hash = match cainome :: cairo_serde :: ClassHash :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "class_hash", + "Upgraded", e)), + }; data_offset += cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& class_hash); return + Ok(AppchainEvent :: + UpgradeableEvent(UpgradeableEvent :: + Upgraded(Upgraded { class_hash }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("ProgramInfoChanged").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "ProgramInfoChanged")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + changed_by = match cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "changed_by", + "ProgramInfoChanged", e)), + }; data_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& changed_by); let old_program_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_program_hash); let new_program_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_program_hash); let old_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_config_hash); let new_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_config_hash); return + Ok(AppchainEvent :: + ConfigEvent(ConfigEvent :: + ProgramInfoChanged(ProgramInfoChanged + { + changed_by, old_program_hash, new_program_hash, + old_config_hash, new_config_hash + }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageSent").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageSent")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageSent", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageSent", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageSent(MessageSent + { message_hash, from, to, selector, nonce, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageConsumed").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageConsumed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageConsumed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageConsumed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageConsumed(MessageConsumed + { message_hash, from, to, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCancellationStarted").unwrap_or_else(| + _ | panic! ("Invalid selector for {}", "MessageCancellationStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCancellationStarted", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCancellationStarted", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageCancellationStarted(MessageCancellationStarted + { message_hash, from, to, selector, payload, nonce }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCanceled").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageCanceled")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCanceled", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCanceled", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageCanceled(MessageCanceled + { message_hash, from, to, selector, payload, nonce }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToStarknetReceived").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "MessageToStarknetReceived")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToStarknetReceived", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToStarknetReceived", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageToStarknetReceived(MessageToStarknetReceived + { message_hash, from, to, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToAppchainSealed").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "MessageToAppchainSealed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToAppchainSealed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToAppchainSealed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageToAppchainSealed(MessageToAppchainSealed + { message_hash, from, to, selector, nonce, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("LogStateUpdate").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "LogStateUpdate")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + state_root = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "state_root", + "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& state_root); let block_number = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "block_number", "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_number); let block_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "block_hash", + "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_hash); return + Ok(AppchainEvent :: + LogStateUpdate(LogStateUpdate + { state_root, block_number, block_hash })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("LogStateTransitionFact").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "LogStateTransitionFact")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + state_transition_fact = match cainome :: cairo_serde :: U256 :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "state_transition_fact", "LogStateTransitionFact", e)), + }; data_offset += cainome :: cairo_serde :: U256 :: + cairo_serialized_size(& state_transition_fact); return + Ok(AppchainEvent :: + LogStateTransitionFact(LogStateTransitionFact + { state_transition_fact })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for AppchainEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferred").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "OwnershipTransferred")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(AppchainEvent :: + OwnableEvent(OwnableEvent :: + OwnershipTransferred(OwnershipTransferred + { previous_owner, new_owner }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("OwnershipTransferStarted").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "OwnershipTransferStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(AppchainEvent :: + OwnableEvent(OwnableEvent :: + OwnershipTransferStarted(OwnershipTransferStarted + { previous_owner, new_owner }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("Upgraded").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "Upgraded")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + class_hash = match cainome :: cairo_serde :: ClassHash :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "class_hash", + "Upgraded", e)), + }; data_offset += cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& class_hash); return + Ok(AppchainEvent :: + UpgradeableEvent(UpgradeableEvent :: + Upgraded(Upgraded { class_hash }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("ProgramInfoChanged").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "ProgramInfoChanged")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + changed_by = match cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "changed_by", + "ProgramInfoChanged", e)), + }; data_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& changed_by); let old_program_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_program_hash); let new_program_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_program_hash); let old_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_config_hash); let new_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_config_hash); return + Ok(AppchainEvent :: + ConfigEvent(ConfigEvent :: + ProgramInfoChanged(ProgramInfoChanged + { + changed_by, old_program_hash, new_program_hash, + old_config_hash, new_config_hash + }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageSent").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageSent")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageSent", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageSent", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageSent(MessageSent + { message_hash, from, to, selector, nonce, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageConsumed").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageConsumed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageConsumed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageConsumed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageConsumed(MessageConsumed + { message_hash, from, to, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCancellationStarted").unwrap_or_else(| + _ | panic! ("Invalid selector for {}", "MessageCancellationStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCancellationStarted", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCancellationStarted", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageCancellationStarted(MessageCancellationStarted + { message_hash, from, to, selector, payload, nonce }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCanceled").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageCanceled")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCanceled", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCanceled", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageCanceled(MessageCanceled + { message_hash, from, to, selector, payload, nonce }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToStarknetReceived").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "MessageToStarknetReceived")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToStarknetReceived", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToStarknetReceived", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageToStarknetReceived(MessageToStarknetReceived + { message_hash, from, to, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToAppchainSealed").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "MessageToAppchainSealed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToAppchainSealed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToAppchainSealed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(AppchainEvent :: + MessagingEvent(MessagingEvent :: + MessageToAppchainSealed(MessageToAppchainSealed + { message_hash, from, to, selector, nonce, payload }))) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("LogStateUpdate").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "LogStateUpdate")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + state_root = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "state_root", + "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& state_root); let block_number = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "block_number", "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_number); let block_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "block_hash", + "LogStateUpdate", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& block_hash); return + Ok(AppchainEvent :: + LogStateUpdate(LogStateUpdate + { state_root, block_number, block_hash })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("LogStateTransitionFact").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "LogStateTransitionFact")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + state_transition_fact = match cainome :: cairo_serde :: U256 :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "state_transition_fact", "LogStateTransitionFact", e)), + }; data_offset += cainome :: cairo_serde :: U256 :: + cairo_serialized_size(& state_transition_fact); return + Ok(AppchainEvent :: + LogStateTransitionFact(LogStateTransitionFact + { state_transition_fact })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum ConfigEvent { ProgramInfoChanged(ProgramInfoChanged) } +impl cainome :: cairo_serde :: CairoSerde for ConfigEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + ConfigEvent :: ProgramInfoChanged(val) => ProgramInfoChanged :: + cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + ConfigEvent :: ProgramInfoChanged(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 0usize)); + temp.extend(ProgramInfoChanged :: cairo_serialize(val)); temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => + Ok(ConfigEvent :: + ProgramInfoChanged(ProgramInfoChanged :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "ConfigEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for ConfigEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("ProgramInfoChanged").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "ProgramInfoChanged")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + changed_by = match cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "changed_by", + "ProgramInfoChanged", e)), + }; data_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& changed_by); let old_program_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_program_hash); let new_program_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_program_hash); let old_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_config_hash); let new_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_config_hash); return + Ok(ConfigEvent :: + ProgramInfoChanged(ProgramInfoChanged + { + changed_by, old_program_hash, new_program_hash, + old_config_hash, new_config_hash + })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for ConfigEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("ProgramInfoChanged").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "ProgramInfoChanged")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + changed_by = match cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "changed_by", + "ProgramInfoChanged", e)), + }; data_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& changed_by); let old_program_hash = match + starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_program_hash); let new_program_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_program_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_program_hash); let old_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "old_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& old_config_hash); let new_config_hash = + match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "new_config_hash", "ProgramInfoChanged", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& new_config_hash); return + Ok(ConfigEvent :: + ProgramInfoChanged(ProgramInfoChanged + { + changed_by, old_program_hash, new_program_hash, + old_config_hash, new_config_hash + })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum MessageToAppchainStatus +{ NotSent, Sealed, Cancelled, Pending(starknet :: core :: types :: Felt) } +impl cainome :: cairo_serde :: CairoSerde for MessageToAppchainStatus +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + MessageToAppchainStatus :: NotSent => 1, MessageToAppchainStatus + :: Sealed => 1, MessageToAppchainStatus :: Cancelled => 1, + MessageToAppchainStatus :: Pending(val) => starknet :: core :: + types :: Felt :: cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + MessageToAppchainStatus :: NotSent => usize :: + cairo_serialize(& 0usize), MessageToAppchainStatus :: Sealed => + usize :: cairo_serialize(& 1usize), MessageToAppchainStatus :: + Cancelled => usize :: cairo_serialize(& 2usize), + MessageToAppchainStatus :: Pending(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 3usize)); + temp.extend(starknet :: core :: types :: Felt :: + cairo_serialize(val)); temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => Ok(MessageToAppchainStatus :: NotSent), 1usize => + Ok(MessageToAppchainStatus :: Sealed), 2usize => + Ok(MessageToAppchainStatus :: Cancelled), 3usize => + Ok(MessageToAppchainStatus :: + Pending(starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "MessageToAppchainStatus"))) + } + } +} #[derive()] pub enum MessageToStarknetStatus +{ NothingToConsume, ReadyToConsume(starknet :: core :: types :: Felt) } impl +cainome :: cairo_serde :: CairoSerde for MessageToStarknetStatus +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + MessageToStarknetStatus :: NothingToConsume => 1, + MessageToStarknetStatus :: ReadyToConsume(val) => starknet :: core + :: types :: Felt :: cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + MessageToStarknetStatus :: NothingToConsume => usize :: + cairo_serialize(& 0usize), MessageToStarknetStatus :: + ReadyToConsume(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 1usize)); + temp.extend(starknet :: core :: types :: Felt :: + cairo_serialize(val)); temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => Ok(MessageToStarknetStatus :: NothingToConsume), 1usize + => + Ok(MessageToStarknetStatus :: + ReadyToConsume(starknet :: core :: types :: Felt :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "MessageToStarknetStatus"))) + } + } +} #[derive()] pub enum MessagingEvent +{ + MessageSent(MessageSent), MessageConsumed(MessageConsumed), + MessageCancellationStarted(MessageCancellationStarted), + MessageCanceled(MessageCanceled), + MessageToStarknetReceived(MessageToStarknetReceived), + MessageToAppchainSealed(MessageToAppchainSealed) +} impl cainome :: cairo_serde :: CairoSerde for MessagingEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + MessagingEvent :: MessageSent(val) => MessageSent :: + cairo_serialized_size(val) + 1, MessagingEvent :: + MessageConsumed(val) => MessageConsumed :: + cairo_serialized_size(val) + 1, MessagingEvent :: + MessageCancellationStarted(val) => MessageCancellationStarted :: + cairo_serialized_size(val) + 1, MessagingEvent :: + MessageCanceled(val) => MessageCanceled :: + cairo_serialized_size(val) + 1, MessagingEvent :: + MessageToStarknetReceived(val) => MessageToStarknetReceived :: + cairo_serialized_size(val) + 1, MessagingEvent :: + MessageToAppchainSealed(val) => MessageToAppchainSealed :: + cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + MessagingEvent :: MessageSent(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 0usize)); + temp.extend(MessageSent :: cairo_serialize(val)); temp + }, MessagingEvent :: MessageConsumed(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 1usize)); + temp.extend(MessageConsumed :: cairo_serialize(val)); temp + }, MessagingEvent :: MessageCancellationStarted(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 2usize)); + temp.extend(MessageCancellationStarted :: + cairo_serialize(val)); temp + }, MessagingEvent :: MessageCanceled(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 3usize)); + temp.extend(MessageCanceled :: cairo_serialize(val)); temp + }, MessagingEvent :: MessageToStarknetReceived(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 4usize)); + temp.extend(MessageToStarknetReceived :: + cairo_serialize(val)); temp + }, MessagingEvent :: MessageToAppchainSealed(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 5usize)); + temp.extend(MessageToAppchainSealed :: cairo_serialize(val)); + temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => + Ok(MessagingEvent :: + MessageSent(MessageSent :: + cairo_deserialize(__felts, __offset + 1) ?)), 1usize => + Ok(MessagingEvent :: + MessageConsumed(MessageConsumed :: + cairo_deserialize(__felts, __offset + 1) ?)), 2usize => + Ok(MessagingEvent :: + MessageCancellationStarted(MessageCancellationStarted :: + cairo_deserialize(__felts, __offset + 1) ?)), 3usize => + Ok(MessagingEvent :: + MessageCanceled(MessageCanceled :: + cairo_deserialize(__felts, __offset + 1) ?)), 4usize => + Ok(MessagingEvent :: + MessageToStarknetReceived(MessageToStarknetReceived :: + cairo_deserialize(__felts, __offset + 1) ?)), 5usize => + Ok(MessagingEvent :: + MessageToAppchainSealed(MessageToAppchainSealed :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "MessagingEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for +MessagingEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("MessageSent").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageSent")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageSent", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageSent", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageSent(MessageSent + { message_hash, from, to, selector, nonce, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageConsumed").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageConsumed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageConsumed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageConsumed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageConsumed(MessageConsumed + { message_hash, from, to, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCancellationStarted").unwrap_or_else(| + _ | panic! ("Invalid selector for {}", "MessageCancellationStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCancellationStarted", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCancellationStarted", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(MessagingEvent :: + MessageCancellationStarted(MessageCancellationStarted + { message_hash, from, to, selector, payload, nonce })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCanceled").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageCanceled")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCanceled", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCanceled", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(MessagingEvent :: + MessageCanceled(MessageCanceled + { message_hash, from, to, selector, payload, nonce })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToStarknetReceived").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "MessageToStarknetReceived")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToStarknetReceived", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToStarknetReceived", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageToStarknetReceived(MessageToStarknetReceived + { message_hash, from, to, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToAppchainSealed").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "MessageToAppchainSealed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToAppchainSealed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToAppchainSealed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageToAppchainSealed(MessageToAppchainSealed + { message_hash, from, to, selector, nonce, payload })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for MessagingEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("MessageSent").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageSent")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageSent", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageSent", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageSent", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageSent", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageSent(MessageSent + { message_hash, from, to, selector, nonce, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageConsumed").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageConsumed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageConsumed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageConsumed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageConsumed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageConsumed(MessageConsumed + { message_hash, from, to, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCancellationStarted").unwrap_or_else(| + _ | panic! ("Invalid selector for {}", "MessageCancellationStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCancellationStarted", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCancellationStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCancellationStarted", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCancellationStarted", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(MessagingEvent :: + MessageCancellationStarted(MessageCancellationStarted + { message_hash, from, to, selector, payload, nonce })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageCanceled").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "MessageCanceled")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageCanceled", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageCanceled", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageCanceled", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageCanceled", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); return + Ok(MessagingEvent :: + MessageCanceled(MessageCanceled + { message_hash, from, to, selector, payload, nonce })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToStarknetReceived").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "MessageToStarknetReceived")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToStarknetReceived", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToStarknetReceived", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let payload = match Vec :: < starknet + :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToStarknetReceived", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageToStarknetReceived(MessageToStarknetReceived + { message_hash, from, to, payload })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("MessageToAppchainSealed").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "MessageToAppchainSealed")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + message_hash = match starknet :: core :: types :: Felt :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "message_hash", "MessageToAppchainSealed", e)), + }; key_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& message_hash); let from = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "from", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& from); let to = match cainome :: + cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "to", + "MessageToAppchainSealed", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& to); let selector = match starknet :: core + :: types :: Felt :: cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "selector", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& selector); let nonce = match starknet :: + core :: types :: Felt :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "nonce", + "MessageToAppchainSealed", e)), + }; data_offset += starknet :: core :: types :: Felt :: + cairo_serialized_size(& nonce); let payload = match Vec :: < + starknet :: core :: types :: Felt > :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "payload", + "MessageToAppchainSealed", e)), + }; data_offset += Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialized_size(& payload); return + Ok(MessagingEvent :: + MessageToAppchainSealed(MessageToAppchainSealed + { message_hash, from, to, selector, nonce, payload })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum OwnableEvent +{ + OwnershipTransferred(OwnershipTransferred), + OwnershipTransferStarted(OwnershipTransferStarted) +} impl cainome :: cairo_serde :: CairoSerde for OwnableEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + OwnableEvent :: OwnershipTransferred(val) => OwnershipTransferred + :: cairo_serialized_size(val) + 1, OwnableEvent :: + OwnershipTransferStarted(val) => OwnershipTransferStarted :: + cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + OwnableEvent :: OwnershipTransferred(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 0usize)); + temp.extend(OwnershipTransferred :: cairo_serialize(val)); + temp + }, OwnableEvent :: OwnershipTransferStarted(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 1usize)); + temp.extend(OwnershipTransferStarted :: cairo_serialize(val)); + temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => + Ok(OwnableEvent :: + OwnershipTransferred(OwnershipTransferred :: + cairo_deserialize(__felts, __offset + 1) ?)), 1usize => + Ok(OwnableEvent :: + OwnershipTransferStarted(OwnershipTransferStarted :: + cairo_deserialize(__felts, __offset + 1) ?)), _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "OwnableEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for +OwnableEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferred").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "OwnershipTransferred")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(OwnableEvent :: + OwnershipTransferred(OwnershipTransferred + { previous_owner, new_owner })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("OwnershipTransferStarted").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "OwnershipTransferStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(OwnableEvent :: + OwnershipTransferStarted(OwnershipTransferStarted + { previous_owner, new_owner })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for OwnableEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("OwnershipTransferred").unwrap_or_else(| _ | + panic! ("Invalid selector for {}", "OwnershipTransferred")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferred", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(OwnableEvent :: + OwnershipTransferred(OwnershipTransferred + { previous_owner, new_owner })) + }; let selector = event.keys [0]; if selector == starknet :: core :: + utils :: + get_selector_from_name("OwnershipTransferStarted").unwrap_or_else(| _ + | panic! ("Invalid selector for {}", "OwnershipTransferStarted")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + previous_owner = match cainome :: cairo_serde :: ContractAddress + :: cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", + "previous_owner", "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& previous_owner); let new_owner = match + cainome :: cairo_serde :: ContractAddress :: + cairo_deserialize(& event.keys, key_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "new_owner", + "OwnershipTransferStarted", e)), + }; key_offset += cainome :: cairo_serde :: ContractAddress :: + cairo_serialized_size(& new_owner); return + Ok(OwnableEvent :: + OwnershipTransferStarted(OwnershipTransferStarted + { previous_owner, new_owner })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum ReentrancyguardEvent {} impl cainome :: cairo_serde :: +CairoSerde for ReentrancyguardEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { match __rust { _ => 0 } } fn + cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: core :: + types :: Felt > { match __rust { _ => vec! [] } } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "ReentrancyguardEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for +ReentrancyguardEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for +ReentrancyguardEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum StateEvent {} impl cainome :: cairo_serde :: CairoSerde +for StateEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { match __rust { _ => 0 } } fn + cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: core :: + types :: Felt > { match __rust { _ => vec! [] } } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "StateEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for StateEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for StateEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} #[derive()] pub enum UpgradeableEvent { Upgraded(Upgraded) } impl cainome :: +cairo_serde :: CairoSerde for UpgradeableEvent +{ + type RustType = Self; const SERIALIZED_SIZE : std :: option :: Option < + usize > = std :: option :: Option :: None; #[inline] fn + cairo_serialized_size(__rust : & Self :: RustType) -> usize + { + match __rust + { + UpgradeableEvent :: Upgraded(val) => Upgraded :: + cairo_serialized_size(val) + 1, _ => 0 + } + } fn cairo_serialize(__rust : & Self :: RustType) -> Vec < starknet :: + core :: types :: Felt > + { + match __rust + { + UpgradeableEvent :: Upgraded(val) => + { + let mut temp = vec! []; + temp.extend(usize :: cairo_serialize(& 0usize)); + temp.extend(Upgraded :: cairo_serialize(val)); temp + }, _ => vec! [] + } + } fn + cairo_deserialize(__felts : & [starknet :: core :: types :: Felt], + __offset : usize) -> cainome :: cairo_serde :: Result < Self :: RustType > + { + let __f = __felts [__offset]; let __index = u128 :: + from_be_bytes(__f.to_bytes_be() [16 ..].try_into().unwrap()); match + __index as usize + { + 0usize => + Ok(UpgradeableEvent :: + Upgraded(Upgraded :: cairo_deserialize(__felts, __offset + 1) ?)), + _ => return + Err(cainome :: cairo_serde :: Error :: + Deserialize(format! + ("Index not handle for enum {}", "UpgradeableEvent"))) + } + } +} impl TryFrom < & starknet :: core :: types :: EmittedEvent > for +UpgradeableEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: EmittedEvent) -> Result < + Self, Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("Upgraded").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "Upgraded")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + class_hash = match cainome :: cairo_serde :: ClassHash :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "class_hash", + "Upgraded", e)), + }; data_offset += cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& class_hash); return + Ok(UpgradeableEvent :: Upgraded(Upgraded { class_hash })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl TryFrom < & starknet :: core :: types :: Event > for UpgradeableEvent +{ + type Error = String; fn + try_from(event : & starknet :: core :: types :: Event) -> Result < Self, + Self :: Error > + { + use cainome :: cairo_serde :: CairoSerde; if event.keys.is_empty() + { return Err("Event has no key".to_string()); } let selector = + event.keys [0]; if selector == starknet :: core :: utils :: + get_selector_from_name("Upgraded").unwrap_or_else(| _ | panic! + ("Invalid selector for {}", "Upgraded")) + { + let mut key_offset = 0 + 1; let mut data_offset = 0; let + class_hash = match cainome :: cairo_serde :: ClassHash :: + cairo_deserialize(& event.data, data_offset) + { + Ok(v) => v, Err(e) => return + Err(format! + ("Could not deserialize field {} for {}: {:?}", "class_hash", + "Upgraded", e)), + }; data_offset += cainome :: cairo_serde :: ClassHash :: + cairo_serialized_size(& class_hash); return + Ok(UpgradeableEvent :: Upgraded(Upgraded { class_hash })) + }; + Err(format! ("Could not match any event from keys {:?}", event.keys)) + } +} impl < A : starknet :: accounts :: ConnectedAccount + Sync > Appchain < A > +{ + #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub fn + appchain_to_sn_messages(& self, message_hash : & starknet :: core :: types + :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider, + MessageToStarknetStatus > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(message_hash)); let __call = starknet :: core :: types + :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("appchain_to_sn_messages"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_facts_registry(& self,) -> cainome :: cairo_serde :: call :: FCall + < A :: Provider, cainome :: cairo_serde :: ContractAddress > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_facts_registry"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_program_info(& self,) -> cainome :: cairo_serde :: call :: FCall < + A :: Provider, + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_program_info"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_state(& self,) -> cainome :: cairo_serde :: call :: FCall < A :: + Provider, + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt, + starknet :: core :: types :: Felt) > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_state"), calldata : __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + is_operator(& self, address : & cainome :: cairo_serde :: ContractAddress) + -> cainome :: cairo_serde :: call :: FCall < A :: Provider, bool > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); let __call = starknet :: core :: types :: + FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("is_operator"), calldata : __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + sn_to_appchain_messages(& self, message_hash : & starknet :: core :: types + :: Felt) -> cainome :: cairo_serde :: call :: FCall < A :: Provider, + MessageToAppchainStatus > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(message_hash)); let __call = starknet :: core :: types + :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("sn_to_appchain_messages"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + cancel_message_getcall(& self, to_address : & cainome :: cairo_serde :: + ContractAddress, selector : & starknet :: core :: types :: Felt, payload : + & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: + core :: types :: Felt) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(nonce)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("cancel_message"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + cancel_message(& self, to_address : & cainome :: cairo_serde :: + ContractAddress, selector : & starknet :: core :: types :: Felt, payload : + & Vec :: < starknet :: core :: types :: Felt > , nonce : & starknet :: + core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(nonce)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("cancel_message"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + consume_message_from_appchain_getcall(& self, from_address : & cainome :: + cairo_serde :: ContractAddress, payload : & Vec :: < starknet :: core :: + types :: Felt >) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(from_address)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("consume_message_from_appchain"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + consume_message_from_appchain(& self, from_address : & cainome :: + cairo_serde :: ContractAddress, payload : & Vec :: < starknet :: core :: + types :: Felt >) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(from_address)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("consume_message_from_appchain"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + register_operator_getcall(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("register_operator"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + register_operator(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("register_operator"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + send_message_to_appchain_getcall(& self, to_address : & cainome :: + cairo_serde :: ContractAddress, selector : & starknet :: core :: types :: + Felt, payload : & Vec :: < starknet :: core :: types :: Felt >) -> + starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("send_message_to_appchain"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + send_message_to_appchain(& self, to_address : & cainome :: cairo_serde :: + ContractAddress, selector : & starknet :: core :: types :: Felt, payload : + & Vec :: < starknet :: core :: types :: Felt >) -> starknet :: accounts :: + ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("send_message_to_appchain"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + set_facts_registry_getcall(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("set_facts_registry"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + set_facts_registry(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("set_facts_registry"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + set_program_info_getcall(& self, program_hash : & starknet :: core :: + types :: Felt, config_hash : & starknet :: core :: types :: Felt) -> + starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(program_hash)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(config_hash)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("set_program_info"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + set_program_info(& self, program_hash : & starknet :: core :: types :: + Felt, config_hash : & starknet :: core :: types :: Felt) -> starknet :: + accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(program_hash)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(config_hash)); let __call = starknet :: core :: types + :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("set_program_info"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + start_message_cancellation_getcall(& self, to_address : & cainome :: + cairo_serde :: ContractAddress, selector : & starknet :: core :: types :: + Felt, payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & + starknet :: core :: types :: Felt) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(nonce)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("start_message_cancellation"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + start_message_cancellation(& self, to_address : & cainome :: cairo_serde + :: ContractAddress, selector : & starknet :: core :: types :: Felt, + payload : & Vec :: < starknet :: core :: types :: Felt > , nonce : & + starknet :: core :: types :: Felt) -> starknet :: accounts :: ExecutionV1 + < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(to_address)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(selector)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(payload)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(nonce)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("start_message_cancellation"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + unregister_operator_getcall(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("unregister_operator"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + unregister_operator(& self, address : & cainome :: cairo_serde :: + ContractAddress) -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); let __call = starknet :: core :: types :: + Call + { + to : self.address, selector : starknet :: macros :: selector! + ("unregister_operator"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn update_getcall(& self, program_output : & StarknetOsOutput) -> starknet + :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(StarknetOsOutput :: + cairo_serialize(program_output)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("update"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn update(& self, program_output : & StarknetOsOutput) -> starknet :: + accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(StarknetOsOutput :: + cairo_serialize(program_output)); let __call = starknet :: core :: + types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("update"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + update_state_getcall(& self, snos_output : & Vec :: < starknet :: core :: + types :: Felt > , program_output : & Vec :: < starknet :: core :: types :: + Felt > , onchain_data_hash : & starknet :: core :: types :: Felt, + onchain_data_size : & cainome :: cairo_serde :: U256) -> starknet :: core + :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(snos_output)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(program_output)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(onchain_data_hash)); + __calldata.extend(cainome :: cairo_serde :: U256 :: + cairo_serialize(onchain_data_size)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("update_state"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + update_state(& self, snos_output : & Vec :: < starknet :: core :: types :: + Felt > , program_output : & Vec :: < starknet :: core :: types :: Felt > , + onchain_data_hash : & starknet :: core :: types :: Felt, onchain_data_size + : & cainome :: cairo_serde :: U256) -> starknet :: accounts :: ExecutionV1 + < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(snos_output)); + __calldata.extend(Vec :: < starknet :: core :: types :: Felt > :: + cairo_serialize(program_output)); + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(onchain_data_hash)); + __calldata.extend(cainome :: cairo_serde :: U256 :: + cairo_serialize(onchain_data_size)); let __call = starknet :: core :: + types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("update_state"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + upgrade_getcall(& self, new_class_hash : & cainome :: cairo_serde :: + ClassHash) -> starknet :: core :: types :: Call + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ClassHash :: + cairo_serialize(new_class_hash)); starknet :: core :: types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("upgrade"), calldata : __calldata, + } + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn upgrade(& self, new_class_hash : & cainome :: cairo_serde :: ClassHash) + -> starknet :: accounts :: ExecutionV1 < A > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ClassHash :: + cairo_serialize(new_class_hash)); let __call = starknet :: core :: + types :: Call + { + to : self.address, selector : starknet :: macros :: selector! + ("upgrade"), calldata : __calldata, + }; self.account.execute_v1(vec! [__call]) + } +} impl < P : starknet :: providers :: Provider + Sync > AppchainReader < P > +{ + #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub fn + appchain_to_sn_messages(& self, message_hash : & starknet :: core :: types + :: Felt) -> cainome :: cairo_serde :: call :: FCall < P, + MessageToStarknetStatus > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(message_hash)); let __call = starknet :: core :: types + :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("appchain_to_sn_messages"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_facts_registry(& self,) -> cainome :: cairo_serde :: call :: FCall + < P, cainome :: cairo_serde :: ContractAddress > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_facts_registry"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_program_info(& self,) -> cainome :: cairo_serde :: call :: FCall < + P, (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt) + > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_program_info"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn get_state(& self,) -> cainome :: cairo_serde :: call :: FCall < P, + (starknet :: core :: types :: Felt, starknet :: core :: types :: Felt, + starknet :: core :: types :: Felt) > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; let __call = starknet :: core :: types :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("get_state"), calldata : __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + is_operator(& self, address : & cainome :: cairo_serde :: ContractAddress) + -> cainome :: cairo_serde :: call :: FCall < P, bool > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(cainome :: cairo_serde :: ContractAddress :: + cairo_serialize(address)); let __call = starknet :: core :: types :: + FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("is_operator"), calldata : __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } #[allow(clippy :: ptr_arg)] #[allow(clippy :: too_many_arguments)] pub + fn + sn_to_appchain_messages(& self, message_hash : & starknet :: core :: types + :: Felt) -> cainome :: cairo_serde :: call :: FCall < P, + MessageToAppchainStatus > + { + use cainome :: cairo_serde :: CairoSerde; let mut __calldata = vec! + []; + __calldata.extend(starknet :: core :: types :: Felt :: + cairo_serialize(message_hash)); let __call = starknet :: core :: types + :: FunctionCall + { + contract_address : self.address, entry_point_selector : starknet + :: macros :: selector! ("sn_to_appchain_messages"), calldata : + __calldata, + }; cainome :: cairo_serde :: call :: FCall :: + new(__call, self.provider(),) + } +} \ No newline at end of file diff --git a/scripts/cairo_fmt.sh b/scripts/cairo_fmt.sh new file mode 100755 index 0000000..e924c7a --- /dev/null +++ b/scripts/cairo_fmt.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +option="--check" + +if [ "$1" == "--fix" ]; then + option="" +fi + +scarb --manifest-path Scarb.toml fmt $option diff --git a/scripts/test_all_features.sh b/scripts/test_all_features.sh new file mode 100644 index 0000000..1a0c89b --- /dev/null +++ b/scripts/test_all_features.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +scarb test --all-features diff --git a/src/appchain.cairo b/src/appchain.cairo index f57cdb6..2fc4e9e 100644 --- a/src/appchain.cairo +++ b/src/appchain.cairo @@ -127,16 +127,11 @@ mod appchain { self.state.initialize(state_root, block_number, block_hash); } - #[abi(embed_v0)] impl Appchain of IAppchain { - /// This function accepts two outputs due to the dynamic nature of the layout, which - /// prevents direct verification of the snos proof. - /// To ensure the correctness of `snos_output`, we compare its hash with the corresponding - /// hash in `program_output`, which serves as a layout bridge proof. fn update_state( ref self: ContractState, - snos_output: Array, + snos_output: Span, program_output: Span, onchain_data_hash: felt252, onchain_data_size: u256 @@ -144,17 +139,13 @@ mod appchain { self.reentrancy_guard.start(); self.config.assert_only_owner_or_operator(); - let snos_output_span = snos_output.span(); - let snos_output_hash = poseidon_hash_span(snos_output_span); + let snos_output_hash = poseidon_hash_span(snos_output); let snos_output_hash_in_bridge_output = program_output.at(4); assert!(snos_output_hash == *snos_output_hash_in_bridge_output); let output_hash = poseidon_hash_span(program_output); let mut snos_output_iter = snos_output.into_iter(); - let program_output_struct = deserialize_os_output( - ref snos_output_iter - ); //Custom deserialization function, inspired by - //https://github.com/starkware-libs/cairo-lang/blob/8e11b8cc65ae1d0959328b1b4a40b92df8b58595/src/starkware/starknet/core/aggregator/output_parser.py + let program_output_struct = deserialize_os_output(ref snos_output_iter); let (current_program_hash, current_config_hash): (felt252, felt252) = self .config diff --git a/src/interface.cairo b/src/interface.cairo index 818b227..f3448ec 100644 --- a/src/interface.cairo +++ b/src/interface.cairo @@ -9,13 +9,21 @@ trait IAppchain { /// based on a proof of the StarknetOS that the state transition /// is valid. /// + /// In the current state of the SN stack, the layout required by SNOS + /// is not yet supported with the starknet onchain verifier (integrity). + /// For this reason, two proofs are required: + /// - A proof for SNOS execution. + /// - A layout bridge proof, which uses a layout supported by the onchain verifier. + /// /// # Arguments /// - /// * `program_output` - The StarknetOS state update output. - /// TODO: DA + facts. + /// * `snos_output` - The StarknetOS state update output. + /// * `program_output` - The layout bridge proof output. + /// * `onchain_data_hash` - The hash of the onchain data. + /// * `onchain_data_size` - The size of the onchain data. fn update_state( ref self: T, - snos_output: Array, + snos_output: Span, program_output: Span, onchain_data_hash: felt252, onchain_data_size: u256 diff --git a/src/messaging/tests/test_messaging.cairo b/src/messaging/tests/test_messaging.cairo index f33bb56..f3bf9bd 100644 --- a/src/messaging/tests/test_messaging.cairo +++ b/src/messaging/tests/test_messaging.cairo @@ -370,7 +370,7 @@ fn cancel_message_cancellation_not_allowed_yet() { #[test] fn gather_messages_from_output_ok() { - let mut felts = get_messages_segments().into_iter(); + let mut felts = get_messages_segments().span().into_iter(); let (messages_to_starknet, messages_to_appchain) = deserialize_messages(ref felts); assert(messages_to_starknet.len() == 1, 'missing msgs to sn'); diff --git a/src/snos_output.cairo b/src/snos_output.cairo index 3b20576..98c8b0c 100644 --- a/src/snos_output.cairo +++ b/src/snos_output.cairo @@ -1,6 +1,6 @@ //! SNOS output related types and variables. //! -use core::array::ArrayIter; +use core::array::SpanIter; use core::iter::IntoIterator; use core::iter::Iterator; use core::num::traits::Zero; @@ -15,7 +15,6 @@ const MESSAGE_TO_STARKNET_HEADER_SIZE: usize = 3; /// right before the payload content. const MESSAGE_TO_APPCHAIN_HEADER_SIZE: usize = 5; - const PREVIOUS_MERKLE_UPDATE_OFFSET: usize = 0; const NEW_MERKLE_UPDATE_OFFSET: usize = 1; const PREV_BLOCK_NUMBER_OFFSET: usize = 2; @@ -77,7 +76,8 @@ struct ContractChanges { class_hash: Option, storage_changes: Array<(felt252, felt252)>, } -fn read_segment(ref input_iter: ArrayIter, segment_length: usize) -> Array { + +fn read_segment(ref input_iter: SpanIter, segment_length: usize) -> Array { let mut segment = array![]; for _i in 0 ..segment_length { @@ -85,13 +85,14 @@ fn read_segment(ref input_iter: ArrayIter, segment_length: usize) -> Ar if x.is_none() { break; } - segment.append(x.unwrap()); + segment.append(*(x.unwrap())); }; return segment; } + /// Custom deserialization function, inspired by -///https://github.com/starkware-libs/cairo-lang/blob/8e11b8cc65ae1d0959328b1b4a40b92df8b58595/src/starkware/starknet/core/aggregator/output_parser.py -fn deserialize_os_output(ref input_iter: ArrayIter) -> StarknetOsOutput { +/// https://github.com/starkware-libs/cairo-lang/blob/8e11b8cc65ae1d0959328b1b4a40b92df8b58595/src/starkware/starknet/core/aggregator/output_parser.py +fn deserialize_os_output(ref input_iter: SpanIter) -> StarknetOsOutput { let _ = read_segment(ref input_iter, 3); let header = read_segment(ref input_iter, HEADER_SIZE); let use_kzg_da = header[USE_KZG_DA_OFFSET]; @@ -129,36 +130,32 @@ fn deserialize_os_output(ref input_iter: ArrayIter) -> StarknetOsOutput classes, } } + pub fn deserialize_messages( - ref input_iter: ArrayIter + ref input_iter: SpanIter ) -> (Span, Span) { - let n_messages_to_l1: usize = input_iter - .next() - .unwrap() + let n_messages_to_l1: usize = (*(input_iter.next().unwrap())) .try_into() .expect('Invalid n_messages_to_l1'); let messages_to_l1 = read_segment(ref input_iter, n_messages_to_l1); - let n_messages_to_l2: usize = input_iter - .next() - .unwrap() + let n_messages_to_l2: usize = (*(input_iter.next().unwrap())) .try_into() .expect('Invalid n_messages_to_l2'); let mut messages_to_l2 = read_segment(ref input_iter, n_messages_to_l2); - let mut iter_messages_to_l1 = messages_to_l1.into_iter(); + let mut iter_messages_to_l1 = messages_to_l1.span().into_iter(); let messages_to_l1 = deserialize_messages_to_l1(ref iter_messages_to_l1); - let mut iter_messages_to_l2 = messages_to_l2.into_iter(); + let mut iter_messages_to_l2 = messages_to_l2.span().into_iter(); let messages_to_l2 = deserialize_messages_to_l2(ref iter_messages_to_l2); (messages_to_l1.span(), messages_to_l2.span()) } + fn deserialize_contract_state( - ref input_iter: ArrayIter, full_output: felt252 + ref input_iter: SpanIter, full_output: felt252 ) -> Array { - let output_n_updates: usize = input_iter - .next() - .unwrap() + let output_n_updates: usize = (*(input_iter.next().unwrap())) .try_into() .expect('Invalid output_n_updates'); let mut contract_changes = array![]; @@ -168,22 +165,23 @@ fn deserialize_contract_state( }; contract_changes } + fn deserialize_contract_state_inner( - ref input_iter: ArrayIter, full_output: felt252 + ref input_iter: SpanIter, full_output: felt252 ) -> ContractChanges { let bound: u256 = 18446744073709551616; // 2^64 - let addr = input_iter.next().unwrap(); - let value: u256 = input_iter.next().unwrap().try_into().expect('Invalid value'); + let addr = *(input_iter.next().unwrap()); + let value: u256 = (*(input_iter.next().unwrap())).try_into().expect('Invalid value'); let new_value = value / bound; let n_actual_updates = value % bound; let was_class_updated = new_value / bound; let new_state_nonce = new_value % bound; let new_state_class_hash = if !full_output.is_zero() { - let _prev_state_class_hash = input_iter.next().unwrap(); - Option::Some(input_iter.next().unwrap()) + let _prev_state_class_hash = *(input_iter.next().unwrap()); + Option::Some(*(input_iter.next().unwrap())) } else { if !was_class_updated.is_zero() { - Option::Some(input_iter.next().unwrap()) + Option::Some(*(input_iter.next().unwrap())) } else { Option::None } @@ -200,43 +198,41 @@ fn deserialize_contract_state_inner( } fn deserialize_da_changes( - ref input_iter: ArrayIter, n_actual_updates: usize, full_output: felt252 + ref input_iter: SpanIter, n_actual_updates: usize, full_output: felt252 ) -> Array<(felt252, felt252)> { let mut storage_changes = array![]; for _ in 0 ..n_actual_updates { - let key = input_iter.next().unwrap(); + let key = *(input_iter.next().unwrap()); if full_output.is_non_zero() { - input_iter.next().unwrap(); + *(input_iter.next().unwrap()); }; - let new_value = input_iter.next().unwrap(); + let new_value = *(input_iter.next().unwrap()); storage_changes.append((key, new_value)); }; storage_changes } fn deserialize_contract_class_da_changes( - ref input_iter: ArrayIter, full_output: felt252 + ref input_iter: SpanIter, full_output: felt252 ) -> Array<(felt252, felt252)> { - let output_n_updates: usize = input_iter - .next() - .unwrap() + let output_n_updates: usize = (*(input_iter.next().unwrap())) .try_into() .expect('Invalid output_n_updates'); let mut contract_changes = array![]; for _ in 0 ..output_n_updates { - let class_hash = input_iter.next().unwrap(); + let class_hash = *(input_iter.next().unwrap()); if full_output.is_non_zero() { - input_iter.next().unwrap(); + *(input_iter.next().unwrap()); }; - let compiled_class_hash = input_iter.next().unwrap(); + let compiled_class_hash = *(input_iter.next().unwrap()); contract_changes.append((class_hash, compiled_class_hash)); }; contract_changes } -fn deserialize_messages_to_l1(ref input_iter: ArrayIter) -> Array { +fn deserialize_messages_to_l1(ref input_iter: SpanIter) -> Array { let mut messages_to_starknet = array![]; loop { let header = read_segment(ref input_iter, MESSAGE_TO_STARKNET_HEADER_SIZE); @@ -254,7 +250,8 @@ fn deserialize_messages_to_l1(ref input_iter: ArrayIter) -> Array) -> Array { + +fn deserialize_messages_to_l2(ref input_iter: SpanIter) -> Array { let mut messages_to_appchain = array![]; loop { let header = read_segment(ref input_iter, MESSAGE_TO_APPCHAIN_HEADER_SIZE); diff --git a/tests/test_appchain.cairo b/tests/test_appchain.cairo index 1fa1854..a463c56 100644 --- a/tests/test_appchain.cairo +++ b/tests/test_appchain.cairo @@ -135,7 +135,7 @@ fn get_output() -> Span { #[test] fn snos_output_deser() { - let mut felts = get_state_update().into_iter(); + let mut felts = get_state_update().span().into_iter(); let output: StarknetOsOutput = deserialize_os_output(ref felts); assert( @@ -238,7 +238,7 @@ fn update_state_ok() { let onchain_data_hash = 0x0; let onchain_data_size: u256 = 0; snf::start_cheat_caller_address(appchain.contract_address, c::OWNER()); - appchain.update_state(snos_output, output, onchain_data_hash, onchain_data_size); + appchain.update_state(snos_output.span(), output, onchain_data_hash, onchain_data_size); let expected_log_state_update = LogStateUpdate { state_root: 2251620073307221877548100532273969460343974267802546890497101472079704728659,