lib.rs 674 B

12345678910111213141516171819202122232425262728293031
  1. use anchor_lang::prelude::*;
  2. declare_id!("AmbiguousDiscriminator111111111111111111111");
  3. #[program]
  4. pub mod ambiguous_discriminator {
  5. use super::*;
  6. /// Compilation should error due to ambiguous discriminators.
  7. pub fn check_accounts(_ctx: Context<CheckAccounts>) -> Result<()> {
  8. Ok(())
  9. }
  10. }
  11. #[derive(Accounts)]
  12. pub struct CheckAccounts<'info> {
  13. pub some_account: Account<'info, SomeAccount>,
  14. pub another_account: Account<'info, AnotherAccount>,
  15. }
  16. #[account(discriminator = 1)]
  17. pub struct SomeAccount {
  18. pub a: u8,
  19. pub b: u16,
  20. pub c: u32,
  21. }
  22. #[account(discriminator = [1, 2, 3, 4])]
  23. pub struct AnotherAccount {
  24. pub a: u32,
  25. }