Skip to content
Closed
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ resolution = true
skip-lint = false

[programs.localnet]
multicall_handler = "27dua7HMuaZrAc6PRfxmvshHChypFLzZVSpKKaDAPjsq"
svm_spoke = "D1WcTLKRyN4TuqnfMBGPvc16nACHfNhFPbgWNExb1aur"
multicall_handler = "Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h"
svm_spoke = "JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

test = "8tsEfDSiE4WUMf97oyyyasLAvWwjeRZb2GByh4w7HckA"

[programs.devnet]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a section in here for main net with the program address now that its on mainnet?

multicall_handler = "27dua7HMuaZrAc6PRfxmvshHChypFLzZVSpKKaDAPjsq"
svm_spoke = "D1WcTLKRyN4TuqnfMBGPvc16nACHfNhFPbgWNExb1aur"
multicall_handler = "Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h"
svm_spoke = "JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq"

[registry]
url = "https://api.apr.dev"
Expand Down
12 changes: 12 additions & 0 deletions deployments/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,17 @@
"1868": {
"SpokePool": { "address": "0x3baD7AD0728f9917d1Bf08af5782dCbD516cDd96", "blockNumber": 1709997 },
"MulticallHandler": { "address": "0x924a9f036260DdD5808007E1AA95f08eD08aA569", "blockNumber": 1711482 }
},
"133268194659241": {
"SvmSpoke": { "address": "JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq", "blockNumber": 356313770 },
"MulticallHandler": { "address": "Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h", "blockNumber": 356321050 },
"MessageTransmitter": { "address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd", "blockNumber": 339604856 },
"TokenMessengerMinter": { "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", "blockNumber": 277864039 }
},
"34268394551451": {
"SvmSpoke": { "address": "JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq", "blockNumber": 317101505 },
"MulticallHandler": { "address": "Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h", "blockNumber": 317112562 },
"MessageTransmitter": { "address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd", "blockNumber": 312515728 },
"TokenMessengerMinter": { "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", "blockNumber": 262177984 }
}
}
4 changes: 2 additions & 2 deletions programs/multicall-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ security_txt! {

// If changing the program ID, make sure to check that the resulting handler_signer PDA has the highest bump of 255 so
// to minimize the compute cost when finding the PDA.
declare_id!("27dua7HMuaZrAc6PRfxmvshHChypFLzZVSpKKaDAPjsq");
declare_id!("Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h");

#[program]
pub mod multicall_handler {
use super::*;

// Handler to receive AcrossV3 message formatted as serialized message compiled instructions. When deserialized,
// Handler to receive Across message formatted as serialized message compiled instructions. When deserialized,
// these are matched with the passed accounts and executed as CPIs.
pub fn handle_v3_across_message(ctx: Context<HandleV3AcrossMessage>, message: Vec<u8>) -> Result<()> {
// Some instructions might require being signed by handler PDA.
Expand Down
4 changes: 2 additions & 2 deletions programs/svm-spoke/src/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod v3_relay_data;
pub mod relay_data;

pub use v3_relay_data::*;
pub use relay_data::*;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anchor_lang::prelude::*;

#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub struct V3RelayData {
pub struct RelayData {
pub depositor: Pubkey,
pub recipient: Pubkey,
pub exclusive_relayer: Pubkey,
Expand Down
8 changes: 4 additions & 4 deletions programs/svm-spoke/src/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ use anchor_spl::{

use crate::{
state::State,
utils::{get_self_authority_pda, get_v3_relay_hash},
V3RelayData,
utils::{get_relay_hash, get_self_authority_pda},
RelayData,
};

pub fn is_local_or_remote_owner(signer: &Signer, state: &Account<State>) -> bool {
signer.key() == state.owner || signer.key() == get_self_authority_pda()
}

pub fn is_relay_hash_valid(relay_hash: &[u8; 32], relay_data: &V3RelayData, state: &Account<State>) -> bool {
relay_hash == &get_v3_relay_hash(relay_data, state.chain_id)
pub fn is_relay_hash_valid(relay_hash: &[u8; 32], relay_data: &RelayData, state: &Account<State>) -> bool {
relay_hash == &get_relay_hash(relay_data, state.chain_id)
}

// Implements the same underlying logic as in Anchor's associated_token constraint macro, except for token_program_check
Expand Down
10 changes: 5 additions & 5 deletions programs/svm-spoke/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct EmergencyDeletedRootBundle {

// Deposit events
#[event]
pub struct V3FundsDeposited {
pub struct FundsDeposited {
pub input_token: Pubkey,
pub output_token: Pubkey,
pub input_amount: u64,
Expand All @@ -67,15 +67,15 @@ pub enum FillType {
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub struct V3RelayExecutionEventInfo {
pub struct RelayExecutionEventInfo {
pub updated_recipient: Pubkey,
pub updated_message_hash: [u8; 32],
pub updated_output_amount: u64,
pub fill_type: FillType,
}

#[event]
pub struct FilledV3Relay {
pub struct FilledRelay {
pub input_token: Pubkey,
pub output_token: Pubkey,
pub input_amount: u64,
Expand All @@ -90,12 +90,12 @@ pub struct FilledV3Relay {
pub depositor: Pubkey,
pub recipient: Pubkey,
pub message_hash: [u8; 32],
pub relay_execution_info: V3RelayExecutionEventInfo,
pub relay_execution_info: RelayExecutionEventInfo,
}

// Slow fill events
#[event]
pub struct RequestedV3SlowFill {
pub struct RequestedSlowFill {
pub input_token: Pubkey,
pub output_token: Pubkey,
pub input_amount: u64,
Expand Down
28 changes: 14 additions & 14 deletions programs/svm-spoke/src/instructions/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface};
use crate::{
constants::{MAX_EXCLUSIVITY_PERIOD_SECONDS, ZERO_DEPOSIT_ID},
error::{CommonError, SvmError},
event::V3FundsDeposited,
event::FundsDeposited,
state::{Route, State},
utils::{get_current_time, get_unsafe_deposit_id, transfer_from},
};
Expand All @@ -25,7 +25,7 @@ use crate::{
output_amount: u64,
destination_chain_id: u64,
)]
pub struct DepositV3<'info> {
pub struct Deposit<'info> {
#[account(mut)]
pub signer: Signer<'info>,
#[account(
Expand Down Expand Up @@ -68,8 +68,8 @@ pub struct DepositV3<'info> {
pub token_program: Interface<'info, TokenInterface>,
}

pub fn _deposit_v3(
ctx: Context<DepositV3>,
pub fn _deposit(
ctx: Context<Deposit>,
depositor: Pubkey,
recipient: Pubkey,
input_token: Pubkey,
Expand Down Expand Up @@ -125,7 +125,7 @@ pub fn _deposit_v3(
applied_deposit_id[28..].copy_from_slice(&state.number_of_deposits.to_be_bytes());
}

emit_cpi!(V3FundsDeposited {
emit_cpi!(FundsDeposited {
input_token,
output_token,
input_amount,
Expand All @@ -144,8 +144,8 @@ pub fn _deposit_v3(
Ok(())
}

pub fn deposit_v3(
ctx: Context<DepositV3>,
pub fn deposit(
ctx: Context<Deposit>,
depositor: Pubkey,
recipient: Pubkey,
input_token: Pubkey,
Expand All @@ -159,7 +159,7 @@ pub fn deposit_v3(
exclusivity_parameter: u32,
message: Vec<u8>,
) -> Result<()> {
_deposit_v3(
_deposit(
ctx,
depositor,
recipient,
Expand All @@ -179,8 +179,8 @@ pub fn deposit_v3(
Ok(())
}

pub fn deposit_v3_now(
ctx: Context<DepositV3>,
pub fn deposit_now(
ctx: Context<Deposit>,
depositor: Pubkey,
recipient: Pubkey,
input_token: Pubkey,
Expand All @@ -195,7 +195,7 @@ pub fn deposit_v3_now(
) -> Result<()> {
let state = &mut ctx.accounts.state;
let current_time = get_current_time(state)?;
deposit_v3(
deposit(
ctx,
depositor,
recipient,
Expand All @@ -214,8 +214,8 @@ pub fn deposit_v3_now(
Ok(())
}

pub fn unsafe_deposit_v3(
ctx: Context<DepositV3>,
pub fn unsafe_deposit(
ctx: Context<Deposit>,
depositor: Pubkey,
recipient: Pubkey,
input_token: Pubkey,
Expand All @@ -232,7 +232,7 @@ pub fn unsafe_deposit_v3(
) -> Result<()> {
// Calculate the unsafe deposit ID as a [u8; 32]
let deposit_id = get_unsafe_deposit_id(ctx.accounts.signer.key(), depositor, deposit_nonce);
_deposit_v3(
_deposit(
ctx,
depositor,
recipient,
Expand Down
42 changes: 19 additions & 23 deletions programs/svm-spoke/src/instructions/fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ use anchor_spl::{
};

use crate::{
common::V3RelayData,
common::RelayData,
constants::DISCRIMINATOR_SIZE,
constraints::is_relay_hash_valid,
error::{CommonError, SvmError},
event::{FillType, FilledV3Relay, V3RelayExecutionEventInfo},
state::{FillStatus, FillStatusAccount, FillV3RelayParams, State},
event::{FillType, FilledRelay, RelayExecutionEventInfo},
state::{FillRelayParams, FillStatus, FillStatusAccount, State},
utils::{get_current_time, hash_non_empty_message, invoke_handler, transfer_from},
};

#[event_cpi]
#[derive(Accounts)]
#[instruction(relay_hash: [u8; 32], relay_data: Option<V3RelayData>)]
pub struct FillV3Relay<'info> {
#[instruction(relay_hash: [u8; 32], relay_data: Option<RelayData>)]
pub struct FillRelay<'info> {
#[account(mut)]
pub signer: Signer<'info>,

// This is required as fallback when None instruction params are passed in arguments.
#[account(mut, seeds = [b"instruction_params", signer.key().as_ref()], bump, close = signer)]
pub instruction_params: Option<Account<'info, FillV3RelayParams>>,
pub instruction_params: Option<Account<'info, FillRelayParams>>,

#[account(
seeds = [b"state", state.seed.to_le_bytes().as_ref()],
Expand Down Expand Up @@ -79,18 +79,14 @@ pub struct FillV3Relay<'info> {
pub system_program: Program<'info, System>,
}

pub fn fill_v3_relay<'info>(
ctx: Context<'_, '_, '_, 'info, FillV3Relay<'info>>,
relay_data: Option<V3RelayData>,
pub fn fill_relay<'info>(
ctx: Context<'_, '_, '_, 'info, FillRelay<'info>>,
relay_data: Option<RelayData>,
repayment_chain_id: Option<u64>,
repayment_address: Option<Pubkey>,
) -> Result<()> {
let FillV3RelayParams { relay_data, repayment_chain_id, repayment_address } = unwrap_fill_v3_relay_params(
relay_data,
repayment_chain_id,
repayment_address,
&ctx.accounts.instruction_params,
);
let FillRelayParams { relay_data, repayment_chain_id, repayment_address } =
unwrap_fill_relay_params(relay_data, repayment_chain_id, repayment_address, &ctx.accounts.instruction_params);

let state = &ctx.accounts.state;
let current_time = get_current_time(state)?;
Expand Down Expand Up @@ -145,7 +141,7 @@ pub fn fill_v3_relay<'info>(
// Empty message is not hashed and emits zeroed bytes32 for easier human observability.
let message_hash = hash_non_empty_message(&relay_data.message);

emit_cpi!(FilledV3Relay {
emit_cpi!(FilledRelay {
input_token: relay_data.input_token,
output_token: relay_data.output_token,
input_amount: relay_data.input_amount,
Expand All @@ -160,7 +156,7 @@ pub fn fill_v3_relay<'info>(
depositor: relay_data.depositor,
recipient: relay_data.recipient,
message_hash,
relay_execution_info: V3RelayExecutionEventInfo {
relay_execution_info: RelayExecutionEventInfo {
updated_recipient: relay_data.recipient,
updated_message_hash: message_hash,
updated_output_amount: relay_data.output_amount,
Expand All @@ -172,19 +168,19 @@ pub fn fill_v3_relay<'info>(
}

// Helper to unwrap optional instruction params with fallback loading from buffer account.
fn unwrap_fill_v3_relay_params(
relay_data: Option<V3RelayData>,
fn unwrap_fill_relay_params(
relay_data: Option<RelayData>,
repayment_chain_id: Option<u64>,
repayment_address: Option<Pubkey>,
account: &Option<Account<FillV3RelayParams>>,
) -> FillV3RelayParams {
account: &Option<Account<FillRelayParams>>,
) -> FillRelayParams {
match (relay_data, repayment_chain_id, repayment_address) {
(Some(relay_data), Some(repayment_chain_id), Some(repayment_address)) => {
FillV3RelayParams { relay_data, repayment_chain_id, repayment_address }
FillRelayParams { relay_data, repayment_chain_id, repayment_address }
}
_ => account
.as_ref()
.map(|account| FillV3RelayParams {
.map(|account| FillRelayParams {
relay_data: account.relay_data.clone(),
repayment_chain_id: account.repayment_chain_id,
repayment_address: account.repayment_address,
Expand Down
Loading
Loading