Skip to content

Commit

Permalink
feat(minor-ampd): update stellar event names (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahramy authored Oct 23, 2024
1 parent a291e51 commit 340975d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions ampd/src/stellar/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::handlers::stellar_verify_msg::Message;
use crate::handlers::stellar_verify_verifier_set::VerifierSetConfirmation;
use crate::stellar::http_client::TxResponse;

const TOPIC_CALLED: &str = "called";
const TOPIC_ROTATED: &str = "rotated";
const TOPIC_CONTRACT_CALLED: &str = "contract_called";
const TOPIC_SIGNERS_ROTATED: &str = "signers_rotated";

impl PartialEq<ContractEventBody> for Message {
fn eq(&self, event: &ContractEventBody) -> bool {
Expand All @@ -25,8 +25,10 @@ impl PartialEq<ContractEventBody> for Message {
return false;
};

let expected_topic: ScVal =
ScSymbol(StringM::from_str(TOPIC_CALLED).expect("must convert str to ScSymbol")).into();
let expected_topic: ScVal = ScSymbol(
StringM::from_str(TOPIC_CONTRACT_CALLED).expect("must convert str to ScSymbol"),
)
.into();

expected_topic == *symbol
&& (ScVal::Address(self.source_address.clone()) == *source_address)
Expand All @@ -48,9 +50,10 @@ impl PartialEq<ContractEventBody> for VerifierSetConfirmation {
return false;
};

let expected_topic: ScVal =
ScSymbol(StringM::from_str(TOPIC_ROTATED).expect("must convert str to ScSymbol"))
.into();
let expected_topic: ScVal = ScSymbol(
StringM::from_str(TOPIC_SIGNERS_ROTATED).expect("must convert str to ScSymbol"),
)
.into();

let Some(weighted_signers_hash) = WeightedSigners::try_from(&self.verifier_set)
.ok()
Expand Down Expand Up @@ -141,7 +144,7 @@ mod test {
use crate::handlers::stellar_verify_verifier_set::VerifierSetConfirmation;
use crate::stellar::http_client::TxResponse;
use crate::stellar::verifier::{
verify_message, verify_verifier_set, TOPIC_CALLED, TOPIC_ROTATED,
verify_message, verify_verifier_set, TOPIC_CONTRACT_CALLED, TOPIC_SIGNERS_ROTATED,
};
use crate::types::{EVMAddress, Hash};
use crate::PREFIX;
Expand Down Expand Up @@ -304,7 +307,7 @@ mod test {

let event_body = ContractEventBody::V0(ContractEventV0 {
topics: vec![
ScVal::Symbol(ScSymbol(StringM::from_str(TOPIC_CALLED).unwrap())),
ScVal::Symbol(ScSymbol(StringM::from_str(TOPIC_CONTRACT_CALLED).unwrap())),
ScVal::Address(msg.source_address.clone()),
ScVal::String(msg.destination_chain.clone()),
ScVal::String(msg.destination_address.clone()),
Expand Down Expand Up @@ -363,7 +366,7 @@ mod test {

let event_body = ContractEventBody::V0(ContractEventV0 {
topics: vec![
ScVal::Symbol(ScSymbol(StringM::from_str(TOPIC_ROTATED).unwrap())),
ScVal::Symbol(ScSymbol(StringM::from_str(TOPIC_SIGNERS_ROTATED).unwrap())),
ScVal::U64(1),
ScVal::Bytes(ScBytes(weighted_signers_hash)),
]
Expand Down

0 comments on commit 340975d

Please sign in to comment.