Remove explicit solana dependencies

This commit is contained in:
Armani Ferrante 2021-01-15 20:10:24 -08:00
parent 13ed9d79bb
commit 41b25afed0
No known key found for this signature in database
GPG Key ID: D597A80BCF8E12B7
22 changed files with 63 additions and 83 deletions

2
Cargo.lock generated
View File

@ -117,7 +117,6 @@ dependencies = [
"anchor-derive-accounts",
"serum-borsh",
"solana-program",
"solana-sdk",
"thiserror",
]
@ -126,7 +125,6 @@ name = "anchor-spl"
version = "0.0.0-alpha.0"
dependencies = [
"anchor-lang",
"solana-program",
"spl-token 3.0.1",
]

View File

@ -12,14 +12,13 @@ derive = []
default = []
[dependencies]
thiserror = "1.0.20"
solana-program = "1.4.3"
solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
anchor-derive-accounts = { path = "./derive/accounts", version = "0.0.0-alpha.0" }
anchor-attribute-program = { path = "./attribute/program", version = "0.0.0-alpha.0" }
anchor-attribute-access-control = { path = "./attribute/access-control", version = "0.0.0-alpha.0" }
anchor-attribute-account = { path = "./attribute/account", version = "0.0.0-alpha.0" }
anchor-attribute-program = { path = "./attribute/program", version = "0.0.0-alpha.0" }
anchor-derive-accounts = { path = "./derive/accounts", version = "0.0.0-alpha.0" }
serum-borsh = { version = "0.8.0-serum.1", features = ["serum-program"] }
solana-program = "1.4.3"
thiserror = "1.0.20"
[workspace]
members = [

View File

@ -24,7 +24,7 @@ pub fn account(
// the proc-macro crate.
let mut discriminator = [0u8; 8];
discriminator.copy_from_slice(
&solana_program::hash::hash(
&anchor_lang::solana_program::hash::hash(
#discriminator_preimage.as_bytes(),
).to_bytes()[..8],
);
@ -43,7 +43,7 @@ pub fn account(
fn try_deserialize(buf: &mut &[u8]) -> Result<Self, ProgramError> {
let mut discriminator = [0u8; 8];
discriminator.copy_from_slice(
&solana_program::hash::hash(
&anchor_lang::solana_program::hash::hash(
#discriminator_preimage.as_bytes(),
).to_bytes()[..8],
);

View File

@ -28,8 +28,6 @@ cpi = ["no-entrypoint"]
[dependencies]
anchor-lang = {{ git = "https://github.com/project-serum/anchor", features = ["derive"] }}
solana-program = "1.4.3"
solana-sdk = {{ version = "1.3.14", default-features = false, features = ["program"] }}
"#,
name,
name.to_snake_case(),

View File

@ -14,5 +14,3 @@ cpi = ["no-entrypoint"]
[dependencies]
anchor-lang = { git = "https://github.com/project-serum/anchor", features = ["derive"] }
solana-program = "1.4.3"
solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }

View File

@ -15,5 +15,3 @@ cpi = ["no-entrypoint"]
[dependencies]
anchor-lang = { git = "https://github.com/project-serum/anchor", features = ["derive"] }
anchor-spl = { git = "https://github.com/project-serum/anchor" }
solana-program = "1.4.3"
solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }

View File

@ -13,6 +13,4 @@ no-entrypoint = []
cpi = ["no-entrypoint"]
[dependencies]
solana-program = "1.4.3"
solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
anchor-lang = { git = "https://github.com/project-serum/anchor", features = ["derive"] }

View File

@ -13,6 +13,4 @@ no-entrypoint = []
cpi = ["no-entrypoint"]
[dependencies]
solana-program = "1.4.3"
solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
anchor-lang = { git = "https://github.com/project-serum/anchor", features = ["derive"] }

View File

@ -13,6 +13,4 @@ no-entrypoint = []
cpi = ["no-entrypoint"]
[dependencies]
solana-program = "1.4.3"
solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
anchor-lang = { git = "https://github.com/project-serum/anchor", features = ["derive"] }

View File

@ -13,6 +13,4 @@ no-entrypoint = []
cpi = ["no-entrypoint"]
[dependencies]
solana-program = "1.4.3"
solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
anchor-lang = { git = "https://github.com/project-serum/anchor", features = ["derive"] }

View File

@ -13,7 +13,5 @@ no-entrypoint = []
cpi = ["no-entrypoint"]
[dependencies]
solana-program = "1.4.3"
solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
anchor-lang = { git = "https://github.com/project-serum/anchor", features = ["derive"] }
puppet = { path = "../puppet", features = ["cpi"] }

View File

@ -13,6 +13,4 @@ no-entrypoint = []
cpi = ["no-entrypoint"]
[dependencies]
solana-program = "1.4.3"
solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
anchor-lang = { git = "https://github.com/project-serum/anchor", features = ["derive"] }

View File

@ -6,5 +6,4 @@ edition = "2018"
[dependencies]
anchor-lang = { path = "../", features = ["derive"] }
solana-program = "1.4.3"
spl-token = { version = "3.0.1", features = ["no-entrypoint"] }

View File

@ -1,6 +1,7 @@
use anchor_lang::solana_program;
use anchor_lang::solana_program::account_info::AccountInfo;
use anchor_lang::solana_program::entrypoint::ProgramResult;
use anchor_lang::{Accounts, CpiContext};
use solana_program::account_info::AccountInfo;
use solana_program::entrypoint::ProgramResult;
pub fn transfer<'a, 'b, 'c, 'info>(
ctx: CpiContext<'a, 'b, 'c, 'info, Transfer<'info>>,

View File

@ -1,8 +1,8 @@
use crate::{Accounts, ToAccountInfo, ToAccountInfos, ToAccountMetas};
use solana_sdk::account_info::AccountInfo;
use solana_sdk::instruction::AccountMeta;
use solana_sdk::program_error::ProgramError;
use solana_sdk::pubkey::Pubkey;
use solana_program::account_info::AccountInfo;
use solana_program::instruction::AccountMeta;
use solana_program::program_error::ProgramError;
use solana_program::pubkey::Pubkey;
impl<'info> Accounts<'info> for AccountInfo<'info> {
fn try_accounts(

View File

@ -1,6 +1,6 @@
use crate::Accounts;
use solana_sdk::account_info::AccountInfo;
use solana_sdk::pubkey::Pubkey;
use solana_program::account_info::AccountInfo;
use solana_program::pubkey::Pubkey;
/// Provides non-argument inputs to the program.
pub struct Context<'a, 'b, 'c, 'info, T> {

View File

@ -1,10 +1,10 @@
use crate::{
AccountDeserialize, AccountSerialize, Accounts, ToAccountInfo, ToAccountInfos, ToAccountMetas,
};
use solana_sdk::account_info::AccountInfo;
use solana_sdk::instruction::AccountMeta;
use solana_sdk::program_error::ProgramError;
use solana_sdk::pubkey::Pubkey;
use solana_program::account_info::AccountInfo;
use solana_program::instruction::AccountMeta;
use solana_program::program_error::ProgramError;
use solana_program::pubkey::Pubkey;
use std::ops::{Deref, DerefMut};
/// Container for any account *not* owned by the current program.

View File

@ -21,10 +21,10 @@
//!
//! Presented here are the Rust primitives for building on Solana.
use solana_sdk::account_info::AccountInfo;
use solana_sdk::instruction::AccountMeta;
use solana_sdk::program_error::ProgramError;
use solana_sdk::pubkey::Pubkey;
use solana_program::account_info::AccountInfo;
use solana_program::instruction::AccountMeta;
use solana_program::program_error::ProgramError;
use solana_program::pubkey::Pubkey;
use std::io::Write;
mod account_info;
@ -43,6 +43,7 @@ pub use anchor_attribute_program::program;
pub use anchor_derive_accounts::Accounts;
/// Default serialization format for anchor instructions and accounts.
pub use borsh::{BorshDeserialize as AnchorDeserialize, BorshSerialize as AnchorSerialize};
pub use solana_program;
/// A data structure of accounts that can be deserialized from the input
/// of a Solana program. Due to the freewheeling nature of the accounts array,
@ -120,21 +121,21 @@ pub mod prelude {
};
pub use borsh;
pub use solana_program::account_info::{next_account_info, AccountInfo};
pub use solana_program::entrypoint::ProgramResult;
pub use solana_program::instruction::AccountMeta;
pub use solana_program::msg;
pub use solana_sdk::account_info::{next_account_info, AccountInfo};
pub use solana_sdk::entrypoint::ProgramResult;
pub use solana_sdk::instruction::AccountMeta;
pub use solana_sdk::program_error::ProgramError;
pub use solana_sdk::pubkey::Pubkey;
pub use solana_sdk::sysvar::clock::Clock;
pub use solana_sdk::sysvar::epoch_schedule::EpochSchedule;
pub use solana_sdk::sysvar::fees::Fees;
pub use solana_sdk::sysvar::instructions::Instructions;
pub use solana_sdk::sysvar::recent_blockhashes::RecentBlockhashes;
pub use solana_sdk::sysvar::rent::Rent;
pub use solana_sdk::sysvar::rewards::Rewards;
pub use solana_sdk::sysvar::slot_hashes::SlotHashes;
pub use solana_sdk::sysvar::slot_history::SlotHistory;
pub use solana_sdk::sysvar::stake_history::StakeHistory;
pub use solana_sdk::sysvar::Sysvar as SolanaSysvar;
pub use solana_program::program_error::ProgramError;
pub use solana_program::pubkey::Pubkey;
pub use solana_program::sysvar::clock::Clock;
pub use solana_program::sysvar::epoch_schedule::EpochSchedule;
pub use solana_program::sysvar::fees::Fees;
pub use solana_program::sysvar::instructions::Instructions;
pub use solana_program::sysvar::recent_blockhashes::RecentBlockhashes;
pub use solana_program::sysvar::rent::Rent;
pub use solana_program::sysvar::rewards::Rewards;
pub use solana_program::sysvar::slot_hashes::SlotHashes;
pub use solana_program::sysvar::slot_history::SlotHistory;
pub use solana_program::sysvar::stake_history::StakeHistory;
pub use solana_program::sysvar::Sysvar as SolanaSysvar;
}

View File

@ -2,10 +2,10 @@ use crate::{
AccountDeserialize, AccountSerialize, Accounts, AccountsInit, CpiAccount, ToAccountInfo,
ToAccountInfos, ToAccountMetas,
};
use solana_sdk::account_info::AccountInfo;
use solana_sdk::instruction::AccountMeta;
use solana_sdk::program_error::ProgramError;
use solana_sdk::pubkey::Pubkey;
use solana_program::account_info::AccountInfo;
use solana_program::instruction::AccountMeta;
use solana_program::program_error::ProgramError;
use solana_program::pubkey::Pubkey;
use std::ops::{Deref, DerefMut};
/// Container for a serializable `account`. Use this to reference any account

View File

@ -1,17 +1,17 @@
use crate::{Accounts, ToAccountInfo, ToAccountInfos, ToAccountMetas};
use solana_sdk::account_info::AccountInfo;
use solana_sdk::instruction::AccountMeta;
use solana_sdk::program_error::ProgramError;
use solana_sdk::pubkey::Pubkey;
use solana_program::account_info::AccountInfo;
use solana_program::instruction::AccountMeta;
use solana_program::program_error::ProgramError;
use solana_program::pubkey::Pubkey;
use std::ops::{Deref, DerefMut};
/// Container for sysvars.
pub struct Sysvar<'info, T: solana_sdk::sysvar::Sysvar> {
pub struct Sysvar<'info, T: solana_program::sysvar::Sysvar> {
info: AccountInfo<'info>,
account: T,
}
impl<'info, T: solana_sdk::sysvar::Sysvar> Sysvar<'info, T> {
impl<'info, T: solana_program::sysvar::Sysvar> Sysvar<'info, T> {
pub fn from_account_info(
acc_info: &AccountInfo<'info>,
) -> Result<Sysvar<'info, T>, ProgramError> {
@ -22,7 +22,7 @@ impl<'info, T: solana_sdk::sysvar::Sysvar> Sysvar<'info, T> {
}
}
impl<'info, T: solana_sdk::sysvar::Sysvar> Accounts<'info> for Sysvar<'info, T> {
impl<'info, T: solana_program::sysvar::Sysvar> Accounts<'info> for Sysvar<'info, T> {
fn try_accounts(
_program_id: &Pubkey,
accounts: &mut &[AccountInfo<'info>],
@ -36,19 +36,19 @@ impl<'info, T: solana_sdk::sysvar::Sysvar> Accounts<'info> for Sysvar<'info, T>
}
}
impl<'info, T: solana_sdk::sysvar::Sysvar> ToAccountMetas for Sysvar<'info, T> {
impl<'info, T: solana_program::sysvar::Sysvar> ToAccountMetas for Sysvar<'info, T> {
fn to_account_metas(&self) -> Vec<AccountMeta> {
vec![AccountMeta::new_readonly(*self.info.key, false)]
}
}
impl<'info, T: solana_sdk::sysvar::Sysvar> ToAccountInfos<'info> for Sysvar<'info, T> {
impl<'info, T: solana_program::sysvar::Sysvar> ToAccountInfos<'info> for Sysvar<'info, T> {
fn to_account_infos(&self) -> Vec<AccountInfo<'info>> {
vec![self.info.clone()]
}
}
impl<'a, T: solana_sdk::sysvar::Sysvar> Deref for Sysvar<'a, T> {
impl<'a, T: solana_program::sysvar::Sysvar> Deref for Sysvar<'a, T> {
type Target = T;
fn deref(&self) -> &Self::Target {
@ -56,13 +56,13 @@ impl<'a, T: solana_sdk::sysvar::Sysvar> Deref for Sysvar<'a, T> {
}
}
impl<'a, T: solana_sdk::sysvar::Sysvar> DerefMut for Sysvar<'a, T> {
impl<'a, T: solana_program::sysvar::Sysvar> DerefMut for Sysvar<'a, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.account
}
}
impl<'info, T: solana_sdk::sysvar::Sysvar> ToAccountInfo<'info> for Sysvar<'info, T> {
impl<'info, T: solana_program::sysvar::Sysvar> ToAccountInfo<'info> for Sysvar<'info, T> {
fn to_account_info(&self) -> AccountInfo<'info> {
self.info.clone()
}

View File

@ -146,7 +146,7 @@ pub fn generate(accs: AccountsStruct) -> proc_macro2::TokenStream {
quote! {
impl#combined_generics anchor_lang::Accounts#trait_generics for #name#strct_generics {
fn try_accounts(program_id: &solana_program::pubkey::Pubkey, accounts: &mut &[solana_program::account_info::AccountInfo<'info>]) -> Result<Self, solana_program::program_error::ProgramError> {
fn try_accounts(program_id: &anchor_lang::solana_program::pubkey::Pubkey, accounts: &mut &[anchor_lang::solana_program::account_info::AccountInfo<'info>]) -> Result<Self, anchor_lang::solana_program::program_error::ProgramError> {
// Deserialize each account.
#(#deser_fields)*
@ -161,7 +161,7 @@ pub fn generate(accs: AccountsStruct) -> proc_macro2::TokenStream {
}
impl#combined_generics anchor_lang::ToAccountInfos#trait_generics for #name#strct_generics {
fn to_account_infos(&self) -> Vec<solana_program::account_info::AccountInfo<'info>> {
fn to_account_infos(&self) -> Vec<anchor_lang::solana_program::account_info::AccountInfo<'info>> {
let mut account_infos = vec![];
#(#to_acc_infos)*
@ -171,7 +171,7 @@ pub fn generate(accs: AccountsStruct) -> proc_macro2::TokenStream {
}
impl#combined_generics anchor_lang::ToAccountMetas for #name#strct_generics {
fn to_account_metas(&self) -> Vec<solana_program::instruction::AccountMeta> {
fn to_account_metas(&self) -> Vec<anchor_lang::solana_program::instruction::AccountMeta> {
let mut account_metas = vec![];
#(#to_acc_metas)*
@ -182,7 +182,7 @@ pub fn generate(accs: AccountsStruct) -> proc_macro2::TokenStream {
}
impl#strct_generics #name#strct_generics {
pub fn exit(&self, program_id: &solana_program::pubkey::Pubkey) -> solana_program::entrypoint::ProgramResult {
pub fn exit(&self, program_id: &anchor_lang::solana_program::pubkey::Pubkey) -> anchor_lang::solana_program::entrypoint::ProgramResult {
#(#on_save)*
Ok(())
}

View File

@ -16,7 +16,7 @@ pub fn generate(program: Program) -> proc_macro2::TokenStream {
use #mod_name::*;
#[cfg(not(feature = "no-entrypoint"))]
solana_program::entrypoint!(entry);
anchor_lang::solana_program::entrypoint!(entry);
#[cfg(not(feature = "no-entrypoint"))]
fn entry(program_id: &Pubkey, accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResult {
let mut data: &[u8] = instruction_data;
@ -156,7 +156,7 @@ fn generate_cpi(program: &Program) -> proc_macro2::TokenStream {
let data = AnchorSerialize::try_to_vec(&ix)
.map_err(|_| ProgramError::InvalidInstructionData)?;
let accounts = ctx.accounts.to_account_metas();
solana_program::instruction::Instruction {
anchor_lang::solana_program::instruction::Instruction {
program_id: *ctx.program.key,
accounts,
data,
@ -164,7 +164,7 @@ fn generate_cpi(program: &Program) -> proc_macro2::TokenStream {
};
let mut acc_infos = ctx.accounts.to_account_infos();
acc_infos.push(ctx.program.clone());
solana_sdk::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&acc_infos,
ctx.signer_seeds,