stellar_axelar_example/interface.rs
1use stellar_axelar_gateway::executable::AxelarExecutableInterface;
2use stellar_axelar_std::types::Token;
3use stellar_axelar_std::{Address, Bytes, BytesN, Env, String};
4
5use crate::contract::AxelarExampleError;
6
7pub trait AxelarExampleInterface: AxelarExecutableInterface {
8 /// Retrieves the address of the gas service.
9 fn gas_service(env: &Env) -> Address;
10
11 /// Sends a message to a specified destination chain.
12 ///
13 /// The function also handles the payment of gas for the cross-chain transaction.
14 ///
15 /// # Arguments
16 /// * `caller` - The address of the caller initiating the message.
17 /// * `destination_chain` - The name of the destination chain where the message will be sent.
18 /// * `destination_address` - The address on the destination chain where the message will be sent.
19 /// * `message` - The message to be sent.
20 /// * `gas_token` - An optional gas token used to pay for gas during the transaction.
21 ///
22 /// # Authorization
23 /// - The `caller` must authorize.
24 fn send(
25 env: &Env,
26 caller: Address,
27 destination_chain: String,
28 destination_address: String,
29 message: Bytes,
30 gas_token: Option<Token>,
31 );
32
33 /// Sends a token to a specified destination chain.
34 ///
35 /// The function also emits an event upon successful transfer.
36 ///
37 /// # Arguments
38 /// * `caller` - The address of the caller initiating the token transfer.
39 /// * `token_id` - The ID of the token to be transferred.
40 /// * `destination_chain` - The name of the destination chain where the token will be sent.
41 /// * `destination_app_contract` - The address of the application contract on the destination chain.
42 /// * `amount` - The amount of the token to be transferred.
43 /// * `recipient` - An optional recipient address on the destination chain.
44 /// * `gas_token` - An optional gas token used to pay for gas during the transaction.
45 ///
46 /// # Authorization
47 /// - The `caller` must authorize.
48 fn send_token(
49 env: &Env,
50 caller: Address,
51 token_id: BytesN<32>,
52 destination_chain: String,
53 destination_app_contract: Bytes,
54 amount: i128,
55 recipient: Option<Bytes>,
56 gas_token: Option<Token>,
57 ) -> Result<(), AxelarExampleError>;
58}