78 lines
2.8 KiB
JavaScript
78 lines
2.8 KiB
JavaScript
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getPastDueConsumptionPeerBalance = exports.getPastDueConsumptionBalances = exports.getPeerBalance = exports.getAllBalances = void 0;
|
|
const http_1 = require("../../utils/http");
|
|
const balancesEndpoint = 'balances';
|
|
const consumedEndpoint = 'consumed';
|
|
/**
|
|
* Get the balances with all known peers including prepaid services
|
|
*
|
|
* @param ky Ky debug instance
|
|
*/
|
|
function getAllBalances(ky) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const response = yield (0, http_1.http)(ky, {
|
|
path: balancesEndpoint,
|
|
responseType: 'json',
|
|
});
|
|
return response.data;
|
|
});
|
|
}
|
|
exports.getAllBalances = getAllBalances;
|
|
/**
|
|
* Get the balances with a specific peer including prepaid services
|
|
*
|
|
* @param ky Ky debug instance
|
|
* @param address Swarm address of peer
|
|
*/
|
|
function getPeerBalance(ky, address) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const response = yield (0, http_1.http)(ky, {
|
|
path: `${balancesEndpoint}/${address}`,
|
|
responseType: 'json',
|
|
});
|
|
return response.data;
|
|
});
|
|
}
|
|
exports.getPeerBalance = getPeerBalance;
|
|
/**
|
|
* Get the past due consumption balances with all known peers
|
|
*
|
|
* @param ky Ky debug instance
|
|
*/
|
|
function getPastDueConsumptionBalances(ky) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const response = yield (0, http_1.http)(ky, {
|
|
path: consumedEndpoint,
|
|
responseType: 'json',
|
|
});
|
|
return response.data;
|
|
});
|
|
}
|
|
exports.getPastDueConsumptionBalances = getPastDueConsumptionBalances;
|
|
/**
|
|
* Get the past due consumption balance with a specific peer
|
|
*
|
|
* @param ky Ky debug instance
|
|
* @param address Swarm address of peer
|
|
*/
|
|
function getPastDueConsumptionPeerBalance(ky, address) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const response = yield (0, http_1.http)(ky, {
|
|
path: `${consumedEndpoint}/${address}`,
|
|
responseType: 'json',
|
|
});
|
|
return response.data;
|
|
});
|
|
}
|
|
exports.getPastDueConsumptionPeerBalance = getPastDueConsumptionPeerBalance;
|