incubed
Version:
Typescript-version of the incubed client
99 lines (98 loc) • 4.26 kB
TypeScript
/***********************************************************
* This file is part of the Slock.it IoT Layer. *
* The Slock.it IoT Layer contains: *
* - USN (Universal Sharing Network) *
* - INCUBED (Trustless INcentivized remote Node Network) *
************************************************************
* Copyright (C) 2016 - 2018 Slock.it GmbH *
* All Rights Reserved. *
************************************************************
* You may use, distribute and modify this code under the *
* terms of the license contract you have concluded with *
* Slock.it GmbH. *
* For information about liability, maintenance etc. also *
* refer to the contract concluded with Slock.it GmbH. *
************************************************************
* For more information, please refer to https://slock.it *
* For questions, please contact info@slock.it *
***********************************************************/
import { IN3Config, RPCRequest, RPCResponse } from '../types/types';
import { Transport } from '../util/transport';
import { EventEmitter } from 'events';
import ChainContext from './ChainContext';
import EthAPI from '../modules/eth/api';
import IpfsAPI from '../modules/ipfs/api';
/** special Error for making sure the correct node is blacklisted */
export declare class BlackListError extends Error {
addresses: string[];
constructor(msg: string, addresses: string[]);
}
/**
* Client for N3.
*
*/
export default class Client extends EventEmitter {
eth: EthAPI;
ipfs: IpfsAPI;
defConfig: IN3Config;
private transport;
private chains;
/**
* creates a new Client.
* @param config the configuration
* @param transport a optional transport-object. default: AxiosTransport
*/
constructor(config?: Partial<IN3Config>, transport?: Transport);
createWeb3Provider(): any;
getChainContext(chainId: string): ChainContext;
config: IN3Config;
/**
* fetches the nodeList from the servers.
* @param chainId if given, the list for the given chainId will be updated otherwise the chainId is taken from the config
*/
updateNodeList(chainId?: string, conf?: Partial<IN3Config>, retryCount?: number): Promise<void>;
/**
* sends a simply RPC-Request
* @param method the method
* @param params the params
* @param chain a optional chainId (default: chainId from config)
* @param config optional config-params overridnig the client config
*/
sendRPC(method: string, params?: any[], chain?: string, config?: Partial<IN3Config>): Promise<RPCResponse>;
/**
* sends a simply RPC-Request
* @param method the method
* @param params the params
* @param chain a optional chainId (default: chainId from config)
* @param config optional config-params overridnig the client config
*/
call(method: string, params: any, chain?: string, config?: Partial<IN3Config>): Promise<any>;
/**
* sends one or a multiple requests.
* if the request is a array the response will be a array as well.
* If the callback is given it will be called with the response, if not a Promise will be returned.
* This function supports callback so it can be used as a Provider for the web3.
*/
send(request: RPCRequest[] | RPCRequest, callback?: (err: Error, response: RPCResponse | RPCResponse[]) => void, config?: Partial<IN3Config>): Promise<RPCResponse | RPCResponse[]>;
/**
* clears all stats and weights, like blocklisted nodes
*/
clearStats(): void;
/** returns the current nodeList for the chainId specified in the config. If needed it will fetch the nodelist from the server first. */
private getNodeList(conf);
/**
* executes the requests
* @param requests requests
* @param conf full configuration
* @param prevExcludes list of nodes to exclude
*/
private sendIntern(requests, conf, prevExcludes?);
}
export declare const aliases: {
kovan: string;
tobalaba: string;
main: string;
ipfs: string;
mainnet: string;
goerli: string;
};