Closed cryptopapi997 closed 1 month ago
This is a known limitation and is documented in #[instruction]
attribute's documentation.
You can access the instruction’s arguments with the
#[instruction(..)]
attribute. You have to list them in the same order as in the instruction but you can omit all arguments after the last one you need.
As the documentation suggests, you have to list num0
and then num1
to make it work as expected. If you were using num0
instead, you could have ommitted num1
.
My mistake, thank you for clarifying
If we define an instruction like this
and then try to call it like this (assuming num1 in typescript is the num1 that was used to derive
demoAcc
)We get the following error
On the other hand, if we switch the parameter that's used in the PDA derivation to come first (even though that's the wrong order for the instruction) like below, it works fine.
This is a bug, as from reading the instruction function you'd think the right way to do it would be to pass num0 as the first param. I've created an MRE here: https://github.com/cryptopapi997/anchor-mre