-
Notifications
You must be signed in to change notification settings - Fork 71
Adds unchecked calls to system program #130
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
base: main
Are you sure you want to change the base?
Adds unchecked calls to system program #130
Conversation
96fb12e
to
60d4104
Compare
60d4104
to
755df53
Compare
/// callee, then Rust's aliasing rules will be violated and cause undefined | ||
/// behavior. | ||
pub unsafe fn invoke_signed_access_unchecked<const ACCOUNTS: usize>( | ||
instruction: &Instruction, |
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.
It could be worth creating a FixedInstruction
variant that takes in const generic for the account metas length. constraining the number of accounts to account metas at type level/compile time.
/// | ||
/// `InvokeParts` is a helper structure that encapsulates all parts of a Solana instruction call, | ||
/// including the program ID, account references, account metadata, and the instruction data payload. | ||
pub struct InvokeParts<'a, const ACCOUNTS: usize, Data> { |
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 don't think this should live in the SDK -- perhaps a pinocchio-client-helpers
crate?
But for now let's just copy the trait + types into the other clients and see if it generalizes well?
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.
we'll need at least one more InstructionData
for slices
Problem
The predefined solana programs(
system
,token
, etc.) only exposeinvoke
andinvoke_signed
calls. It would be nice to haveunsafe
calls as well.Solution
Invoke
trait that contains default implementations for 'invoke' and 'invoke_signed' as well as for the unsafe counter parts.Invoke
is auto implemented for any type that can convert intoInvokeParts
which contains all the necessary information to run an invoke call.From<T> for InvokeParts
for all instructionsNOTES