UNPKG

@radixdlt/application

Version:

A JavaScript client library for interacting with the Radix Distributed Ledger.

36 lines 3.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAPI = void 0; const neverthrow_1 = require("neverthrow"); const responseHandlers_1 = require("./responseHandlers"); const ramda_1 = require("ramda"); const _types_1 = require("./_types"); const callAPI = (endpoint) => (call, handleResponse) => (params) => (0, ramda_1.pipe)(call, (0, ramda_1.andThen)(handleResponse), value => // @ts-ignore neverthrow_1.ResultAsync.fromPromise(value, (e) => e).andThen(r => r))(endpoint, params); const setupAPICall = (call) => ( // eslint-disable-next-line @typescript-eslint/no-explicit-any handleResponse) => (endpoint) => callAPI(endpoint)(call, handleResponse); const getAPI = (call) => { const setupAPIResponse = setupAPICall(call); return { [_types_1.ApiMethod.NETWORK_ID]: setupAPIResponse(responseHandlers_1.handleNetworkIdResponse)(_types_1.ApiMethod.NETWORK_ID), [_types_1.ApiMethod.TOKEN_BALANCES]: setupAPIResponse(responseHandlers_1.handleTokenBalancesResponse)(_types_1.ApiMethod.TOKEN_BALANCES), [_types_1.ApiMethod.VALIDATORS]: setupAPIResponse(responseHandlers_1.handleValidatorsResponse)(_types_1.ApiMethod.VALIDATORS), [_types_1.ApiMethod.LOOKUP_TX]: setupAPIResponse(responseHandlers_1.handleLookupTXResponse)(_types_1.ApiMethod.LOOKUP_TX), [_types_1.ApiMethod.LOOKUP_VALIDATOR]: setupAPIResponse(responseHandlers_1.handleLookupValidatorResponse)(_types_1.ApiMethod.LOOKUP_VALIDATOR), [_types_1.ApiMethod.TRANSACTION_HISTORY]: setupAPIResponse(responseHandlers_1.handleTransactionHistoryResponse)(_types_1.ApiMethod.TRANSACTION_HISTORY), [_types_1.ApiMethod.NATIVE_TOKEN]: setupAPIResponse(responseHandlers_1.handleTokenInfoResponse)(_types_1.ApiMethod.NATIVE_TOKEN), [_types_1.ApiMethod.TOKEN_INFO]: setupAPIResponse(responseHandlers_1.handleTokenInfoResponse)(_types_1.ApiMethod.TOKEN_INFO), [_types_1.ApiMethod.STAKES]: setupAPIResponse(responseHandlers_1.handleStakesResponse)(_types_1.ApiMethod.STAKES), [_types_1.ApiMethod.UNSTAKES]: setupAPIResponse(responseHandlers_1.handleUnstakesResponse)(_types_1.ApiMethod.UNSTAKES), [_types_1.ApiMethod.TX_STATUS]: setupAPIResponse(responseHandlers_1.handleTransactionStatusResponse)(_types_1.ApiMethod.TX_STATUS), [_types_1.ApiMethod.NETWORK_TX_THROUGHPUT]: setupAPIResponse(responseHandlers_1.handleNetworkxThroughputResponse)(_types_1.ApiMethod.NETWORK_TX_THROUGHPUT), [_types_1.ApiMethod.NETWORK_TX_DEMAND]: setupAPIResponse(responseHandlers_1.handleNetworkxDemandResponse)(_types_1.ApiMethod.NETWORK_TX_DEMAND), [_types_1.ApiMethod.BUILD_TX_FROM_INTENT]: setupAPIResponse(responseHandlers_1.handleBuildTransactionResponse)(_types_1.ApiMethod.BUILD_TX_FROM_INTENT), [_types_1.ApiMethod.FINALIZE_TX]: setupAPIResponse(responseHandlers_1.handleFinalizeTransactionResponse)(_types_1.ApiMethod.FINALIZE_TX), [_types_1.ApiMethod.SUBMIT_TX]: setupAPIResponse(responseHandlers_1.handleSubmitTransactionResponse)(_types_1.ApiMethod.SUBMIT_TX), }; }; exports.getAPI = getAPI; //# sourceMappingURL=interface.js.map