@stellar/stellar-sdk 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +1275 -0
  2. package/LICENSE +228 -0
  3. package/README.md +274 -0
  4. package/dist/stellar-sdk.js +56470 -0
  5. package/dist/stellar-sdk.min.js +2 -0
  6. package/dist/stellar-sdk.min.js.LICENSE.txt +71 -0
  7. package/lib/browser.d.ts +6 -0
  8. package/lib/browser.js +37 -0
  9. package/lib/config.d.ts +52 -0
  10. package/lib/config.js +49 -0
  11. package/lib/contract_spec.d.ts +130 -0
  12. package/lib/contract_spec.js +549 -0
  13. package/lib/errors.d.ts +59 -0
  14. package/lib/errors.js +105 -0
  15. package/lib/federation/api.d.ts +11 -0
  16. package/lib/federation/api.js +7 -0
  17. package/lib/federation/index.d.ts +2 -0
  18. package/lib/federation/index.js +24 -0
  19. package/lib/federation/server.d.ts +118 -0
  20. package/lib/federation/server.js +253 -0
  21. package/lib/friendbot/index.d.ts +5 -0
  22. package/lib/friendbot/index.js +7 -0
  23. package/lib/horizon/account_call_builder.d.ts +55 -0
  24. package/lib/horizon/account_call_builder.js +64 -0
  25. package/lib/horizon/account_response.d.ts +58 -0
  26. package/lib/horizon/account_response.js +50 -0
  27. package/lib/horizon/assets_call_builder.d.ts +27 -0
  28. package/lib/horizon/assets_call_builder.js +45 -0
  29. package/lib/horizon/call_builder.d.ts +128 -0
  30. package/lib/horizon/call_builder.js +360 -0
  31. package/lib/horizon/claimable_balances_call_builder.d.ts +49 -0
  32. package/lib/horizon/claimable_balances_call_builder.js +58 -0
  33. package/lib/horizon/effect_call_builder.d.ts +53 -0
  34. package/lib/horizon/effect_call_builder.js +58 -0
  35. package/lib/horizon/friendbot_builder.d.ts +5 -0
  36. package/lib/horizon/friendbot_builder.js +33 -0
  37. package/lib/horizon/horizon_api.d.ts +523 -0
  38. package/lib/horizon/horizon_api.js +96 -0
  39. package/lib/horizon/horizon_axios_client.d.ts +30 -0
  40. package/lib/horizon/horizon_axios_client.js +48 -0
  41. package/lib/horizon/index.d.ts +7 -0
  42. package/lib/horizon/index.js +78 -0
  43. package/lib/horizon/ledger_call_builder.d.ts +22 -0
  44. package/lib/horizon/ledger_call_builder.js +39 -0
  45. package/lib/horizon/liquidity_pool_call_builder.d.ts +38 -0
  46. package/lib/horizon/liquidity_pool_call_builder.js +61 -0
  47. package/lib/horizon/offer_call_builder.d.ts +64 -0
  48. package/lib/horizon/offer_call_builder.js +81 -0
  49. package/lib/horizon/operation_call_builder.d.ts +68 -0
  50. package/lib/horizon/operation_call_builder.js +71 -0
  51. package/lib/horizon/orderbook_call_builder.d.ts +16 -0
  52. package/lib/horizon/orderbook_call_builder.js +46 -0
  53. package/lib/horizon/path_call_builder.d.ts +31 -0
  54. package/lib/horizon/path_call_builder.js +42 -0
  55. package/lib/horizon/payment_call_builder.d.ts +36 -0
  56. package/lib/horizon/payment_call_builder.js +48 -0
  57. package/lib/horizon/server.d.ts +361 -0
  58. package/lib/horizon/server.js +507 -0
  59. package/lib/horizon/server_api.d.ts +279 -0
  60. package/lib/horizon/server_api.js +19 -0
  61. package/lib/horizon/strict_receive_path_call_builder.d.ts +34 -0
  62. package/lib/horizon/strict_receive_path_call_builder.js +51 -0
  63. package/lib/horizon/strict_send_path_call_builder.d.ts +34 -0
  64. package/lib/horizon/strict_send_path_call_builder.js +51 -0
  65. package/lib/horizon/trade_aggregation_call_builder.d.ts +48 -0
  66. package/lib/horizon/trade_aggregation_call_builder.js +82 -0
  67. package/lib/horizon/trades_call_builder.d.ts +50 -0
  68. package/lib/horizon/trades_call_builder.js +74 -0
  69. package/lib/horizon/transaction_call_builder.d.ts +58 -0
  70. package/lib/horizon/transaction_call_builder.js +66 -0
  71. package/lib/horizon/types/account.d.ts +5 -0
  72. package/lib/horizon/types/account.js +5 -0
  73. package/lib/horizon/types/assets.d.ts +19 -0
  74. package/lib/horizon/types/assets.js +5 -0
  75. package/lib/horizon/types/effects.d.ts +285 -0
  76. package/lib/horizon/types/effects.js +62 -0
  77. package/lib/horizon/types/offer.d.ts +20 -0
  78. package/lib/horizon/types/offer.js +5 -0
  79. package/lib/horizon/types/trade.d.ts +13 -0
  80. package/lib/horizon/types/trade.js +5 -0
  81. package/lib/index.d.ts +14 -0
  82. package/lib/index.js +79 -0
  83. package/lib/soroban/api.d.ts +247 -0
  84. package/lib/soroban/api.js +32 -0
  85. package/lib/soroban/axios.d.ts +3 -0
  86. package/lib/soroban/axios.js +16 -0
  87. package/lib/soroban/browser.d.ts +6 -0
  88. package/lib/soroban/browser.js +37 -0
  89. package/lib/soroban/index.d.ts +8 -0
  90. package/lib/soroban/index.js +72 -0
  91. package/lib/soroban/jsonrpc.d.ts +33 -0
  92. package/lib/soroban/jsonrpc.js +93 -0
  93. package/lib/soroban/parsers.d.ts +17 -0
  94. package/lib/soroban/parsers.js +111 -0
  95. package/lib/soroban/server.d.ts +427 -0
  96. package/lib/soroban/server.js +598 -0
  97. package/lib/soroban/transaction.d.ts +20 -0
  98. package/lib/soroban/transaction.js +55 -0
  99. package/lib/soroban/utils.d.ts +1 -0
  100. package/lib/soroban/utils.js +9 -0
  101. package/lib/stellartoml/index.d.ts +121 -0
  102. package/lib/stellartoml/index.js +78 -0
  103. package/lib/utils.d.ts +12 -0
  104. package/lib/utils.js +32 -0
  105. package/lib/webauth/errors.d.ts +4 -0
  106. package/lib/webauth/errors.js +37 -0
  107. package/lib/webauth/index.d.ts +2 -0
  108. package/lib/webauth/index.js +27 -0
  109. package/lib/webauth/utils.d.ts +294 -0
  110. package/lib/webauth/utils.js +332 -0
  111. package/package.json +153 -0
  112. package/types/dom-monkeypatch.d.ts +126 -0
@@ -0,0 +1,279 @@
1
+ import { Asset } from "@stellar/stellar-base";
2
+ import { Omit } from "utility-types";
3
+ import { HorizonApi } from "./horizon_api";
4
+ import { AccountRecordSigners as AccountRecordSignersType } from "./types/account";
5
+ import { AssetRecord as AssetRecordType } from "./types/assets";
6
+ import * as Effects from "./types/effects";
7
+ import { OfferRecord as OfferRecordType } from "./types/offer";
8
+ import { Trade } from "./types/trade";
9
+ export declare namespace ServerApi {
10
+ export type OfferRecord = OfferRecordType;
11
+ export type AccountRecordSigners = AccountRecordSignersType;
12
+ export type AssetRecord = AssetRecordType;
13
+ export interface CollectionPage<T extends HorizonApi.BaseResponse = HorizonApi.BaseResponse> {
14
+ records: T[];
15
+ next: () => Promise<CollectionPage<T>>;
16
+ prev: () => Promise<CollectionPage<T>>;
17
+ }
18
+ export interface CallFunctionTemplateOptions {
19
+ cursor?: string | number;
20
+ limit?: number;
21
+ order?: "asc" | "desc";
22
+ }
23
+ export type CallFunction<T extends HorizonApi.BaseResponse = HorizonApi.BaseResponse> = () => Promise<T>;
24
+ export type CallCollectionFunction<T extends HorizonApi.BaseResponse = HorizonApi.BaseResponse> = (options?: CallFunctionTemplateOptions) => Promise<CollectionPage<T>>;
25
+ 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 | Effects.LiquidityPoolDeposited | Effects.LiquidityPoolWithdrew | Effects.LiquidityPoolCreated | Effects.LiquidityPoolRemoved | Effects.LiquidityPoolRevoked | Effects.LiquidityPoolTrade | Effects.ContractCredited | Effects.ContractDebited | Trade;
26
+ export type EffectRecord = BaseEffectRecordFromTypes & EffectRecordMethods;
27
+ export interface ClaimableBalanceRecord extends HorizonApi.BaseResponse {
28
+ id: string;
29
+ paging_token: string;
30
+ asset: string;
31
+ amount: string;
32
+ sponsor?: string;
33
+ last_modified_ledger: number;
34
+ claimants: HorizonApi.Claimant[];
35
+ }
36
+ export interface AccountRecord extends HorizonApi.BaseResponse {
37
+ id: string;
38
+ paging_token: string;
39
+ account_id: string;
40
+ sequence: string;
41
+ sequence_ledger?: number;
42
+ sequence_time?: string;
43
+ subentry_count: number;
44
+ home_domain?: string;
45
+ inflation_destination?: string;
46
+ last_modified_ledger: number;
47
+ last_modified_time: string;
48
+ thresholds: HorizonApi.AccountThresholds;
49
+ flags: HorizonApi.Flags;
50
+ balances: HorizonApi.BalanceLine[];
51
+ signers: AccountRecordSigners[];
52
+ data: (options: {
53
+ value: string;
54
+ }) => Promise<{
55
+ value: string;
56
+ }>;
57
+ data_attr: {
58
+ [key: string]: string;
59
+ };
60
+ sponsor?: string;
61
+ num_sponsoring: number;
62
+ num_sponsored: number;
63
+ effects: CallCollectionFunction<EffectRecord>;
64
+ offers: CallCollectionFunction<OfferRecord>;
65
+ operations: CallCollectionFunction<OperationRecord>;
66
+ payments: CallCollectionFunction<PaymentOperationRecord>;
67
+ trades: CallCollectionFunction<TradeRecord>;
68
+ }
69
+ export interface LiquidityPoolRecord extends HorizonApi.BaseResponse {
70
+ id: string;
71
+ paging_token: string;
72
+ fee_bp: number;
73
+ type: HorizonApi.LiquidityPoolType;
74
+ total_trustlines: string;
75
+ total_shares: string;
76
+ reserves: HorizonApi.Reserve[];
77
+ }
78
+ export enum TradeType {
79
+ all = "all",
80
+ liquidityPools = "liquidity_pool",
81
+ orderbook = "orderbook"
82
+ }
83
+ interface EffectRecordMethods {
84
+ operation?: CallFunction<OperationRecord>;
85
+ precedes?: CallFunction<EffectRecord>;
86
+ succeeds?: CallFunction<EffectRecord>;
87
+ }
88
+ export interface LedgerRecord extends HorizonApi.BaseResponse {
89
+ id: string;
90
+ paging_token: string;
91
+ hash: string;
92
+ prev_hash: string;
93
+ sequence: number;
94
+ successful_transaction_count: number;
95
+ failed_transaction_count: number;
96
+ operation_count: number;
97
+ tx_set_operation_count: number | null;
98
+ closed_at: string;
99
+ total_coins: string;
100
+ fee_pool: string;
101
+ max_tx_set_size: number;
102
+ protocol_version: number;
103
+ header_xdr: string;
104
+ base_fee_in_stroops: number;
105
+ base_reserve_in_stroops: number;
106
+ /**
107
+ * @deprecated This will be removed in the next major version: the property
108
+ * no longer exists on the Horizon API
109
+ */
110
+ transaction_count: number;
111
+ /**
112
+ * @deprecated This will be removed in the next major version: the property
113
+ * no longer exists on the Horizon API
114
+ */
115
+ base_fee: number;
116
+ /**
117
+ * @deprecated This will be removed in the next major version: the property
118
+ * no longer exists on the Horizon API
119
+ */
120
+ base_reserve: string;
121
+ effects: CallCollectionFunction<EffectRecord>;
122
+ operations: CallCollectionFunction<OperationRecord>;
123
+ self: CallFunction<LedgerRecord>;
124
+ transactions: CallCollectionFunction<TransactionRecord>;
125
+ }
126
+ import OperationResponseType = HorizonApi.OperationResponseType;
127
+ import OperationResponseTypeI = HorizonApi.OperationResponseTypeI;
128
+ export interface BaseOperationRecord<T extends OperationResponseType = OperationResponseType, TI extends OperationResponseTypeI = OperationResponseTypeI> extends HorizonApi.BaseOperationResponse<T, TI> {
129
+ self: CallFunction<OperationRecord>;
130
+ succeeds: CallFunction<OperationRecord>;
131
+ precedes: CallFunction<OperationRecord>;
132
+ effects: CallCollectionFunction<EffectRecord>;
133
+ transaction: CallFunction<TransactionRecord>;
134
+ }
135
+ export interface CreateAccountOperationRecord extends BaseOperationRecord<OperationResponseType.createAccount, OperationResponseTypeI.createAccount>, HorizonApi.CreateAccountOperationResponse {
136
+ }
137
+ export interface PaymentOperationRecord extends BaseOperationRecord<OperationResponseType.payment, OperationResponseTypeI.payment>, HorizonApi.PaymentOperationResponse {
138
+ sender: CallFunction<AccountRecord>;
139
+ receiver: CallFunction<AccountRecord>;
140
+ }
141
+ export interface PathPaymentOperationRecord extends BaseOperationRecord<OperationResponseType.pathPayment, OperationResponseTypeI.pathPayment>, HorizonApi.PathPaymentOperationResponse {
142
+ }
143
+ export interface PathPaymentStrictSendOperationRecord extends BaseOperationRecord<OperationResponseType.pathPaymentStrictSend, OperationResponseTypeI.pathPaymentStrictSend>, HorizonApi.PathPaymentStrictSendOperationResponse {
144
+ }
145
+ export interface ManageOfferOperationRecord extends BaseOperationRecord<OperationResponseType.manageOffer, OperationResponseTypeI.manageOffer>, HorizonApi.ManageOfferOperationResponse {
146
+ }
147
+ export interface PassiveOfferOperationRecord extends BaseOperationRecord<OperationResponseType.createPassiveOffer, OperationResponseTypeI.createPassiveOffer>, HorizonApi.PassiveOfferOperationResponse {
148
+ }
149
+ export interface SetOptionsOperationRecord extends BaseOperationRecord<OperationResponseType.setOptions, OperationResponseTypeI.setOptions>, HorizonApi.SetOptionsOperationResponse {
150
+ }
151
+ export interface ChangeTrustOperationRecord extends BaseOperationRecord<OperationResponseType.changeTrust, OperationResponseTypeI.changeTrust>, HorizonApi.ChangeTrustOperationResponse {
152
+ }
153
+ export interface AllowTrustOperationRecord extends BaseOperationRecord<OperationResponseType.allowTrust, OperationResponseTypeI.allowTrust>, HorizonApi.AllowTrustOperationResponse {
154
+ }
155
+ export interface AccountMergeOperationRecord extends BaseOperationRecord<OperationResponseType.accountMerge, OperationResponseTypeI.accountMerge>, HorizonApi.AccountMergeOperationResponse {
156
+ }
157
+ export interface InflationOperationRecord extends BaseOperationRecord<OperationResponseType.inflation, OperationResponseTypeI.inflation>, HorizonApi.InflationOperationResponse {
158
+ }
159
+ export interface ManageDataOperationRecord extends BaseOperationRecord<OperationResponseType.manageData, OperationResponseTypeI.manageData>, HorizonApi.ManageDataOperationResponse {
160
+ }
161
+ export interface BumpSequenceOperationRecord extends BaseOperationRecord<OperationResponseType.bumpSequence, OperationResponseTypeI.bumpSequence>, HorizonApi.BumpSequenceOperationResponse {
162
+ }
163
+ export interface CreateClaimableBalanceOperationRecord extends BaseOperationRecord<OperationResponseType.createClaimableBalance, OperationResponseTypeI.createClaimableBalance>, HorizonApi.CreateClaimableBalanceOperationResponse {
164
+ }
165
+ export interface ClaimClaimableBalanceOperationRecord extends BaseOperationRecord<OperationResponseType.claimClaimableBalance, OperationResponseTypeI.claimClaimableBalance>, HorizonApi.ClaimClaimableBalanceOperationResponse {
166
+ }
167
+ export interface BeginSponsoringFutureReservesOperationRecord extends BaseOperationRecord<OperationResponseType.beginSponsoringFutureReserves, OperationResponseTypeI.beginSponsoringFutureReserves>, HorizonApi.BeginSponsoringFutureReservesOperationResponse {
168
+ }
169
+ export interface EndSponsoringFutureReservesOperationRecord extends BaseOperationRecord<OperationResponseType.endSponsoringFutureReserves, OperationResponseTypeI.endSponsoringFutureReserves>, HorizonApi.EndSponsoringFutureReservesOperationResponse {
170
+ }
171
+ export interface RevokeSponsorshipOperationRecord extends BaseOperationRecord<OperationResponseType.revokeSponsorship, OperationResponseTypeI.revokeSponsorship>, HorizonApi.RevokeSponsorshipOperationResponse {
172
+ }
173
+ export interface ClawbackOperationRecord extends BaseOperationRecord<OperationResponseType.clawback, OperationResponseTypeI.clawback>, HorizonApi.ClawbackOperationResponse {
174
+ }
175
+ export interface ClawbackClaimableBalanceOperationRecord extends BaseOperationRecord<OperationResponseType.clawbackClaimableBalance, OperationResponseTypeI.clawbackClaimableBalance>, HorizonApi.ClawbackClaimableBalanceOperationResponse {
176
+ }
177
+ export interface SetTrustLineFlagsOperationRecord extends BaseOperationRecord<OperationResponseType.setTrustLineFlags, OperationResponseTypeI.setTrustLineFlags>, HorizonApi.SetTrustLineFlagsOperationResponse {
178
+ }
179
+ export interface DepositLiquidityOperationRecord extends BaseOperationRecord<OperationResponseType.liquidityPoolDeposit, OperationResponseTypeI.liquidityPoolDeposit>, HorizonApi.DepositLiquidityOperationResponse {
180
+ }
181
+ export interface WithdrawLiquidityOperationRecord extends BaseOperationRecord<OperationResponseType.liquidityPoolWithdraw, OperationResponseTypeI.liquidityPoolWithdraw>, HorizonApi.WithdrawLiquidityOperationResponse {
182
+ }
183
+ export interface InvokeHostFunctionOperationRecord extends BaseOperationRecord<OperationResponseType.invokeHostFunction, OperationResponseTypeI.invokeHostFunction>, HorizonApi.InvokeHostFunctionOperationResponse {
184
+ }
185
+ export interface BumpFootprintExpirationOperationRecord extends BaseOperationRecord<OperationResponseType.bumpFootprintExpiration, OperationResponseTypeI.bumpFootprintExpiration>, HorizonApi.BumpFootprintExpirationOperationResponse {
186
+ }
187
+ export interface RestoreFootprintOperationRecord extends BaseOperationRecord<OperationResponseType.restoreFootprint, OperationResponseTypeI.restoreFootprint>, HorizonApi.RestoreFootprintOperationResponse {
188
+ }
189
+ export type OperationRecord = CreateAccountOperationRecord | PaymentOperationRecord | PathPaymentOperationRecord | ManageOfferOperationRecord | PassiveOfferOperationRecord | SetOptionsOperationRecord | ChangeTrustOperationRecord | AllowTrustOperationRecord | AccountMergeOperationRecord | InflationOperationRecord | ManageDataOperationRecord | BumpSequenceOperationRecord | PathPaymentStrictSendOperationRecord | CreateClaimableBalanceOperationRecord | ClaimClaimableBalanceOperationRecord | BeginSponsoringFutureReservesOperationRecord | EndSponsoringFutureReservesOperationRecord | RevokeSponsorshipOperationRecord | ClawbackClaimableBalanceOperationRecord | ClawbackOperationRecord | SetTrustLineFlagsOperationRecord | DepositLiquidityOperationRecord | WithdrawLiquidityOperationRecord | InvokeHostFunctionOperationRecord | BumpFootprintExpirationOperationRecord | RestoreFootprintOperationRecord;
190
+ export namespace TradeRecord {
191
+ interface Base extends HorizonApi.BaseResponse {
192
+ id: string;
193
+ paging_token: string;
194
+ ledger_close_time: string;
195
+ trade_type: TradeType;
196
+ base_account?: string;
197
+ base_amount: string;
198
+ base_asset_type: string;
199
+ base_asset_code?: string;
200
+ base_asset_issuer?: string;
201
+ counter_account?: string;
202
+ counter_amount: string;
203
+ counter_asset_type: string;
204
+ counter_asset_code?: string;
205
+ counter_asset_issuer?: string;
206
+ base_is_seller: boolean;
207
+ price?: {
208
+ n: string;
209
+ d: string;
210
+ };
211
+ operation: CallFunction<OperationRecord>;
212
+ }
213
+ export interface Orderbook extends Base {
214
+ trade_type: TradeType.orderbook;
215
+ base_offer_id: string;
216
+ base_account: string;
217
+ counter_offer_id: string;
218
+ counter_account: string;
219
+ base: CallFunction<AccountRecord>;
220
+ counter: CallFunction<AccountRecord>;
221
+ }
222
+ export interface LiquidityPool extends Base {
223
+ trade_type: TradeType.liquidityPools;
224
+ base_liquidity_pool_id?: string;
225
+ counter_liquidity_pool_id?: string;
226
+ liquidity_pool_fee_bp: number;
227
+ base: CallFunction<AccountRecord | LiquidityPoolRecord>;
228
+ counter: CallFunction<AccountRecord | LiquidityPoolRecord>;
229
+ }
230
+ export {};
231
+ }
232
+ export type TradeRecord = TradeRecord.Orderbook | TradeRecord.LiquidityPool;
233
+ export interface TransactionRecord extends Omit<HorizonApi.TransactionResponse, "ledger"> {
234
+ ledger_attr: HorizonApi.TransactionResponse["ledger"];
235
+ account: CallFunction<AccountRecord>;
236
+ effects: CallCollectionFunction<EffectRecord>;
237
+ ledger: CallFunction<LedgerRecord>;
238
+ operations: CallCollectionFunction<OperationRecord>;
239
+ precedes: CallFunction<TransactionRecord>;
240
+ self: CallFunction<TransactionRecord>;
241
+ succeeds: CallFunction<TransactionRecord>;
242
+ }
243
+ export interface OrderbookRecord extends HorizonApi.BaseResponse {
244
+ bids: Array<{
245
+ price_r: {
246
+ d: number;
247
+ n: number;
248
+ };
249
+ price: string;
250
+ amount: string;
251
+ }>;
252
+ asks: Array<{
253
+ price_r: {
254
+ d: number;
255
+ n: number;
256
+ };
257
+ price: string;
258
+ amount: string;
259
+ }>;
260
+ base: Asset;
261
+ counter: Asset;
262
+ }
263
+ export interface PaymentPathRecord extends HorizonApi.BaseResponse {
264
+ path: Array<{
265
+ asset_code: string;
266
+ asset_issuer: string;
267
+ asset_type: string;
268
+ }>;
269
+ source_amount: string;
270
+ source_asset_type: string;
271
+ source_asset_code: string;
272
+ source_asset_issuer: string;
273
+ destination_amount: string;
274
+ destination_asset_type: string;
275
+ destination_asset_code: string;
276
+ destination_asset_issuer: string;
277
+ }
278
+ export {};
279
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ServerApi = void 0;
7
+ var _horizon_api = require("./horizon_api");
8
+ var ServerApi;
9
+ (function (_ServerApi) {
10
+ var TradeType = function (TradeType) {
11
+ TradeType["all"] = "all";
12
+ TradeType["liquidityPools"] = "liquidity_pool";
13
+ TradeType["orderbook"] = "orderbook";
14
+ return TradeType;
15
+ }({});
16
+ _ServerApi.TradeType = TradeType;
17
+ var OperationResponseType = _horizon_api.HorizonApi.OperationResponseType;
18
+ var OperationResponseTypeI = _horizon_api.HorizonApi.OperationResponseTypeI;
19
+ })(ServerApi || (exports.ServerApi = ServerApi = {}));
@@ -0,0 +1,34 @@
1
+ /// <reference types="urijs" />
2
+ import { Asset } from "@stellar/stellar-base";
3
+ import { CallBuilder } from "./call_builder";
4
+ import { ServerApi } from "./server_api";
5
+ /**
6
+ * The Stellar Network allows payments to be made across assets through path
7
+ * payments. A strict receive path payment specifies a series of assets to route
8
+ * a payment through, from source asset (the asset debited from the payer) to
9
+ * destination asset (the asset credited to the payee).
10
+ *
11
+ * A path search is specified using:
12
+ *
13
+ * * The source address or source assets.
14
+ * * The asset and amount that the destination account should receive
15
+ *
16
+ * As part of the search, horizon will load a list of assets available to the
17
+ * source address and will find any payment paths from those source assets to
18
+ * the desired destination asset. The search's amount parameter will be used to
19
+ * determine if there a given path can satisfy a payment of the desired amount.
20
+ *
21
+ * If a list of assets is passed as the source, horizon will find any payment
22
+ * paths from those source assets to the desired destination asset.
23
+ *
24
+ * Do not create this object directly, use {@link Server#strictReceivePaths}.
25
+ * @see [Find Payment Paths](https://developers.stellar.org/api/aggregations/paths/)
26
+ * @extends CallBuilder
27
+ * @param {string} serverUrl Horizon server URL.
28
+ * @param {string|Asset[]} source The sender's account ID or a list of Assets. Any returned path must use a source that the sender can hold.
29
+ * @param {Asset} destinationAsset The destination asset.
30
+ * @param {string} destinationAmount The amount, denominated in the destination asset, that any returned path should be able to satisfy.
31
+ */
32
+ export declare class StrictReceivePathCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.PaymentPathRecord>> {
33
+ constructor(serverUrl: URI, source: string | Asset[], destinationAsset: Asset, destinationAmount: string);
34
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.StrictReceivePathCallBuilder = void 0;
8
+ var _call_builder = require("./call_builder");
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ var StrictReceivePathCallBuilder = exports.StrictReceivePathCallBuilder = function (_CallBuilder) {
22
+ _inherits(StrictReceivePathCallBuilder, _CallBuilder);
23
+ var _super = _createSuper(StrictReceivePathCallBuilder);
24
+ function StrictReceivePathCallBuilder(serverUrl, source, destinationAsset, destinationAmount) {
25
+ var _this;
26
+ _classCallCheck(this, StrictReceivePathCallBuilder);
27
+ _this = _super.call(this, serverUrl);
28
+ _this.url.segment("paths/strict-receive");
29
+ if (typeof source === "string") {
30
+ _this.url.setQuery("source_account", source);
31
+ } else {
32
+ var assets = source.map(function (asset) {
33
+ if (asset.isNative()) {
34
+ return "native";
35
+ }
36
+ return "".concat(asset.getCode(), ":").concat(asset.getIssuer());
37
+ }).join(",");
38
+ _this.url.setQuery("source_assets", assets);
39
+ }
40
+ _this.url.setQuery("destination_amount", destinationAmount);
41
+ if (!destinationAsset.isNative()) {
42
+ _this.url.setQuery("destination_asset_type", destinationAsset.getAssetType());
43
+ _this.url.setQuery("destination_asset_code", destinationAsset.getCode());
44
+ _this.url.setQuery("destination_asset_issuer", destinationAsset.getIssuer());
45
+ } else {
46
+ _this.url.setQuery("destination_asset_type", "native");
47
+ }
48
+ return _this;
49
+ }
50
+ return _createClass(StrictReceivePathCallBuilder);
51
+ }(_call_builder.CallBuilder);
@@ -0,0 +1,34 @@
1
+ /// <reference types="urijs" />
2
+ import { Asset } from "@stellar/stellar-base";
3
+ import { CallBuilder } from "./call_builder";
4
+ import { ServerApi } from "./server_api";
5
+ /**
6
+ * The Stellar Network allows payments to be made across assets through path
7
+ * payments. A strict send path payment specifies a series of assets to route a
8
+ * payment through, from source asset (the asset debited from the payer) to
9
+ * destination asset (the asset credited to the payee).
10
+ *
11
+ * A strict send path search is specified using:
12
+ *
13
+ * The source asset
14
+ * The source amount
15
+ * The destination assets or destination account.
16
+ *
17
+ * As part of the search, horizon will load a list of assets available to the
18
+ * source address and will find any payment paths from those source assets to
19
+ * the desired destination asset. The search's source_amount parameter will be
20
+ * used to determine if there a given path can satisfy a payment of the desired
21
+ * amount.
22
+ *
23
+ * Do not create this object directly, use {@link Server#strictSendPaths}.
24
+ * @see [Find Payment Paths](https://developers.stellar.org/api/aggregations/paths/)
25
+ * @extends CallBuilder
26
+ * @param {string} serverUrl Horizon server URL.
27
+ * @param {Asset} sourceAsset The asset to be sent.
28
+ * @param {string} sourceAmount The amount, denominated in the source asset, that any returned path should be able to satisfy.
29
+ * @param {string|Asset[]} destination The destination account or the destination assets.
30
+ *
31
+ */
32
+ export declare class StrictSendPathCallBuilder extends CallBuilder<ServerApi.CollectionPage<ServerApi.PaymentPathRecord>> {
33
+ constructor(serverUrl: URI, sourceAsset: Asset, sourceAmount: string, destination: string | Asset[]);
34
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.StrictSendPathCallBuilder = void 0;
8
+ var _call_builder = require("./call_builder");
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ var StrictSendPathCallBuilder = exports.StrictSendPathCallBuilder = function (_CallBuilder) {
22
+ _inherits(StrictSendPathCallBuilder, _CallBuilder);
23
+ var _super = _createSuper(StrictSendPathCallBuilder);
24
+ function StrictSendPathCallBuilder(serverUrl, sourceAsset, sourceAmount, destination) {
25
+ var _this;
26
+ _classCallCheck(this, StrictSendPathCallBuilder);
27
+ _this = _super.call(this, serverUrl);
28
+ _this.url.segment("paths/strict-send");
29
+ if (sourceAsset.isNative()) {
30
+ _this.url.setQuery("source_asset_type", "native");
31
+ } else {
32
+ _this.url.setQuery("source_asset_type", sourceAsset.getAssetType());
33
+ _this.url.setQuery("source_asset_code", sourceAsset.getCode());
34
+ _this.url.setQuery("source_asset_issuer", sourceAsset.getIssuer());
35
+ }
36
+ _this.url.setQuery("source_amount", sourceAmount);
37
+ if (typeof destination === "string") {
38
+ _this.url.setQuery("destination_account", destination);
39
+ } else {
40
+ var assets = destination.map(function (asset) {
41
+ if (asset.isNative()) {
42
+ return "native";
43
+ }
44
+ return "".concat(asset.getCode(), ":").concat(asset.getIssuer());
45
+ }).join(",");
46
+ _this.url.setQuery("destination_assets", assets);
47
+ }
48
+ return _this;
49
+ }
50
+ return _createClass(StrictSendPathCallBuilder);
51
+ }(_call_builder.CallBuilder);
@@ -0,0 +1,48 @@
1
+ /// <reference types="urijs" />
2
+ import { Asset } from "@stellar/stellar-base";
3
+ import { CallBuilder } from "./call_builder";
4
+ import { HorizonApi } from "./horizon_api";
5
+ import { ServerApi } from "./server_api";
6
+ /**
7
+ * Trade Aggregations facilitate efficient gathering of historical trade data.
8
+ * Do not create this object directly, use {@link Server#tradeAggregation}.
9
+ *
10
+ * @class TradeAggregationCallBuilder
11
+ * @extends CallBuilder
12
+ * @constructor
13
+ * @param {string} serverUrl serverUrl Horizon server URL.
14
+ * @param {Asset} base base asset
15
+ * @param {Asset} counter counter asset
16
+ * @param {long} start_time lower time boundary represented as millis since epoch
17
+ * @param {long} end_time upper time boundary represented as millis since epoch
18
+ * @param {long} resolution segment duration as millis since epoch. *Supported values are 1 minute (60000), 5 minutes (300000), 15 minutes (900000), 1 hour (3600000), 1 day (86400000) and 1 week (604800000).
19
+ * @param {long} offset segments can be offset using this parameter. Expressed in milliseconds. *Can only be used if the resolution is greater than 1 hour. Value must be in whole hours, less than the provided resolution, and less than 24 hours.
20
+ */
21
+ export declare class TradeAggregationCallBuilder extends CallBuilder<ServerApi.CollectionPage<TradeAggregationRecord>> {
22
+ constructor(serverUrl: URI, base: Asset, counter: Asset, start_time: number, end_time: number, resolution: number, offset: number);
23
+ /**
24
+ * @private
25
+ * @param {long} resolution Trade data resolution in milliseconds
26
+ * @returns {boolean} true if the resolution is allowed
27
+ */
28
+ private isValidResolution;
29
+ /**
30
+ * @private
31
+ * @param {long} offset Time offset in milliseconds
32
+ * @param {long} resolution Trade data resolution in milliseconds
33
+ * @returns {boolean} true if the offset is valid
34
+ */
35
+ private isValidOffset;
36
+ }
37
+ interface TradeAggregationRecord extends HorizonApi.BaseResponse {
38
+ timestamp: number | string;
39
+ trade_count: number | string;
40
+ base_volume: string;
41
+ counter_volume: string;
42
+ avg: string;
43
+ high: string;
44
+ low: string;
45
+ open: string;
46
+ close: string;
47
+ }
48
+ export {};
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.TradeAggregationCallBuilder = void 0;
8
+ var _call_builder = require("./call_builder");
9
+ var _errors = require("../errors");
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
12
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
16
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
19
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
21
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
+ var allowedResolutions = [60000, 300000, 900000, 3600000, 86400000, 604800000];
23
+ var TradeAggregationCallBuilder = exports.TradeAggregationCallBuilder = function (_CallBuilder) {
24
+ _inherits(TradeAggregationCallBuilder, _CallBuilder);
25
+ var _super = _createSuper(TradeAggregationCallBuilder);
26
+ function TradeAggregationCallBuilder(serverUrl, base, counter, start_time, end_time, resolution, offset) {
27
+ var _this;
28
+ _classCallCheck(this, TradeAggregationCallBuilder);
29
+ _this = _super.call(this, serverUrl);
30
+ _this.url.segment("trade_aggregations");
31
+ if (!base.isNative()) {
32
+ _this.url.setQuery("base_asset_type", base.getAssetType());
33
+ _this.url.setQuery("base_asset_code", base.getCode());
34
+ _this.url.setQuery("base_asset_issuer", base.getIssuer());
35
+ } else {
36
+ _this.url.setQuery("base_asset_type", "native");
37
+ }
38
+ if (!counter.isNative()) {
39
+ _this.url.setQuery("counter_asset_type", counter.getAssetType());
40
+ _this.url.setQuery("counter_asset_code", counter.getCode());
41
+ _this.url.setQuery("counter_asset_issuer", counter.getIssuer());
42
+ } else {
43
+ _this.url.setQuery("counter_asset_type", "native");
44
+ }
45
+ if (typeof start_time !== "number" || typeof end_time !== "number") {
46
+ throw new _errors.BadRequestError("Invalid time bounds", [start_time, end_time]);
47
+ } else {
48
+ _this.url.setQuery("start_time", start_time.toString());
49
+ _this.url.setQuery("end_time", end_time.toString());
50
+ }
51
+ if (!_this.isValidResolution(resolution)) {
52
+ throw new _errors.BadRequestError("Invalid resolution", resolution);
53
+ } else {
54
+ _this.url.setQuery("resolution", resolution.toString());
55
+ }
56
+ if (!_this.isValidOffset(offset, resolution)) {
57
+ throw new _errors.BadRequestError("Invalid offset", offset);
58
+ } else {
59
+ _this.url.setQuery("offset", offset.toString());
60
+ }
61
+ return _this;
62
+ }
63
+ _createClass(TradeAggregationCallBuilder, [{
64
+ key: "isValidResolution",
65
+ value: function isValidResolution(resolution) {
66
+ for (var _i = 0, _allowedResolutions = allowedResolutions; _i < _allowedResolutions.length; _i++) {
67
+ var allowed = _allowedResolutions[_i];
68
+ if (allowed === resolution) {
69
+ return true;
70
+ }
71
+ }
72
+ return false;
73
+ }
74
+ }, {
75
+ key: "isValidOffset",
76
+ value: function isValidOffset(offset, resolution) {
77
+ var hour = 3600000;
78
+ return !(offset > resolution || offset >= 24 * hour || offset % hour !== 0);
79
+ }
80
+ }]);
81
+ return TradeAggregationCallBuilder;
82
+ }(_call_builder.CallBuilder);