Skip to content
Open
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
65 changes: 45 additions & 20 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ members = [
"sdk/log/crate",
"sdk/log/macro",
"sdk/pinocchio",
"sdk/pubkey",
]

[workspace.package]
Expand All @@ -22,9 +21,9 @@ rust-version = "1.84"
five8_const = "0.1.4"
pinocchio = { version = "0.9", path = "sdk/pinocchio" }
pinocchio-log-macro = { version = "0.5", path = "sdk/log/macro" }
pinocchio-pubkey = { version = "0.3", path = "sdk/pubkey" }
quote = "1.0"
regex = "1"
solana-address = { version = "1.0", git = "https://github.com/febo/solana-sdk.git", branch = "copy-feature" }
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 @@ -72,13 +72,13 @@ use pinocchio::{
entrypoint,
msg,
ProgramResult,
pubkey::Pubkey
Address
};

entrypoint!(process_instruction);

pub fn process_instruction(
program_id: &Pubkey,
program_id: &Address,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
Expand Down Expand Up @@ -153,15 +153,15 @@ use pinocchio::{
no_allocator,
program_entrypoint,
ProgramResult,
pubkey::Pubkey
Address
};

program_entrypoint!(process_instruction);
default_panic_handler!();
no_allocator!();

pub fn process_instruction(
program_id: &Pubkey,
program_id: &Address,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
Expand Down Expand Up @@ -193,13 +193,13 @@ mod entrypoint {
entrypoint,
msg,
ProgramResult,
pubkey::Pubkey
Address
};

entrypoint!(process_instruction);

pub fn process_instruction(
program_id: &Pubkey,
program_id: &Address,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
Expand Down
2 changes: 1 addition & 1 deletion programs/associated-token-account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ crate-type = ["rlib"]

[dependencies]
pinocchio = { workspace = true }
pinocchio-pubkey = { workspace = true }
solana-address = { workspace = true, features = ["decode"] }
2 changes: 1 addition & 1 deletion programs/associated-token-account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

pub mod instructions;

pinocchio_pubkey::declare_id!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
solana_address::declare_id!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
2 changes: 1 addition & 1 deletion programs/memo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ crate-type = ["rlib"]

[dependencies]
pinocchio = { workspace = true }
pinocchio-pubkey = { workspace = true }
solana-address = { workspace = true, features = ["decode"] }
4 changes: 2 additions & 2 deletions programs/memo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod instructions;

/// Legacy symbols from Memo version 1
pub mod v1 {
pinocchio_pubkey::declare_id!("Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo");
solana_address::declare_id!("Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo");
}

pinocchio_pubkey::declare_id!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
solana_address::declare_id!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
2 changes: 1 addition & 1 deletion programs/system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ crate-type = ["rlib"]

[dependencies]
pinocchio = { workspace = true }
pinocchio-pubkey = { workspace = true }
solana-address = { workspace = true, features = ["decode"] }
17 changes: 8 additions & 9 deletions programs/system/src/instructions/allocate_with_seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ use pinocchio::{
account_info::AccountInfo,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
pubkey::Pubkey,
ProgramResult,
Address, ProgramResult,
};

/// Allocate space for and assign an account at an address derived
/// from a base public key and a seed.
/// from a base address and a seed.
///
/// ### Accounts:
/// 0. `[WRITE]` Allocated account
Expand All @@ -18,19 +17,19 @@ pub struct AllocateWithSeed<'a, 'b, 'c> {

/// Base account.
///
/// The account matching the base Pubkey below must be provided as
/// The account matching the base address below must be provided as
/// a signer, but may be the same as the funding account and provided
/// as account 0.
pub base: &'a AccountInfo,

/// String of ASCII chars, no longer than `Pubkey::MAX_SEED_LEN`.
/// String of ASCII chars, no longer than [`MAX_SEED_LEN`](https://docs.rs/solana-address/latest/solana_address/constant.MAX_SEED_LEN.html).
pub seed: &'b str,

/// Number of bytes of memory to allocate.
pub space: u64,

/// Address of program that will own the new account.
pub owner: &'c Pubkey,
pub owner: &'c Address,
}

impl AllocateWithSeed<'_, '_, '_> {
Expand All @@ -49,14 +48,14 @@ impl AllocateWithSeed<'_, '_, '_> {

// instruction data
// - [0..4 ]: instruction discriminator
// - [4..36 ]: base pubkey
// - [4..36 ]: base address
// - [36..44]: seed length
// - [44.. ]: seed (max 32)
// - [.. +8]: account space
// - [.. +32]: owner pubkey
// - [.. +32]: owner address
let mut instruction_data = [0; 112];
instruction_data[0] = 9;
instruction_data[4..36].copy_from_slice(self.base.key());
instruction_data[4..36].copy_from_slice(self.base.key().as_array());
instruction_data[36..44].copy_from_slice(&u64::to_le_bytes(self.seed.len() as u64));

let offset = 44 + self.seed.len();
Expand Down
9 changes: 4 additions & 5 deletions programs/system/src/instructions/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ use pinocchio::{
account_info::AccountInfo,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
pubkey::Pubkey,
ProgramResult,
Address, ProgramResult,
};

/// Assign account to a program
///
/// ### Accounts:
/// 0. `[WRITE, SIGNER]` Assigned account public key
/// 0. `[WRITE, SIGNER]` Assigned account address
pub struct Assign<'a, 'b> {
/// Account to be assigned.
pub account: &'a AccountInfo,

/// Program account to assign as owner.
pub owner: &'b Pubkey,
pub owner: &'b Address,
}

impl Assign<'_, '_> {
Expand All @@ -31,7 +30,7 @@ impl Assign<'_, '_> {

// instruction data
// - [0..4 ]: instruction discriminator
// - [4..36]: owner pubkey
// - [4..36]: owner address
let mut instruction_data = [0; 36];
instruction_data[0] = 1;
instruction_data[4..36].copy_from_slice(self.owner.as_ref());
Expand Down
15 changes: 7 additions & 8 deletions programs/system/src/instructions/assign_with_seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use pinocchio::{
account_info::AccountInfo,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
pubkey::Pubkey,
ProgramResult,
Address, ProgramResult,
};

/// Assign account to a program based on a seed.
Expand All @@ -17,16 +16,16 @@ pub struct AssignWithSeed<'a, 'b, 'c> {

/// Base account.
///
/// The account matching the base Pubkey below must be provided as
/// The account matching the base `Address` below must be provided as
/// a signer, but may be the same as the funding account and provided
/// as account 0.
pub base: &'a AccountInfo,

/// String of ASCII chars, no longer than `Pubkey::MAX_SEED_LEN`.
/// String of ASCII chars, no longer than [`MAX_SEED_LEN`](https://docs.rs/solana-address/latest/solana_address/constant.MAX_SEED_LEN.html).
pub seed: &'b str,

/// Address of program that will own the new account.
pub owner: &'c Pubkey,
pub owner: &'c Address,
}

impl AssignWithSeed<'_, '_, '_> {
Expand All @@ -45,13 +44,13 @@ impl AssignWithSeed<'_, '_, '_> {

// instruction data
// - [0..4 ]: instruction discriminator
// - [4..36 ]: base pubkey
// - [4..36 ]: base address
// - [36..44]: seed length
// - [44.. ]: seed (max 32)
// - [.. +32]: owner pubkey
// - [.. +32]: owner address
let mut instruction_data = [0; 104];
instruction_data[0] = 10;
instruction_data[4..36].copy_from_slice(self.base.key());
instruction_data[4..36].copy_from_slice(self.base.key().as_array());
instruction_data[36..44].copy_from_slice(&u64::to_le_bytes(self.seed.len() as u64));

let offset = 44 + self.seed.len();
Expand Down
Loading