@bandprotocol/bandchain.js
Version:
TypeScript library for Cosmos SDK and BandChain
109 lines (108 loc) • 4.51 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LCDQueryClient = void 0;
//@ts-nocheck
const helpers_1 = require("../../../helpers");
class LCDQueryClient {
req;
constructor({ requestClient }) {
this.req = requestClient;
this.currentFeeds = this.currentFeeds.bind(this);
this.isFeeder = this.isFeeder.bind(this);
this.params = this.params.bind(this);
this.price = this.price.bind(this);
this.prices = this.prices.bind(this);
this.allPrices = this.allPrices.bind(this);
this.referenceSourceConfig = this.referenceSourceConfig.bind(this);
this.signalTotalPowers = this.signalTotalPowers.bind(this);
this.validValidator = this.validValidator.bind(this);
this.validatorPrices = this.validatorPrices.bind(this);
this.vote = this.vote.bind(this);
}
/* CurrentFeeds is an RPC method that returns a list of current supported feeds. */
async currentFeeds(_params = {}) {
const endpoint = `feeds/v1beta1/current_feeds`;
return await this.req.get(endpoint);
}
/* IsFeeder is an RPC method that returns whether an account is a feeder for a specified validator. */
async isFeeder(params) {
const endpoint = `feeds/v1beta1/feeder/${params.validator}/${params.feeder}`;
return await this.req.get(endpoint);
}
/* Params is an RPC method that returns all parameters of the module. */
async params(_params = {}) {
const endpoint = `feeds/v1beta1/params`;
return await this.req.get(endpoint);
}
/* Price is an RPC method that returns price by signal id. */
async price(params) {
const endpoint = `feeds/v1beta1/prices/${params.signalId}`;
return await this.req.get(endpoint);
}
/* Prices is an RPC method that prices by signal ids. */
async prices(params) {
const options = {
params: {}
};
if (typeof params?.signalIds !== "undefined") {
options.params.signal_ids = params.signalIds;
}
const endpoint = `feeds/v1beta1/prices`;
return await this.req.get(endpoint, options);
}
/* AllPrices is an RPC method that returns all prices. */
async allPrices(params = {
pagination: undefined
}) {
const options = {
params: {}
};
if (typeof params?.pagination !== "undefined") {
(0, helpers_1.setPaginationParams)(options, params.pagination);
}
const endpoint = `feeds/v1beta1/all_prices`;
return await this.req.get(endpoint, options);
}
/* ReferenceSourceConfig is an RPC method that returns information on the reference price source. */
async referenceSourceConfig(_params = {}) {
const endpoint = `feeds/v1beta1/reference_source_config`;
return await this.req.get(endpoint);
}
/* SignalTotalPowers is an RPC method that returns all signal-total-powers or specified signal-total-power by signal
id. */
async signalTotalPowers(params) {
const options = {
params: {}
};
if (typeof params?.signalIds !== "undefined") {
options.params.signal_ids = params.signalIds;
}
if (typeof params?.pagination !== "undefined") {
(0, helpers_1.setPaginationParams)(options, params.pagination);
}
const endpoint = `feeds/v1beta1/signal_total_powers`;
return await this.req.get(endpoint, options);
}
/* ValidValidator is an RPC method that returns a flag to show if the validator is required to send prices. */
async validValidator(params) {
const endpoint = `feeds/v1beta1/validators/${params.validator}/valid`;
return await this.req.get(endpoint);
}
/* ValidatorPrices is an RPC method that returns prices of a validator. */
async validatorPrices(params) {
const options = {
params: {}
};
if (typeof params?.signalIds !== "undefined") {
options.params.signal_ids = params.signalIds;
}
const endpoint = `feeds/v1beta1/validators/${params.validator}/prices`;
return await this.req.get(endpoint, options);
}
/* Vote is an RPC method that returns signals of a voter. */
async vote(params) {
const endpoint = `feeds/v1beta1/voters/${params.voter}/vote`;
return await this.req.get(endpoint);
}
}
exports.LCDQueryClient = LCDQueryClient;