import { setPaginationParams } from "../../../helpers"; import { LCDClient } from "@osmonauts/lcd"; import { QueryAccountsRequest, QueryAccountsResponseSDKType, QueryAccountRequest, QueryAccountResponseSDKType, QueryParamsRequest, QueryParamsResponseSDKType, QueryModuleAccountsRequest, QueryModuleAccountsResponseSDKType, Bech32PrefixRequest, Bech32PrefixResponseSDKType, AddressBytesToStringRequest, AddressBytesToStringResponseSDKType, AddressStringToBytesRequest, AddressStringToBytesResponseSDKType } from "./query"; export class LCDQueryClient { req: LCDClient; constructor({ requestClient }: { requestClient: LCDClient; }) { this.req = requestClient; this.accounts = this.accounts.bind(this); this.account = this.account.bind(this); this.params = this.params.bind(this); this.moduleAccounts = this.moduleAccounts.bind(this); this.bech32Prefix = this.bech32Prefix.bind(this); this.addressBytesToString = this.addressBytesToString.bind(this); this.addressStringToBytes = this.addressStringToBytes.bind(this); } /* 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.req.get(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.req.get(endpoint); } /* Params queries all parameters. */ async params(_params: QueryParamsRequest = {}): Promise { const endpoint = `cosmos/auth/v1beta1/params`; return await this.req.get(endpoint); } /* ModuleAccounts returns all the existing module accounts. */ async moduleAccounts(_params: QueryModuleAccountsRequest = {}): Promise { const endpoint = `cosmos/auth/v1beta1/module_accounts`; return await this.req.get(endpoint); } /* Bech32 queries bech32Prefix */ async bech32Prefix(_params: Bech32PrefixRequest = {}): Promise { const endpoint = `cosmos/auth/v1beta1/bech32`; return await this.req.get(endpoint); } /* AddressBytesToString converts Account Address bytes to string */ async addressBytesToString(params: AddressBytesToStringRequest): Promise { const endpoint = `cosmos/auth/v1beta1/bech32/${params.addressBytes}`; return await this.req.get(endpoint); } /* AddressStringToBytes converts Address string to bytes */ async addressStringToBytes(params: AddressStringToBytesRequest): Promise { const endpoint = `cosmos/auth/v1beta1/bech32/${params.addressString}`; return await this.req.get(endpoint); } }