Skip to content

Commit

Permalink
feat: add support for solana message id's
Browse files Browse the repository at this point in the history
  • Loading branch information
eloylp committed Jul 8, 2024
1 parent b37114e commit addfec5
Show file tree
Hide file tree
Showing 5 changed files with 388 additions and 2 deletions.
10 changes: 10 additions & 0 deletions contracts/voting-verifier/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ mod test {
use axelar_wasm_std::{
msg_id::{
base_58_event_index::Base58TxDigestAndEventIndex,
base_58_solana_event_index::Base58SolanaTxDigestAndEventIndex,
tx_hash_event_index::HexTxHashAndEventIndex, MessageIdFormat,
},
nonempty,
Expand Down Expand Up @@ -224,6 +225,15 @@ mod test {
.to_string()
.parse()
.unwrap(),
MessageIdFormat::Base58SolanaTxDigestAndEventIndex => {
Base58SolanaTxDigestAndEventIndex::new_from_b58_encoded_signature_and_index(
id, index,
)
.unwrap()
.to_string()
.parse()
.unwrap()
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions contracts/voting-verifier/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::str::FromStr;
use std::vec::Vec;

use axelar_wasm_std::msg_id::base_58_event_index::Base58TxDigestAndEventIndex;
use axelar_wasm_std::msg_id::base_58_solana_event_index::Base58SolanaTxDigestAndEventIndex;
use axelar_wasm_std::msg_id::tx_hash_event_index::HexTxHashAndEventIndex;
use axelar_wasm_std::msg_id::MessageIdFormat;
use cosmwasm_schema::cw_serde;
Expand Down Expand Up @@ -137,6 +138,12 @@ fn parse_message_id(

Ok((id.tx_hash_as_hex(), id.event_index))
}
MessageIdFormat::Base58SolanaTxDigestAndEventIndex => {
let id = Base58SolanaTxDigestAndEventIndex::from_str(&message_id)
.map_err(|_| ContractError::InvalidMessageID(message_id.into()))?;

Ok((id.tx_digest_as_base58(), id.event_index))
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/axelar-wasm-std/src/hash.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub type Hash = [u8; 32];
pub type Hash = [u8; 32];
Loading

0 comments on commit addfec5

Please sign in to comment.