UNPKG

sensible-sdk

Version:

Sensible-SDK

126 lines (125 loc) 4.81 kB
export declare enum API_NET { MAIN = "mainnet", TEST = "testnet" } export declare enum API_TARGET { SENSIBLE = "sensible", METASV = "metasv", SHOW = "show" } export declare type NonFungibleTokenUnspent = { txId: string; outputIndex: number; tokenAddress: string; tokenIndex: string; metaTxId: string; metaOutputIndex: number; }; export declare type FungibleTokenUnspent = { txId: string; outputIndex: number; tokenAddress: string; tokenAmount: string; }; export declare type SA_utxo = { txId: string; outputIndex: number; satoshis: number; address: string; }; export declare type FungibleTokenSummary = { codehash: string; genesis: string; sensibleId: string; pendingBalance: string; balance: string; symbol: string; decimal: number; }; export declare type NonFungibleTokenSummary = { codehash: string; genesis: string; sensibleId: string; count: string; pendingCount: string; metaTxId: string; metaOutputIndex: number; supply: string; }; export declare type FungibleTokenBalance = { balance: string; pendingBalance: string; utxoCount: number; decimal: number; }; export declare type NftSellUtxo = { codehash: string; genesis: string; tokenIndex: string; txId: string; outputIndex: number; sellerAddress: string; satoshisPrice: number; }; export declare type AuthorizationOption = { /** * should be provided in MetaSV */ authorization?: string; /** * should be provided in MetaSV */ privateKey?: any; }; export declare type OutpointSpent = { spentTxId: string; spentInputIndex: number; }; export interface SensibleApiBase { authorize: (options: AuthorizationOption) => void; getUnspents: (address: string) => Promise<SA_utxo[]>; getRawTxData: (txid: string) => Promise<string>; broadcast: (hex: string) => Promise<string>; getFungibleTokenUnspents: (codehash: string, genesis: string, address: string, size?: number) => Promise<FungibleTokenUnspent[]>; getFungibleTokenBalance: (codehash: string, genesis: string, address: string) => Promise<FungibleTokenBalance>; getFungibleTokenSummary(address: string): Promise<FungibleTokenSummary[]>; getNonFungibleTokenUnspents(codehash: string, genesis: string, address: string, cursor?: number, size?: number): Promise<NonFungibleTokenUnspent[]>; getNonFungibleTokenUnspentDetail(codehash: string, genesis: string, tokenIndex: string): Promise<NonFungibleTokenUnspent>; getNonFungibleTokenSummary(address: string): Promise<NonFungibleTokenSummary[]>; getBalance(address: string): Promise<{ balance: number; pendingBalance: number; }>; getNftSellUtxo(codehash: string, genesis: string, tokenIndex: string): Promise<NftSellUtxo>; getNftSellList(codehash: string, genesis: string, cursor?: number, size?: number): Promise<NftSellUtxo[]>; getNftSellListByAddress(address: string, cursor?: number, size?: number): Promise<NftSellUtxo[]>; getOutpointSpent(txId: string, index: number): Promise<OutpointSpent>; } export declare class SensibleApi implements SensibleApiBase { private apiTarget; private apiHandler; constructor(apiNet: API_NET, apiTarget?: API_TARGET, serverBase?: string); /** * Authorization to use MetaSV * @param options * @returns */ authorize(options: AuthorizationOption): void; getUnspents(address: string): Promise<SA_utxo[]>; getBalance(address: string): Promise<{ balance: number; pendingBalance: number; }>; getRawTxData(txid: string): Promise<string>; broadcast(hex: string): Promise<string>; getFungibleTokenUnspents(codehash: string, genesis: string, address: string, size?: number): Promise<FungibleTokenUnspent[]>; getFungibleTokenBalance(codehash: string, genesis: string, address: string): Promise<FungibleTokenBalance>; getFungibleTokenSummary(address: string): Promise<FungibleTokenSummary[]>; getNonFungibleTokenUnspents(codehash: string, genesis: string, address: string, cursor?: number, size?: number): Promise<NonFungibleTokenUnspent[]>; getNonFungibleTokenUnspentDetail(codehash: string, genesis: string, tokenIndex: string): Promise<NonFungibleTokenUnspent>; getNonFungibleTokenSummary(address: string): Promise<NonFungibleTokenSummary[]>; getNftSellUtxo(codehash: string, genesis: string, tokenIndex: string): Promise<NftSellUtxo>; getNftSellList(codehash: string, genesis: string, cursor?: number, size?: number): Promise<NftSellUtxo[]>; getNftSellListByAddress(address: string, cursor?: number, size?: number): Promise<NftSellUtxo[]>; getOutpointSpent(txId: string, index: number): Promise<OutpointSpent>; }