Skip to content

Commit

Permalink
feat: WIPs from code reading session 3 (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismaree authored Oct 31, 2024
1 parent e803b6b commit a663586
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use crate::{
State,
};

//TODO: we have inconsistent imports in this file, in some places referencing from source crates (SvmSpoke::id)
// rather than importing at the top. fix overall and check other files.

#[derive(Accounts)]
#[instruction(params: HandleReceiveMessageParams)]
pub struct HandleReceiveMessage<'info> {
Expand Down Expand Up @@ -44,13 +47,14 @@ pub struct HandleReceiveMessageParams {
pub authority_bump: u8,
}

// TODO: consider refactoring this to be consistent with using free functions.
impl<'info> HandleReceiveMessage<'info> {
pub fn handle_receive_message(&self, params: &HandleReceiveMessageParams) -> Result<Vec<u8>> {
// Return instruction data for the self invoked CPI based on the received message body.
translate_message(&params.message_body)
}
}

// TODO: ensure that CCTP blocks re-played messages sent over the bridge. i.e one pauseDeposit Call cant be replayed.
fn translate_message(data: &Vec<u8>) -> Result<Vec<u8>> {
match utils::get_solidity_selector(data)? {
s if s == utils::encode_solidity_selector("pauseDeposits(bool)") => {
Expand Down
1 change: 1 addition & 0 deletions programs/svm-spoke/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub mod svm_spoke {
}

// CCTP methods.
// TODO: consider refactoring this to be consistent with using free functions.
pub fn handle_receive_message<'info>(
ctx: Context<'_, '_, '_, 'info, HandleReceiveMessage<'info>>,
params: HandleReceiveMessageParams,
Expand Down

0 comments on commit a663586

Please sign in to comment.