UNPKG

@funded-labs/dab-js

Version:
99 lines (98 loc) 2.96 kB
import { Principal } from '@dfinity/principal'; export declare type AccountIdentifier = string; export declare type TokenIdentifier = string; export declare type Balance = bigint; export declare type SubAccount = number[]; export declare type Memo = number[]; export declare type Fee = bigint; export declare type Time = bigint; export declare type TokenIndex = number; export declare type Tokens = TokenIndex[]; export declare type User = { addres?: AccountIdentifier; } | { principal?: Principal; }; export declare type CommonError = { InvalidToken: TokenIdentifier; } | { Other: string; }; export interface ResultOk<T> { ok: T; } export interface ResultError<T> { err: T; } export declare type Result<Ok, Error> = ResultOk<Ok> | ResultError<Error>; interface BalanceRequest { token: TokenIdentifier; user: User; } export interface Listing { locked?: Time; seller: Principal; price: bigint; } export interface TokenMetaData { name: string; decimals: number; symbol: string; fee?: number; } export declare type Extension = string; declare type Details = [AccountIdentifier, Listing]; declare type BalanceResult = Result<Balance, CommonError>; declare type DetailsResult = Result<Details, CommonError>; declare type TokensResult = Result<Tokens, CommonError>; declare type TokenExt = [TokenIndex, Listing[], Int8Array[]]; declare type TokensExtResult = Result<TokenExt[], CommonError>; declare type SupplyResponse = Result<Balance, CommonError>; interface TransferRequest { to: User; from: User; token: TokenIdentifier; amount: Balance; memo: Memo; notify: boolean; subaccount?: SubAccount; fee: bigint; } declare type TransferError = { Unauthorized: AccountIdentifier; } | { InsufficientBalance: null; } | { Rejected: null; } | { InvalidToken: TokenIdentifier; } | { CannotNotify: AccountIdentifier; } | { Other: string; }; declare type TransferResult = Result<Balance, TransferError>; export interface FungibleMetadata { fungible: TokenMetaData & { metadata?: Int8Array[]; }; } export interface NonFungibleMetadata { nonfungible: { metadata: Int8Array[]; }; } export declare type Metadata = FungibleMetadata | NonFungibleMetadata; export declare type MetadataResponse = Result<Metadata, CommonError>; export default interface _SERVICE { extensions: () => Promise<Extension[]>; balance: (arg_0: BalanceRequest) => Promise<BalanceResult>; details: (token: TokenIdentifier) => Promise<DetailsResult>; tokens: (account: AccountIdentifier) => Promise<TokensResult>; tokens_ext: (account: AccountIdentifier) => Promise<TokensExtResult>; transfer: (arg_0: TransferRequest) => Promise<TransferResult>; metadata: (token: TokenIdentifier) => Promise<MetadataResponse>; supply: (token: TokenIdentifier) => Promise<SupplyResponse>; } export declare const init: () => never[]; export {};