How to use the @liskhq/lisk-api-client.APIClient.constants function in @liskhq/lisk-api-client

To help you get started, we’ve selected a few @liskhq/lisk-api-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LiskHQ / lisk-sdk / commander / src / utils / api.ts View on Github external
* for licensing information.
 *
 * Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation,
 * no part of this software, including this file, may be copied, modified,
 * propagated, or distributed except according to the terms contained in the
 * LICENSE file.
 *
 * Removal or modification of this copyright notice is prohibited.
 *
 */
import { APIClient } from '@liskhq/lisk-api-client';

import { NETHASHES } from './constants';

const seedNodes: { readonly [key: string]: ReadonlyArray } = {
	main: APIClient.constants.MAINNET_NODES,
	test: APIClient.constants.TESTNET_NODES,
};

interface APIClientOptions {
	readonly network: string;
	readonly nodes: ReadonlyArray;
}

export const getAPIClient = ({
	nodes,
	network,
}: APIClientOptions): APIClient => {
	const nethash = NETHASHES[network] || network;
	const clientNodes = nodes && nodes.length > 0 ? nodes : seedNodes[network];

	return new APIClient(clientNodes, { nethash });
github LiskHQ / lisk-sdk / commander / src / utils / api.ts View on Github external
*
 * Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation,
 * no part of this software, including this file, may be copied, modified,
 * propagated, or distributed except according to the terms contained in the
 * LICENSE file.
 *
 * Removal or modification of this copyright notice is prohibited.
 *
 */
import { APIClient } from '@liskhq/lisk-api-client';

import { NETHASHES } from './constants';

const seedNodes: { readonly [key: string]: ReadonlyArray } = {
	main: APIClient.constants.MAINNET_NODES,
	test: APIClient.constants.TESTNET_NODES,
};

interface APIClientOptions {
	readonly network: string;
	readonly nodes: ReadonlyArray;
}

export const getAPIClient = ({
	nodes,
	network,
}: APIClientOptions): APIClient => {
	const nethash = NETHASHES[network] || network;
	const clientNodes = nodes && nodes.length > 0 ? nodes : seedNodes[network];

	return new APIClient(clientNodes, { nethash });
};

@liskhq/lisk-api-client

An API client for the Lisk network

Apache-2.0
Latest version published 2 months ago

Package Health Score

87 / 100
Full package analysis