New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@liskhq/lisk-api-client

Package Overview
Dependencies
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liskhq/lisk-api-client - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

dist-node/account.d.ts

63

dist-node/api_client.d.ts

@@ -1,43 +0,24 @@

import { HashMap, InitOptions } from './api_types';
import * as constants from './constants';
import { AccountsResource } from './resources/accounts';
import { BlocksResource } from './resources/blocks';
import { DappsResource } from './resources/dapps';
import { DelegatesResource } from './resources/delegates';
import { NodeResource } from './resources/node';
import { PeersResource } from './resources/peers';
import { TransactionsResource } from './resources/transactions';
import { VotersResource } from './resources/voters';
import { VotesResource } from './resources/votes';
export interface ClientOptions {
readonly engine?: string;
readonly name?: string;
readonly version?: string;
}
import { EventCallback, Channel, RegisteredSchemas } from './types';
import { Node } from './node';
import { Account } from './account';
import { Block } from './block';
import { Transaction } from './transaction';
export declare class APIClient {
static get constants(): typeof constants;
static createMainnetAPIClient(options?: InitOptions): APIClient;
static createTestnetAPIClient(options?: InitOptions): APIClient;
accounts: AccountsResource;
bannedNodes: ReadonlyArray<string>;
blocks: BlocksResource;
currentNode: string;
dapps: DappsResource;
delegates: DelegatesResource;
headers: HashMap;
node: NodeResource;
nodes: ReadonlyArray<string>;
peers: PeersResource;
randomizeNodes: boolean;
transactions: TransactionsResource;
voters: VotersResource;
votes: VotesResource;
constructor(nodes: ReadonlyArray<string>, providedOptions?: InitOptions);
banActiveNode(): boolean;
banActiveNodeAndSelect(): boolean;
banNode(node: string): boolean;
getNewNode(): string;
hasAvailableNodes(): boolean;
initialize(nodes: ReadonlyArray<string>, providedOptions?: InitOptions): void;
isBanned(node: string): boolean;
private readonly _channel;
private _schemas;
private _nodeInfo;
private _node;
private _account;
private _block;
private _transaction;
constructor(channel: Channel);
init(): Promise<void>;
disconnect(): Promise<void>;
invoke<T = Record<string, unknown>>(actionName: string, params?: Record<string, unknown>): Promise<T>;
subscribe<T = Record<string, unknown>>(eventName: string, cb: EventCallback<T>): void;
get schemas(): RegisteredSchemas;
get node(): Node;
get account(): Account;
get block(): Block;
get transaction(): Transaction;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const os = require("os");
const constants = require("./constants");
const accounts_1 = require("./resources/accounts");
const blocks_1 = require("./resources/blocks");
const dapps_1 = require("./resources/dapps");
const delegates_1 = require("./resources/delegates");
const node_1 = require("./resources/node");
const peers_1 = require("./resources/peers");
const transactions_1 = require("./resources/transactions");
const voters_1 = require("./resources/voters");
const votes_1 = require("./resources/votes");
const defaultOptions = {
bannedNodes: [],
randomizeNodes: true,
};
const commonHeaders = {
Accept: 'application/json',
'Content-Type': 'application/json',
};
const getClientHeaders = (clientOptions) => {
const { name = '????', version = '????', engine = '????' } = clientOptions;
const liskElementsInformation = 'LiskElements/1.0 (+https://github.com/LiskHQ/lisk-elements)';
const locale = process.env.LC_ALL ||
process.env.LC_MESSAGES ||
process.env.LANG ||
process.env.LANGUAGE;
const systemInformation = `${os.platform()} ${os.release()}; ${os.arch()}${locale ? `; ${locale}` : ''}`;
return {
'User-Agent': `${name}/${version} (${engine}) ${liskElementsInformation} ${systemInformation}`,
};
};
const node_1 = require("./node");
const account_1 = require("./account");
const block_1 = require("./block");
const transaction_1 = require("./transaction");
class APIClient {
constructor(nodes, providedOptions = {}) {
this.initialize(nodes, providedOptions);
this.accounts = new accounts_1.AccountsResource(this);
this.blocks = new blocks_1.BlocksResource(this);
this.dapps = new dapps_1.DappsResource(this);
this.delegates = new delegates_1.DelegatesResource(this);
this.node = new node_1.NodeResource(this);
this.peers = new peers_1.PeersResource(this);
this.transactions = new transactions_1.TransactionsResource(this);
this.voters = new voters_1.VotersResource(this);
this.votes = new votes_1.VotesResource(this);
constructor(channel) {
this._channel = channel;
}
static get constants() {
return constants;
async init() {
this._schemas = await this._channel.invoke('app:getSchema');
this._node = new node_1.Node(this._channel);
this._account = new account_1.Account(this._channel, this._schemas);
this._block = new block_1.Block(this._channel, this._schemas);
this._nodeInfo = await this._node.getNodeInfo();
this._transaction = new transaction_1.Transaction(this._channel, this._schemas, this._nodeInfo);
}
static createMainnetAPIClient(options) {
return new APIClient(constants.MAINNET_NODES, {
genesisBlockPayloadHash: constants.MAINNET_NETHASH,
...options,
});
async disconnect() {
return this._channel.disconnect();
}
static createTestnetAPIClient(options) {
return new APIClient(constants.TESTNET_NODES, {
genesisBlockPayloadHash: constants.TESTNET_NETHASH,
...options,
});
async invoke(actionName, params) {
return this._channel.invoke(actionName, params);
}
banActiveNode() {
return this.banNode(this.currentNode);
subscribe(eventName, cb) {
this._channel.subscribe(eventName, cb);
}
banActiveNodeAndSelect() {
const banned = this.banActiveNode();
if (banned) {
this.currentNode = this.getNewNode();
}
return banned;
get schemas() {
return this._schemas;
}
banNode(node) {
if (!this.isBanned(node)) {
this.bannedNodes = [...this.bannedNodes, node];
return true;
}
return false;
get node() {
return this._node;
}
getNewNode() {
const nodes = this.nodes.filter((node) => !this.isBanned(node));
if (nodes.length === 0) {
throw new Error('Cannot get new node: all nodes have been banned.');
}
const randomIndex = Math.floor(Math.random() * nodes.length);
return nodes[randomIndex];
get account() {
return this._account;
}
hasAvailableNodes() {
return this.nodes.some((node) => !this.isBanned(node));
get block() {
return this._block;
}
initialize(nodes, providedOptions = {}) {
if (!Array.isArray(nodes) || nodes.length <= 0) {
throw new Error('APIClient requires nodes for initialization.');
}
if (typeof providedOptions !== 'object' || Array.isArray(providedOptions)) {
throw new Error('APIClient takes an optional object as the second parameter.');
}
const options = { ...defaultOptions, ...providedOptions };
this.headers = {
...commonHeaders,
...(options.genesisBlockPayloadHash
? { nethash: options.genesisBlockPayloadHash }
: {}),
...(options.client ? getClientHeaders(options.client) : {}),
};
this.nodes = nodes;
this.bannedNodes = [...(options.bannedNodes || [])];
this.currentNode = options.node || this.getNewNode();
this.randomizeNodes = options.randomizeNodes !== false;
get transaction() {
return this._transaction;
}
isBanned(node) {
return this.bannedNodes.includes(node);
}
}
exports.APIClient = APIClient;
//# sourceMappingURL=api_client.js.map

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

export * from './api_client';
export { createIPCClient, createWSClient, createClient } from './create_clients';
export type { APIClient } from './api_client';
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./api_client"));
var create_clients_1 = require("./create_clients");
exports.createIPCClient = create_clients_1.createIPCClient;
exports.createWSClient = create_clients_1.createWSClient;
exports.createClient = create_clients_1.createClient;
//# sourceMappingURL=index.js.map
{
"name": "@liskhq/lisk-api-client",
"version": "4.0.0",
"version": "5.0.0",
"description": "An API client for the Lisk network",

@@ -27,5 +27,7 @@ "author": "Lisk Foundation <admin@lisk.io>, lightcurve GmbH <admin@lightcurve.io>",

"format": "prettier --write '**/*'",
"lint": "tslint --format verbose --project .",
"lint:fix": "npm run lint -- --fix",
"lint": "eslint --ext .js,.ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"test": "jest",
"test:coverage": "jest --coverage=true --coverage-reporters=text",
"test:ci": "jest --coverage=true --coverage-reporters=json --verbose",
"test:watch": "npm test -- --watch",

@@ -38,21 +40,32 @@ "prebuild": "rm -r dist-node/* || mkdir dist-node || true",

"dependencies": {
"@types/node": "12.12.11",
"axios": "0.19.2"
"@liskhq/lisk-codec": "^0.1.0",
"@liskhq/lisk-cryptography": "^3.0.0",
"@liskhq/lisk-transactions": "^5.0.0",
"isomorphic-ws": "4.0.1",
"pm2-axon": "4.0.0",
"pm2-axon-rpc": "0.6.0",
"ws": "7.4.0"
},
"devDependencies": {
"@types/jest": "25.1.3",
"@types/jest-when": "2.7.0",
"jest": "25.1.0",
"@liskhq/lisk-chain": "^0.2.0",
"@types/jest": "26.0.13",
"@types/jest-when": "2.7.1",
"@types/node": "12.12.11",
"@typescript-eslint/eslint-plugin": "3.10.1",
"@typescript-eslint/parser": "3.10.1",
"eslint": "7.8.1",
"eslint-config-lisk-base": "1.2.2",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jest": "24.0.0",
"jest": "26.4.2",
"jest-extended": "0.11.5",
"jest-when": "2.7.0",
"prettier": "1.19.1",
"source-map-support": "0.5.16",
"ts-jest": "25.2.1",
"jest-when": "2.7.2",
"prettier": "2.0.5",
"source-map-support": "0.5.19",
"ts-jest": "26.3.0",
"ts-node": "8.6.2",
"tsconfig-paths": "3.9.0",
"tslint": "6.0.0",
"tslint-config-prettier": "1.18.0",
"tslint-immutable": "6.0.1",
"typescript": "3.8.3"
}
}

@@ -13,3 +13,3 @@ # @liskhq/lisk-api-client

Copyright 2016-2019 Lisk Foundation
Copyright 2016-2020 Lisk Foundation

@@ -16,0 +16,0 @@ Licensed under the Apache License, Version 2.0 (the "License");

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