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
39 changes: 31 additions & 8 deletions Cargo.lock

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

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ pinocchio = { version = "0.9", path = "sdk/pinocchio" }
pinocchio-log-macro = { version = "0.5", path = "sdk/log/macro" }
quote = "1.0"
regex = "1"
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" }
solana-account-view = { version = "0.0.0", git = "https://github.com/febo/solana-sdk.git", branch = "solana-instruction-view" }
solana-address = { version = "1.0", git = "https://github.com/febo/solana-sdk.git", branch = "solana-instruction-view" }
solana-instruction-view = { version = "0.0.0", git = "https://github.com/febo/solana-sdk.git", branch = "solana-instruction-view" }
solana-program-error = { version = "3.0.0", git = "https://github.com/febo/solana-sdk.git", branch = "solana-instruction-view" }
syn = "1.0"

[workspace.metadata.cli]
Expand Down
4 changes: 3 additions & 1 deletion programs/associated-token-account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ rust-version = { workspace = true }
crate-type = ["rlib"]

[dependencies]
pinocchio = { workspace = true }
solana-account-view = { workspace = true }
solana-address = { workspace = true, features = ["decode"] }
solana-instruction-view = { workspace = true, features = ["cpi"] }
solana-program-error = { workspace = true }
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,9 +1,9 @@
use pinocchio::{
account::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
ProgramResult,
use solana_account_view::AccountView;
use solana_instruction_view::{
cpi::{invoke_signed, Signer},
AccountRole, InstructionView,
};
use solana_program_error::ProgramResult;

/// Creates an associated token account for the given wallet address and token mint.
/// Returns an error if the account exists.
Expand Down Expand Up @@ -39,21 +39,21 @@ impl Create<'_> {
#[inline(always)]
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 6] = [
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()),
let account_metas: [AccountRole; 6] = [
AccountRole::writable_signer(self.funding_account.address()),
AccountRole::writable(self.account.address()),
AccountRole::readonly(self.wallet.address()),
AccountRole::readonly(self.mint.address()),
AccountRole::readonly(self.system_program.address()),
AccountRole::readonly(self.token_program.address()),
];

// Instruction data:
// - [0]: Instruction discriminator (1 byte, u8) (0 for Create)

let instruction_data = [0u8];

let instruction = Instruction {
let instruction = InstructionView {
program_id: &crate::ID,
accounts: &account_metas,
data: &instruction_data,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pinocchio::{
account::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
ProgramResult,
use solana_account_view::AccountView;
use solana_instruction_view::{
cpi::{invoke_signed, Signer},
AccountRole, InstructionView,
};
use solana_program_error::ProgramResult;

/// Creates an associated token account for the given wallet address and
/// token mint, if it doesn't already exist. Returns an error if the
Expand Down Expand Up @@ -40,21 +40,21 @@ impl CreateIdempotent<'_> {
#[inline(always)]
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 6] = [
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()),
let account_metas: [AccountRole; 6] = [
AccountRole::writable_signer(self.funding_account.address()),
AccountRole::writable(self.account.address()),
AccountRole::readonly(self.wallet.address()),
AccountRole::readonly(self.mint.address()),
AccountRole::readonly(self.system_program.address()),
AccountRole::readonly(self.token_program.address()),
];

// Instruction data:
// - [0]: Instruction discriminator (1 byte, u8) (1 for CreateIdempotent)

let instruction_data = [1u8];

let instruction = Instruction {
let instruction = InstructionView {
program_id: &crate::ID,
accounts: &account_metas,
data: &instruction_data,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pinocchio::{
account::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
ProgramResult,
use solana_account_view::AccountView;
use solana_instruction_view::{
cpi::{invoke_signed, Signer},
AccountRole, InstructionView,
};
use solana_program_error::ProgramResult;

/// Transfers from and closes a nested associated token account: an
/// associated token account owned by an associated token account.
Expand Down Expand Up @@ -50,22 +50,22 @@ impl RecoverNested<'_> {
#[inline(always)]
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 7] = [
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()),
let account_metas: [AccountRole; 7] = [
AccountRole::writable(self.account.address()),
AccountRole::readonly(self.mint.address()),
AccountRole::writable(self.destination_account.address()),
AccountRole::readonly(self.owner_account.address()),
AccountRole::readonly(self.owner_mint.address()),
AccountRole::writable_signer(self.wallet.address()),
AccountRole::readonly(self.token_program.address()),
];

// Instruction data:
// - [0]: Instruction discriminator (1 byte, u8) (2 for RecoverNested)

let instruction_data = [2u8];

let instruction = Instruction {
let instruction = InstructionView {
program_id: &crate::ID,
accounts: &account_metas,
data: &instruction_data,
Expand Down
4 changes: 3 additions & 1 deletion programs/memo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ rust-version = { workspace = true }
crate-type = ["rlib"]

[dependencies]
pinocchio = { workspace = true }
solana-account-view = { workspace = true }
solana-address = { workspace = true, features = ["decode"] }
solana-instruction-view = { workspace = true, features = ["cpi"] }
solana-program-error = { workspace = true }
17 changes: 8 additions & 9 deletions programs/memo/src/instructions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use core::mem::MaybeUninit;

use pinocchio::{
account::AccountView,
cpi::{slice_invoke_signed, MAX_CPI_ACCOUNTS},
error::ProgramError,
instruction::{AccountMeta, Instruction, Signer},
ProgramResult,
use solana_account_view::AccountView;
use solana_instruction_view::{
cpi::{slice_invoke_signed, Signer, MAX_CPI_ACCOUNTS},
AccountRole, InstructionView,
};
use solana_program_error::{ProgramError, ProgramResult};

/// Memo instruction.
///
Expand All @@ -27,7 +26,7 @@ impl Memo<'_, '_, '_> {

#[inline(always)]
pub fn invoke_signed(&self, signers_seeds: &[Signer]) -> ProgramResult {
const UNINIT_META: MaybeUninit<AccountMeta> = MaybeUninit::<AccountMeta>::uninit();
const UNINIT_META: MaybeUninit<AccountRole> = MaybeUninit::<AccountRole>::uninit();

// We don't know num_accounts at compile time, so we use MAX_CPI_ACCOUNTS
let mut account_metas = [UNINIT_META; MAX_CPI_ACCOUNTS];
Expand All @@ -43,14 +42,14 @@ impl Memo<'_, '_, '_> {
// SAFETY: i is less than len(self.signers)
account_metas
.get_unchecked_mut(i)
.write(AccountMeta::readonly_signer(
.write(AccountRole::readonly_signer(
self.signers.get_unchecked(i).address(),
));
}
}

// SAFETY: len(account_metas) <= MAX_CPI_ACCOUNTS
let instruction = Instruction {
let instruction = InstructionView {
program_id: &crate::ID,
accounts: unsafe {
core::slice::from_raw_parts(account_metas.as_ptr() as _, num_accounts)
Expand Down
3 changes: 3 additions & 0 deletions programs/system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ crate-type = ["rlib"]

[dependencies]
pinocchio = { workspace = true }
solana-account-view = { workspace = true }
solana-address = { workspace = true, features = ["decode"] }
solana-instruction-view = { workspace = true, features = ["cpi"] }
solana-program-error = { workspace = true }
20 changes: 10 additions & 10 deletions programs/system/src/instructions/advance_nonce_account.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pinocchio::{
account::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
ProgramResult,
use solana_account_view::AccountView;
use solana_instruction_view::{
cpi::{invoke_signed, Signer},
AccountRole, InstructionView,
};
use solana_program_error::ProgramResult;

/// Consumes a stored nonce, replacing it with a successor.
///
Expand Down Expand Up @@ -31,14 +31,14 @@ impl AdvanceNonceAccount<'_> {
#[inline(always)]
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 3] = [
AccountMeta::writable(self.account.address()),
AccountMeta::readonly(self.recent_blockhashes_sysvar.address()),
AccountMeta::readonly_signer(self.authority.address()),
let account_metas: [AccountRole; 3] = [
AccountRole::writable(self.account.address()),
AccountRole::readonly(self.recent_blockhashes_sysvar.address()),
AccountRole::readonly_signer(self.authority.address()),
];

// instruction
let instruction = Instruction {
let instruction = InstructionView {
program_id: &crate::ID,
accounts: &account_metas,
data: &[4],
Expand Down
16 changes: 8 additions & 8 deletions programs/system/src/instructions/allocate.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pinocchio::{
account::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
ProgramResult,
use solana_account_view::AccountView;
use solana_instruction_view::{
cpi::{invoke_signed, Signer},
AccountRole, InstructionView,
};
use solana_program_error::ProgramResult;

/// Allocate space in a (possibly new) account without funding.
///
Expand All @@ -26,8 +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.address())];
let account_metas: [AccountRole; 1] =
[AccountRole::writable_signer(self.account.address())];

// instruction data
// - [0..4 ]: instruction discriminator
Expand All @@ -36,7 +36,7 @@ impl Allocate<'_> {
instruction_data[0] = 8;
instruction_data[4..12].copy_from_slice(&self.space.to_le_bytes());

let instruction = Instruction {
let instruction = InstructionView {
program_id: &crate::ID,
accounts: &account_metas,
data: &instruction_data,
Expand Down
Loading