Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eoscafe/light-api

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eoscafe/light-api - npm Package Compare versions

Comparing version 3.2.8 to 3.2.9

21

dist/index.js
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
// TypeScript Definitions
__exportStar(require("./src/types/api"), exports);
// Light API
__export(require("./src/jsonrpc"));
__export(require("./src/endpoints"));
__export(require("./src/rpcerror"));
__exportStar(require("./src/jsonrpc"), exports);
__exportStar(require("./src/endpoints"), exports);
__exportStar(require("./src/rpcerror"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GET_TOKEN_HOLDER_COUNT = exports.GET_CODEHASH = exports.GET_TOPSTAKE = exports.GET_TOPRAM = exports.GET_USERCOUNT = exports.GET_TOPHOLDERS = exports.GET_TOKEN_BALANCE = exports.GET_SYNC_INFO = exports.GET_NETWORKS = exports.GET_KEY_ACCOUNTS = exports.GET_BALANCES = exports.GET_ACCOUNT_INFO = exports.GET_ACCOUNT = void 0;
exports.GET_ACCOUNT = "/api/account";

@@ -4,0 +5,0 @@ exports.GET_ACCOUNT_INFO = "/api/accinfo";

@@ -1,2 +0,2 @@

import { GetAccount, GetBalances, GetKeyAccounts, GetCodehash, GetAccountInfo } from "./types/api";
import { GetAccount, GetBalances, GetKeyAccounts, GetNetworks, GetTopHolders, GetTopRam, GetTopStake, GetCodehash, GetAccountInfo } from "./types/api";
export declare type Fetch = (url: string | Request, init?: RequestInit) => Promise<Response>;

@@ -62,3 +62,3 @@ /**

* @param {string} key public key
* @returns {Promise<GetKeyAccounts[]>} accounts
* @returns {Promise<GetKeyAccounts>} accounts
*/

@@ -73,3 +73,3 @@ get_key_accounts(key: string): Promise<GetKeyAccounts[]>;

*/
get_networks(): Promise<import("./types/common").ChainInfo[]>;
get_networks(): Promise<GetNetworks>;
/**

@@ -105,3 +105,3 @@ * [GET /api/sync]

*/
get_topholders(contract: string, token: string, num: number): Promise<string[][]>;
get_topholders(contract: string, token: string, num: number): Promise<GetTopHolders>;
/**

@@ -124,3 +124,3 @@ * [GET /api/usercount]

*/
get_topram(num: number): Promise<(string | number)[][]>;
get_topram(num: number): Promise<GetTopRam>;
/**

@@ -135,3 +135,3 @@ * [GET /api/topstake]

*/
get_topstake(num: number): Promise<(string | number)[][]>;
get_topstake(num: number): Promise<GetTopStake>;
/**

@@ -138,0 +138,0 @@ * [GET /api/codehash]

"use strict";
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
const endpoints_1 = require("./endpoints");
const rpcerror_1 = require("./rpcerror");
const chainToEndpoint = {
exports.JsonRpc = void 0;
var endpoints_1 = require("./endpoints");
var rpcerror_1 = require("./rpcerror");
var chainToEndpoint = {
telos: "https://api.light.xeos.me",

@@ -22,11 +51,14 @@ eos: "https://api.light.xeos.me",

worbli: "https://lightapi.eosamsterdam.net",
lynx: "https://lightapi.eosamsterdam.net",
coffe: "https://hyperion.coffe.io",
proton: "https://lightapi.eosamsterdam.net"
proton: "https://testnet-lightapi.eosams.xeos.me",
waxtest: "https://testnet-lightapi.eosams.xeos.me",
protontest: "https://testnet-lightapi.eosams.xeos.me",
telostest: "https://testnet-lightapi.eosams.xeos.me",
};
const keyEndpoints = [
var keyEndpoints = [
"https://api.light.xeos.me",
"https://lightapi.eosgeneva.io",
"https://lightapi.eosamsterdam.net",
"https://hyperion.coffe.io"
"https://hyperion.coffe.io",
"https://testnet-lightapi.eosams.xeos.me"
];

@@ -42,4 +74,5 @@ /**

*/
class JsonRpc {
constructor(chain, args = {}) {
var JsonRpc = /** @class */ (function () {
function JsonRpc(chain, args) {
if (args === void 0) { args = {}; }
this.chain = chain || "eos";

@@ -62,36 +95,48 @@ this.endpoint = args.endpoint || chainToEndpoint[chain] || chainToEndpoint.eos;

*/
get(path, endpoint = this.endpoint) {
return __awaiter(this, void 0, void 0, function* () {
let response;
let json;
const url = endpoint + path;
try {
const f = this.fetchBuiltin;
response = yield f(url, {
method: "GET",
});
if (response.status !== 200) {
throw new rpcerror_1.RpcStatusError(response);
JsonRpc.prototype.get = function (path, endpoint) {
if (endpoint === void 0) { endpoint = this.endpoint; }
return __awaiter(this, void 0, void 0, function () {
var response, json, url, f, text, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = endpoint + path;
_a.label = 1;
case 1:
_a.trys.push([1, 4, , 5]);
f = this.fetchBuiltin;
return [4 /*yield*/, f(url, {
method: "GET",
})];
case 2:
response = _a.sent();
if (response.status !== 200) {
throw new rpcerror_1.RpcStatusError(response);
}
return [4 /*yield*/, response.text()];
case 3:
text = _a.sent();
try {
json = JSON.parse(text);
if (json.processed && json.processed.except) {
throw new rpcerror_1.RpcError(json);
}
}
catch (_b) {
json = text;
}
return [3 /*break*/, 5];
case 4:
e_1 = _a.sent();
e_1.isFetchError = true;
throw e_1;
case 5:
if (!response.ok) {
throw new rpcerror_1.RpcError(json);
}
return [2 /*return*/, json];
}
const text = yield response.text();
try {
json = JSON.parse(text);
if (json.processed && json.processed.except) {
throw new rpcerror_1.RpcError(json);
}
}
catch (_a) {
json = text;
}
}
catch (e) {
e.isFetchError = true;
throw e;
}
if (!response.ok) {
throw new rpcerror_1.RpcError(json);
}
return json;
});
});
}
};
/**

@@ -105,6 +150,6 @@ * [GET /api/account]

*/
get_account(accountName) {
const url = `${endpoints_1.GET_ACCOUNT}/${this.chain}/${accountName}`;
JsonRpc.prototype.get_account = function (accountName) {
var url = endpoints_1.GET_ACCOUNT + "/" + this.chain + "/" + accountName;
return this.get(url);
}
};
/**

@@ -118,6 +163,6 @@ * [GET /api/accinfo]

*/
get_account_info(accountName) {
const url = `${endpoints_1.GET_ACCOUNT_INFO}/${this.chain}/${accountName}`;
JsonRpc.prototype.get_account_info = function (accountName) {
var url = endpoints_1.GET_ACCOUNT_INFO + "/" + this.chain + "/" + accountName;
return this.get(url);
}
};
/**

@@ -131,6 +176,6 @@ * [GET /api/balances]

*/
get_balances(accountName) {
const url = `${endpoints_1.GET_BALANCES}/${this.chain}/${accountName}`;
JsonRpc.prototype.get_balances = function (accountName) {
var url = endpoints_1.GET_BALANCES + "/" + this.chain + "/" + accountName;
return this.get(url);
}
};
/**

@@ -142,13 +187,21 @@ * [GET /api/key]

* @param {string} key public key
* @returns {Promise<GetKeyAccounts[]>} accounts
* @returns {Promise<GetKeyAccounts>} accounts
*/
get_key_accounts(key) {
return __awaiter(this, void 0, void 0, function* () {
const promises = keyEndpoints.map((endpoint) => __awaiter(this, void 0, void 0, function* () {
const url = `${endpoints_1.GET_KEY_ACCOUNTS}/${key}`;
return yield this.get(url, endpoint);
}));
return yield Promise.all(promises);
JsonRpc.prototype.get_key_accounts = function (key) {
return __awaiter(this, void 0, void 0, function () {
var promises;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
promises = keyEndpoints.map(function (endpoint) {
var url = endpoints_1.GET_KEY_ACCOUNTS + "/" + key;
return _this.get(url, endpoint);
});
return [4 /*yield*/, Promise.all(promises)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
}
};
/**

@@ -161,5 +214,5 @@ * [GET /api/networks]

*/
get_networks() {
JsonRpc.prototype.get_networks = function () {
return this.get(endpoints_1.GET_NETWORKS);
}
};
/**

@@ -172,6 +225,6 @@ * [GET /api/sync]

*/
get_sync_info() {
const url = `${endpoints_1.GET_SYNC_INFO}/${this.chain}`;
JsonRpc.prototype.get_sync_info = function () {
var url = endpoints_1.GET_SYNC_INFO + "/" + this.chain;
return this.get(url);
}
};
/**

@@ -187,6 +240,6 @@ * [GET /api/tokenbalance]

*/
get_token_balance(account, contract, token) {
const url = `${endpoints_1.GET_TOKEN_BALANCE}/${this.chain}/${account}/${contract}/${token}`;
JsonRpc.prototype.get_token_balance = function (account, contract, token) {
var url = endpoints_1.GET_TOKEN_BALANCE + "/" + this.chain + "/" + account + "/" + contract + "/" + token;
return this.get(url);
}
};
/**

@@ -203,6 +256,6 @@ * [GET /api/topholders]

*/
get_topholders(contract, token, num) {
const url = `${endpoints_1.GET_TOPHOLDERS}/${this.chain}/${contract}/${token}/${num}`;
JsonRpc.prototype.get_topholders = function (contract, token, num) {
var url = endpoints_1.GET_TOPHOLDERS + "/" + this.chain + "/" + contract + "/" + token + "/" + num;
return this.get(url);
}
};
/**

@@ -215,6 +268,6 @@ * [GET /api/usercount]

*/
get_usercount() {
const url = `${endpoints_1.GET_USERCOUNT}/${this.chain}`;
JsonRpc.prototype.get_usercount = function () {
var url = endpoints_1.GET_USERCOUNT + "/" + this.chain;
return this.get(url);
}
};
/**

@@ -229,6 +282,6 @@ * [GET /api/topram]

*/
get_topram(num) {
const url = `${endpoints_1.GET_TOPRAM}/${this.chain}/${num}`;
JsonRpc.prototype.get_topram = function (num) {
var url = endpoints_1.GET_TOPRAM + "/" + this.chain + "/" + num;
return this.get(url);
}
};
/**

@@ -243,6 +296,6 @@ * [GET /api/topstake]

*/
get_topstake(num) {
const url = `${endpoints_1.GET_TOPSTAKE}/${this.chain}/${num}`;
JsonRpc.prototype.get_topstake = function (num) {
var url = endpoints_1.GET_TOPSTAKE + "/" + this.chain + "/" + num;
return this.get(url);
}
};
/**

@@ -257,6 +310,6 @@ * [GET /api/codehash]

*/
get_codehash(hash) {
const url = `${endpoints_1.GET_CODEHASH}/${hash}`;
JsonRpc.prototype.get_codehash = function (hash) {
var url = endpoints_1.GET_CODEHASH + "/" + hash;
return this.get(url);
}
};
/**

@@ -272,8 +325,9 @@ * [GET /api/holdercount]

*/
get_tokenholder_count(contract, token) {
const url = `${endpoints_1.GET_TOKEN_HOLDER_COUNT}/${this.chain}/${contract}/${token}`;
JsonRpc.prototype.get_tokenholder_count = function (contract, token) {
var url = endpoints_1.GET_TOKEN_HOLDER_COUNT + "/" + this.chain + "/" + contract + "/" + token;
return this.get(url);
}
}
};
return JsonRpc;
}());
exports.JsonRpc = JsonRpc;
//# sourceMappingURL=jsonrpc.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.RpcStatusError = exports.RpcError = void 0;
/**

@@ -9,17 +23,21 @@ * @private

*/
class RpcError extends Error {
constructor(json) {
var RpcError = /** @class */ (function (_super) {
__extends(RpcError, _super);
function RpcError(json) {
var _this = this;
if (json.error && json.error.details && json.error.details.length && json.error.details[0].message) {
super(json.error.details[0].message);
_this = _super.call(this, json.error.details[0].message) || this;
}
else if (json.processed && json.processed.except && json.processed.except.message) {
super(json.processed.except.message);
_this = _super.call(this, json.processed.except.message) || this;
}
else {
super(json.message);
_this = _super.call(this, json.message) || this;
}
Object.setPrototypeOf(this, RpcError.prototype);
this.json = json;
Object.setPrototypeOf(_this, RpcError.prototype);
_this.json = json;
return _this;
}
}
return RpcError;
}(Error));
exports.RpcError = RpcError;

@@ -29,12 +47,19 @@ /**

*/
class RpcStatusError extends Error {
constructor(response) {
var RpcStatusError = /** @class */ (function (_super) {
__extends(RpcStatusError, _super);
function RpcStatusError(response) {
var _this = this;
if (response.status === 405) {
super(response.statusText);
_this = _super.call(this, response.statusText) || this;
}
Object.setPrototypeOf(this, RpcStatusError.prototype);
this.response = response;
else {
_this = _super.call(this) || this;
}
Object.setPrototypeOf(_this, RpcStatusError.prototype);
_this.response = response;
return _this;
}
}
return RpcStatusError;
}(Error));
exports.RpcStatusError = RpcStatusError;
//# sourceMappingURL=rpcerror.js.map
{
"name": "@eoscafe/light-api",
"version": "3.2.8",
"version": "3.2.9",
"description": "Light API HTTP Javascript library",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc