UNPKG

@emeraldpay/api-node

Version:
36 lines 1.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AddressClient = void 0; const api_1 = require("@emeraldpay/api"); const channel_1 = require("../channel"); const address_grpc_pb_1 = require("../generated/address_grpc_pb"); const Factory_1 = require("./Factory"); // eslint-disable-next-line @typescript-eslint/no-var-requires const { version: clientVersion } = require('../../package.json'); class AddressClient { constructor(hostname, credentials, agents, retries = 3) { this.convert = new api_1.address.ConvertAddress(Factory_1.classFactory); const agent = [...agents, `emerald-client-node/${clientVersion}`].join(' '); this.client = new address_grpc_pb_1.AddressClient(hostname, credentials, { 'grpc.primary_user_agent': agent }); this.channel = new channel_1.NativeChannel(this.client); this.credentials = credentials; this.retries = retries; } setConnectionListener(listener) { this.channel.setListener(listener); } describe(request) { const protoRequest = this.convert.describeRequest(request); const mapper = this.convert.describeResponse(); const call = (0, channel_1.callSingle)(this.client.describe.bind(this.client), mapper); return (0, api_1.publishToPromise)((0, api_1.readOnce)(this.channel, call, protoRequest, this.retries)); } describeXpub(request) { const protoRequest = this.convert.describeXpubRequest(request); const mapper = this.convert.describeXpubResponse(); const call = (0, channel_1.callSingle)(this.client.describeXpub.bind(this.client), mapper); return (0, api_1.publishToPromise)((0, api_1.readOnce)(this.channel, call, protoRequest, this.retries)); } } exports.AddressClient = AddressClient; //# sourceMappingURL=AddressClient.js.map