raiden-api-sdk
Version:
SDK for interacting with the Raiden API
51 lines (50 loc) • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var rxjs_1 = require("rxjs");
var operators_1 = require("rxjs/operators");
var apis_1 = require("./apis");
var ajax_1 = require("rxjs/ajax");
var errors_1 = require("./errors");
var Node = /** @class */ (function () {
function Node(nodeApi) {
this.nodeApi = nodeApi;
}
Node.create = function (config) {
var nodeApi = new apis_1.RaidenNodeApi(config);
return new Node(nodeApi);
};
/**
* Query your address
*
* @remarks
* When raiden starts, you choose an ethereum address which will
* also be your raiden address.
*
* @example
* ```typescript
* import Raiden from 'raiden-api-sdk';
*
* (async function() {
* const raiden = Raiden.create();
* const ourAddress = await raiden.node.ourAddress().toPromise();
*
* // 0xA44e09ea90eAF80DC1B59aA45687e2c4d572049D
* console.log(ourAddress);
* })()
* ```
*
* @since 0.100.3
* @throws {@link RaidenAPIError}
* @see {@link https://raiden-network.readthedocs.io/en/latest/rest_api.html#get--api-(version)-address}
*/
Node.prototype.ourAddress = function () {
return this.nodeApi.getAddress().pipe(operators_1.map(function (val) { return val.ourAddress; }), operators_1.catchError(function (err) {
if (err instanceof ajax_1.AjaxError) {
return rxjs_1.throwError(new errors_1.RaidenAPIError(err));
}
return rxjs_1.throwError(err);
}));
};
return Node;
}());
exports.Node = Node;