@@ -21,20 +21,19 @@ use {
2121 keypair:: signer_from_path,
2222 } ,
2323 solana_cli_output:: {
24- return_signers_data, CliSignOnlyData , CliSignature , OutputFormat , QuietDisplay ,
25- ReturnSignersConfig , VerboseDisplay ,
24+ display :: build_balance_message , return_signers_data, CliSignOnlyData , CliSignature ,
25+ OutputFormat , QuietDisplay , ReturnSignersConfig , VerboseDisplay ,
2626 } ,
2727 solana_client:: rpc_request:: TokenAccountsFilter ,
2828 solana_remote_wallet:: remote_wallet:: RemoteWalletManager ,
2929 solana_sdk:: {
3030 instruction:: AccountMeta ,
31- native_token:: * ,
3231 program_option:: COption ,
3332 pubkey:: Pubkey ,
3433 signature:: { Keypair , Signer } ,
3534 } ,
3635 solana_system_interface:: program as system_program,
37- spl_associated_token_account_client :: address:: get_associated_token_address_with_program_id,
36+ spl_associated_token_account_interface :: address:: get_associated_token_address_with_program_id,
3837 spl_pod:: optional_keys:: OptionalNonZeroPubkey ,
3938 spl_token_2022:: extension:: confidential_transfer:: account_info:: {
4039 ApplyPendingBalanceAccountInfo , TransferAccountInfo , WithdrawAccountInfo ,
@@ -95,7 +94,7 @@ fn print_error_and_exit<T, E: Display>(e: E) -> T {
9594fn amount_to_raw_amount ( amount : Amount , decimals : u8 , all_amount : Option < u64 > , name : & str ) -> u64 {
9695 match amount {
9796 Amount :: Raw ( ui_amount) => ui_amount,
98- Amount :: Decimal ( ui_amount) => spl_token :: ui_amount_to_amount ( ui_amount, decimals) ,
97+ Amount :: Decimal ( ui_amount) => spl_token_2022 :: ui_amount_to_amount ( ui_amount, decimals) ,
9998 Amount :: All => {
10099 if let Some ( raw_amount) = all_amount {
101100 raw_amount
@@ -145,8 +144,8 @@ async fn check_wallet_balance(
145144 Err ( format ! (
146145 "Wallet {}, has insufficient balance: {} required, {} available" ,
147146 wallet,
148- lamports_to_sol ( required_balance) ,
149- lamports_to_sol ( balance)
147+ build_balance_message ( required_balance, false , false ) ,
148+ build_balance_message ( balance, false , false )
150149 )
151150 . into ( ) )
152151 } else {
@@ -822,7 +821,7 @@ async fn command_set_transfer_fee(
822821 "Setting transfer fee for {} to {} bps, {} maximum" ,
823822 token_pubkey,
824823 transfer_fee_basis_points,
825- spl_token :: amount_to_ui_amount( maximum_fee, decimals)
824+ spl_token_2022 :: amount_to_ui_amount( maximum_fee, decimals)
826825 ) ,
827826 ) ;
828827
@@ -877,7 +876,7 @@ async fn command_create_account(
877876 }
878877
879878 if immutable_owner {
880- if config. program_id == spl_token :: id ( ) {
879+ if config. program_id == spl_token_interface :: id ( ) {
881880 return Err ( format ! (
882881 "Specified --immutable, but token program {} does not support the extension" ,
883882 config. program_id
@@ -1331,7 +1330,9 @@ async fn command_transfer(
13311330 // the amount the user wants to transfer, as a u64
13321331 let transfer_balance = match ui_amount {
13331332 Amount :: Raw ( ui_amount) => ui_amount,
1334- Amount :: Decimal ( ui_amount) => spl_token:: ui_amount_to_amount ( ui_amount, mint_info. decimals ) ,
1333+ Amount :: Decimal ( ui_amount) => {
1334+ spl_token_2022:: ui_amount_to_amount ( ui_amount, mint_info. decimals )
1335+ }
13351336 Amount :: All => {
13361337 if config. sign_only {
13371338 return Err ( "Use of ALL keyword to burn tokens requires online signing"
@@ -1351,7 +1352,7 @@ async fn command_transfer(
13511352 } else {
13521353 ""
13531354 } ,
1354- spl_token :: amount_to_ui_amount( transfer_balance, mint_info. decimals) ,
1355+ spl_token_2022 :: amount_to_ui_amount( transfer_balance, mint_info. decimals) ,
13551356 sender,
13561357 recipient
13571358 ) ,
@@ -1806,7 +1807,9 @@ async fn command_burn(
18061807
18071808 let amount = match ui_amount {
18081809 Amount :: Raw ( ui_amount) => ui_amount,
1809- Amount :: Decimal ( ui_amount) => spl_token:: ui_amount_to_amount ( ui_amount, mint_info. decimals ) ,
1810+ Amount :: Decimal ( ui_amount) => {
1811+ spl_token_2022:: ui_amount_to_amount ( ui_amount, mint_info. decimals )
1812+ }
18101813 Amount :: All => {
18111814 if config. sign_only {
18121815 return Err ( "Use of ALL keyword to burn tokens requires online signing"
@@ -1821,7 +1824,7 @@ async fn command_burn(
18211824 config,
18221825 format ! (
18231826 "Burn {} tokens\n Source: {}" ,
1824- spl_token :: amount_to_ui_amount( amount, mint_info. decimals) ,
1827+ spl_token_2022 :: amount_to_ui_amount( amount, mint_info. decimals) ,
18251828 account
18261829 ) ,
18271830 ) ;
@@ -1861,7 +1864,7 @@ async fn command_mint(
18611864 config,
18621865 format ! (
18631866 "Minting {} tokens\n Token: {}\n Recipient: {}" ,
1864- spl_token :: amount_to_ui_amount( amount, mint_info. decimals) ,
1867+ spl_token_2022 :: amount_to_ui_amount( amount, mint_info. decimals) ,
18651868 token,
18661869 recipient
18671870 ) ,
@@ -1973,12 +1976,14 @@ async fn command_wrap(
19731976 immutable_owner : bool ,
19741977 bulk_signers : BulkSigners ,
19751978) -> CommandResult {
1976- let lamports = match amount {
1977- Amount :: Raw ( amount) => amount,
1978- Amount :: Decimal ( amount) => sol_to_lamports ( amount) ,
1979+ let lamports = match amount. sol_to_lamport ( ) {
19791980 Amount :: All => {
19801981 return Err ( "ALL keyword not supported for SOL amount" . into ( ) ) ;
19811982 }
1983+ Amount :: Raw ( amount) => amount,
1984+ Amount :: Decimal ( _) => {
1985+ unreachable ! ( ) ;
1986+ }
19821987 } ;
19831988 let token = native_token_client_from_config ( config) ?;
19841989
@@ -1989,7 +1994,7 @@ async fn command_wrap(
19891994 config,
19901995 format ! (
19911996 "Wrapping {} SOL into {}" ,
1992- lamports_to_sol ( lamports) ,
1997+ build_balance_message ( lamports, false , false ) ,
19931998 account
19941999 ) ,
19952000 ) ;
@@ -2005,7 +2010,7 @@ async fn command_wrap(
20052010 }
20062011
20072012 let res = if immutable_owner {
2008- if config. program_id == spl_token :: id ( ) {
2013+ if config. program_id == spl_token_interface :: id ( ) {
20092014 return Err ( format ! (
20102015 "Specified --immutable, but token program {} does not support the extension" ,
20112016 config. program_id
@@ -2070,7 +2075,10 @@ async fn command_unwrap(
20702075
20712076 println_display (
20722077 config,
2073- format ! ( " Amount: {} SOL" , lamports_to_sol( account_data. lamports) ) ,
2078+ format ! (
2079+ " Amount: {} SOL" ,
2080+ build_balance_message( account_data. lamports, false , false )
2081+ ) ,
20742082 ) ;
20752083 }
20762084
@@ -2116,7 +2124,7 @@ async fn command_approve(
21162124 config,
21172125 format ! (
21182126 "Approve {} tokens\n Account: {}\n Delegate: {}" ,
2119- spl_token :: amount_to_ui_amount( amount, mint_info. decimals) ,
2127+ spl_token_2022 :: amount_to_ui_amount( amount, mint_info. decimals) ,
21202128 account,
21212129 delegate
21222130 ) ,
@@ -2337,7 +2345,7 @@ async fn command_accounts(
23372345 vec ! [ TokenAccountsFilter :: ProgramId ( config. program_id) ]
23382346 } else {
23392347 vec ! [
2340- TokenAccountsFilter :: ProgramId ( spl_token :: id( ) ) ,
2348+ TokenAccountsFilter :: ProgramId ( spl_token_interface :: id( ) ) ,
23412349 TokenAccountsFilter :: ProgramId ( spl_token_2022_interface:: id( ) ) ,
23422350 ]
23432351 } ;
@@ -3366,7 +3374,9 @@ async fn command_deposit_withdraw_confidential_tokens(
33663374 // the amount the user wants to deposit or withdraw, as a u64
33673375 let amount = match ui_amount {
33683376 Amount :: Raw ( ui_amount) => ui_amount,
3369- Amount :: Decimal ( ui_amount) => spl_token:: ui_amount_to_amount ( ui_amount, mint_info. decimals ) ,
3377+ Amount :: Decimal ( ui_amount) => {
3378+ spl_token_2022:: ui_amount_to_amount ( ui_amount, mint_info. decimals )
3379+ }
33703380 Amount :: All => {
33713381 if config. sign_only {
33723382 return Err ( "Use of ALL keyword to burn tokens requires online signing"
@@ -3388,7 +3398,7 @@ async fn command_deposit_withdraw_confidential_tokens(
33883398 config,
33893399 format ! (
33903400 "Depositing {} confidential tokens" ,
3391- spl_token :: amount_to_ui_amount( amount, mint_info. decimals) ,
3401+ spl_token_2022 :: amount_to_ui_amount( amount, mint_info. decimals) ,
33923402 ) ,
33933403 ) ;
33943404 let current_balance = state_with_extension. base . amount ;
@@ -3408,7 +3418,7 @@ async fn command_deposit_withdraw_confidential_tokens(
34083418 config,
34093419 format ! (
34103420 "Withdrawing {} confidential tokens" ,
3411- spl_token :: amount_to_ui_amount( amount, mint_info. decimals)
3421+ spl_token_2022 :: amount_to_ui_amount( amount, mint_info. decimals)
34123422 ) ,
34133423 ) ;
34143424 }
0 commit comments