From 340e9c13f42191a1caa6092d811ed930a64c1f7b Mon Sep 17 00:00:00 2001 From: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:00:29 +0200 Subject: [PATCH] lang: Remove `EventIndex` (#3244) --- CHANGELOG.md | 1 + lang/attribute/event/src/lib.rs | 10 +--------- .../program/src/declare_program/mods/events.rs | 1 - lang/src/lib.rs | 1 - tests/events/programs/events/src/lib.rs | 2 -- 5 files changed, 2 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 186a36bdd9..ca0351d6b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ The minor version will be incremented upon a breaking change and the patch versi - ts: Upgrade `typescript` to `5.5.4` and remove the generic parameters of `SimulateResponse` ([#3221](https://github.com/coral-xyz/anchor/pull/3221)). - ts: Remove `StateCoder`([#3224](https://github.com/coral-xyz/anchor/pull/3224)). - cli: Accept integers for `warp_slot` ([#3235](https://github.com/coral-xyz/anchor/pull/3235)). +- lang: Remove `EventIndex` ([#3244](https://github.com/coral-xyz/anchor/pull/3244)). ## [0.30.1] - 2024-06-20 diff --git a/lang/attribute/event/src/lib.rs b/lang/attribute/event/src/lib.rs index 76182fc465..19258fbe21 100644 --- a/lang/attribute/event/src/lib.rs +++ b/lang/attribute/event/src/lib.rs @@ -42,7 +42,7 @@ pub fn event( .unwrap_or_else(|| gen_discriminator("event", event_name)); let ret = quote! { - #[derive(anchor_lang::__private::EventIndex, AnchorSerialize, AnchorDeserialize)] + #[derive(AnchorSerialize, AnchorDeserialize)] #event_strct impl anchor_lang::Event for #event_name { @@ -72,14 +72,6 @@ pub fn event( proc_macro::TokenStream::from(ret) } -// EventIndex is a marker macro. It functionally does nothing other than -// allow one to mark fields with the `#[index]` inert attribute, which is -// used to add metadata to IDLs. -#[proc_macro_derive(EventIndex, attributes(index))] -pub fn derive_event(_item: proc_macro::TokenStream) -> proc_macro::TokenStream { - proc_macro::TokenStream::from(quote! {}) -} - /// Logs an event that can be subscribed to by clients. /// Uses the [`sol_log_data`](https://docs.rs/solana-program/latest/solana_program/log/fn.sol_log_data.html) /// syscall which results in the following log: diff --git a/lang/attribute/program/src/declare_program/mods/events.rs b/lang/attribute/program/src/declare_program/mods/events.rs index eff282952e..2d54970559 100644 --- a/lang/attribute/program/src/declare_program/mods/events.rs +++ b/lang/attribute/program/src/declare_program/mods/events.rs @@ -16,7 +16,6 @@ pub fn gen_events_mod(idl: &Idl) -> proc_macro2::TokenStream { .expect("Type must exist"); quote! { - #[derive(anchor_lang::__private::EventIndex)] #ty_def impl anchor_lang::Event for #name { diff --git a/lang/src/lib.rs b/lang/src/lib.rs index a27114e4d3..dd4d3b64b8 100644 --- a/lang/src/lib.rs +++ b/lang/src/lib.rs @@ -452,7 +452,6 @@ pub mod prelude { #[doc(hidden)] pub mod __private { pub use anchor_attribute_account::ZeroCopyAccessor; - pub use anchor_attribute_event::EventIndex; pub use base64; pub use bytemuck; diff --git a/tests/events/programs/events/src/lib.rs b/tests/events/programs/events/src/lib.rs index ff3f57c0e3..c1c8e59526 100644 --- a/tests/events/programs/events/src/lib.rs +++ b/tests/events/programs/events/src/lib.rs @@ -46,13 +46,11 @@ pub struct TestEventCpi {} #[event] pub struct MyEvent { pub data: u64, - #[index] pub label: String, } #[event] pub struct MyOtherEvent { pub data: u64, - #[index] pub label: String, }