-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#### Problem Version 2.1 of the Solana crates is out, but all of the Rust programs are still on v2.0. #### Summary of changes Bump crates to v2.1, Rust to 1.81, and use component crates wherever possible. The CPI program has a higher CU usage also, so update the README to reflect that.
- Loading branch information
Showing
13 changed files
with
1,365 additions
and
775 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,2 @@ | ||
//! Program entrypoint | ||
#![cfg(not(feature = "no-entrypoint"))] | ||
|
||
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey}; | ||
|
||
solana_program::entrypoint!(process_instruction); | ||
fn process_instruction( | ||
program_id: &Pubkey, | ||
accounts: &[AccountInfo], | ||
instruction_data: &[u8], | ||
) -> ProgramResult { | ||
crate::processor::process_instruction(program_id, accounts, instruction_data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,35 @@ | ||
//! A program demonstrating the transfer of lamports | ||
#![deny(missing_docs)] | ||
#![forbid(unsafe_code)] | ||
#![allow(clippy::arithmetic_side_effects)] | ||
|
||
mod entrypoint; | ||
pub mod processor; | ||
use { | ||
solana_account_info::{next_account_info, AccountInfo}, | ||
solana_program_error::ProgramResult, | ||
solana_pubkey::Pubkey, | ||
}; | ||
|
||
solana_program_entrypoint::entrypoint!(process_instruction); | ||
|
||
/// Instruction processor | ||
pub fn process_instruction( | ||
_program_id: &Pubkey, | ||
accounts: &[AccountInfo], | ||
instruction_data: &[u8], | ||
) -> ProgramResult { | ||
// Create an iterator to safely reference accounts in the slice | ||
let account_info_iter = &mut accounts.iter(); | ||
let transfer_amount = u64::from_le_bytes(instruction_data.try_into().unwrap()); | ||
|
||
// As part of the program specification the first account is the source | ||
// account and the second is the destination account | ||
let source_info = next_account_info(account_info_iter)?; | ||
let destination_info = next_account_info(account_info_iter)?; | ||
|
||
// Withdraw five lamports from the source | ||
**source_info.try_borrow_mut_lamports()? -= transfer_amount; | ||
// Deposit five lamports into the destination | ||
**destination_info.try_borrow_mut_lamports()? += transfer_amount; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters