Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pinocchio = { version = "0.9", path = "sdk/pinocchio" }
pinocchio-log-macro = { version = "0.5", path = "sdk/log/macro" }
quote = "1.0"
regex = "1"
solana-address = { version = "1.0", git = "https://github.com/febo/solana-sdk.git", branch = "copy-feature" }
solana-account-view = { version = "0.0.0", git = "https://github.com/febo/solana-sdk.git", branch = "solana-account-view" }
solana-address = { version = "1.0", git = "https://github.com/febo/solana-sdk.git", branch = "solana-account-view" }
syn = "1.0"

[workspace.metadata.cli]
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ If all dependencies are `no_std`, you should append [`nostd_panic_handler!`](htt
To use the `entrypoint!` macro, use the following in your entrypoint definition:
```rust
use pinocchio::{
account_info::AccountInfo,
account::AccountView,
entrypoint,
msg,
ProgramResult,
Expand All @@ -79,7 +79,7 @@ entrypoint!(process_instruction);

pub fn process_instruction(
program_id: &Address,
accounts: &[AccountInfo],
accounts: &[AccountView],
instruction_data: &[u8],
) -> ProgramResult {
msg!("Hello from my program!");
Expand Down Expand Up @@ -147,7 +147,7 @@ When writing programs, it can be useful to make sure the program does not attemp
To use the `no_allocator!` macro, use the following in your entrypoint definition:
```rust
use pinocchio::{
account_info::AccountInfo,
account::AccountView,
default_panic_handler,
msg,
no_allocator,
Expand All @@ -162,7 +162,7 @@ no_allocator!();

pub fn process_instruction(
program_id: &Address,
accounts: &[AccountInfo],
accounts: &[AccountView],
instruction_data: &[u8],
) -> ProgramResult {
msg!("Hello from `no_std` program!");
Expand All @@ -189,7 +189,7 @@ The symbols emitted by the entrypoint macros — program entrypoint, global
#[cfg(feature = "bpf-entrypoint")]
mod entrypoint {
use pinocchio::{
account_info::AccountInfo,
account::AccountView,
entrypoint,
msg,
ProgramResult,
Expand All @@ -200,7 +200,7 @@ mod entrypoint {

pub fn process_instruction(
program_id: &Address,
accounts: &[AccountInfo],
accounts: &[AccountView],
instruction_data: &[u8],
) -> ProgramResult {
msg!("Hello from my program!");
Expand Down
26 changes: 13 additions & 13 deletions programs/associated-token-account/src/instructions/create.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
ProgramResult,
Expand All @@ -17,17 +17,17 @@ use pinocchio::{
/// 5. `[]` SPL Token program
pub struct Create<'a> {
/// Funding account (must be a system account)
pub funding_account: &'a AccountInfo,
pub funding_account: &'a AccountView,
/// Associated token account address to be created
pub account: &'a AccountInfo,
pub account: &'a AccountView,
/// Wallet address for the new associated token account
pub wallet: &'a AccountInfo,
pub wallet: &'a AccountView,
/// The token mint for the new associated token account
pub mint: &'a AccountInfo,
pub mint: &'a AccountView,
/// System program
pub system_program: &'a AccountInfo,
pub system_program: &'a AccountView,
/// SPL Token program
pub token_program: &'a AccountInfo,
pub token_program: &'a AccountView,
}

impl Create<'_> {
Expand All @@ -40,12 +40,12 @@ impl Create<'_> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 6] = [
AccountMeta::writable_signer(self.funding_account.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::readonly(self.wallet.key()),
AccountMeta::readonly(self.mint.key()),
AccountMeta::readonly(self.system_program.key()),
AccountMeta::readonly(self.token_program.key()),
AccountMeta::writable_signer(self.funding_account.address()),
AccountMeta::writable(self.account.address()),
AccountMeta::readonly(self.wallet.address()),
AccountMeta::readonly(self.mint.address()),
AccountMeta::readonly(self.system_program.address()),
AccountMeta::readonly(self.token_program.address()),
];

// Instruction data:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
ProgramResult,
Expand All @@ -18,17 +18,17 @@ use pinocchio::{
/// 5. `[]` SPL Token program
pub struct CreateIdempotent<'a> {
/// Funding account (must be a system account)
pub funding_account: &'a AccountInfo,
pub funding_account: &'a AccountView,
/// Associated token account address to be created
pub account: &'a AccountInfo,
pub account: &'a AccountView,
/// Wallet address for the new associated token account
pub wallet: &'a AccountInfo,
pub wallet: &'a AccountView,
/// The token mint for the new associated token account
pub mint: &'a AccountInfo,
pub mint: &'a AccountView,
/// System program
pub system_program: &'a AccountInfo,
pub system_program: &'a AccountView,
/// SPL Token program
pub token_program: &'a AccountInfo,
pub token_program: &'a AccountView,
}

impl CreateIdempotent<'_> {
Expand All @@ -41,12 +41,12 @@ impl CreateIdempotent<'_> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 6] = [
AccountMeta::writable_signer(self.funding_account.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::readonly(self.wallet.key()),
AccountMeta::readonly(self.mint.key()),
AccountMeta::readonly(self.system_program.key()),
AccountMeta::readonly(self.token_program.key()),
AccountMeta::writable_signer(self.funding_account.address()),
AccountMeta::writable(self.account.address()),
AccountMeta::readonly(self.wallet.address()),
AccountMeta::readonly(self.mint.address()),
AccountMeta::readonly(self.system_program.address()),
AccountMeta::readonly(self.token_program.address()),
];

// Instruction data:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
ProgramResult,
Expand All @@ -26,19 +26,19 @@ use pinocchio::{
/// 6. `[]` SPL Token program
pub struct RecoverNested<'a> {
/// Nested associated token account, must be owned by `owner_associated_token_account`
pub account: &'a AccountInfo,
pub account: &'a AccountView,
/// Token mint for the nested associated token account
pub mint: &'a AccountInfo,
pub mint: &'a AccountView,
/// Wallet's associated token account
pub destination_account: &'a AccountInfo,
pub destination_account: &'a AccountView,
/// Owner associated token account address, must be owned by `wallet_account`
pub owner_account: &'a AccountInfo,
pub owner_account: &'a AccountView,
/// Token mint for the owner associated token account
pub owner_mint: &'a AccountInfo,
pub owner_mint: &'a AccountView,
/// Wallet address for the owner associated token account
pub wallet: &'a AccountInfo,
pub wallet: &'a AccountView,
/// SPL Token program
pub token_program: &'a AccountInfo,
pub token_program: &'a AccountView,
}

impl RecoverNested<'_> {
Expand All @@ -51,13 +51,13 @@ impl RecoverNested<'_> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 7] = [
AccountMeta::writable(self.account.key()),
AccountMeta::readonly(self.mint.key()),
AccountMeta::writable(self.destination_account.key()),
AccountMeta::readonly(self.owner_account.key()),
AccountMeta::readonly(self.owner_mint.key()),
AccountMeta::writable_signer(self.wallet.key()),
AccountMeta::readonly(self.token_program.key()),
AccountMeta::writable(self.account.address()),
AccountMeta::readonly(self.mint.address()),
AccountMeta::writable(self.destination_account.address()),
AccountMeta::readonly(self.owner_account.address()),
AccountMeta::readonly(self.owner_mint.address()),
AccountMeta::writable_signer(self.wallet.address()),
AccountMeta::readonly(self.token_program.address()),
];

// Instruction data:
Expand Down
6 changes: 3 additions & 3 deletions programs/memo/src/instructions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::mem::MaybeUninit;

use pinocchio::{
account_info::AccountInfo,
account::AccountView,
cpi::{slice_invoke_signed, MAX_CPI_ACCOUNTS},
error::ProgramError,
instruction::{AccountMeta, Instruction, Signer},
Expand All @@ -14,7 +14,7 @@ use pinocchio::{
/// 0. `..+N` `[SIGNER]` N signing accounts
pub struct Memo<'a, 'b, 'c> {
/// Signing accounts
pub signers: &'b [&'a AccountInfo],
pub signers: &'b [&'a AccountView],
/// Memo
pub memo: &'c str,
}
Expand Down Expand Up @@ -44,7 +44,7 @@ impl Memo<'_, '_, '_> {
account_metas
.get_unchecked_mut(i)
.write(AccountMeta::readonly_signer(
self.signers.get_unchecked(i).key(),
self.signers.get_unchecked(i).address(),
));
}
}
Expand Down
14 changes: 7 additions & 7 deletions programs/system/src/instructions/advance_nonce_account.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
ProgramResult,
Expand All @@ -13,13 +13,13 @@ use pinocchio::{
/// 2. `[SIGNER]` Nonce authority
pub struct AdvanceNonceAccount<'a> {
/// Nonce account.
pub account: &'a AccountInfo,
pub account: &'a AccountView,

/// Recent blockhashes sysvar.
pub recent_blockhashes_sysvar: &'a AccountInfo,
pub recent_blockhashes_sysvar: &'a AccountView,

/// Nonce authority.
pub authority: &'a AccountInfo,
pub authority: &'a AccountView,
}

impl AdvanceNonceAccount<'_> {
Expand All @@ -32,9 +32,9 @@ impl AdvanceNonceAccount<'_> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 3] = [
AccountMeta::writable(self.account.key()),
AccountMeta::readonly(self.recent_blockhashes_sysvar.key()),
AccountMeta::readonly_signer(self.authority.key()),
AccountMeta::writable(self.account.address()),
AccountMeta::readonly(self.recent_blockhashes_sysvar.address()),
AccountMeta::readonly_signer(self.authority.address()),
];

// instruction
Expand Down
7 changes: 4 additions & 3 deletions programs/system/src/instructions/allocate.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
ProgramResult,
Expand All @@ -11,7 +11,7 @@ use pinocchio::{
/// 0. `[WRITE, SIGNER]` New account
pub struct Allocate<'a> {
/// Account to be assigned.
pub account: &'a AccountInfo,
pub account: &'a AccountView,

/// Number of bytes of memory to allocate.
pub space: u64,
Expand All @@ -26,7 +26,8 @@ impl Allocate<'_> {
#[inline(always)]
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 1] = [AccountMeta::writable_signer(self.account.key())];
let account_metas: [AccountMeta; 1] =
[AccountMeta::writable_signer(self.account.address())];

// instruction data
// - [0..4 ]: instruction discriminator
Expand Down
Loading