ic-query-cli 0.101.0

Command-line wrapper for read-only Internet Computer metadata queries
Documentation
//! Typed ICRC account operations and account-history collection modes.

use super::options::{
    IcrcAccountOptions, IcrcAllowanceOptions, IcrcTransactionListOptions,
    IcrcTransactionPageOptions, IcrcTransactionRefreshOptions,
};
use crate::cli::common::{
    COLLECTION_MODE_CACHE_ONLY, COLLECTION_MODE_FORCE_REFRESH, COLLECTION_MODE_LIVE,
    collection_help,
};
use clap::Subcommand;

///
/// AccountCommand
///
/// Parsed native account operation and its arguments.
///

#[derive(Subcommand)]
#[command(about = "Inspect ICRC account balances, allowances, and transaction history", long_about = None)]
pub(super) enum AccountCommand {
    #[command(about = "Show a generic ICRC account balance", long_about = None, after_help = collection_help(COLLECTION_MODE_LIVE, "Examples:\n  icq icrc account balance ryjl3-tyaaa-aaaaa-aaaba-cai aaaaa-aa\n  icq icrc account balance ryjl3-tyaaa-aaaaa-aaaba-cai aaaaa-aa --subaccount 0000000000000000000000000000000000000000000000000000000000000000"))]
    Balance(IcrcAccountOptions),
    #[command(about = "Show a generic ICRC account allowance", long_about = None, after_help = collection_help(COLLECTION_MODE_LIVE, "Examples:\n  icq icrc account allowance ryjl3-tyaaa-aaaaa-aaaba-cai aaaaa-aa aaaaa-aa\n  icq icrc account allowance ryjl3-tyaaa-aaaaa-aaaba-cai aaaaa-aa aaaaa-aa --owner-subaccount 0000000000000000000000000000000000000000000000000000000000000000 --spender-subaccount 0000000000000000000000000000000000000000000000000000000000000000"))]
    Allowance(IcrcAllowanceOptions),
    #[command(subcommand)]
    Transaction(TransactionCommand),
}

///
/// TransactionCommand
///
/// Parsed account-history operation, preserving explicit collection modes.
///

#[derive(Subcommand)]
#[command(about = "Inspect live pages and complete cached account transaction history", long_about = None)]
pub(super) enum TransactionCommand {
    #[command(about = "Show an ICRC account transaction-history page from its index", long_about = None, after_help = collection_help(COLLECTION_MODE_LIVE, "Examples:\n  icq icrc account transaction page mxzaz-hqaaa-aaaar-qaada-cai aaaaa-aa\n  icq icrc account transaction page mxzaz-hqaaa-aaaar-qaada-cai aaaaa-aa --start 100 --limit 25 --json\n  icq icrc account transaction page ryjl3-tyaaa-aaaaa-aaaba-cai aaaaa-aa --index-canister-id qhbym-qaaaa-aaaaa-aaafq-cai"))]
    Page(IcrcTransactionPageOptions),
    #[command(about = "List rows from a complete local ICRC account-history cache", long_about = None, after_help = collection_help(COLLECTION_MODE_CACHE_ONLY, "Examples:\n  icq icrc account transaction list mxzaz-hqaaa-aaaar-qaada-cai aaaaa-aa\n  icq icrc account transaction list mxzaz-hqaaa-aaaar-qaada-cai aaaaa-aa --sort oldest --limit 100 --json"))]
    List(IcrcTransactionListOptions),
    #[command(about = "Fetch and atomically cache complete ICRC account history", long_about = None, after_help = collection_help(COLLECTION_MODE_FORCE_REFRESH, "Examples:\n  icq icrc account transaction refresh mxzaz-hqaaa-aaaar-qaada-cai aaaaa-aa\n  icq icrc account transaction refresh ryjl3-tyaaa-aaaaa-aaaba-cai aaaaa-aa --index-canister-id qhbym-qaaaa-aaaaa-aaafq-cai --page-size 100 --json"))]
    Refresh(IcrcTransactionRefreshOptions),
    #[command(subcommand)]
    Cache(TransactionCacheCommand),
}

///
/// TransactionCacheCommand
///
/// Parsed local account-history cache inspection.
///

#[derive(Subcommand)]
#[command(about = "Inspect local complete account-history cache state", long_about = None)]
pub(super) enum TransactionCacheCommand {
    #[command(about = "Show local account-history cache and latest refresh-attempt status", long_about = None, after_help = collection_help(COLLECTION_MODE_CACHE_ONLY, "Examples:\n  icq icrc account transaction cache status mxzaz-hqaaa-aaaar-qaada-cai aaaaa-aa\n  icq icrc account transaction cache status mxzaz-hqaaa-aaaar-qaada-cai aaaaa-aa --json"))]
    Status(IcrcAccountOptions),
}