@newfound8ion/newcoin.farm-js
Version:
JS Library to interact with newcoin.farm smart contract.
46 lines (45 loc) • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChainApi = void 0;
class ChainApi {
constructor(nodeos_url, contract, fetch) {
this.nodeos_url = nodeos_url;
this.contract = contract;
this.fetch = fetch;
}
async getCurrencyStats(payload) {
return await this.fetch(`${this.nodeos_url}/v1/chain/get_currency_stats`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
}
async getCurrencyBalance(payload) {
return await this.fetch(`${this.nodeos_url}/v1/chain/get_currency_balance`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
}
async getTableRows(payload) {
return await this.fetch(`${this.nodeos_url}/v1/chain/get_table_rows`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
}
async getDeposit(opts) {
return this.getTableRows({
json: true,
code: this.contract,
scope: opts.owner,
table: "deposits",
table_key: opts.id,
lower_bound: opts.id,
upper_bound: opts.id,
key_type: "i64",
index_position: "1",
});
}
}
exports.ChainApi = ChainApi;