UNPKG

rosetta-sdk-typescript

Version:

Typescript SDK to create and interact with Rosetta API implementations.

110 lines (109 loc) 5.91 kB
"use strict"; /* tslint:disable */ /* eslint-disable */ /** * Rosetta * Build Once. Integrate Your Blockchain Everywhere. * * The version of the OpenAPI document: 1.4.10 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; 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.EventsApi = exports.EventsApiController = void 0; const models_1 = require("../models"); const runtime = __importStar(require("../runtime")); /** * EventsApi - controller interface for the server side implementation. * * @export * @interface EventsApiController */ class EventsApiController { /** * * @param service - The service that implements */ constructor(service) { this.service = service; } /** * `/events/blocks` allows the caller to query a sequence of BlockEvents indicating which blocks were added and removed from storage to reach the current state. Following BlockEvents allows lightweight clients to update their state without needing to implement their own syncing logic (like finding the common parent in a reorg). `/events/blocks` is considered an \"indexer\" endpoint and Rosetta implementations are not required to complete it to adhere to the Rosetta spec. However, any Rosetta \"indexer\" MUST support this endpoint. * [INDEXER] Get a range of BlockEvents * * @param req - The request object, where the body is a EventsBlocksRequest */ eventsBlocks(req) { return this.service.eventsBlocks(models_1.EventsBlocksRequestFromJSON(req.body)).then(models_1.EventsBlocksResponseToJSON); } } exports.EventsApiController = EventsApiController; /** * */ class EventsApi extends runtime.BaseAPI { /** * `/events/blocks` allows the caller to query a sequence of BlockEvents indicating which blocks were added and removed from storage to reach the current state. Following BlockEvents allows lightweight clients to update their state without needing to implement their own syncing logic (like finding the common parent in a reorg). `/events/blocks` is considered an \"indexer\" endpoint and Rosetta implementations are not required to complete it to adhere to the Rosetta spec. However, any Rosetta \"indexer\" MUST support this endpoint. * [INDEXER] Get a range of BlockEvents */ eventsBlocksRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters.eventsBlocksRequest === null || requestParameters.eventsBlocksRequest === undefined) { throw new runtime.RequiredError('eventsBlocksRequest', 'Required parameter requestParameters.eventsBlocksRequest was null or undefined when calling eventsBlocks.'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; const response = yield this.request({ path: `/events/blocks`, method: 'POST', headers: headerParameters, query: queryParameters, body: models_1.EventsBlocksRequestToJSON(requestParameters.eventsBlocksRequest), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => models_1.EventsBlocksResponseFromJSON(jsonValue)); }); } /** * `/events/blocks` allows the caller to query a sequence of BlockEvents indicating which blocks were added and removed from storage to reach the current state. Following BlockEvents allows lightweight clients to update their state without needing to implement their own syncing logic (like finding the common parent in a reorg). `/events/blocks` is considered an \"indexer\" endpoint and Rosetta implementations are not required to complete it to adhere to the Rosetta spec. However, any Rosetta \"indexer\" MUST support this endpoint. * [INDEXER] Get a range of BlockEvents */ eventsBlocks(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.eventsBlocksRaw(requestParameters, initOverrides); return yield response.value(); }); } } exports.EventsApi = EventsApi;