@ellcrys/spell
Version:
The official JavaScript library for Ellcrys
136 lines (135 loc) • 3.76 kB
TypeScript
/// <reference types="node" />
import { Address } from "../key";
import Decimal from "decimal.js";
import RPCClient from "../rpcclient";
import TxUtility from "./tx_util";
import { PrivateKey } from "..";
export declare const NumDecimals = 18;
export declare const TxPayloadVersion: Buffer;
/**
* Transaction builder provides
* transaction creation and execution
* capabilities.
*
* @class TxBuilder
*/
export default class TxBuilder {
balance: TxBalanceBuilder;
constructor(client: RPCClient);
}
/**
* TxBalanceBuilder provides the ability to
* build and execute a balance transaction
*
* @class TxBalanceBuilder
*/
export declare class TxBalanceBuilder extends TxUtility {
/**
* The transaction data
*
* @protected
* @type {Transaction}
* @memberof TxBalanceBuilder
*/
protected data: Transaction;
/**
* The RPC client
*
* @protected
* @type {RPCClient}
* @memberof TxBalanceBuilder
*/
protected client: undefined | RPCClient;
/**
* Creates an instance of TxBalanceBuilder.
*
* @param {RPCClient} [client] The RPC client
* @memberof TxBalanceBuilder
*/
constructor(client?: RPCClient);
/**
* Set the sender address
*
* @param {string|Address} address The address
* @returns {TxBalanceBuilder}
* @memberof TxBalanceBuilder
*/
from(address: string | Address): TxBalanceBuilder;
/**
* Set the recipient address
*
* @param {string|Address} address The address
* @returns {TxBalanceBuilder}
* @memberof TxBalanceBuilder
*/
to(address: string | Address): TxBalanceBuilder;
/**
* The next nonce of the sending account
*
* @param {number} n The next nonce of the sender
* @returns {TxBalanceBuilder}
* @memberof TxBalanceBuilder
*/
nonce(num: number): TxBalanceBuilder;
/**
* Set the amount to send from the
* sender to the recipient
*
* @param {string} value The amount to send
* @returns {TxBalanceBuilder}
* @memberof TxBalanceBuilder
*/
value(value: string | Decimal): TxBalanceBuilder;
/**
* Set the fee to be paid for this
* transaction
*
* @param {string} value The amount to pay as fee
* @returns {TxBalanceBuilder}
* @memberof TxBalanceBuilder
*/
fee(fee: string | Decimal): TxBalanceBuilder;
/**
* Reset the transaction builder
*
* @memberof TxBalanceBuilder
*/
reset(): void;
/**
* Performs final operations such computing and
* setting the transaction hash and signature as
* well as setting the sender public key and time.
*
* @protected
* @param {PrivateKey} sk The sender's private key
* @returns {Promise<string>} Returns the transaction hash
* @memberof TxBalanceBuilder
*/
protected finalize(sk?: PrivateKey): Promise<string>;
/**
* Returns the transaction data without sending
* it to the network. It will finalize the transaction
* if the sender's private key is provided.
*
* @param {PrivateKey} [sk] The senders private key
* @memberof TxBalanceBuilder
*/
payload(sk?: PrivateKey): Promise<Transaction>;
/**
* Send the transaction to the network
*
* @param {PrivateKey} sk The sender's private key
* @returns {Promise<TxResult>}
* @memberof TxBalanceBuilder
*/
send(sk: PrivateKey): Promise<TxResult>;
/**
* Returns a base58 serialized version of the
* transaction.
*
* @param {PrivateKey} sk The sender's private key
* @returns {string}
* @memberof TxBalanceBuilder
*/
packed(sk: PrivateKey): Promise<string>;
}