Execution
Execution
Executing messages in an ADO is a fairly simple process. We expose a new struct called ExecuteContext
which has your regular dependencies, info and environment alongside a new AMPPkt
struct (amp_ctx
) that includes info about the current AMP packet if the message was received via the AMPReceive
message type.
An AMP Packet includes some useful information such as the origin
field which includes the original sender of the packet.
If you are using this for authorisation purposes please verify that the sender is someone you can trust.
In order to expose this data we must first call the method for handling AMPReceive
messages and provide it your standard execution handler. This is done by our andr_execute_fn
macro:
As a catchall we provide the .execute(ctx, msg)
call to handle any Andromeda specific messages. If you are looking to use another execute message handler such as cw721-base check out our CW721 contract here.
Attributes
There are a lot of cases where we want messages to have specific validation checks, these validation checks are usually extremely common and add a bit of overhead to implement and validate. To reduce this some of these redundant checks have been moved to "attributes". These are field attributes on the ExecuteMsg
variants that define what validation should occur when the message is called (even when it is called via AMP). These include:
nonpayable
- This message should not accept fundsrestricted
- This message should only be callable by the contract ownerdirect
- This messae should not be callable via AMP
These can be applied in any particular order or combination. The checks for these are then performed using the andr_execute_fn
macro so they do not require any extra code, however they do add methods to the ExecuteMsg
enum that may be used as necessary.
Last updated
Was this helpful?