-
Notifications
You must be signed in to change notification settings - Fork 172
sdk: Improve IntrospectedInstruction #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sdk: Improve IntrospectedInstruction #295
Conversation
| let offset = u16::from_le_bytes(unsafe { *(self.raw as *const [u8; 2]) }) as usize | ||
| * size_of::<IntrospectedInstructionAccount>() | ||
| + ADDRESS_BYTES; | ||
| let offset = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit in particular looks much nicer!
Co-authored-by: Fernando Otero <[email protected]>
Co-authored-by: Fernando Otero <[email protected]>
| pub struct IntrospectedInstruction<'a> { | ||
| pub raw: *const u8, | ||
| pub marker: PhantomData<&'a [u8]>, | ||
| marker: PhantomData<&'a [u8]>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
febo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
| /// | ||
| /// It is private and used internally within the `get_instruction_account_at` function, which | ||
| /// performs the necessary index verification. However, to optimize performance for users | ||
| /// who are sure that the index is in bounds, we have exposed it as an unsafe function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess, this comment was copied from get_instruction_account_at_unchecked and should not be here
Made several improvements to the
IntrospectedInstructionAPI, including:num_account_metas(&self) -> usizehelper functionnew_unchecked(raw: *const u8) -> IntrospectedInstructionfunction that is consumed internally to avoid having to exposePhantomDataas a public fieldnum_instructionsreferusizeand removed all inline usize casts