#idl #anchor #solana #generation #drift

drift-idl-gen

Generates Drift v2 structs/types from anchor IDL

2 releases

0.1.1 Oct 22, 2024
0.1.0 Sep 28, 2024

#2 in #drift

Download history 150/week @ 2024-09-23 37/week @ 2024-09-30 8/week @ 2024-10-07 8/week @ 2024-10-14 169/week @ 2024-10-21 12/week @ 2024-10-28 17/week @ 2024-11-04

207 downloads per month
Used in drift-rs

Apache-2.0

28KB
611 lines

drfit-idl-gen

Generates rust anchor structs from IDL json This is implemented rather than another project for a couple reasons:

  1. #[repr(C)] other IDL generation tools do not provide the ability to market structs with repr(C) which is necessary for ffi functionality throught the drift-rs project.
  2. does not rely on anchor vendored solana crates. anchor is pinned to older versions of the solana crates. drift-rs seeks to be readily upgradable to use lastest solana crates.

Dev Note ⚠️

  • An important assumption in this code is that the underlying types (serialization and deserialization) does not change among solana crate versions i.e solana_sdk_1.16::Pubkey == solana_sdk_2.x::Pubkey == anchor_lang::solana_sdk::Pubkey this allows the generated IDL code to ignore the anchor version of crates.

lib.rs:

Auto-generated IDL types, manual edits do not persist (see crates/drift-idl-gen)

Dependencies

~1–2MB
~45K SLoC