Common Types
Defining recurring structs used by our ADOs.
This section contains the definitions of structures used by many of our ADOs. To avoid redefining them every time, they will be placed in this section and referenced.
A struct used to store the denom and amount of funds.
Rust
JSON
pub struct Coin {
pub denom: String,
pub amount: Uint128,
}
{
"denom":"uandr",
"amount":"1000000"
}
Name | Type | Description |
denom | String | The denomination of the funds. |
amount | Uint128 | The amount of funds. |
Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future).
Rust
pub enum Expiration {
AtHeight(u64),
AtTime(Timestamp),
Never {},
}
AtHeight: AtHeight will expire when
env.block.height
>= height.AtTime: AtTime will expire when
env.block.time
>= time.Never: Never will never expire. Used to express the empty variant.
A point in time in nanosecond precision.
pub struct Timestamp(Uint64)
{
"expiration":{
"at_height": 500
}
or
{
"expiration":{
"at_time":"124655832000000000"
}
When building ADOs, the recipient of a function/message could be another ADO or an address. This is why we use the Recipient enum to differentiate between a user recipient and an ADO recipient.
The
Recipient
enum looks as follows: Rust
JSON
pub enum Recipient {
Addr(String),
ADO(ADORecipient),
}
{
"addr":"andr1..."
}
or
{
"a_d_o":{
"address":{
"identifier":" splitter-contract"
}
}
}
pub enum Recipient {
Addr(String),
ADO(ADORecipient),
}
Addr: When the recipient address is not another ADO. It is assumed that it is a valid address.
ADO: When the recipient address is another ADO. Uses the
ADORecipient
struct defined below.The address can be either a contract address or the human-readable identifier used in an app contract.
pub struct ADORecipient {
pub address: AndrAddress,
pub msg: Option<Binary>,
}
Name | Type | Description |
---|---|---|
address | AndrAddress | |
msg | Option<Binary> | An optional message to attach for the recipient. |
A struct used to reference another ADO contract. Can be either an address or the name of an ADO component in an app.
Rust
JSON
pub struct AndrAddress {
pub identifier: String,
}
{
"identifier":"andr1..."
}
or
{
"identifier":"component-name"
}