Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(axelar-gateway)!: fix message bcs peel #54

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions move/axelar_gateway/sources/types/message.move
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module axelar_gateway::message {
use std::ascii::String;
use sui::bcs::{Self, BCS};
use sui::address;
use sui::hash;

use axelar_gateway::bytes32::{Self, Bytes32};
Expand All @@ -18,12 +17,6 @@ module axelar_gateway::message {
payload_hash: Bytes32,
}

/// ------
/// Errors
/// ------
/// Invalid bytes length
const EInvalidLength: u64 = 0;

/// -----------------
/// Public Functions
/// -----------------
Expand Down Expand Up @@ -51,17 +44,14 @@ module axelar_gateway::message {
let source_chain = bcs.peel_vec_u8().to_ascii_string();
let message_id = bcs.peel_vec_u8().to_ascii_string();
let source_address = bcs.peel_vec_u8().to_ascii_string();

let destination_id_bytes = bcs.peel_vec_u8();
assert!(destination_id_bytes.length() == 32, EInvalidLength);

let destination_id = bcs.peel_address();
let payload_hash = bytes32::peel(bcs);

Message {
source_chain,
message_id,
source_address,
destination_id: address::from_bytes(destination_id_bytes),
destination_id,
payload_hash,
}
}
Expand Down
Loading