fetch_account_info

Function fetch_account_info 

Source
pub async fn fetch_account_info(
    address: &str,
    pubkey_base64: &str,
    config: &Config,
) -> Result<BaseAccount, Box<dyn Error>>
Expand description

Fetches Cosmos BaseAccount information from the REST endpoint.

This function attempts to retrieve account metadata (e.g., sequence and account number) from the configured Cosmos REST endpoint using the provided Bech32 address.

If the account does not exist on-chain (404 response), a default BaseAccount is returned using the provided public key in base64 format.

§Arguments

  • address - The Bech32 Cosmos address to fetch account info for.
  • pubkey_base64 - The base64-encoded public key used in case the account is not yet on-chain.
  • config - A reference to the configuration containing the Cosmos REST URL.

§Returns

A Result containing either:

  • BaseAccount with account metadata (either fetched or default), or
  • An error if the request fails or the response cannot be parsed.

§Errors

Returns an error if the HTTP request fails, if the REST endpoint returns an unexpected status, or if the response body cannot be parsed into an AccountWrapper.