Browse Source

lang: Remove `discriminator` method from `Discriminator` trait (#3163)

acheron 1 year ago
parent
commit
46f52da34b
3 changed files with 2 additions and 4 deletions
  1. 1 0
      CHANGELOG.md
  2. 0 3
      lang/src/lib.rs
  3. 1 1
      tests/zero-copy/programs/zero-copy/tests/compute_unit_test.rs

+ 1 - 0
CHANGELOG.md

@@ -62,6 +62,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 - lang: `#[account]` attribute arguments no longer parses identifiers as namespaces ([#3140](https://github.com/coral-xyz/anchor/pull/3140)).
 - spl: Rename metadata interface instruction fields from `token_program_id` to `program_id` ([#3076](https://github.com/coral-xyz/anchor/pull/3076)).
 - lang, ts: Remove "8 byte" requirement from discriminator error messages ([#3161](https://github.com/coral-xyz/anchor/pull/3161)).
+- lang: Remove `discriminator` method from `Discriminator` trait ([#3163](https://github.com/coral-xyz/anchor/pull/3163)).
 
 ## [0.30.1] - 2024-06-20
 

+ 0 - 3
lang/src/lib.rs

@@ -303,9 +303,6 @@ pub trait Event: AnchorSerialize + AnchorDeserialize + Discriminator {
 /// 8 byte unique identifier for a type.
 pub trait Discriminator {
     const DISCRIMINATOR: &'static [u8];
-    fn discriminator() -> &'static [u8] {
-        Self::DISCRIMINATOR
-    }
 }
 
 /// Defines the space of an account for initialization.

+ 1 - 1
tests/zero-copy/programs/zero-copy/tests/compute_unit_test.rs

@@ -22,7 +22,7 @@ async fn update_foo() {
     let foo_pubkey = Pubkey::new_unique();
     let foo_account = {
         let mut foo_data = Vec::new();
-        foo_data.extend_from_slice(&zero_copy::Foo::discriminator());
+        foo_data.extend_from_slice(zero_copy::Foo::DISCRIMINATOR);
         foo_data.extend_from_slice(bytemuck::bytes_of(&zero_copy::Foo {
             authority: authority.pubkey(),
             ..zero_copy::Foo::default()