@xchainjs/xchain-binance
Version:
Custom Binance client and utilities used by XChainJS clients
74 lines (73 loc) • 2.71 kB
TypeScript
import { Fees, Network, Tx, TxType } from '@xchainjs/xchain-client';
import { Account, DexFees, Fee, TransferFee, Tx as BinanceTx, TxType as BinanceTxType } from './types/binance';
import { Transfer, TransferEvent } from './types/binance-ws';
import { DerivePath } from './types/common';
/**
* Function to extract hash from a transfer event
* @see https://docs.binance.org/api-reference/dex-api/ws-streams.html#3-transfer
* @param {TransferEvent} transfer The transfer event. (optional)
* @returns {string|undefined} The hash from transfer event.
*/
export declare const getHashFromTransfer: (transfer?: {
data?: Pick<Transfer, 'H'>;
}) => string | undefined;
/**
* Function to extract hash from a memo
* @param {TransferEvent} transfer The transfer event. (optional)
* @returns {string|undefined} The hash from the memo.
*/
export declare const getTxHashFromMemo: (transfer?: TransferEvent) => string | undefined;
/**
* Type guard function for 'Fee'
* @param {Fee|TransferFee|DexFees} v
* @returns {boolean} `true` or `false`.
*/
export declare const isFee: (v: Fee | TransferFee | DexFees) => v is Fee;
/**
* Type guard function for 'TransferFee'
* @param {Fee|TransferFee|DexFees} v
* @returns {boolean} `true` or `false`.
*/
export declare const isTransferFee: (v: Fee | TransferFee | DexFees) => v is TransferFee;
/**
* Type guard function for 'DexFees'
* @param {Fee|TransferFee|DexFees} v
* @returns {boolean} `true` or `false`.
*/
export declare const isDexFees: (v: Fee | TransferFee | DexFees) => v is DexFees;
/**
* Type guard function for 'Account'
* @param {unknown} v
* @returns {boolean} `true` or `false`.
*/
export declare const isAccount: (v: unknown) => v is Account;
/**
* Function to determine the transaction type
* @param {BinanceTxType} t
* @returns {TxType} `transfer` or `unknown`.
*/
export declare const getTxType: (t: BinanceTxType) => TxType;
/**
* Function to parse a transaction
* @param {BinanceTx} t The transaction to be parsed. (optional)
* @returns {Tx|null} The transaction parsed from the binance tx.
*/
export declare const parseTx: (tx: BinanceTx) => Tx | null;
/**
* Function to get derivation path
* @param {number} index (optional)
* @returns {DerivePath} The binance derivation path by the index.
*/
export declare const getDerivePath: (index?: number) => DerivePath;
/**
* Function to get default fees
* @returns {Fees} The default fee.
*/
export declare const getDefaultFees: () => Fees;
/**
* Function to get address prefix based on the network
* @param {Network} network
* @returns {string} The address prefix based on the network.
*
**/
export declare const getPrefix: (network: Network) => "bnb" | "tbnb";