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
|
<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
|
```manpage
|
||||||
solana-wallet-get-transaction-count
|
solana-wallet-get-transaction-count
|
||||||
Get current 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)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum WalletCommand {
|
pub enum WalletCommand {
|
||||||
Address,
|
Address,
|
||||||
|
Fees,
|
||||||
Airdrop(u64),
|
Airdrop(u64),
|
||||||
Balance(Pubkey),
|
Balance(Pubkey),
|
||||||
Cancel(Pubkey),
|
Cancel(Pubkey),
|
||||||
|
@ -164,6 +165,7 @@ pub fn parse_command(
|
||||||
) -> Result<WalletCommand, Box<dyn error::Error>> {
|
) -> Result<WalletCommand, Box<dyn error::Error>> {
|
||||||
let response = match matches.subcommand() {
|
let response = match matches.subcommand() {
|
||||||
("address", Some(_address_matches)) => Ok(WalletCommand::Address),
|
("address", Some(_address_matches)) => Ok(WalletCommand::Address),
|
||||||
|
("fees", Some(_fees_matches)) => Ok(WalletCommand::Fees),
|
||||||
("airdrop", Some(airdrop_matches)) => {
|
("airdrop", Some(airdrop_matches)) => {
|
||||||
let lamports = airdrop_matches.value_of("lamports").unwrap().parse()?;
|
let lamports = airdrop_matches.value_of("lamports").unwrap().parse()?;
|
||||||
Ok(WalletCommand::Airdrop(lamports))
|
Ok(WalletCommand::Airdrop(lamports))
|
||||||
|
@ -375,6 +377,14 @@ pub fn parse_command(
|
||||||
|
|
||||||
type ProcessResult = Result<String, Box<dyn error::Error>>;
|
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(
|
fn process_airdrop(
|
||||||
rpc_client: &RpcClient,
|
rpc_client: &RpcClient,
|
||||||
config: &WalletConfig,
|
config: &WalletConfig,
|
||||||
|
@ -988,6 +998,8 @@ pub fn process_command(config: &WalletConfig) -> ProcessResult {
|
||||||
// Get address of this client
|
// Get address of this client
|
||||||
WalletCommand::Address => unreachable!(),
|
WalletCommand::Address => unreachable!(),
|
||||||
|
|
||||||
|
WalletCommand::Fees => process_fees(&rpc_client),
|
||||||
|
|
||||||
// Request an airdrop from Solana Drone;
|
// Request an airdrop from Solana Drone;
|
||||||
WalletCommand::Airdrop(lamports) => {
|
WalletCommand::Airdrop(lamports) => {
|
||||||
process_airdrop(&rpc_client, config, drone_addr, *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)
|
.version(version)
|
||||||
.setting(AppSettings::SubcommandRequiredElseHelp)
|
.setting(AppSettings::SubcommandRequiredElseHelp)
|
||||||
.subcommand(SubCommand::with_name("address").about("Get your public key"))
|
.subcommand(SubCommand::with_name("address").about("Get your public key"))
|
||||||
|
.subcommand(SubCommand::with_name("fees").about("Display current cluster fees"))
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("airdrop")
|
SubCommand::with_name("airdrop")
|
||||||
.about("Request a batch of lamports")
|
.about("Request a batch of lamports")
|
||||||
|
|
|
@ -11,7 +11,7 @@ solana-wallet --help
|
||||||
echo "\`\`\`"
|
echo "\`\`\`"
|
||||||
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
|
for x in "${commands[@]}"; do
|
||||||
echo "\`\`\`manpage"
|
echo "\`\`\`manpage"
|
||||||
|
|
Loading…
Reference in New Issue