@tangany/waas
Version:
node.js SDK for Tangany Wallet as a Service API
126 lines (125 loc) • 3.81 kB
TypeScript
import { Optional, TransactionStatus } from "../types/common";
import { IHateoasLink, IHateoasLinks, INodeStatus, IRecipient, ISearchResponse } from "./common";
import { IWalletBalance } from "./wallet";
/**
* Represents an Ethereum transaction recipient configuration.
* One of the properties `to` or `wallet` must be set.
* If both are set, the specified address needs to belong to the wallet.
*/
export interface IEthereumRecipient extends Optional<IRecipient, "amount"> {
/** Ethereum transaction data payload */
data?: string;
}
/**
* Represents an Ethereum transaction recipient configuration without data property.
*/
export interface IEthereumRecipientNoData extends Optional<IRecipient, "amount"> {
}
/**
* Represents the details for a single Ethereum transaction
*/
export interface IEthereumTransaction {
isError: boolean;
blockNr: number | null;
status: TransactionStatus;
confirmations: number | null;
data: string | null;
from: string | null;
to: string | null;
contractCreation: string | null;
gasPrice: string | null;
gas: number | null;
gasUsed: number | null;
nonce: number | null;
value: string | null;
timestamp: number | null;
transactionIndex: number | null;
}
/**
* Represents an Ethereum transaction estimation
*/
export interface IEthereumTransactionEstimation {
gas: string;
gasPrice: string;
fee: string;
data: string;
}
/**
* Represents the API response that is returned once an Ethereum transaction is sent through a synchronous endpoint.
*/
export interface IEthereumTransactionSentResponse {
hash: string;
nonce: string;
links: IHateoasLink<"transaction">[];
}
/**
* Represents the output of an asynchronous request for a confirmed Ethereum transaction
*/
export interface IAsyncEthereumTransactionOutput {
hash: string;
blockNr: number;
data: string;
status: string;
nonce: number;
gas: string;
gasPrice: string;
links: IHateoasLink<"transaction">[];
}
/**
* Represents status and information about an Ethereum wallet
*/
export interface IEthWalletBalance extends IWalletBalance {
nonce: number;
}
/**
* Represents a personal Ethereum signature
*/
export interface IEthereumPersonalSignature {
payload: string;
payloadHash: string;
signature: string;
address: string;
}
export interface IEthStatus extends INodeStatus<IEthStatusInfo> {
}
interface IEthStatusInfo {
peerCount: number | null;
protocolVersion: string | null;
blockNumber: number | null;
chainId: number | null;
gasPrice: number | null;
}
/**
* Represents the response of a ERC20 token wallet balance
*/
export interface ITokenBalance {
balance: string;
currency: string;
}
/**
* Query parameters describing filters to narrow down a search in all transactions of a chain.
* `from` and `to` must contain lower case Ethereum addresses
* `blocknr` and `nonce` must be stringified numbers > "0"
* `iserror` must be a stringified boolean "true" or "false"
* `index` must be >= "0" and `limit` must be within "1" and "100"
*/
export interface ITransactionSearchParams {
from?: string;
to?: string;
blocknr?: string;
nonce?: string;
iserror?: string;
sort?: "value" | "valuedesc" | "blocknr" | "blocknrdesc" | "nonce" | "noncedesc" | "to" | "todesc" | "from" | "fromdesc" | "timestamp" | "timestampdesc" | "transactionindex" | "transactionindexdesc";
limit?: string;
index?: string;
}
export interface IWalletTransactionSearchParams extends ITransactionSearchParams {
direction?: "in" | "out";
}
export interface ITransactionSearchResponse extends ISearchResponse<IHateoasLinks> {
list: {
hash: string;
links: IHateoasLink<"transaction">[];
}[];
}
export {};