Timeline for Anchor CPI within the same program without passing the program
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 26, 2023 at 22:35 | comment | added | neft | @Whiteseal is spot on. There are cases where the constraints are different, or perhaps you want to use things like init macros etc that may be different depending on the inputs, even though they require the same accounts to be passed in. So CPI within the same program seems like a completely valid use case. | |
Feb 18, 2023 at 7:03 | comment | added | Whiteseal | If you have different constraints in B and C, but they accept the same accounts, for example B requires a tokenAccount owned by some key, C requires the same kind of token account but owned by another key, it can be cleaner to split them. | |
Feb 17, 2023 at 8:07 | comment | added | vicyyn | Use the constraints in the parent instruction. verify that the accounts you passed are all valid. Then do whatever you need based on what your program has. | |
Feb 16, 2023 at 20:13 | comment | added | Whiteseal | Redirecting via CPI lets you use constraints in accounts, so A can take an UncheckedAccount and perform no validation, and pass it via CPI to B which reads it like a pda and validates the seeds, or passes it to C which reads it like a TokenAccount and validates something else. You can do the same thing without constraints, but it's a neat utility. | |
Feb 10, 2023 at 21:15 | history | answered | vicyyn | CC BY-SA 4.0 |