Macro anchor_lang::require_keys_eq
source · macro_rules! require_keys_eq { ($value1: expr, $value2: expr, $error_code:expr $(,)?) => { ... }; ($value1: expr, $value2: expr $(,)?) => { ... }; }
Expand description
Ensures two pubkeys values are equal.
Use require_eq to compare two non-pubkey values.
Can be used with or without a custom error code.
Example
ⓘ
pub fn set_data(ctx: Context<SetData>, data: u64) -> Result<()> {
require_keys_eq!(ctx.accounts.data.authority.key(), ctx.accounts.authority.key());
ctx.accounts.data.data = data;
Ok(())
}