Then the handler of this action gets access to the receiver already parsed and the validation happens behind the scenes. A handler could look like this:
#[collection]
pub mod my_actions {
use super::*;
pub fn send_donation(ctx: Context<SendDonationAction>) -> Result<Transaction> {
let account_pubkey = &ctx.payload.account; // payload.account should be parsed too
let receiver_pubkey = &ctx.params.receiver; // receiver is already a pubkey
// ...
}
}
Note that the account and receiver come from the HTTP request as strings. Look into extractors with custom types.
Using the type Pubkey in the query and params attributes from a derive Action should be validated and parsed before reaching the context.
Assuming there's a case like this:
Then the handler of this action gets access to the receiver already parsed and the validation happens behind the scenes. A handler could look like this:
Note that the account and receiver come from the HTTP request as strings. Look into extractors with custom types.