| Crates.io | vialabs-stellar-macros |
| lib.rs | vialabs-stellar-macros |
| version | 0.1.9 |
| created_at | 2025-10-31 17:31:39.777422+00 |
| updated_at | 2025-11-04 15:48:07.118594+00 |
| description | Proc macro for providing default implementations of traits for Stellar contracts in the VIA cross-chain messaging system |
| homepage | |
| repository | https://github.com/vialabs-io/via-drivers |
| max_upload_size | |
| id | 1910391 |
| size | 10,783 |
Proc macro for providing default implementations of traits for Stellar contracts in the VIA cross-chain messaging system.
The vialabs-stellar-macros crate provides the #[default_impl] attribute macro that automatically generates default implementations for trait methods. This allows contract developers to focus on implementing only the custom logic they need, while the macro provides standard implementations for the rest.
The macro currently supports the full MessageClientV4Interface trait and provides all of the needed default implementations.
Note: The message_process method is not provided by default and must be implemented by the contract.
Add the macro crate to your contract's Cargo.toml:
[dependencies]
vialabs-stellar-macros = "0.1.9"
vialabs-stellar-common = "0.1.9"
soroban-sdk = "23.0.2"
Inside your contract file:
use vialabs_stellar_macros::default_impl;
use vialabs_stellar_common::message_client_v4::MessageClientV4Interface;
#[contract]
pub struct MyContract;
#[default_impl]
#[contractimpl]
impl MessageClientV4Interface for MyContract {
fn message_process(env: &Env, message: ProcessFromGatewayRequest) {
// Your custom implementation here
// All other methods will be automatically provided by the macro
}
}
Important: Only message_process can be overridden. All other methods will always use the default implementation provided by the macro, even if you try to provide a custom implementation.
#[default_impl]
#[contractimpl]
impl MessageClientV4Interface for MyContract {
fn message_process(env: &Env, message: ProcessFromGatewayRequest) {
// Only this method can be customized
// Custom implementation here
}
// This will panic
fn message_send(env: &Env, destination_chain: u64, chain_data: Bytes, confirmations: u32) -> u128 {
0u128
}
}