@tangany/waas
Version:
node.js SDK for Tangany Wallet as a Service API
145 lines (144 loc) • 5.5 kB
TypeScript
import { AxiosInstance } from "axios";
import Bottleneck from "bottleneck";
import { Bitcoin } from "./btc";
import { Ethereum } from "./eth";
import { Transaction } from "./types/common";
import { Request } from "./request";
import { Wallet } from "./wallet";
import { Tezos } from "./xtz";
export declare enum WalletVersion {
LATEST = "latest"
}
export declare enum WalletSecurity {
SOFTWARE = "software",
HSM = "hsm"
}
export declare enum EthereumPublicNetwork {
MAINNET = "mainnet",
ROPSTEN = "ropsten",
POLYGON = "polygon",
BINANCE = "bsc",
GOERLI = "goerli"
}
export declare enum EthereumTxSpeed {
DEFAULT = "default",
FAST = "fast",
SLOW = "slow",
NONE = "none"
}
export declare enum BitcoinNetwork {
BITCOIN = "bitcoin",
TESTNET = "testnet"
}
export declare enum TezosNetwork {
MAINNET = "mainnet"
}
export declare enum BlockchainTxConfirmations {
NONE = "none",
DEFAULT = "default",
SECURE = "secure"
}
export declare enum BitcoinTxSpeed {
SLOW = "slow",
DEFAULT = "default",
FAST = "fast"
}
export declare enum ApiVersion {
V1 = "v1",
V2_ALPHA = "v2-alpha"
}
interface IWaaSOptions {
clientId?: string;
clientSecret?: string;
subscription?: string;
vaultUrl?: string;
ethereumNetwork?: EthereumPublicNetwork | string;
ethereumTxSpeed?: EthereumTxSpeed;
ethereumTxConfirmations?: BlockchainTxConfirmations | number;
ethereumGasPrice?: string;
ethereumGas?: number;
ethereumNonce?: number;
ethereumChainId?: number;
useGasTank?: boolean;
bitcoinNetwork?: BitcoinNetwork;
bitcoinTxConfirmations?: BlockchainTxConfirmations | number;
bitcoinTxSpeed?: BitcoinTxSpeed;
bitcoinMaxFeeRate?: number;
bitcoinFeeRate?: number;
tezosNetwork?: TezosNetwork;
tezosGasLimit?: number;
tezosStorageLimit?: number;
tezosOperationConfirmation?: BlockchainTxConfirmations | number;
requestId?: string;
}
export declare const recipientType: object;
export declare const btcRecipientType: object;
export declare const ethereumRecipientType: object;
export declare const ethereumRecipientTypeSendAsync: object;
/**
* Instantiates a new API interface. Multiple instances with different settings can run in parallel
* @param options - api options
* @param options.clientId - Subscription client id
* @param options.clientSecret - Subscription client secret
* @param options.subscription - Subscription code
* @param options.vaultUrl - Tangany vault url
* @param options.ethereumNetwork - Public Ethereum network name or private Ethereum network url
* @param options.ethereumTxConfirmations - Amount of block confirmations required to consider an Ethereum transaction as valid
* @param options.ethereumTxSpeed - Amount of additional gas fee that is added to the base gas fee for the given Ethereum network to speed up the mining process of the transaction
* @param options.bitcoinNetwork - Public Bitcoin network name
* @param options.bitcoinTxConfirmations - Amount of block confirmations required for Bitcoin balance outputs to be included in the total wallet balance calculation
* @param options.bitcoinTxSpeed - Target amount of block confirmations for the transaction to be included to the Bitcoin network
* @param options.bitcoinMaxFeeRate - Maximum allowed fee rate in sat/vbyte for a Bitcoin transaction
* @param options.bitcoinFeeRate - User-defined transaction fee rate in sat/vbyte for a Bitcoin transaction
* @param version - WaaS API version
* @param limiterEnabled - Enable API throttling limiter
*/
export declare class Waas {
/**
* Exposes the preconfigured AxiosInstance for arbitrary api calls
*/
get axios(): AxiosInstance;
/**
* Execute the statusGetterCall periodically until timeout and resolves the status
* @param statusGetterCall - function to fetch the transaction status from a blockchain
* @param [hash} - transaction hash
* @param [timeout] - if the statusGetterCall did not resolved during the timeout period (in ms) the function will reject
* @param [ms] - milliseconds delay between api polling attempts
*/
static waitForTxStatus(statusGetterCall: () => Promise<Transaction>, hash?: string, timeout?: number, ms?: number): Promise<Transaction>;
instance: AxiosInstance;
limiter?: Bottleneck;
constructor(options?: IWaaSOptions, version?: ApiVersion, limiterEnabled?: boolean);
/**
* read wallet based api calls
* @param [name] - wallet name
*/
wallet(name?: string): Wallet;
/**
* read eth based api calls
* @param [txHash] - Ethereum transaction hash
*/
eth(txHash?: string): Ethereum;
/**
* read btc based api calls
* @param [txHash] - Bitcoin transaction hash
*/
btc(txHash?: string): Bitcoin;
/**
* read xtz based api calls
* @param [txHash] - Tezos transaction hash
*/
xtz(txHash?: string): Tezos;
/**
* read api calls for asynchronous requests
* @param id - Unique identifier for an asynchronous request
*/
request<T extends Record<string, any>>(id: string): Request<T>;
/**
* wrap async call to the bottleneck limiter
* @param fn - function that returns a promise function. Pass the promise function's arguments via the functions argument
* @param args - promise function arguments
*/
wrap<T>(fn: (args: any) => Promise<T>, ...args: any): Promise<T>;
}
export {};