Skip to content

Commit

Permalink
Partial revert "Updates documentation around what needs to be passed …
Browse files Browse the repository at this point in the history
…in CPI. (#21633)"

6f3f6ed
  • Loading branch information
Lichtso committed Dec 20, 2021
1 parent c0c3d7c commit 3586ffa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ mod acme {

`invoke()` is built into Solana's runtime and is responsible for routing the
given instruction to the `token` program via the instruction's `program_id`
field. The caller has to pass all the accounts required by the instruction
being invoked, except for the executable account (with the key `program_id`).
field.

Note that `invoke` requires the caller to pass all the accounts required by the
instruction being invoked. This means that both the executable account (the
ones that matches the instruction's program id) and the accounts passed to the
instruction processor.

Before invoking `pay()`, the runtime must ensure that `acme` didn't modify any
accounts owned by `token`. It does this by applying the runtime's policy to the
Expand Down
8 changes: 8 additions & 0 deletions sdk/program/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use crate::{
/// Notes:
/// - RefCell checking can be compute unit expensive, to avoid that expense use
/// `invoke_unchecked` instead, but at your own risk.
/// - The program id of the instruction being issued must also be included in
/// `account_infos`.
pub fn invoke(instruction: &Instruction, account_infos: &[AccountInfo]) -> ProgramResult {
invoke_signed(instruction, account_infos, &[])
}
Expand All @@ -17,6 +19,8 @@ pub fn invoke(instruction: &Instruction, account_infos: &[AccountInfo]) -> Progr
/// - The missing checks ensured that the invocation doesn't violate the borrow
/// rules of the `AccountInfo` fields that are wrapped in `RefCell`s. To
/// include the checks call `invoke` instead.
/// - The program id of the instruction being issued must also be included in
/// `account_infos`.
pub fn invoke_unchecked(instruction: &Instruction, account_infos: &[AccountInfo]) -> ProgramResult {
invoke_signed_unchecked(instruction, account_infos, &[])
}
Expand All @@ -26,6 +30,8 @@ pub fn invoke_unchecked(instruction: &Instruction, account_infos: &[AccountInfo]
/// Notes:
/// - RefCell checking can be compute unit expensive, to avoid that expense use
/// `invoke_signed_unchecked` instead, but at your own risk.
/// - The program id of the instruction being issued must also be included in
/// `account_infos`.
pub fn invoke_signed(
instruction: &Instruction,
account_infos: &[AccountInfo],
Expand Down Expand Up @@ -57,6 +63,8 @@ pub fn invoke_signed(
/// - The missing checks ensured that the invocation doesn't violate the borrow
/// rules of the `AccountInfo` fields that are wrapped in `RefCell`s. To
/// include the checks call `invoke_signed` instead.
/// - The program id of the instruction being issued must also be included in
/// `account_infos`.
pub fn invoke_signed_unchecked(
instruction: &Instruction,
account_infos: &[AccountInfo],
Expand Down

0 comments on commit 3586ffa

Please sign in to comment.