Skip to content

Use AccountView from Solana SDK #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: febo/solana-address
Choose a base branch
from
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
27 changes: 24 additions & 3 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pinocchio-pubkey = { path = "sdk/pubkey", version = "0.2" }
pinocchio-log-macro = { version = "0.4", 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 = "account-view" }
solana-address = { version = "0.0.0", git = "https://github.com/febo/solana-sdk.git", branch = "solana-address" }
syn = "1.0"

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_view::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_view::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_view::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
14 changes: 7 additions & 7 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_view::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 Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account_view::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 Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account_view::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 Down
8 changes: 4 additions & 4 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_view::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,

/// RecentBlockhashes 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 Down
4 changes: 2 additions & 2 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_view::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 Down
6 changes: 3 additions & 3 deletions programs/system/src/instructions/allocate_with_seed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account_view::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
Address, ProgramResult,
Expand All @@ -13,14 +13,14 @@ use pinocchio::{
/// 1. `[SIGNER]` Base account
pub struct AllocateWithSeed<'a, 'b, 'c> {
/// Allocated account.
pub account: &'a AccountInfo,
pub account: &'a AccountView,

/// Base account.
///
/// 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,
pub base: &'a AccountView,

/// 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,
Expand Down
4 changes: 2 additions & 2 deletions programs/system/src/instructions/assign.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account_view::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
Address, ProgramResult,
Expand All @@ -11,7 +11,7 @@ use pinocchio::{
/// 0. `[WRITE, SIGNER]` Assigned account address
pub struct Assign<'a, 'b> {
/// Account to be assigned.
pub account: &'a AccountInfo,
pub account: &'a AccountView,

/// Program account to assign as owner.
pub owner: &'b Address,
Expand Down
6 changes: 3 additions & 3 deletions programs/system/src/instructions/assign_with_seed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account_view::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
Address, ProgramResult,
Expand All @@ -12,14 +12,14 @@ use pinocchio::{
/// 1. `[SIGNER]` Base account
pub struct AssignWithSeed<'a, 'b, 'c> {
/// Allocated account.
pub account: &'a AccountInfo,
pub account: &'a AccountView,

/// Base account.
///
/// 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,
pub base: &'a AccountView,

/// 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,
Expand Down
6 changes: 3 additions & 3 deletions programs/system/src/instructions/authorize_nonce_account.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account_view::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
Address, ProgramResult,
Expand All @@ -14,10 +14,10 @@ use pinocchio::{
/// 1. `[SIGNER]` Nonce authority
pub struct AuthorizeNonceAccount<'a, 'b> {
/// Nonce account.
pub account: &'a AccountInfo,
pub account: &'a AccountView,

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

/// New entity authorized to execute nonce instructions on the account.
pub new_authority: &'b Address,
Expand Down
6 changes: 3 additions & 3 deletions programs/system/src/instructions/create_account.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account_view::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
Address, ProgramResult,
Expand All @@ -12,10 +12,10 @@ use pinocchio::{
/// 1. `[WRITE, SIGNER]` New account
pub struct CreateAccount<'a> {
/// Funding account.
pub from: &'a AccountInfo,
pub from: &'a AccountView,

/// New account.
pub to: &'a AccountInfo,
pub to: &'a AccountView,

/// Number of lamports to transfer to the new account.
pub lamports: u64,
Expand Down
8 changes: 4 additions & 4 deletions programs/system/src/instructions/create_account_with_seed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pinocchio::{
account_info::AccountInfo,
account_view::AccountView,
instruction::{AccountMeta, Instruction, Signer},
program::invoke_signed,
Address, ProgramResult,
Expand All @@ -14,17 +14,17 @@ use pinocchio::{
/// provided as a signer, but may be the same as the funding account
pub struct CreateAccountWithSeed<'a, 'b, 'c> {
/// Funding account.
pub from: &'a AccountInfo,
pub from: &'a AccountView,

/// New account.
pub to: &'a AccountInfo,
pub to: &'a AccountView,

/// Base account.
///
/// 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: Option<&'a AccountInfo>,
pub base: Option<&'a AccountView>,

/// 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,
Expand Down
Loading