bank.go

Overview

The `bank.go` file is part of the `cosmos` package and provides a set of utility methods to query blockchain-related financial data from a Cosmos SDK-based blockchain via HTTP REST API calls. It primarily interacts with the LCD (Light Client Daemon) REST endpoints to retrieve information about token supply, staking, distribution parameters, and minting provisions.

Each method in this file belongs to an `HTTPClient` receiver and performs a specific query by sending an HTTP GET request to the corresponding Cosmos SDK REST endpoint. The responses are unmarshaled into internal Go structs, and key values are extracted and returned as strings.

This file abstracts the complexity of direct REST API calls and JSON parsing, offering a clean, simple interface to obtain financial metrics from the Cosmos blockchain.


Details of Types and Methods

Type: HTTPClient


Method: GetTotalSupply

func (c *HTTPClient) GetTotalSupply(denom string) (string, error)

Method: GetAnnualProvisions

func (c *HTTPClient) GetAnnualProvisions() (string, error)

Method: GetCommunityTax

func (c *HTTPClient) GetCommunityTax() (string, error)

Method: GetBondedTokens

func (c *HTTPClient) GetBondedTokens() (string, error)

Important Implementation Notes


Interaction with Other System Components


Visual Diagram

classDiagram
    class HTTPClient {
        +GetTotalSupply(denom string) string, error
        +GetAnnualProvisions() string, error
        +GetCommunityTax() string, error
        +GetBondedTokens() string, error
    }

    %% Indicate that HTTPClient depends on LCD REST client internally (not shown in file)
    class LCDClient {
        +R() *Request
    }

    HTTPClient --> LCDClient : uses

Summary

The `bank.go` file provides a concise and robust interface to retrieve key blockchain economic parameters from a Cosmos SDK blockchain via REST API calls. It encapsulates various domain-specific queries related to token supply, inflation, community tax, and staking pool statistics, returning results as strings with consistent error handling. It depends on an HTTP REST client abstraction (`LCD`) and serves as a foundational component for applications interacting with Cosmos blockchain financial data.