Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 674b0ac

Browse files
authored
token-cli: Add token-client dependency for token-2022 support (#3386)
1 parent 80b8ff3 commit 674b0ac

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

token/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ solana-sdk = "=1.10.33"
2929
solana-transaction-status = "=1.10.33"
3030
spl-token = { version = "3.3", path="../program", features = [ "no-entrypoint" ] }
3131
spl-token-2022 = { version = "0.4", path="../program-2022", features = [ "no-entrypoint" ] }
32+
spl-token-client = { version = "0.1", path="../client" }
3233
spl-associated-token-account = { version = "1.0.5", path="../../associated-token-account/program", features = [ "no-entrypoint" ] }
3334
spl-memo = { version = "3.0.1", path="../../memo/program", features = ["no-entrypoint"] }
3435
strum = "0.24"

token/cli/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use spl_token_2022::{
1313
extension::StateWithExtensionsOwned,
1414
state::{Account, Mint},
1515
};
16+
use spl_token_client::client::{ProgramClient, ProgramRpcClientSendTransaction};
1617
use std::{process::exit, sync::Arc};
1718

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

3536
pub(crate) struct Config<'a> {
3637
pub(crate) rpc_client: Arc<RpcClient>,
38+
pub(crate) program_client: Arc<dyn ProgramClient<ProgramRpcClientSendTransaction>>,
3739
pub(crate) websocket_url: String,
3840
pub(crate) output_format: OutputFormat,
3941
pub(crate) fee_payer: Pubkey,

token/cli/src/main.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use spl_token_2022::{
4747
instruction::*,
4848
state::{Account, Mint, Multisig},
4949
};
50+
use spl_token_client::client::{ProgramClient, ProgramRpcClient, ProgramRpcClientSendTransaction};
5051
use std::{
5152
collections::HashMap, fmt::Display, process::exit, str::FromStr, string::ToString, sync::Arc,
5253
};
@@ -319,7 +320,7 @@ async fn command_create_token(
319320

320321
let minimum_balance_for_rent_exemption = if !config.sign_only {
321322
config
322-
.rpc_client
323+
.program_client
323324
.get_minimum_balance_for_rent_exemption(Mint::LEN)
324325
.await?
325326
} else {
@@ -383,7 +384,7 @@ async fn command_create_account(
383384
) -> CommandResult {
384385
let minimum_balance_for_rent_exemption = if !config.sign_only {
385386
config
386-
.rpc_client
387+
.program_client
387388
.get_minimum_balance_for_rent_exemption(Account::LEN)
388389
.await?
389390
} else {
@@ -476,7 +477,7 @@ async fn command_create_multisig(
476477

477478
let minimum_balance_for_rent_exemption = if !config.sign_only {
478479
config
479-
.rpc_client
480+
.program_client
480481
.get_minimum_balance_for_rent_exemption(Multisig::LEN)
481482
.await?
482483
} else {
@@ -824,7 +825,7 @@ async fn command_transfer(
824825
if fund_recipient {
825826
if !config.sign_only {
826827
minimum_balance_for_rent_exemption += config
827-
.rpc_client
828+
.program_client
828829
.get_minimum_balance_for_rent_exemption(Account::LEN)
829830
.await?;
830831
println_display(
@@ -1600,7 +1601,7 @@ async fn command_gc(
16001601

16011602
let minimum_balance_for_rent_exemption = if !config.sign_only {
16021603
config
1603-
.rpc_client
1604+
.program_client
16041605
.get_minimum_balance_for_rent_exemption(Account::LEN)
16051606
.await?
16061607
} else {
@@ -2760,8 +2761,12 @@ async fn main() -> Result<(), Error> {
27602761
json_rpc_url,
27612762
CommitmentConfig::confirmed(),
27622763
));
2764+
let program_client: Arc<dyn ProgramClient<ProgramRpcClientSendTransaction>> = Arc::new(
2765+
ProgramRpcClient::new(rpc_client.clone(), ProgramRpcClientSendTransaction),
2766+
);
27632767
Config {
27642768
rpc_client,
2769+
program_client,
27652770
websocket_url,
27662771
output_format,
27672772
fee_payer,
@@ -3329,8 +3334,12 @@ mod tests {
33293334
) -> Config<'a> {
33303335
let websocket_url = test_validator.rpc_pubsub_url();
33313336
let rpc_client = Arc::new(test_validator.get_async_rpc_client());
3337+
let program_client: Arc<dyn ProgramClient<ProgramRpcClientSendTransaction>> = Arc::new(
3338+
ProgramRpcClient::new(rpc_client.clone(), ProgramRpcClientSendTransaction),
3339+
);
33323340
Config {
33333341
rpc_client,
3342+
program_client,
33343343
websocket_url,
33353344
output_format: OutputFormat::JsonCompact,
33363345
fee_payer: payer.pubkey(),

0 commit comments

Comments
 (0)