-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/its-add-flow-limit
- Loading branch information
Showing
15 changed files
with
225 additions
and
119 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,97 @@ | ||
use crate::types::Message; | ||
use soroban_sdk::{Address, Bytes, BytesN, Env, String, Symbol}; | ||
|
||
pub fn call_contract( | ||
env: &Env, | ||
caller: Address, | ||
destination_chain: String, | ||
destination_address: String, | ||
payload: Bytes, | ||
payload_hash: BytesN<32>, | ||
) { | ||
let topics = ( | ||
Symbol::new(env, "contract_called"), | ||
caller, | ||
destination_chain, | ||
destination_address, | ||
payload_hash, | ||
); | ||
env.events().publish(topics, payload); | ||
} | ||
|
||
pub fn approve_message(env: &Env, message: Message) { | ||
let topics = (Symbol::new(env, "message_approved"), message); | ||
env.events().publish(topics, ()); | ||
} | ||
|
||
pub fn execute_message(env: &Env, message: Message) { | ||
let topics = (Symbol::new(env, "message_executed"), message); | ||
env.events().publish(topics, ()); | ||
} | ||
|
||
pub fn rotate_signers(env: &Env, epoch: u64, signers_hash: BytesN<32>) { | ||
let topics = (Symbol::new(env, "signers_rotated"), epoch, signers_hash); | ||
env.events().publish(topics, ()); | ||
|
||
use core::fmt::Debug; | ||
|
||
use axelar_soroban_std::events::Event; | ||
use cfg_if::cfg_if; | ||
use soroban_sdk::{Address, Bytes, BytesN, Env, IntoVal, String, Symbol, Topics, Val, Vec}; | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
pub struct ContractCalledEvent { | ||
pub caller: Address, | ||
pub destination_chain: String, | ||
pub destination_address: String, | ||
pub payload: Bytes, | ||
pub payload_hash: BytesN<32>, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
pub struct MessageApprovedEvent { | ||
pub message: Message, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
pub struct MessageExecutedEvent { | ||
pub message: Message, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
pub struct SignersRotatedEvent { | ||
pub epoch: u64, | ||
pub signers_hash: BytesN<32>, | ||
} | ||
|
||
impl Event for ContractCalledEvent { | ||
fn topics(&self, env: &Env) -> impl Topics + Debug { | ||
( | ||
Symbol::new(env, "contract_called"), | ||
self.caller.to_val(), | ||
self.destination_chain.to_val(), | ||
self.destination_address.to_val(), | ||
self.payload_hash.to_val(), | ||
) | ||
} | ||
|
||
fn data(&self, _env: &Env) -> impl IntoVal<Env, Val> + Debug { | ||
(self.payload.to_val(),) | ||
} | ||
} | ||
|
||
impl Event for MessageApprovedEvent { | ||
fn topics(&self, env: &Env) -> impl Topics + Debug { | ||
(Symbol::new(env, "message_approved"), self.message.clone()) | ||
} | ||
|
||
fn data(&self, env: &Env) -> impl IntoVal<Env, Val> + Debug { | ||
Vec::<Val>::new(env) | ||
} | ||
} | ||
|
||
impl Event for MessageExecutedEvent { | ||
fn topics(&self, env: &Env) -> impl Topics + Debug { | ||
(Symbol::new(env, "message_executed"), self.message.clone()) | ||
} | ||
|
||
fn data(&self, env: &Env) -> impl IntoVal<Env, Val> + Debug { | ||
Vec::<Val>::new(env) | ||
} | ||
} | ||
|
||
impl Event for SignersRotatedEvent { | ||
fn topics(&self, env: &Env) -> impl Topics + Debug { | ||
( | ||
Symbol::new(env, "signers_rotated"), | ||
self.epoch, | ||
self.signers_hash.to_val(), | ||
) | ||
} | ||
|
||
fn data(&self, env: &Env) -> impl IntoVal<Env, Val> + Debug { | ||
Vec::<Val>::new(env) | ||
} | ||
} | ||
|
||
cfg_if! { | ||
if #[cfg(any(test, feature = "testutils"))] { | ||
use axelar_soroban_std::impl_event_testutils; | ||
|
||
impl_event_testutils!( | ||
ContractCalledEvent, | ||
(Symbol, Address, String, String, BytesN<32>), | ||
(Bytes) | ||
); | ||
impl_event_testutils!(MessageApprovedEvent, (Symbol, Message), ()); | ||
impl_event_testutils!(MessageExecutedEvent, (Symbol, Message), ()); | ||
impl_event_testutils!(SignersRotatedEvent, (Symbol, u64, BytesN<32>), ()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.