rosetta-sdk-typescript
Version:
Typescript SDK to create and interact with Rosetta API implementations.
151 lines (150 loc) • 12.1 kB
JavaScript
;
/* 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.AccountApi = exports.AccountApiController = void 0;
const models_1 = require("../models");
const runtime = __importStar(require("../runtime"));
/**
* AccountApi - controller interface for the server side implementation.
*
* @export
* @interface AccountApiController
*/
class AccountApiController {
/**
*
* @param service - The service that implements
*/
constructor(service) {
this.service = service;
}
/**
* Get an array of all AccountBalances for an AccountIdentifier and the BlockIdentifier at which the balance lookup was performed. The BlockIdentifier must always be returned because some consumers of account balance data need to know specifically at which block the balance was calculated to compare balances they compute from operations with the balance returned by the node. It is important to note that making a balance request for an account without populating the SubAccountIdentifier should not result in the balance of all possible SubAccountIdentifiers being returned. Rather, it should result in the balance pertaining to no SubAccountIdentifiers being returned (sometimes called the liquid balance). To get all balances associated with an account, it may be necessary to perform multiple balance requests with unique AccountIdentifiers. It is also possible to perform a historical balance lookup (if the server supports it) by passing in an optional BlockIdentifier.
* Get an Account\'s Balance
*
* @param req - The request object, where the body is a AccountBalanceRequest
*/
accountBalance(req) {
return this.service.accountBalance(models_1.AccountBalanceRequestFromJSON(req.body)).then(models_1.AccountBalanceResponseToJSON);
}
/**
* Get an array of all unspent coins for an AccountIdentifier and the BlockIdentifier at which the lookup was performed. If your implementation does not support coins (i.e. it is for an account-based blockchain), you do not need to implement this endpoint. If you implementation does support coins (i.e. it is fro a UTXO-based blockchain), you MUST also complete the `/account/balance` endpoint. It is important to note that making a coins request for an account without populating the SubAccountIdentifier should not result in the coins of all possible SubAccountIdentifiers being returned. Rather, it should result in the coins pertaining to no SubAccountIdentifiers being returned. To get all coins associated with an account, it may be necessary to perform multiple coin requests with unique AccountIdentifiers. Optionally, an implementation may choose to support updating an AccountIdentifier\'s unspent coins based on the contents of the mempool. Note, using this functionality breaks any guarantee of idempotency.
* Get an Account\'s Unspent Coins
*
* @param req - The request object, where the body is a AccountCoinsRequest
*/
accountCoins(req) {
return this.service.accountCoins(models_1.AccountCoinsRequestFromJSON(req.body)).then(models_1.AccountCoinsResponseToJSON);
}
}
exports.AccountApiController = AccountApiController;
/**
*
*/
class AccountApi extends runtime.BaseAPI {
/**
* Get an array of all AccountBalances for an AccountIdentifier and the BlockIdentifier at which the balance lookup was performed. The BlockIdentifier must always be returned because some consumers of account balance data need to know specifically at which block the balance was calculated to compare balances they compute from operations with the balance returned by the node. It is important to note that making a balance request for an account without populating the SubAccountIdentifier should not result in the balance of all possible SubAccountIdentifiers being returned. Rather, it should result in the balance pertaining to no SubAccountIdentifiers being returned (sometimes called the liquid balance). To get all balances associated with an account, it may be necessary to perform multiple balance requests with unique AccountIdentifiers. It is also possible to perform a historical balance lookup (if the server supports it) by passing in an optional BlockIdentifier.
* Get an Account\'s Balance
*/
accountBalanceRaw(requestParameters, initOverrides) {
return __awaiter(this, void 0, void 0, function* () {
if (requestParameters.accountBalanceRequest === null || requestParameters.accountBalanceRequest === undefined) {
throw new runtime.RequiredError('accountBalanceRequest', 'Required parameter requestParameters.accountBalanceRequest was null or undefined when calling accountBalance.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/json';
const response = yield this.request({
path: `/account/balance`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: models_1.AccountBalanceRequestToJSON(requestParameters.accountBalanceRequest),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => models_1.AccountBalanceResponseFromJSON(jsonValue));
});
}
/**
* Get an array of all AccountBalances for an AccountIdentifier and the BlockIdentifier at which the balance lookup was performed. The BlockIdentifier must always be returned because some consumers of account balance data need to know specifically at which block the balance was calculated to compare balances they compute from operations with the balance returned by the node. It is important to note that making a balance request for an account without populating the SubAccountIdentifier should not result in the balance of all possible SubAccountIdentifiers being returned. Rather, it should result in the balance pertaining to no SubAccountIdentifiers being returned (sometimes called the liquid balance). To get all balances associated with an account, it may be necessary to perform multiple balance requests with unique AccountIdentifiers. It is also possible to perform a historical balance lookup (if the server supports it) by passing in an optional BlockIdentifier.
* Get an Account\'s Balance
*/
accountBalance(requestParameters, initOverrides) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.accountBalanceRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
* Get an array of all unspent coins for an AccountIdentifier and the BlockIdentifier at which the lookup was performed. If your implementation does not support coins (i.e. it is for an account-based blockchain), you do not need to implement this endpoint. If you implementation does support coins (i.e. it is fro a UTXO-based blockchain), you MUST also complete the `/account/balance` endpoint. It is important to note that making a coins request for an account without populating the SubAccountIdentifier should not result in the coins of all possible SubAccountIdentifiers being returned. Rather, it should result in the coins pertaining to no SubAccountIdentifiers being returned. To get all coins associated with an account, it may be necessary to perform multiple coin requests with unique AccountIdentifiers. Optionally, an implementation may choose to support updating an AccountIdentifier\'s unspent coins based on the contents of the mempool. Note, using this functionality breaks any guarantee of idempotency.
* Get an Account\'s Unspent Coins
*/
accountCoinsRaw(requestParameters, initOverrides) {
return __awaiter(this, void 0, void 0, function* () {
if (requestParameters.accountCoinsRequest === null || requestParameters.accountCoinsRequest === undefined) {
throw new runtime.RequiredError('accountCoinsRequest', 'Required parameter requestParameters.accountCoinsRequest was null or undefined when calling accountCoins.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/json';
const response = yield this.request({
path: `/account/coins`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: models_1.AccountCoinsRequestToJSON(requestParameters.accountCoinsRequest),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => models_1.AccountCoinsResponseFromJSON(jsonValue));
});
}
/**
* Get an array of all unspent coins for an AccountIdentifier and the BlockIdentifier at which the lookup was performed. If your implementation does not support coins (i.e. it is for an account-based blockchain), you do not need to implement this endpoint. If you implementation does support coins (i.e. it is fro a UTXO-based blockchain), you MUST also complete the `/account/balance` endpoint. It is important to note that making a coins request for an account without populating the SubAccountIdentifier should not result in the coins of all possible SubAccountIdentifiers being returned. Rather, it should result in the coins pertaining to no SubAccountIdentifiers being returned. To get all coins associated with an account, it may be necessary to perform multiple coin requests with unique AccountIdentifiers. Optionally, an implementation may choose to support updating an AccountIdentifier\'s unspent coins based on the contents of the mempool. Note, using this functionality breaks any guarantee of idempotency.
* Get an Account\'s Unspent Coins
*/
accountCoins(requestParameters, initOverrides) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.accountCoinsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
}
exports.AccountApi = AccountApi;