UNPKG

@bajetech/astrax-api

Version:

Utility functions to interact with AstraX web extension

115 lines (114 loc) 2.94 kB
import BigNumber from "bignumber.js"; import { AssetType, Frontier } from "xdb-digitalbits-sdk"; import { SERVICE_TYPES, EXTERNAL_SERVICE_TYPES } from "../constants/services"; import { APPLICATION_STATE } from "../constants/applicationState"; import { NetworkDetails } from "../helpers/digitalbits"; interface Issuer { key: string; name?: string; url?: string; hostName?: string; } interface NativeToken { type: AssetType; code: string; } interface AssetToken { type: AssetType; code: string; issuer: Issuer; anchorAsset?: string; numAccounts?: BigNumber; amount?: BigNumber; bidCount?: BigNumber; askCount?: BigNumber; spread?: BigNumber; } declare type Token = NativeToken | AssetToken; interface Balance { token: Token; available: BigNumber; total: BigNumber; buyingLiabilities: BigNumber; sellingLiabilities: BigNumber; } interface AssetBalance extends Balance { token: AssetToken; sponsor?: string; } interface NativeBalance extends Balance { token: NativeToken; minimumBalance: BigNumber; } interface BalanceMap { [key: string]: AssetBalance | NativeBalance; native: NativeBalance; } export interface Response { error: string; messagedId: number; applicationState: APPLICATION_STATE; publicKey: string; privateKey: string; hasPrivateKey: boolean; mnemonicPhrase: string; isCorrectPhrase: boolean; confirmedPassword: boolean; password: string; mnemonicPhraseToConfirm: string; recoverMnemonic: string; transaction: { sign: (sourceKeys: {}) => void; }; signedTransaction: string; source: string; type: SERVICE_TYPES; url: string; isDataSharingAllowed: boolean; isTestnet: boolean; isMemoValidationEnabled: boolean; isSafetyValidationEnabled: boolean; networkDetails: NetworkDetails; allAccounts: Array<Account>; accountName: string; assetCode: string; iconUrl: string; network: string; } export interface ExternalRequest { transactionXdr: string; network: string; type: EXTERNAL_SERVICE_TYPES; } export interface Account { publicKey: string; name: string; imported: boolean; } export interface Settings { isDataSharingAllowed: boolean; networkDetails: NetworkDetails; isMemoValidationEnabled: boolean; isSafetyValidationEnabled: boolean; } export interface AssetIcons { [code: string]: string; } export declare type Balances = BalanceMap | null; export declare type FrontierOperation = Frontier.PaymentOperationResponse & { transaction_attr: Frontier.TransactionResponse; }; export interface AccountDetailsInterface { balances: Balances; isFunded: boolean | null; operations: Array<FrontierOperation> | []; } declare global { interface Window { astrax: boolean; astraxApi: { [key: string]: any; }; } } export {};