solitaire: remove unused client code
This commit is contained in:
parent
9aad49d631
commit
a8d1ed129b
|
@ -264,7 +264,6 @@ dependencies = [
|
|||
"solana-program",
|
||||
"solana-sdk",
|
||||
"solitaire",
|
||||
"solitaire-client",
|
||||
"wormhole-bridge-solana",
|
||||
]
|
||||
|
||||
|
@ -284,7 +283,6 @@ dependencies = [
|
|||
"solana-program",
|
||||
"solana-sdk",
|
||||
"solitaire",
|
||||
"solitaire-client",
|
||||
"wormhole-bridge-solana",
|
||||
]
|
||||
|
||||
|
@ -508,7 +506,6 @@ dependencies = [
|
|||
"solana-program",
|
||||
"solana-sdk",
|
||||
"solitaire",
|
||||
"solitaire-client",
|
||||
"wormhole-bridge-solana",
|
||||
]
|
||||
|
||||
|
@ -1577,7 +1574,6 @@ dependencies = [
|
|||
"solana-program-test",
|
||||
"solana-sdk",
|
||||
"solitaire",
|
||||
"solitaire-client",
|
||||
"spl-associated-token-account",
|
||||
"spl-token",
|
||||
"spl-token-metadata",
|
||||
|
@ -3178,16 +3174,6 @@ dependencies = [
|
|||
"solana-program",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solitaire-client"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"borsh",
|
||||
"solana-program",
|
||||
"solana-sdk",
|
||||
"solitaire",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
|
@ -3480,7 +3466,6 @@ dependencies = [
|
|||
"solana-program-test",
|
||||
"solana-sdk",
|
||||
"solitaire",
|
||||
"solitaire-client",
|
||||
"spl-token",
|
||||
"spl-token-metadata",
|
||||
"wasm-bindgen",
|
||||
|
@ -3503,7 +3488,6 @@ dependencies = [
|
|||
"solana-program",
|
||||
"solana-sdk",
|
||||
"solitaire",
|
||||
"solitaire-client",
|
||||
"spl-token-metadata",
|
||||
"token-bridge",
|
||||
]
|
||||
|
@ -4060,7 +4044,6 @@ dependencies = [
|
|||
"solana-program-test",
|
||||
"solana-sdk",
|
||||
"solitaire",
|
||||
"solitaire-client",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
|
@ -4081,7 +4064,6 @@ dependencies = [
|
|||
"solana-program",
|
||||
"solana-sdk",
|
||||
"solitaire",
|
||||
"solitaire-client",
|
||||
"spl-token",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
|
|
@ -8,7 +8,6 @@ members = [
|
|||
"modules/nft_bridge/program",
|
||||
"modules/token_bridge/client",
|
||||
"modules/token_bridge/program",
|
||||
"solitaire/client",
|
||||
"solitaire/program",
|
||||
"solitaire/rocksalt",
|
||||
]
|
||||
|
|
|
@ -18,5 +18,4 @@ solana-sdk = "=1.9.4"
|
|||
solana-cli-config = "=1.9.4"
|
||||
solana-clap-utils = "=1.9.4"
|
||||
solitaire = { path = "../../solitaire/program" }
|
||||
solitaire-client = { path = "../../solitaire/client" }
|
||||
wormhole-bridge-solana = { path = "../program", features = ["client"] }
|
||||
wormhole-bridge-solana = { path = "../program", features = ["client"] }
|
||||
|
|
|
@ -58,9 +58,9 @@ use solana_sdk::{
|
|||
use solitaire::{
|
||||
processors::seeded::Seeded,
|
||||
AccountState,
|
||||
Derive,
|
||||
Info,
|
||||
};
|
||||
use solitaire_client::Derive;
|
||||
|
||||
struct Config {
|
||||
rpc_client: RpcClient,
|
||||
|
|
|
@ -9,7 +9,7 @@ crate-type = ["cdylib", "lib"]
|
|||
name = "cpi_poster"
|
||||
|
||||
[features]
|
||||
client = ["solitaire/client", "solitaire-client", "no-entrypoint"]
|
||||
client = ["no-entrypoint"]
|
||||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
no-entrypoint = ["solitaire/no-entrypoint"]
|
||||
|
@ -22,7 +22,6 @@ primitive-types = { version = "0.9.0", default-features = false }
|
|||
sha3 = "0.9.1"
|
||||
solana-program = "=1.9.4"
|
||||
wormhole-bridge-solana = { path = "../program", features = ["no-entrypoint"] }
|
||||
solitaire-client = { path = "../../solitaire/client", optional = true }
|
||||
solitaire = { path = "../../solitaire/program" }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -9,7 +9,7 @@ crate-type = ["cdylib", "lib"]
|
|||
name = "bridge"
|
||||
|
||||
[features]
|
||||
client = ["solitaire/client", "solitaire-client", "no-entrypoint"]
|
||||
client = ["no-entrypoint"]
|
||||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
wasm = ["no-entrypoint", "wasm-bindgen"]
|
||||
|
@ -24,7 +24,6 @@ primitive-types = { version = "0.9.0", default-features = false }
|
|||
serde = { version = "1.0", features = ["derive"] }
|
||||
sha3 = "0.9.1"
|
||||
solana-program = "=1.9.4"
|
||||
solitaire-client = { path = "../../solitaire/client", optional = true }
|
||||
solitaire = { path = "../../solitaire/program" }
|
||||
wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true }
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ crate-type = ["cdylib", "lib"]
|
|||
name = "bridge_stub"
|
||||
|
||||
[features]
|
||||
client = ["solitaire/client", "solitaire-client", "no-entrypoint"]
|
||||
client = ["no-entrypoint"]
|
||||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
no-entrypoint = ["solitaire/no-entrypoint"]
|
||||
|
@ -21,7 +21,6 @@ byteorder = "1.4.3"
|
|||
primitive-types = { version = "0.9.0", default-features = false }
|
||||
sha3 = "0.9.1"
|
||||
solana-program = "=1.9.4"
|
||||
solitaire-client = { path = "../../solitaire/client", optional = true }
|
||||
solitaire = { path = "../../solitaire/program" }
|
||||
wormhole-bridge-solana = { path = "../program", features = ["no-entrypoint"] }
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ name = "wormhole_migration"
|
|||
no-entrypoint = ["solitaire/no-entrypoint", "rand"]
|
||||
trace = ["solitaire/trace"]
|
||||
wasm = ["no-entrypoint", "wasm-bindgen"]
|
||||
client = ["solitaire-client", "solitaire/client", "no-entrypoint"]
|
||||
client = ["no-entrypoint"]
|
||||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
|
||||
|
@ -24,7 +24,6 @@ solitaire = { path = "../solitaire/program" }
|
|||
sha3 = "0.9.1"
|
||||
solana-program = "*"
|
||||
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
|
||||
solitaire-client = { path = "../solitaire/client", optional = true }
|
||||
wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
rand = { version = "0.7.3", optional = true }
|
||||
|
|
|
@ -12,7 +12,7 @@ name = "nft_bridge"
|
|||
no-entrypoint = ["solitaire/no-entrypoint", "instructions", "rand"]
|
||||
trace = ["solitaire/trace"]
|
||||
wasm = ["no-entrypoint", "wasm-bindgen"]
|
||||
client = ["solitaire-client", "solitaire/client", "no-entrypoint"]
|
||||
client = ["no-entrypoint"]
|
||||
cpi = ["no-entrypoint"]
|
||||
instructions = []
|
||||
default = []
|
||||
|
@ -29,7 +29,6 @@ solana-program = "*"
|
|||
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
|
||||
spl-associated-token-account = { version = "1.0.2", features = ["no-entrypoint"] }
|
||||
primitive-types = { version = "0.9.0", default-features = false }
|
||||
solitaire-client = { path = "../../../solitaire/client", optional = true }
|
||||
spl-token-metadata = { path = "../../token_bridge/token-metadata" }
|
||||
wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
@ -15,7 +15,6 @@ solana-program = "=1.9.4"
|
|||
solana-sdk = "=1.9.4"
|
||||
solana-cli-config = "=1.9.4"
|
||||
solitaire = { path = "../../../solitaire/program" }
|
||||
solitaire-client = { path = "../../../solitaire/client" }
|
||||
solana-clap-utils = "=1.9.4"
|
||||
hex = "0.4.3"
|
||||
spl-token-metadata = { path = "../token-metadata" }
|
||||
spl-token-metadata = { path = "../token-metadata" }
|
||||
|
|
|
@ -49,9 +49,9 @@ use solana_sdk::{
|
|||
};
|
||||
use solitaire::{
|
||||
processors::seeded::Seeded,
|
||||
Derive,
|
||||
Info,
|
||||
};
|
||||
use solitaire_client::Derive;
|
||||
|
||||
struct Config {
|
||||
rpc_client: RpcClient,
|
||||
|
|
|
@ -12,7 +12,7 @@ name = "token_bridge"
|
|||
no-entrypoint = ["solitaire/no-entrypoint", "instructions", "rand"]
|
||||
trace = ["solitaire/trace"]
|
||||
wasm = ["no-entrypoint", "wasm-bindgen"]
|
||||
client = ["solitaire-client", "solitaire/client", "no-entrypoint"]
|
||||
client = ["no-entrypoint"]
|
||||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
instructions = []
|
||||
|
@ -28,7 +28,6 @@ sha3 = "0.9.1"
|
|||
solana-program = "*"
|
||||
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
|
||||
primitive-types = { version = "0.9.0", default-features = false }
|
||||
solitaire-client = { path = "../../../solitaire/client", optional = true }
|
||||
spl-token-metadata = { path = "../token-metadata" }
|
||||
wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
[package]
|
||||
name = "solitaire-client"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
solana-sdk = "=1.9.4"
|
||||
solana-program = "=1.9.4"
|
||||
solitaire = {path = "../program", features = ["no-entrypoint"]}
|
||||
borsh = "=0.9.1"
|
|
@ -1,7 +1,3 @@
|
|||
mod to_instruction;
|
||||
|
||||
use to_instruction::*;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::quote;
|
||||
|
@ -15,43 +11,6 @@ use syn::{
|
|||
Generics,
|
||||
};
|
||||
|
||||
#[proc_macro_derive(ToInstruction)]
|
||||
pub fn derive_to_instruction(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
let name = input.ident;
|
||||
|
||||
// Type params of the instruction context account
|
||||
let type_params: Vec<GenericParam> = input
|
||||
.generics
|
||||
.type_params()
|
||||
.map(|v| GenericParam::Type(v.clone()))
|
||||
.collect();
|
||||
|
||||
// Generics lifetimes of the peel type
|
||||
let mut peel_g = input.generics.clone();
|
||||
peel_g.params = parse_quote!('a, 'b: 'a, 'c);
|
||||
|
||||
// Params of the instruction context
|
||||
let mut type_generics = input.generics.clone();
|
||||
type_generics.params = parse_quote!('b);
|
||||
for x in &type_params {
|
||||
type_generics.params.push(x.clone());
|
||||
}
|
||||
|
||||
// Combined lifetimes of peel and the instruction context
|
||||
let mut combined_generics = Generics {
|
||||
params: peel_g.params,
|
||||
..Default::default()
|
||||
};
|
||||
for x in &type_params {
|
||||
combined_generics.params.push(x.clone());
|
||||
}
|
||||
let (combined_impl_g, _, _) = combined_generics.split_for_impl();
|
||||
|
||||
let expanded = generate_to_instruction(&name, &combined_impl_g, &input.data);
|
||||
TokenStream::from(expanded)
|
||||
}
|
||||
|
||||
/// Generate a FromAccounts implementation for a product of accounts. Each field is constructed by
|
||||
/// a call to the Verify::verify instance of its type.
|
||||
#[proc_macro_derive(FromAccounts)]
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
//! Derive macro logic for ToInstruction
|
||||
|
||||
use proc_macro2::{
|
||||
Span,
|
||||
TokenStream as TokenStream2,
|
||||
};
|
||||
use quote::quote;
|
||||
use syn::{
|
||||
Data,
|
||||
DataStruct,
|
||||
Fields,
|
||||
};
|
||||
|
||||
pub fn generate_to_instruction(
|
||||
name: &syn::Ident,
|
||||
impl_generics: &syn::ImplGenerics,
|
||||
data: &Data,
|
||||
) -> TokenStream2 {
|
||||
match *data {
|
||||
Data::Struct(DataStruct {
|
||||
fields: Fields::Named(ref fields),
|
||||
..
|
||||
}) => {
|
||||
let expanded_appends = fields.named.iter().map(|field| {
|
||||
let name = &field.ident;
|
||||
let ty = &field.ty;
|
||||
|
||||
quote! {
|
||||
account_metas.append(&mut <#ty as solitaire_client::Wrap>::wrap(&self.#name)?);
|
||||
if let Some(pair) = <#ty as solitaire_client::Wrap>::keypair(self.#name) {
|
||||
signers.push(pair);
|
||||
}
|
||||
}
|
||||
});
|
||||
let client_struct_name =
|
||||
syn::Ident::new(&format!("{}Accounts", name), Span::call_site());
|
||||
|
||||
let client_struct_decl = generate_clientside_struct(&client_struct_name, data);
|
||||
|
||||
quote! {
|
||||
/// Solitaire-generated client-side #name representation
|
||||
#[cfg(feature = "client")]
|
||||
#client_struct_decl
|
||||
|
||||
/// Solitaire-generatied ToInstruction implementation
|
||||
#[cfg(feature = "client")]
|
||||
impl #impl_generics solitaire_client::ToInstruction for #client_struct_name {
|
||||
fn to_ix(
|
||||
self,
|
||||
program_id: solana_program::pubkey::Pubkey,
|
||||
ix_data: &[u8]) -> std::result::Result<
|
||||
(solitaire_client::Instruction, Vec<solitaire_client::Keypair>),
|
||||
solitaire::ErrBox
|
||||
> {
|
||||
use solana_program::{pubkey::Pubkey, instruction::Instruction};
|
||||
let mut account_metas = Vec::new();
|
||||
let mut signers = Vec::new();
|
||||
let mut deps = Vec::new();
|
||||
|
||||
#(#expanded_appends;)*
|
||||
|
||||
// Add dependencies
|
||||
deps.dedup();
|
||||
let mut dep_ams = deps.iter().map(|v| solana_program::instruction::AccountMeta::new_readonly(*v, false)).collect();
|
||||
account_metas.append(&mut dep_ams);
|
||||
|
||||
Ok((solana_program::instruction::Instruction::new_with_bytes(program_id,
|
||||
ix_data,
|
||||
account_metas), signers))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_clientside_struct(
|
||||
client_struct_name: &syn::Ident,
|
||||
data: &Data,
|
||||
) -> TokenStream2 {
|
||||
match *data {
|
||||
Data::Struct(DataStruct {
|
||||
fields: Fields::Named(ref fields),
|
||||
..
|
||||
}) => {
|
||||
let expanded_fields = fields.named.iter().map(|field| {
|
||||
let field_name = &field.ident;
|
||||
|
||||
quote! {
|
||||
#field_name: solitaire_client::AccEntry
|
||||
}
|
||||
});
|
||||
|
||||
quote! {
|
||||
pub struct #client_struct_name {
|
||||
#(pub #expanded_fields,)*
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue