vialabs-stellar-common-0.1.0 has been yanked.
Stellar Contract Interfaces
This directory contains shared interfaces, types, and traits that can be used across multiple Stellar contracts.
Structure
contracts/interfaces/
├── Cargo.toml # Package configuration
├── src/
│ ├── lib.rs # Main library file that re-exports all interfaces
│ ├── message_gateway_v4.rs # Message Gateway V4 interface
│ └── token_interface.rs # Token interface (example)
Usage
In Contract Cargo.toml
Add the interfaces as a dependency:
[]
= { = true }
= { = true }
In Contract Code
Import and use the interfaces:
use ;
use TokenInterface;
;
Adding New Interfaces
- Create a new file in
src/(e.g.,my_interface.rs) - Define your interface traits and types
- Add the module to
src/lib.rs: - Optionally re-export commonly used types:
pub use *;
Benefits
- Code Reuse: Share interfaces across multiple contracts
- Type Safety: Ensure contracts implement the same interface
- Maintainability: Update interfaces in one place
- Consistency: Standardize contract interfaces across your project
Example Interfaces
message_gateway_v4: Message Gateway V4 contract interfacetoken_interface: Standard token contract interface (example)