import { PageRequest, PageResponse } from "../../base/query/v1beta1/pagination"; import { Any } from "../../../google/protobuf/any"; import { Params } from "./auth"; import { LCDClient } from "@osmonauts/lcd"; import { setPaginationParams } from "@osmonauts/helpers"; import { QueryAccountsRequest, QueryAccountsResponse, QueryAccountRequest, QueryAccountResponse, QueryParamsRequest, QueryParamsResponse, QueryModuleAccountsRequest, QueryModuleAccountsResponse, Bech32PrefixRequest, Bech32PrefixResponse, AddressBytesToStringRequest, AddressBytesToStringResponse, AddressStringToBytesRequest, AddressStringToBytesResponse } from "./query"; export class LCDQueryClient extends LCDClient { constructor({ restEndpoint }: { restEndpoint: string; }) { super({ restEndpoint }); } /* Accounts returns all the existing accounts Since: cosmos-sdk 0.43 */ async accounts(params: QueryAccountsRequest = { pagination: undefined }): Promise { const options: any = { params: {} }; if (typeof params?.pagination !== "undefined") { setPaginationParams(options, params.pagination); } const endpoint = `cosmos/auth/v1beta1/accounts`; return await this.request(endpoint, options); } /* Account returns account details based on address. */ async account(params: QueryAccountRequest): Promise { const endpoint = `cosmos/auth/v1beta1/accounts/${params.address}`; return await this.request(endpoint); } /* Params queries all parameters. */ async params(_params: QueryParamsRequest = {}): Promise { const endpoint = `cosmos/auth/v1beta1/params`; return await this.request(endpoint); } /* ModuleAccounts returns all the existing module accounts. */ async moduleAccounts(_params: QueryModuleAccountsRequest = {}): Promise { const endpoint = `cosmos/auth/v1beta1/module_accounts`; return await this.request(endpoint); } /* Bech32 queries bech32Prefix */ async bech32Prefix(_params: Bech32PrefixRequest = {}): Promise { const endpoint = `cosmos/auth/v1beta1/bech32`; return await this.request(endpoint); } /* AddressBytesToString converts Account Address bytes to string */ async addressBytesToString(params: AddressBytesToStringRequest): Promise { const endpoint = `cosmos/auth/v1beta1/bech32/${params.address_bytes}`; return await this.request(endpoint); } /* AddressStringToBytes converts Address string to bytes */ async addressStringToBytes(params: AddressStringToBytesRequest): Promise { const endpoint = `cosmos/auth/v1beta1/bech32/${params.address_string}`; return await this.request(endpoint); } }