-
Notifications
You must be signed in to change notification settings - Fork 3
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: add custom executable interface for AxelarExecutableInterface for ease of use #265
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #265 +/- ##
==========================================
- Coverage 97.68% 97.67% -0.02%
==========================================
Files 71 72 +1
Lines 3884 3910 +26
==========================================
+ Hits 3794 3819 +25
- Misses 90 91 +1 ☔ View full report in Codecov by Sentry. |
#[macro_export] | ||
macro_rules! derive_only { | ||
() => { | ||
/// Marker trait for interfaces that should not be implemented by using `contractimpl`. | ||
/// | ||
/// **DO NOT IMPLEMENT THIS MANUALLY!** | ||
#[doc(hidden)] | ||
pub trait DeriveOnly {} | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I use the same DeriveOnly trait for all traits that need it, the auto-implementations inside the macros might collide, e.g. when a contract implements both the AxelarExecutableInterface and the InterchainTokenExecutableInterface, so to work around that restriction, each crate that defines such a trait must have their own local DeriveOnly trait
/// This method doesn't get exposed from the contract, as Soroban SDK's contractimpl macro ignores default trait methods. | ||
fn validate_message( | ||
fn __gateway(env: &Env) -> Address; | ||
fn __validated_execute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn __validated_execute( | |
fn __execute( |
Don't find it to be that readable if a user doesn't have the context already, and it's implied being an internal function. Also matches our EVM executable better
|
||
derive_only!(); | ||
|
||
pub trait CustomAxelarExecutableInterface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub trait CustomAxelarExecutableInterface { | |
pub trait CustomAxelarExecutable { |
source_address: String, | ||
payload: Bytes, | ||
) -> Result<(), #error_alias> { | ||
stellar_axelar_gateway::executable::validate_message::<Self>(env, &source_chain, &message_id, &source_address, &payload).map_err(|err| match err{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stellar_axelar_gateway::executable::validate_message::<Self>(env, &source_chain, &message_id, &source_address, &payload).map_err(|err| match err{ | |
stellar_axelar_gateway::executable::validate_message::<Self>(env, &source_chain, &message_id, &source_address, &payload).map_err(|err| match err { |
})?; | ||
Self::__validated_execute(env, source_chain, message_id, source_address, payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
})?; | |
Self::__validated_execute(env, source_chain, message_id, source_address, payload) | |
})?; | |
Self::__validated_execute(env, source_chain, message_id, source_address, payload) |
No description provided.