| 386 | /// created. |
| 387 | #[inline(always)] |
| 388 | fn validate( |
| 389 | extension_type: ExtensionType, |
| 390 | input_data: &mut [u8], |
| 391 | current_data: Option<&mut [u8]>, |
| 392 | authority: &Pubkey, |
| 393 | ) -> Result<(), AssetError> { |
| 394 | if let Some(current_data) = current_data { |
| 395 | on_update(extension_type, current_data, input_data, Some(authority)).map_err(|error| { |
| 396 | msg!("[ERROR] {}", error); |
| 397 | AssetError::ExtensionDataInvalid |
| 398 | }) |
| 399 | } else { |
| 400 | match extension_type { |
| 401 | ExtensionType::None | ExtensionType::Manager | ExtensionType::Proxy => { |
| 402 | err!( |
| 403 | AssetError::ExtensionDataInvalid, |
| 404 | "invalid extension type: {:?}", |
| 405 | extension_type |
| 406 | ) |
| 407 | } |
| 408 | _ => on_create(extension_type, input_data, Some(authority)).map_err(|error| { |
| 409 | msg!("[ERROR] {}", error); |
| 410 | AssetError::ExtensionDataInvalid |
| 411 | }), |
| 412 | } |
| 413 | } |
| 414 | } |