import { Asset } from "@digitalbits-blockchain/xdb-digitalbits-base"; import { Omit } from "utility-types"; import { Frontier } from "./frontier_api"; import { AccountRecordSigners as AccountRecordSignersType } from "./types/account"; import { AssetRecord as AssetRecordType } from "./types/assets"; import * as Effects from "./types/effects"; import { OfferRecord as OfferRecordType } from "./types/offer"; import { Trade } from "./types/trade"; export declare namespace ServerApi { export type OfferRecord = OfferRecordType; export type AccountRecordSigners = AccountRecordSignersType; export type AssetRecord = AssetRecordType; export interface CollectionPage { records: T[]; next: () => Promise>; prev: () => Promise>; } export interface CallFunctionTemplateOptions { cursor?: string | number; limit?: number; order?: "asc" | "desc"; } export type CallFunction = () => Promise; export type CallCollectionFunction = (options?: CallFunctionTemplateOptions) => Promise>; type BaseEffectRecordFromTypes = Effects.AccountCreated | Effects.AccountCredited | Effects.AccountDebited | Effects.AccountThresholdsUpdated | Effects.AccountHomeDomainUpdated | Effects.AccountFlagsUpdated | Effects.DataCreated | Effects.DataRemoved | Effects.DataUpdated | Effects.SequenceBumped | Effects.SignerCreated | Effects.SignerRemoved | Effects.SignerUpdated | Effects.TrustlineCreated | Effects.TrustlineRemoved | Effects.TrustlineUpdated | Effects.TrustlineAuthorized | Effects.TrustlineDeauthorized | Effects.TrustlineAuthorizedToMaintainLiabilities | Effects.ClaimableBalanceCreated | Effects.ClaimableBalanceClaimed | Effects.ClaimableBalanceClaimantCreated | Effects.AccountSponsorshipCreated | Effects.AccountSponsorshipRemoved | Effects.AccountSponsorshipUpdated | Effects.TrustlineSponsorshipCreated | Effects.TrustlineSponsorshipUpdated | Effects.TrustlineSponsorshipRemoved | Effects.DateSponsorshipCreated | Effects.DateSponsorshipUpdated | Effects.DateSponsorshipRemoved | Effects.ClaimableBalanceSponsorshipCreated | Effects.ClaimableBalanceSponsorshipRemoved | Effects.ClaimableBalanceSponsorshipUpdated | Effects.SignerSponsorshipCreated | Effects.SignerSponsorshipUpdated | Effects.SignerSponsorshipRemoved | Trade; export type EffectRecord = BaseEffectRecordFromTypes & EffectRecordMethods; export interface ClaimableBalanceRecord extends Frontier.BaseResponse { id: string; paging_token: string; asset: string; amount: string; sponsor?: string; last_modified_ledger: number; claimants: Frontier.Claimant[]; } export interface AccountRecord extends Frontier.BaseResponse { id: string; paging_token: string; account_id: string; sequence: string; sequence_ledger?: number; sequence_time?: string; subentry_count: number; home_domain?: string; inflation_destination?: string; last_modified_ledger: number; last_modified_time: string; thresholds: Frontier.AccountThresholds; flags: Frontier.Flags; balances: Frontier.BalanceLine[]; signers: AccountRecordSigners[]; data: (options: { value: string; }) => Promise<{ value: string; }>; data_attr: { [key: string]: string; }; sponsor?: string; num_sponsoring: number; num_sponsored: number; effects: CallCollectionFunction; offers: CallCollectionFunction; operations: CallCollectionFunction; payments: CallCollectionFunction; trades: CallCollectionFunction; } export interface LiquidityPoolRecord extends Frontier.BaseResponse { id: string; paging_token: string; fee_bp: number; type: Frontier.LiquidityPoolType; total_trustlines: string; total_shares: string; reserves: Frontier.Reserve[]; } export enum TradeType { all = "all", liquidityPools = "liquidity_pool", orderbook = "orderbook" } interface EffectRecordMethods { operation?: CallFunction; precedes?: CallFunction; succeeds?: CallFunction; } export interface LedgerRecord extends Frontier.BaseResponse { id: string; paging_token: string; hash: string; prev_hash: string; sequence: number; successful_transaction_count: number; failed_transaction_count: number; operation_count: number; tx_set_operation_count: number | null; closed_at: string; total_coins: string; fee_pool: string; max_tx_set_size: number; protocol_version: number; header_xdr: string; base_fee_in_nibbs: number; base_reserve_in_nibbs: number; transaction_count: number; base_fee: number; base_reserve: string; effects: CallCollectionFunction; operations: CallCollectionFunction; self: CallFunction; transactions: CallCollectionFunction; } import OperationResponseType = Frontier.OperationResponseType; import OperationResponseTypeI = Frontier.OperationResponseTypeI; export interface BaseOperationRecord extends Frontier.BaseOperationResponse { self: CallFunction; succeeds: CallFunction; precedes: CallFunction; effects: CallCollectionFunction; transaction: CallFunction; } export interface CreateAccountOperationRecord extends BaseOperationRecord, Frontier.CreateAccountOperationResponse { } export interface PaymentOperationRecord extends BaseOperationRecord, Frontier.PaymentOperationResponse { sender: CallFunction; receiver: CallFunction; } export interface PathPaymentOperationRecord extends BaseOperationRecord, Frontier.PathPaymentOperationResponse { } export interface PathPaymentStrictSendOperationRecord extends BaseOperationRecord, Frontier.PathPaymentStrictSendOperationResponse { } export interface ManageOfferOperationRecord extends BaseOperationRecord, Frontier.ManageOfferOperationResponse { } export interface PassiveOfferOperationRecord extends BaseOperationRecord, Frontier.PassiveOfferOperationResponse { } export interface SetOptionsOperationRecord extends BaseOperationRecord, Frontier.SetOptionsOperationResponse { } export interface ChangeTrustOperationRecord extends BaseOperationRecord, Frontier.ChangeTrustOperationResponse { } export interface AllowTrustOperationRecord extends BaseOperationRecord, Frontier.AllowTrustOperationResponse { } export interface AccountMergeOperationRecord extends BaseOperationRecord, Frontier.AccountMergeOperationResponse { } export interface InflationOperationRecord extends BaseOperationRecord, Frontier.InflationOperationResponse { } export interface ManageDataOperationRecord extends BaseOperationRecord, Frontier.ManageDataOperationResponse { } export interface BumpSequenceOperationRecord extends BaseOperationRecord, Frontier.BumpSequenceOperationResponse { } export interface CreateClaimableBalanceOperationRecord extends BaseOperationRecord, Frontier.CreateClaimableBalanceOperationResponse { } export interface ClaimClaimableBalanceOperationRecord extends BaseOperationRecord, Frontier.ClaimClaimableBalanceOperationResponse { } export interface BeginSponsoringFutureReservesOperationRecord extends BaseOperationRecord, Frontier.BeginSponsoringFutureReservesOperationResponse { } export interface EndSponsoringFutureReservesOperationRecord extends BaseOperationRecord, Frontier.EndSponsoringFutureReservesOperationResponse { } export interface RevokeSponsorshipOperationRecord extends BaseOperationRecord, Frontier.RevokeSponsorshipOperationResponse { } export type OperationRecord = CreateAccountOperationRecord | PaymentOperationRecord | PathPaymentOperationRecord | ManageOfferOperationRecord | PassiveOfferOperationRecord | SetOptionsOperationRecord | ChangeTrustOperationRecord | AllowTrustOperationRecord | AccountMergeOperationRecord | InflationOperationRecord | ManageDataOperationRecord | BumpSequenceOperationRecord | PathPaymentStrictSendOperationRecord | CreateClaimableBalanceOperationRecord | ClaimClaimableBalanceOperationRecord | BeginSponsoringFutureReservesOperationRecord | EndSponsoringFutureReservesOperationRecord | RevokeSponsorshipOperationRecord; export namespace TradeRecord { interface Base extends Frontier.BaseResponse { id: string; paging_token: string; ledger_close_time: string; trade_type: TradeType; base_account?: string; base_amount: string; base_asset_type: string; base_asset_code?: string; base_asset_issuer?: string; counter_account?: string; counter_amount: string; counter_asset_type: string; counter_asset_code?: string; counter_asset_issuer?: string; base_is_seller: boolean; price?: { n: string; d: string; }; operation: CallFunction; } export interface Orderbook extends Base { trade_type: TradeType.orderbook; base_offer_id: string; base_account: string; counter_offer_id: string; counter_account: string; base: CallFunction; counter: CallFunction; } export interface LiquidityPool extends Base { trade_type: TradeType.liquidityPools; base_liquidity_pool_id?: string; counter_liquidity_pool_id?: string; liquidity_pool_fee_bp: number; base: CallFunction; counter: CallFunction; } export {}; } export type TradeRecord = TradeRecord.Orderbook | TradeRecord.LiquidityPool; export interface TransactionRecord extends Omit { ledger_attr: Frontier.TransactionResponse["ledger"]; account: CallFunction; effects: CallCollectionFunction; ledger: CallFunction; operations: CallCollectionFunction; precedes: CallFunction; self: CallFunction; succeeds: CallFunction; } export interface OrderbookRecord extends Frontier.BaseResponse { bids: Array<{ price_r: { d: number; n: number; }; price: string; amount: string; }>; asks: Array<{ price_r: { d: number; n: number; }; price: string; amount: string; }>; base: Asset; counter: Asset; } export interface PaymentPathRecord extends Frontier.BaseResponse { path: Array<{ asset_code: string; asset_issuer: string; asset_type: string; }>; source_amount: string; source_asset_type: string; source_asset_code: string; source_asset_issuer: string; destination_amount: string; destination_asset_type: string; destination_asset_code: string; destination_asset_issuer: string; } export {}; }