meta-contract
Version:
Meta Contract SDK
137 lines (136 loc) • 5.22 kB
TypeScript
export declare enum API_NET {
MAIN = "mainnet",
TEST = "testnet"
}
export declare enum API_TARGET {
MVC = "mvcapi",
CYBER3 = "cyber3",
METALET = "metalet",
APIMVC = "microvisionchain"
}
export type NonFungibleTokenUnspent = {
txId: string;
outputIndex: number;
tokenAddress: string;
tokenIndex: string;
metaTxId: string;
metaOutputIndex: number;
};
export type FungibleTokenUnspent = {
txId: string;
outputIndex: number;
tokenAddress: string;
tokenAmount: string;
};
export type SA_utxo = {
txId: string;
outputIndex: number;
satoshis: number;
address: string;
height: number;
flag: string;
};
export type FungibleTokenSummary = {
codehash: string;
genesis: string;
sensibleId: string;
pendingBalance: string;
balance: string;
symbol: string;
decimal: number;
};
export type NonFungibleTokenSummary = {
codehash: string;
genesis: string;
sensibleId: string;
count: string;
pendingCount: string;
metaTxId: string;
metaOutputIndex: number;
supply: string;
};
export type FungibleTokenBalance = {
balance: string;
pendingBalance: string;
utxoCount: number;
decimal: number;
};
export type NftSellUtxo = {
codehash: string;
genesis: string;
tokenIndex: string;
txId: string;
outputIndex: number;
sellerAddress: string;
contractAddress?: string;
satoshisPrice: number;
price: number;
};
export type AuthorizationOption = {
/**
* should be provided in MetaSV
*/
authorization?: string;
/**
* should be provided in MetaSV
*/
privateKey?: any;
};
export type OutpointSpent = {
spentTxId: string;
spentInputIndex: number;
};
export interface ApiBase {
authorize: (options: AuthorizationOption) => void;
getUnspents: (address: string, flag?: string) => Promise<SA_utxo[]>;
getRawTxData: (txid: string) => Promise<string>;
checkTxSeen: (txid: string) => Promise<boolean>;
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, includesNotReady?: boolean): 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>;
getXpubLiteUtxo(xpub: string): Promise<any>;
getXpubLiteBalance(xpub: string): Promise<any>;
}
export declare class Api implements ApiBase {
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, flag?: string): Promise<SA_utxo[]>;
getBalance(address: string): Promise<{
balance: number;
pendingBalance: number;
}>;
getRawTxData(txid: string): Promise<string>;
checkTxSeen(txid: string): Promise<boolean>;
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, includesNotReady?: boolean): 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>;
getXpubLiteUtxo(xpub: string): Promise<any>;
getXpubLiteBalance(xpub: string): Promise<any>;
}