1- import { Asset , AssetType } from "stellar-base" ;
1+ import { Asset } from "stellar-base" ;
22import { Omit } from "utility-types" ;
33import { Horizon } from "./horizon_api" ;
44
5+ // more types
6+ import { AccountRecordSigners as AccountRecordSignersType } from "./types/account" ;
7+ import { AssetRecord as AssetRecordType } from "./types/assets" ;
8+ import * as Effects from "./types/effects" ;
9+ import { OfferRecord as OfferRecordType } from "./types/offer" ;
10+ import { Trade } from "./types/trade" ;
11+
512/* tslint:disable-next-line: no-namespace */
613export namespace ServerApi {
14+ export type OfferRecord = OfferRecordType ;
15+ export type AccountRecordSigners = AccountRecordSignersType ;
16+ export type AssetRecord = AssetRecordType ;
717 export interface CollectionPage <
818 T extends Horizon . BaseResponse = Horizon . BaseResponse
919 > {
@@ -25,10 +35,55 @@ export namespace ServerApi {
2535 T extends Horizon . BaseResponse = Horizon . BaseResponse
2636 > = ( options ?: CallFunctionTemplateOptions ) => Promise < CollectionPage < T > > ;
2737
28- export interface AccountRecordSigners {
29- key : string ;
30- weight : number ;
31- type : string ;
38+ type BaseEffectRecordFromTypes =
39+ | Effects . AccountCreated
40+ | Effects . AccountCredited
41+ | Effects . AccountDebited
42+ | Effects . AccountThresholdsUpdated
43+ | Effects . AccountHomeDomainUpdated
44+ | Effects . AccountFlagsUpdated
45+ | Effects . DataCreated
46+ | Effects . DataRemoved
47+ | Effects . DataUpdated
48+ | Effects . SequenceBumped
49+ | Effects . SignerCreated
50+ | Effects . SignerRemoved
51+ | Effects . SignerUpdated
52+ | Effects . TrustlineCreated
53+ | Effects . TrustlineRemoved
54+ | Effects . TrustlineUpdated
55+ | Effects . TrustlineAuthorized
56+ | Effects . TrustlineDeauthorized
57+ | Effects . TrustlineAuthorizedToMaintainLiabilities
58+ | Effects . ClaimableBalanceCreated
59+ | Effects . ClaimableBalanceClaimed
60+ | Effects . ClaimableBalanceClaimantCreated
61+ | Effects . AccountSponsorshipCreated
62+ | Effects . AccountSponsorshipRemoved
63+ | Effects . AccountSponsorshipUpdated
64+ | Effects . TrustlineSponsorshipCreated
65+ | Effects . TrustlineSponsorshipUpdated
66+ | Effects . TrustlineSponsorshipRemoved
67+ | Effects . DateSponsorshipCreated
68+ | Effects . DateSponsorshipUpdated
69+ | Effects . DateSponsorshipRemoved
70+ | Effects . ClaimableBalanceSponsorshipCreated
71+ | Effects . ClaimableBalanceSponsorshipRemoved
72+ | Effects . ClaimableBalanceSponsorshipUpdated
73+ | Effects . SignerSponsorshipCreated
74+ | Effects . SignerSponsorshipUpdated
75+ | Effects . SignerSponsorshipRemoved
76+ | Trade ;
77+
78+ export type EffectRecord = BaseEffectRecordFromTypes & EffectRecordMethods ;
79+ export interface ClaimableBalanceRecord extends Horizon . BaseResponse {
80+ id : string ;
81+ paging_token : string ;
82+ asset : string ;
83+ amount : string ;
84+ sponsor ?: string ;
85+ last_modified_ledger : number ;
86+ claimants : Horizon . Claimant [ ] ;
3287 }
3388 export interface AccountRecord extends Horizon . BaseResponse {
3489 id : string ;
@@ -56,110 +111,11 @@ export namespace ServerApi {
56111 payments : CallCollectionFunction < PaymentOperationRecord > ;
57112 trades : CallCollectionFunction < TradeRecord > ;
58113 }
59-
60- export interface ClaimableBalanceRecord extends Horizon . BaseResponse {
61- id : string ;
62- paging_token : string ;
63- asset : string ;
64- amount : string ;
65- sponsor ?: string ;
66- last_modified_ledger : number ;
67- claimants : Horizon . Claimant [ ] ;
68- }
69-
70- export interface EffectRecord extends Horizon . BaseResponse {
71- account : string ;
72- paging_token : string ;
73- type_i : string ;
74- type : string ;
75- created_at : string ;
76- id : string ;
77-
78- // account_debited / credited / trustline_created
79- amount ?: any ;
80- asset_type ?: string ;
81- asset_code ?: string ;
82- asset_issuer ?: string ;
83-
84- // trustline_created / removed
85- limit ?: string ;
86-
87- // signer_created
88- public_key ?: string ;
89-
90- // trade
91- offer_id ?: number | string ;
92- bought_amount ?: string ;
93- bought_asset_type ?: string ;
94- bought_asset_code ?: string ;
95- bought_asset_issuer ?: string ;
96- sold_amount ?: string ;
97- sold_asset_type ?: string ;
98- sold_asset_code ?: string ;
99- sold_asset_issuer ?: string ;
100-
101- // account_created
102- starting_balance ?: string ;
103-
104- // These were retrieved from the go repo, not through direct observation
105- // so they could be wrong!
106-
107- // account thresholds updated
108- low_threshold ?: number ;
109- med_threshold ?: number ;
110- high_threshold ?: number ;
111-
112- // home domain updated
113- home_domain ?: string ;
114-
115- // account flags updated
116- auth_required_flag ?: boolean ;
117- auth_revokable_flag ?: boolean ;
118-
119- // seq bumped
120- new_seq ?: number | string ;
121-
122- // signer created / removed / updated
123- weight ?: number ;
124- key ?: string ;
125-
126- // trustline authorized / deauthorized
127- trustor ?: string ;
128-
129- // claimable_balance_created
130- // claimable_balance_claimant_created
131- // claimable_balance_claimed
132- balance_id ?: string ;
133- asset ?: string ;
134- predicate ?: Horizon . Predicate ;
135-
136- // account_sponsorship_created
137- // trustline_sponsorship_created
138- // claimable_balance_sponsorship_created
139- // signer_sponsorship_created
140- // data_sponsorship_created
141- sponsor ?: string ;
142- signer ?: string ;
143- data_name ?: string ;
144-
145- // account_sponsorship_updated
146- // account_sponsorship_removed
147- // trustline_sponsorship_updated
148- // trustline_sponsorship_removed
149- // claimable_balance_sponsorship_updated
150- // claimable_balance_sponsorship_removed
151- // signer_sponsorship_updated
152- // signer_sponsorship_removed
153- // data_sponsorship_updated
154- // data_sponsorship_removed
155- new_sponsor ?: string ;
156- former_sponsor ?: string ;
157-
114+ interface EffectRecordMethods {
158115 operation ?: CallFunction < OperationRecord > ;
159116 precedes ?: CallFunction < EffectRecord > ;
160117 succeeds ?: CallFunction < EffectRecord > ;
161118 }
162-
163119 export interface LedgerRecord extends Horizon . BaseResponse {
164120 id : string ;
165121 paging_token : string ;
@@ -186,26 +142,6 @@ export namespace ServerApi {
186142 transactions : CallCollectionFunction < TransactionRecord > ;
187143 }
188144
189- export interface OfferAsset {
190- asset_type : AssetType ;
191- asset_code ?: string ;
192- asset_issuer ?: string ;
193- }
194-
195- export interface OfferRecord extends Horizon . BaseResponse {
196- id : number | string ;
197- paging_token : string ;
198- seller : string ;
199- selling : OfferAsset ;
200- buying : OfferAsset ;
201- amount : string ;
202- price_r : Horizon . PriceRShorthand ;
203- price : string ;
204- last_modified_ledger : number ;
205- last_modified_time : string ;
206- sponsor ?: string ;
207- }
208-
209145 import OperationResponseType = Horizon . OperationResponseType ;
210146 import OperationResponseTypeI = Horizon . OperationResponseTypeI ;
211147 export interface BaseOperationRecord <
@@ -218,7 +154,6 @@ export namespace ServerApi {
218154 effects : CallCollectionFunction < EffectRecord > ;
219155 transaction : CallFunction < TransactionRecord > ;
220156 }
221-
222157 export interface CreateAccountOperationRecord
223158 extends BaseOperationRecord <
224159 OperationResponseType . createAccount ,
@@ -350,7 +285,6 @@ export namespace ServerApi {
350285 | BeginSponsoringFutureReservesOperationRecord
351286 | EndSponsoringFutureReservesOperationRecord
352287 | RevokeSponsorshipOperationRecord ;
353-
354288 export interface TradeRecord extends Horizon . BaseResponse {
355289 id : string ;
356290 paging_token : string ;
@@ -374,7 +308,6 @@ export namespace ServerApi {
374308 counter : CallFunction < AccountRecord > ;
375309 operation : CallFunction < OperationRecord > ;
376310 }
377-
378311 export interface TransactionRecord
379312 extends Omit < Horizon . TransactionResponse , "ledger" > {
380313 ledger_attr : Horizon . TransactionResponse [ "ledger" ] ;
@@ -387,21 +320,6 @@ export namespace ServerApi {
387320 self : CallFunction < TransactionRecord > ;
388321 succeeds : CallFunction < TransactionRecord > ;
389322 }
390-
391- export interface AssetRecord extends Horizon . BaseResponse {
392- asset_type : AssetType . credit4 | AssetType . credit12 ;
393- asset_code : string ;
394- asset_issuer : string ;
395- paging_token : string ;
396- accounts : Horizon . AssetAccounts ;
397- num_claimable_balances : number ;
398- balances : Horizon . AssetBalances ;
399- claimable_balances_amount : string ;
400- amount : string ;
401- num_accounts : number ;
402- flags : Horizon . Flags ;
403- }
404-
405323 export interface OrderbookRecord extends Horizon . BaseResponse {
406324 bids : Array < {
407325 price_r : {
@@ -422,7 +340,6 @@ export namespace ServerApi {
422340 base : Asset ;
423341 counter : Asset ;
424342 }
425-
426343 export interface PaymentPathRecord extends Horizon . BaseResponse {
427344 path : Array < {
428345 asset_code : string ;
0 commit comments