Add |wallet fees| subcommand for easy viewing of the current cluster fees (#4596)
This commit is contained in:
parent
53deb7919c
commit
002fbc4d53
|
@ -284,6 +284,18 @@ ARGS:
|
|||
<PATH> /path/to/program.o
|
||||
```
|
||||
|
||||
```manpage
|
||||
solana-wallet-fees
|
||||
Display current cluster fees
|
||||
|
||||
USAGE:
|
||||
solana-wallet fees
|
||||
|
||||
FLAGS:
|
||||
-h, --help Prints help information
|
||||
-V, --version Prints version information
|
||||
```
|
||||
|
||||
```manpage
|
||||
solana-wallet-get-transaction-count
|
||||
Get current transaction count
|
||||
|
|
|
@ -42,6 +42,7 @@ const USERDATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA
|
|||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum WalletCommand {
|
||||
Address,
|
||||
Fees,
|
||||
Airdrop(u64),
|
||||
Balance(Pubkey),
|
||||
Cancel(Pubkey),
|
||||
|
@ -164,6 +165,7 @@ pub fn parse_command(
|
|||
) -> Result<WalletCommand, Box<dyn error::Error>> {
|
||||
let response = match matches.subcommand() {
|
||||
("address", Some(_address_matches)) => Ok(WalletCommand::Address),
|
||||
("fees", Some(_fees_matches)) => Ok(WalletCommand::Fees),
|
||||
("airdrop", Some(airdrop_matches)) => {
|
||||
let lamports = airdrop_matches.value_of("lamports").unwrap().parse()?;
|
||||
Ok(WalletCommand::Airdrop(lamports))
|
||||
|
@ -375,6 +377,14 @@ pub fn parse_command(
|
|||
|
||||
type ProcessResult = Result<String, Box<dyn error::Error>>;
|
||||
|
||||
fn process_fees(rpc_client: &RpcClient) -> ProcessResult {
|
||||
let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;
|
||||
|
||||
Ok(format!(
|
||||
"blockhash: {}\nlamports per signature: {}",
|
||||
recent_blockhash, fee_calculator.lamports_per_signature
|
||||
))
|
||||
}
|
||||
fn process_airdrop(
|
||||
rpc_client: &RpcClient,
|
||||
config: &WalletConfig,
|
||||
|
@ -988,6 +998,8 @@ pub fn process_command(config: &WalletConfig) -> ProcessResult {
|
|||
// Get address of this client
|
||||
WalletCommand::Address => unreachable!(),
|
||||
|
||||
WalletCommand::Fees => process_fees(&rpc_client),
|
||||
|
||||
// Request an airdrop from Solana Drone;
|
||||
WalletCommand::Airdrop(lamports) => {
|
||||
process_airdrop(&rpc_client, config, drone_addr, *lamports)
|
||||
|
@ -1258,6 +1270,7 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
|
|||
.version(version)
|
||||
.setting(AppSettings::SubcommandRequiredElseHelp)
|
||||
.subcommand(SubCommand::with_name("address").about("Get your public key"))
|
||||
.subcommand(SubCommand::with_name("fees").about("Display current cluster fees"))
|
||||
.subcommand(
|
||||
SubCommand::with_name("airdrop")
|
||||
.about("Request a batch of lamports")
|
||||
|
|
|
@ -11,7 +11,7 @@ solana-wallet --help
|
|||
echo "\`\`\`"
|
||||
echo ""
|
||||
|
||||
commands=(address airdrop balance cancel confirm deploy get-transaction-count pay send-signature send-timestamp)
|
||||
commands=(address airdrop balance cancel confirm deploy fees get-transaction-count pay send-signature send-timestamp)
|
||||
|
||||
for x in "${commands[@]}"; do
|
||||
echo "\`\`\`manpage"
|
||||
|
|
Loading…
Reference in New Issue