@logosnetwork/logos-rpc-client
Version:
Promise-based client for interacting and building services on top of the Logos network.
378 lines (377 loc) • 14.2 kB
TypeScript
import { API } from './api';
export declare type RPCClient = (params: any) => Promise<any>;
export declare function createAxiosClient(baseURL?: string, targetURL?: string): RPCClient;
export declare const convert: {
toReason(amount: string | number, denomination: "reason" | "LOGOS"): string;
fromReason(amount: string, denomination: "reason" | "LOGOS"): string;
fromTo(amount: string, currentDec: number, preferedDec: number): string;
};
export interface LogosConstructorOptions {
url?: string;
proxyURL?: string;
rpcClient?: RPCClient;
debug?: boolean;
}
export declare type Denomination = 'reason' | 'LOGOS';
export default class Logos {
rpc: <Action extends string>(rpc_action: Action, body?: API[Action]["body"]) => Promise<API[Action]["response"]>;
debug: boolean;
constructor(options?: LogosConstructorOptions);
changeServer(baseURL: string, targetURL?: string): void;
_log(message: string): void;
readonly accounts: {
toAddress(publicKey: string): Promise<{
account: string;
}>;
reasonBalance(account: string): Promise<{
balance: string;
pending: string;
}>;
logosBalance(account: string): Promise<string>;
balances(accounts: string[]): Promise<{
[account: string]: {
balance: string;
pending: string;
};
}>;
blockCount(account: string): Promise<{
block_count: string;
}>;
history(account: string, count?: number, details?: boolean, head?: string): Promise<{
hash?: string;
type?: string;
origin?: string;
signature?: string;
previous: string;
next?: string;
fee?: string;
sequence?: string;
work?: string;
number_transactions?: string;
request_block_hash?: string;
request_block_index?: string;
transactions?: {
destination: string;
amount: string;
}[];
transaction?: {
destination: string;
amount: string;
};
send_hash?: string;
index_to_send_block?: string;
token_id?: string;
symbol?: string;
name?: string;
total_supply?: string;
fee_type?: "flat" | "percentage";
fee_rate?: string;
settings?: ("issuance" | "modify_issuance" | "revoke" | "modify_revoke" | "freeze" | "modify_freeze" | "adjust_fee" | "modify_adjust_fee" | "whitelist" | "modify_whitelist")[];
controllers?: {
account: string;
privileges: ("issuance" | "revoke" | "freeze" | "adjust_fee" | "whitelist" | "change_issuance" | "change_modify_issuance" | "change_revoke" | "change_modify_revoke" | "change_freeze" | "change_modify_freeze" | "change_adjust_fee" | "change_modify_adjust_fee" | "change_whitelist" | "change_modify_whitelist" | "update_issuer_info" | "update_controller" | "burn" | "distribute" | "withdraw_fee" | "withdraw_logos")[];
}[];
issuer_info?: string;
timestamp?: string;
source?: string;
status?: "frozen" | "unfrozen" | "whitelisted" | "not_whitelisted";
setting?: "issuance" | "revoke" | "freeze" | "adjust_fee" | "whitelist";
value?: string;
token_fee?: string;
action?: "add" | "remove";
controller?: {
account: string;
privileges: ("issuance" | "revoke" | "freeze" | "adjust_fee" | "whitelist" | "change_issuance" | "change_modify_issuance" | "change_revoke" | "change_modify_revoke" | "change_freeze" | "change_modify_freeze" | "change_adjust_fee" | "change_modify_adjust_fee" | "change_whitelist" | "change_modify_whitelist" | "update_issuer_info" | "update_controller" | "burn" | "distribute" | "withdraw_fee" | "withdraw_logos")[];
};
new_info?: string;
}[]>;
info(account: string): Promise<{
type: string;
frontier: string;
receive_tip: string;
open_block?: string;
representative_block?: string;
balance: string;
modified_timestamp?: string;
request_count: string;
sequence: string;
token_balance?: string;
total_supply?: string;
token_fee_balance?: string;
symbol?: string;
name?: string;
issuer_info?: string;
fee_rate?: string;
fee_type?: "flat" | "percentage";
controllers?: {
account: string;
privileges: ("issuance" | "revoke" | "freeze" | "adjust_fee" | "whitelist" | "change_issuance" | "change_modify_issuance" | "change_revoke" | "change_modify_revoke" | "change_freeze" | "change_modify_freeze" | "change_adjust_fee" | "change_modify_adjust_fee" | "change_whitelist" | "change_modify_whitelist" | "update_issuer_info" | "update_controller" | "burn" | "distribute" | "withdraw_fee" | "withdraw_logos")[];
}[];
settings?: ("issuance" | "modify_issuance" | "revoke" | "modify_revoke" | "freeze" | "modify_freeze" | "adjust_fee" | "modify_adjust_fee" | "whitelist" | "modify_whitelist")[];
issuance_request?: string;
tokens?: {
[tokenID: string]: {
whitelisted: string;
frozen: string;
balance: string;
};
};
}>;
};
readonly requests: {
info(hash: string): Promise<{
hash?: string;
type?: string;
origin?: string;
signature?: string;
previous: string;
next?: string;
fee?: string;
sequence?: string;
work?: string;
number_transactions?: string;
request_block_hash?: string;
request_block_index?: string;
transactions?: {
destination: string;
amount: string;
}[];
transaction?: {
destination: string;
amount: string;
};
send_hash?: string;
index_to_send_block?: string;
token_id?: string;
symbol?: string;
name?: string;
total_supply?: string;
fee_type?: "flat" | "percentage";
fee_rate?: string;
settings?: ("issuance" | "modify_issuance" | "revoke" | "modify_revoke" | "freeze" | "modify_freeze" | "adjust_fee" | "modify_adjust_fee" | "whitelist" | "modify_whitelist")[];
controllers?: {
account: string;
privileges: ("issuance" | "revoke" | "freeze" | "adjust_fee" | "whitelist" | "change_issuance" | "change_modify_issuance" | "change_revoke" | "change_modify_revoke" | "change_freeze" | "change_modify_freeze" | "change_adjust_fee" | "change_modify_adjust_fee" | "change_whitelist" | "change_modify_whitelist" | "update_issuer_info" | "update_controller" | "burn" | "distribute" | "withdraw_fee" | "withdraw_logos")[];
}[];
issuer_info?: string;
timestamp?: string;
source?: string;
status?: "frozen" | "unfrozen" | "whitelisted" | "not_whitelisted";
setting?: "issuance" | "revoke" | "freeze" | "adjust_fee" | "whitelist";
value?: string;
token_fee?: string;
action?: "add" | "remove";
controller?: {
account: string;
privileges: ("issuance" | "revoke" | "freeze" | "adjust_fee" | "whitelist" | "change_issuance" | "change_modify_issuance" | "change_revoke" | "change_modify_revoke" | "change_freeze" | "change_modify_freeze" | "change_adjust_fee" | "change_modify_adjust_fee" | "change_whitelist" | "change_modify_whitelist" | "update_issuer_info" | "update_controller" | "burn" | "distribute" | "withdraw_fee" | "withdraw_logos")[];
};
new_info?: string;
}>;
publish(request: string): Promise<{
hash: string;
}>;
};
readonly epochs: {
delegateIPs(time?: "current" | "next"): Promise<{
delegates: {
0: {
ip: string;
};
1: {
ip: string;
};
2: {
ip: string;
};
3: {
ip: string;
};
4: {
ip: string;
};
5: {
ip: string;
};
6: {
ip: string;
};
7: {
ip: string;
};
8: {
ip: string;
};
9: {
ip: string;
};
10: {
ip: string;
};
11: {
ip: string;
};
12: {
ip: string;
};
13: {
ip: string;
};
14: {
ip: string;
};
15: {
ip: string;
};
16: {
ip: string;
};
17: {
ip: string;
};
18: {
ip: string;
};
19: {
ip: string;
};
20: {
ip: string;
};
21: {
ip: string;
};
22: {
ip: string;
};
23: {
ip: string;
};
24: {
ip: string;
};
25: {
ip: string;
};
26: {
ip: string;
};
27: {
ip: string;
};
28: {
ip: string;
};
29: {
ip: string;
};
30: {
ip: string;
};
31: {
ip: string;
};
};
}>;
history(count: string | number, hash: string): Promise<{
history: {
account: string;
epoch_number: string;
micro_block_tip: string;
transaction_fee_pool: string;
signature: string;
delegates: {
account: string;
vote: string;
stake: string;
}[];
}[];
}>;
get(hashes: [string]): Promise<{
blocks: {
account: string;
epoch_number: string;
micro_block_tip: string;
transaction_fee_pool: string;
signature: string;
delegates: {
account: string;
vote: string;
stake: string;
}[];
}[];
}>;
};
readonly microEpochs: {
history(count: string | number, hash: string): Promise<{
history: {
timestamp: string;
previous: string;
hash: string;
delegate: string;
epoch_number: string;
micro_block_number: string;
last_micro_block: string;
tips: string[];
number_batch_blocks: string;
signature: string;
}[];
}>;
get(hashes: [string]): Promise<{
blocks: {
timestamp: string;
previous: string;
hash: string;
delegate: string;
epoch_number: string;
micro_block_number: string;
last_micro_block: string;
tips: string[];
number_batch_blocks: string;
signature: string;
}[];
}>;
};
readonly requestBlocks: {
history(count: string | number, delegateIndex: string | number, hash: string): Promise<any>;
get(hashes: [string]): Promise<any>;
};
static convert: {
toReason(amount: string | number, denomination: "reason" | "LOGOS"): string;
fromReason(amount: string, denomination: "reason" | "LOGOS"): string;
fromTo(amount: string, currentDec: number, preferedDec: number): string;
};
readonly convert: {
toReason(amount: string | number, denomination: "reason" | "LOGOS"): string;
fromReason(amount: string, denomination: "reason" | "LOGOS"): string;
fromTo(amount: string, currentDec: number, preferedDec: number): string;
};
readonly key: {
create(): Promise<{
privateKey: string;
publicKey: string;
address: string;
}>;
expand(privateKey: string): Promise<{
privateKey: string;
publicKey: string;
address: string;
}>;
};
readonly work: {
generate(hash: string): Promise<{
work: string;
}>;
validate(work: string, hash: string): Promise<{
valid: string;
}>;
};
available(): Promise<string>;
generateMicroBlock(last?: boolean): Promise<{
contents: string;
}>;
deterministicKey(seed: string, index?: string | number): Promise<{
private: string;
public: string;
account: string;
}>;
}