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

feat(interchain-token-service): parameterize execute error #127

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion contracts/axelar-gateway/src/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub trait AxelarExecutableInterface {
message_id: String,
source_address: String,
payload: Bytes,
);
) -> Result<(), soroban_sdk::Error>;
Copy link
Member

Choose a reason for hiding this comment

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

See MigratableInterface for how to parameterize the error


/// Validate if a gateway has approved a message.
/// This should be called from an implementation of `execute` before executing custom app logic.
Expand Down
4 changes: 3 additions & 1 deletion contracts/example/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ impl AxelarExecutableInterface for Example {
message_id: String,
source_address: String,
payload: Bytes,
) {
) -> Result<(), soroban_sdk::Error> {
let _ = Self::validate_message(&env, &source_chain, &message_id, &source_address, &payload);

event::executed(&env, source_chain, message_id, source_address, payload);

Ok(())
}
}

Expand Down
10 changes: 6 additions & 4 deletions contracts/interchain-token-service/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use axelar_soroban_std::{
use interchain_token::InterchainTokenClient;
use soroban_sdk::token::{self, StellarAssetClient};
use soroban_sdk::xdr::{FromXdr, ToXdr};
use soroban_sdk::{contract, contractimpl, panic_with_error, Address, Bytes, BytesN, Env, String};
use soroban_sdk::{contract, contractimpl, Address, Bytes, BytesN, Env, String};
use soroban_token_sdk::metadata::TokenMetadata;

use crate::abi::{get_message_type, MessageType as EncodedMessageType};
Expand Down Expand Up @@ -420,12 +420,14 @@ impl AxelarExecutableInterface for InterchainTokenService {
message_id: String,
source_address: String,
payload: Bytes,
) {
) -> Result<(), soroban_sdk::Error> {
Self::validate_message(&env, &source_chain, &message_id, &source_address, &payload)
.unwrap_or_else(|err| panic_with_error!(env, err));
.map_err(Into::<soroban_sdk::Error>::into)?;

Self::execute_message(&env, source_chain, message_id, source_address, payload)
.unwrap_or_else(|err| panic_with_error!(env, err));
.map_err(Into::<soroban_sdk::Error>::into)?;

Ok(())
}
}

Expand Down
Loading