Trait ink_lang::reflect::ContractAmountDispatchables
source · [−]pub trait ContractAmountDispatchables {
const MESSAGES: usize;
const CONSTRUCTORS: usize;
}
Expand description
Reflects the number of dispatchable ink! messages and constructors respectively.
Note
- This is automatically implemented by all ink! smart contracts.
- All ink! constructors and ink! messages of an ink! smart contract are dispatchables. This explicitly includes ink! messages from ink! trait implementations.
Usage
use ink_lang as ink;
#[ink::contract]
pub mod contract {
#[ink(storage)]
pub struct Contract {}
impl Contract {
#[ink(constructor)]
pub fn constructor1() -> Self { Contract {} }
#[ink(constructor)]
pub fn constructor2() -> Self { Contract {} }
#[ink(message)]
pub fn message1(&self) {}
#[ink(message)]
pub fn message2(&self) {}
#[ink(message)]
pub fn message3(&self) {}
}
}
use contract::Contract;
fn main() {
assert_eq!(<Contract as ContractAmountDispatchables>::CONSTRUCTORS, 2);
assert_eq!(<Contract as ContractAmountDispatchables>::MESSAGES, 3);
}
Required Associated Constants
const CONSTRUCTORS: usize
const CONSTRUCTORS: usize
The number of dispatchable ink! constructors.