Skip to content

Commit

Permalink
token-cli: Add token-client dependency for token-2022 support
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque committed Jul 27, 2022
1 parent fb46b9a commit 1fc124e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 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 token/cli/Cargo.toml
Expand Up @@ -29,6 +29,7 @@ solana-sdk = "=1.10.29"
solana-transaction-status = "=1.10.29"
spl-token = { version = "3.3", path="../program", features = [ "no-entrypoint" ] }
spl-token-2022 = { version = "0.4", path="../program-2022", features = [ "no-entrypoint" ] }
spl-token-client = { version = "0.1", path="../client" }
spl-associated-token-account = { version = "1.0.5", path="../../associated-token-account/program", features = [ "no-entrypoint" ] }
spl-memo = { version = "3.0.1", path="../../memo/program", features = ["no-entrypoint"] }
strum = "0.24"
Expand Down
2 changes: 2 additions & 0 deletions token/cli/src/config.rs
Expand Up @@ -13,6 +13,7 @@ use spl_token_2022::{
extension::StateWithExtensionsOwned,
state::{Account, Mint},
};
use spl_token_client::client::{ProgramClient, ProgramRpcClientSendTransaction};
use std::{process::exit, sync::Arc};

#[cfg(test)]
Expand All @@ -34,6 +35,7 @@ pub(crate) struct MintInfo {

pub(crate) struct Config<'a> {
pub(crate) rpc_client: Arc<RpcClient>,
pub(crate) program_client: Arc<dyn ProgramClient<ProgramRpcClientSendTransaction>>,
pub(crate) websocket_url: String,
pub(crate) output_format: OutputFormat,
pub(crate) fee_payer: Pubkey,
Expand Down
19 changes: 14 additions & 5 deletions token/cli/src/main.rs
Expand Up @@ -47,6 +47,7 @@ use spl_token_2022::{
instruction::*,
state::{Account, Mint, Multisig},
};
use spl_token_client::client::{ProgramClient, ProgramRpcClient, ProgramRpcClientSendTransaction};
use std::{
collections::HashMap, fmt::Display, process::exit, str::FromStr, string::ToString, sync::Arc,
};
Expand Down Expand Up @@ -319,7 +320,7 @@ async fn command_create_token(

let minimum_balance_for_rent_exemption = if !config.sign_only {
config
.rpc_client
.program_client
.get_minimum_balance_for_rent_exemption(Mint::LEN)
.await?
} else {
Expand Down Expand Up @@ -383,7 +384,7 @@ async fn command_create_account(
) -> CommandResult {
let minimum_balance_for_rent_exemption = if !config.sign_only {
config
.rpc_client
.program_client
.get_minimum_balance_for_rent_exemption(Account::LEN)
.await?
} else {
Expand Down Expand Up @@ -476,7 +477,7 @@ async fn command_create_multisig(

let minimum_balance_for_rent_exemption = if !config.sign_only {
config
.rpc_client
.program_client
.get_minimum_balance_for_rent_exemption(Multisig::LEN)
.await?
} else {
Expand Down Expand Up @@ -824,7 +825,7 @@ async fn command_transfer(
if fund_recipient {
if !config.sign_only {
minimum_balance_for_rent_exemption += config
.rpc_client
.program_client
.get_minimum_balance_for_rent_exemption(Account::LEN)
.await?;
println_display(
Expand Down Expand Up @@ -1600,7 +1601,7 @@ async fn command_gc(

let minimum_balance_for_rent_exemption = if !config.sign_only {
config
.rpc_client
.program_client
.get_minimum_balance_for_rent_exemption(Account::LEN)
.await?
} else {
Expand Down Expand Up @@ -2760,8 +2761,12 @@ async fn main() -> Result<(), Error> {
json_rpc_url,
CommitmentConfig::confirmed(),
));
let program_client: Arc<dyn ProgramClient<ProgramRpcClientSendTransaction>> = Arc::new(
ProgramRpcClient::new(rpc_client.clone(), ProgramRpcClientSendTransaction),
);
Config {
rpc_client,
program_client,
websocket_url,
output_format,
fee_payer,
Expand Down Expand Up @@ -3328,8 +3333,12 @@ mod tests {
) -> Config<'a> {
let websocket_url = test_validator.rpc_pubsub_url();
let rpc_client = Arc::new(test_validator.get_async_rpc_client());
let program_client: Arc<dyn ProgramClient<ProgramRpcClientSendTransaction>> = Arc::new(
ProgramRpcClient::new(rpc_client.clone(), ProgramRpcClientSendTransaction),
);
Config {
rpc_client,
program_client,
websocket_url,
output_format: OutputFormat::JsonCompact,
fee_payer: payer.pubkey(),
Expand Down

0 comments on commit 1fc124e

Please sign in to comment.