@keetanetwork/anchor 0.0.37 → 0.0.39

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 (52) hide show
  1. package/lib/encrypted-container.d.ts +53 -3
  2. package/lib/encrypted-container.d.ts.map +1 -1
  3. package/lib/encrypted-container.js +549 -93
  4. package/lib/encrypted-container.js.map +1 -1
  5. package/lib/http-server/index.d.ts.map +1 -1
  6. package/lib/http-server/index.js +58 -5
  7. package/lib/http-server/index.js.map +1 -1
  8. package/lib/queue/drivers/queue_firestore.d.ts +29 -0
  9. package/lib/queue/drivers/queue_firestore.d.ts.map +1 -0
  10. package/lib/queue/drivers/queue_firestore.js +279 -0
  11. package/lib/queue/drivers/queue_firestore.js.map +1 -0
  12. package/lib/queue/index.d.ts +57 -0
  13. package/lib/queue/index.d.ts.map +1 -1
  14. package/lib/queue/index.js +127 -21
  15. package/lib/queue/index.js.map +1 -1
  16. package/lib/resolver.d.ts +4 -15
  17. package/lib/resolver.d.ts.map +1 -1
  18. package/lib/resolver.js +468 -636
  19. package/lib/resolver.js.map +1 -1
  20. package/lib/utils/signing.d.ts +12 -3
  21. package/lib/utils/signing.d.ts.map +1 -1
  22. package/lib/utils/signing.js +7 -13
  23. package/lib/utils/signing.js.map +1 -1
  24. package/lib/utils/types.d.ts +14 -2
  25. package/lib/utils/types.d.ts.map +1 -1
  26. package/lib/utils/types.js.map +1 -1
  27. package/npm-shrinkwrap.json +7 -7
  28. package/package.json +3 -2
  29. package/services/asset-movement/client.d.ts +2 -2
  30. package/services/asset-movement/client.d.ts.map +1 -1
  31. package/services/asset-movement/client.js +2 -2
  32. package/services/asset-movement/client.js.map +1 -1
  33. package/services/asset-movement/common.d.ts +201 -24
  34. package/services/asset-movement/common.d.ts.map +1 -1
  35. package/services/asset-movement/common.js +305 -80
  36. package/services/asset-movement/common.js.map +1 -1
  37. package/services/fx/client.d.ts +38 -11
  38. package/services/fx/client.d.ts.map +1 -1
  39. package/services/fx/client.js +187 -42
  40. package/services/fx/client.js.map +1 -1
  41. package/services/fx/common.d.ts +55 -6
  42. package/services/fx/common.d.ts.map +1 -1
  43. package/services/fx/common.js +142 -16
  44. package/services/fx/common.js.map +1 -1
  45. package/services/fx/server.d.ts +51 -7
  46. package/services/fx/server.d.ts.map +1 -1
  47. package/services/fx/server.js +333 -109
  48. package/services/fx/server.js.map +1 -1
  49. package/services/fx/util.d.ts +31 -0
  50. package/services/fx/util.d.ts.map +1 -0
  51. package/services/fx/util.js +132 -0
  52. package/services/fx/util.js.map +1 -0
@@ -3,14 +3,14 @@ import { getDefaultResolver } from '../../config.js';
3
3
  import { Buffer } from '../../lib/utils/buffer.js';
4
4
  import crypto from '../../lib/utils/crypto.js';
5
5
  import { validateURL } from '../../lib/utils/url.js';
6
- import { assertKeetaNetTokenPublicKeyString, isKeetaFXAnchorEstimateResponse, isKeetaFXAnchorExchangeResponse, isKeetaFXAnchorQuoteResponse } from './common.js';
7
- import { KeetaAnchorUserError } from '../../lib/error.js';
6
+ import { assertKeetaNetTokenPublicKeyString, isKeetaFXAnchorEstimateResponse, isKeetaFXAnchorExchangeResponse, isKeetaFXAnchorQuoteResponse, Errors as FXErrors } from './common.js';
7
+ import { KeetaAnchorError, KeetaAnchorUserError } from '../../lib/error.js';
8
8
  function typedFxServiceEntries(obj) {
9
9
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
10
10
  return Object.entries(obj);
11
11
  }
12
12
  const KeetaFXAnchorClientAccessToken = Symbol('KeetaFXAnchorClientAccessToken');
13
- async function getEndpoints(resolver, request, _ignored_account) {
13
+ async function getEndpoints(resolver, request, _ignored_account, sharedCriteria) {
14
14
  const criteria = {};
15
15
  if (request.from !== undefined) {
16
16
  criteria.inputCurrencyCode = request.from.publicKeyString.get();
@@ -21,7 +21,7 @@ async function getEndpoints(resolver, request, _ignored_account) {
21
21
  const response = await resolver.lookup('fx', {
22
22
  ...criteria
23
23
  // kycProviders: 'TODO' XXX:TODO
24
- });
24
+ }, sharedCriteria);
25
25
  if (response === undefined) {
26
26
  return (null);
27
27
  }
@@ -115,6 +115,28 @@ class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
115
115
  affinity: input.affinity
116
116
  });
117
117
  }
118
+ async #parseResponseError(data) {
119
+ if (typeof data !== 'object' || data === null) {
120
+ throw (new Error('Response is not an error'));
121
+ }
122
+ if (!('ok' in data) || data.ok) {
123
+ throw (new Error('Response is not an error'));
124
+ }
125
+ let errorStr;
126
+ try {
127
+ return (await KeetaAnchorError.fromJSON(data));
128
+ }
129
+ catch (error) {
130
+ this.logger?.debug('Failed to parse error response as KeetaAnchorError', error, data);
131
+ }
132
+ if ('error' in data && typeof data.error === 'string') {
133
+ errorStr = data.error;
134
+ }
135
+ else {
136
+ errorStr = 'Unknown error';
137
+ }
138
+ return (new Error(`FX request failed: ${errorStr}`));
139
+ }
118
140
  async getEstimate() {
119
141
  const serviceURL = await this.serviceInfo.operations.getEstimate;
120
142
  if (serviceURL !== undefined) {
@@ -134,7 +156,7 @@ class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
134
156
  throw (new Error(`Invalid response from FX estimate service: ${JSON.stringify(requestInformationJSON)}`));
135
157
  }
136
158
  if (!requestInformationJSON.ok) {
137
- throw (new Error(`FX estimate request failed: ${requestInformationJSON.error}`));
159
+ throw (await this.#parseResponseError(requestInformationJSON));
138
160
  }
139
161
  this.logger?.debug(`FX estimate request successful, to provider ${estimateURL} for ${JSON.stringify(KeetaNetLib.Utils.Conversion.toJSONSerializable(this.conversion))}`);
140
162
  const estimateJSON = requestInformationJSON.estimate;
@@ -145,7 +167,24 @@ class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
145
167
  min: BigInt(estimateJSON.expectedCost.min),
146
168
  max: BigInt(estimateJSON.expectedCost.max),
147
169
  token: KeetaNetLib.Account.fromPublicKeyString(estimateJSON.expectedCost.token)
148
- }
170
+ },
171
+ ...(estimateJSON.convertedAmountBound !== undefined ? { convertedAmountBound: BigInt(estimateJSON.convertedAmountBound) } : {}),
172
+ ...(() => {
173
+ if (estimateJSON.requiresQuote === undefined) {
174
+ return ({});
175
+ }
176
+ else if (estimateJSON.requiresQuote) {
177
+ return ({ requiresQuote: true });
178
+ // We have to disable this as doing !estimateJSON.requiresQuote breaks the compiler, and that is what eslint wants us to do
179
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
180
+ }
181
+ else if (estimateJSON.requiresQuote === false) {
182
+ return ({
183
+ requiresQuote: false,
184
+ account: KeetaNetLib.Account.fromPublicKeyString(estimateJSON.account)
185
+ });
186
+ }
187
+ })()
149
188
  });
150
189
  }
151
190
  else {
@@ -181,7 +220,7 @@ class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
181
220
  throw (new Error(`Invalid response from FX quote service: ${JSON.stringify(requestInformationJSON)}`));
182
221
  }
183
222
  if (!requestInformationJSON.ok) {
184
- throw (new Error(`FX quote request failed: ${requestInformationJSON.error}`));
223
+ throw (await this.#parseResponseError(requestInformationJSON));
185
224
  }
186
225
  if (estimate !== undefined && tolerance !== undefined) {
187
226
  const quoteAmount = BigInt(requestInformationJSON.quote.convertedAmount);
@@ -205,27 +244,59 @@ class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
205
244
  signed: quoteJSON.signed
206
245
  });
207
246
  }
208
- async createExchange(quote, block) {
247
+ async createExchange(input, block) {
209
248
  let swapBlock = block;
210
249
  if (swapBlock === undefined) {
211
250
  /* Liquidity Provider that will complete the swap */
212
- const liquidityProvider = quote.account;
213
- /* Assume affinity is 'from' and assign appropriate variables */
214
- let sendAmount = quote.request.amount;
215
- let receiveAmount = quote.convertedAmount;
216
- /* If affinity is 'to' then reverse amounts */
217
- if (quote.request.affinity === 'to') {
218
- sendAmount = quote.convertedAmount;
219
- receiveAmount = quote.request.amount;
251
+ let liquidityProvider;
252
+ let request;
253
+ let convertedAmountBound;
254
+ if ('estimate' in input) {
255
+ if (input.estimate.requiresQuote !== false) {
256
+ throw (new FXErrors.QuoteRequired());
257
+ }
258
+ liquidityProvider = input.estimate.account;
259
+ request = input.estimate.request;
260
+ if (input.estimate.convertedAmountBound !== undefined) {
261
+ convertedAmountBound = input.estimate.convertedAmountBound;
262
+ }
263
+ else {
264
+ convertedAmountBound = input.estimate.convertedAmount;
265
+ }
266
+ }
267
+ else {
268
+ liquidityProvider = input.quote.account;
269
+ request = input.quote.request;
270
+ convertedAmountBound = input.quote.convertedAmount;
271
+ }
272
+ let sendAmount;
273
+ let receiveAmount;
274
+ if (request.affinity === 'to') {
275
+ sendAmount = convertedAmountBound;
276
+ receiveAmount = request.amount;
277
+ }
278
+ else if (request.affinity === 'from') {
279
+ sendAmount = request.amount;
280
+ receiveAmount = convertedAmountBound;
281
+ }
282
+ else {
283
+ throw (new Error('Invalid affinity in conversion request'));
220
284
  }
221
285
  /* Construct the required operations for the swap request */
222
286
  const builder = this.client.initBuilder();
223
- builder.send(liquidityProvider, sendAmount, quote.request.from);
224
- builder.receive(liquidityProvider, receiveAmount, quote.request.to, true);
225
- /* If cost is required then send the required amount as well */
226
- if (quote.cost.amount > 0) {
227
- builder.send(liquidityProvider, quote.cost.amount, quote.cost.token);
287
+ if ('quote' in input) {
288
+ /* If cost is required then send the required amount as well */
289
+ if (input.quote.cost.amount > 0) {
290
+ builder.send(liquidityProvider, input.quote.cost.amount, input.quote.cost.token);
291
+ }
292
+ }
293
+ else if ('estimate' in input) {
294
+ if (input.estimate.expectedCost.max > 0) {
295
+ builder.send(liquidityProvider, input.estimate.expectedCost.max, input.estimate.expectedCost.token);
296
+ }
228
297
  }
298
+ builder.receive(liquidityProvider, receiveAmount, request.to, request.affinity === 'to');
299
+ builder.send(liquidityProvider, sendAmount, request.from);
229
300
  const blocks = await builder.computeBlocks();
230
301
  if (blocks.blocks.length !== 1) {
231
302
  throw (new Error('Creating Swap Generated more than 1 block'));
@@ -235,6 +306,13 @@ class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
235
306
  if (swapBlock == undefined) {
236
307
  throw (new Error('User Swap Block is undefined'));
237
308
  }
309
+ let bodyAdditionalData;
310
+ if ('quote' in input) {
311
+ bodyAdditionalData = { quote: input.quote };
312
+ }
313
+ else {
314
+ bodyAdditionalData = { request: input.estimate.request };
315
+ }
238
316
  const serviceURL = (await this.serviceInfo.operations.createExchange)();
239
317
  const requestInformation = await fetch(serviceURL, {
240
318
  method: 'POST',
@@ -244,23 +322,29 @@ class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
244
322
  },
245
323
  body: JSON.stringify({
246
324
  request: {
247
- quote: KeetaNetLib.Utils.Conversion.toJSONSerializable(quote),
325
+ ...(KeetaNetLib.Utils.Conversion.toJSONSerializable(bodyAdditionalData)),
248
326
  block: Buffer.from(swapBlock.toBytes()).toString('base64')
249
327
  }
250
328
  })
251
329
  });
252
330
  const requestInformationJSON = await requestInformation.json();
331
+ // Ensure status defaults to 'completed' if not provided (for backward compatibility)
332
+ if (typeof requestInformationJSON === 'object' && requestInformationJSON !== null && !('status' in requestInformationJSON)) {
333
+ Object.assign(requestInformationJSON, { status: 'completed' });
334
+ Object.assign(requestInformationJSON, { blockhash: swapBlock.hash.toString() });
335
+ }
336
+ // Validate response
253
337
  if (!isKeetaFXAnchorExchangeResponse(requestInformationJSON)) {
254
338
  throw (new Error(`Invalid response from FX exchange service: ${JSON.stringify(requestInformationJSON)}`));
255
339
  }
256
340
  if (!requestInformationJSON.ok) {
257
- throw (new Error(`FX exchange request failed: ${requestInformationJSON.error}`));
341
+ throw (await this.#parseResponseError(requestInformationJSON));
258
342
  }
259
343
  this.logger?.debug(`FX exchange request successful, to provider ${serviceURL} for ${swapBlock.hash.toString()}`);
260
344
  return (requestInformationJSON);
261
345
  }
262
346
  async getExchangeStatus(exchangeID) {
263
- const serviceURL = (await this.serviceInfo.operations.getExchangeStatus)({ exchangeID });
347
+ const serviceURL = (await this.serviceInfo.operations.getExchangeStatus)({ id: exchangeID });
264
348
  const requestInformation = await fetch(serviceURL, {
265
349
  method: 'GET',
266
350
  headers: {
@@ -272,7 +356,7 @@ class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
272
356
  throw (new Error(`Invalid response from FX exchange status service: ${JSON.stringify(requestInformationJSON)}`));
273
357
  }
274
358
  if (!requestInformationJSON.ok) {
275
- throw (new Error(`FX exchange status failed: ${requestInformationJSON.error}`));
359
+ throw (await this.#parseResponseError(requestInformationJSON));
276
360
  }
277
361
  this.logger?.debug(`FX exchange status request successful, to provider ${serviceURL} for ${exchangeID}`);
278
362
  return (requestInformationJSON);
@@ -306,26 +390,56 @@ class KeetaFXAnchorExchangeWithProvider {
306
390
  class KeetaFXAnchorQuoteWithProvider {
307
391
  provider;
308
392
  quote;
393
+ isQuote = true;
309
394
  constructor(provider, quote) {
310
395
  this.provider = provider;
311
396
  this.quote = quote;
312
397
  }
398
+ get request() {
399
+ return (this.quote.request);
400
+ }
313
401
  async createExchange(block) {
314
- const exchange = await this.provider.createExchange(this.quote, block);
402
+ const exchange = await this.provider.createExchange({ quote: this.quote }, block);
315
403
  return (new KeetaFXAnchorExchangeWithProvider(this.provider, exchange));
316
404
  }
405
+ /**
406
+ * Re-fetch the quote from the provider.
407
+ *
408
+ * @returns a new KeetaFXAnchorQuoteWithProvider with the updated quote
409
+ */
410
+ async refetch() {
411
+ const quote = await this.provider.getQuote();
412
+ return (new KeetaFXAnchorQuoteWithProvider(this.provider, quote));
413
+ }
317
414
  }
318
415
  class KeetaFXAnchorEstimateWithProvider {
319
416
  provider;
320
417
  estimate;
418
+ isQuote = false;
321
419
  constructor(provider, estimate) {
322
420
  this.provider = provider;
323
421
  this.estimate = estimate;
324
422
  }
423
+ get request() {
424
+ return (this.estimate.request);
425
+ }
325
426
  async getQuote(tolerance) {
326
427
  const quote = await this.provider.getQuote(this.estimate, tolerance);
327
428
  return (new KeetaFXAnchorQuoteWithProvider(this.provider, quote));
328
429
  }
430
+ async createExchange(block) {
431
+ const exchange = await this.provider.createExchange({ estimate: this.estimate }, block);
432
+ return (new KeetaFXAnchorExchangeWithProvider(this.provider, exchange));
433
+ }
434
+ /**
435
+ * Re-fetch the estimate from the provider.
436
+ *
437
+ * @returns a new KeetaFXAnchorEstimateWithProvider with the updated estimate
438
+ */
439
+ async refetch() {
440
+ const estimate = await this.provider.getEstimate();
441
+ return (new KeetaFXAnchorEstimateWithProvider(this.provider, estimate));
442
+ }
329
443
  }
330
444
  class KeetaFXAnchorClient extends KeetaFXAnchorBase {
331
445
  resolver;
@@ -409,7 +523,7 @@ class KeetaFXAnchorClient extends KeetaFXAnchorBase {
409
523
  affinity: input.affinity
410
524
  });
411
525
  }
412
- async listPossibleConversions(input, options = {}) {
526
+ async listPossibleConversions(input, options = {}, sharedCriteria) {
413
527
  if (input.from !== undefined && input.to !== undefined) {
414
528
  throw (new KeetaAnchorUserError('Only one of from or two should be provided'));
415
529
  }
@@ -418,7 +532,7 @@ class KeetaFXAnchorClient extends KeetaFXAnchorBase {
418
532
  }
419
533
  const conversion = await this.canonicalizeConversionTokens(input);
420
534
  const account = options.account ?? this.#account;
421
- const providerEndpoints = await getEndpoints(this.resolver, conversion, account);
535
+ const providerEndpoints = await getEndpoints(this.resolver, conversion, account, sharedCriteria);
422
536
  if (providerEndpoints === null) {
423
537
  return (null);
424
538
  }
@@ -449,10 +563,10 @@ class KeetaFXAnchorClient extends KeetaFXAnchorBase {
449
563
  ;
450
564
  return ({ conversions: [...conversions] });
451
565
  }
452
- async getBaseProvidersForConversion(request, options = {}) {
566
+ async getBaseProvidersForConversion(request, options = {}, sharedCriteria) {
453
567
  const conversion = await this.canonicalizeConversionInput(request);
454
568
  const account = options.account ?? this.#account;
455
- const providerEndpoints = await getEndpoints(this.resolver, conversion, account);
569
+ const providerEndpoints = await getEndpoints(this.resolver, conversion, account, sharedCriteria);
456
570
  if (providerEndpoints === null) {
457
571
  return (null);
458
572
  }
@@ -461,8 +575,8 @@ class KeetaFXAnchorClient extends KeetaFXAnchorBase {
461
575
  });
462
576
  return (providers);
463
577
  }
464
- async getEstimates(request, options = {}) {
465
- const estimateProviders = await this.getBaseProvidersForConversion(request, options);
578
+ async getEstimates(request, options = {}, sharedCriteria) {
579
+ const estimateProviders = await this.getBaseProvidersForConversion(request, options, sharedCriteria);
466
580
  if (estimateProviders === null) {
467
581
  return (null);
468
582
  }
@@ -480,24 +594,55 @@ class KeetaFXAnchorClient extends KeetaFXAnchorBase {
480
594
  }
481
595
  return (results);
482
596
  }
483
- async getQuotes(request, options = {}) {
484
- const estimateProviders = await this.getBaseProvidersForConversion(request, options);
597
+ async #multiRequestQuotes(request, options = {}, sharedCriteria) {
598
+ const estimateProviders = await this.getBaseProvidersForConversion(request, options, sharedCriteria);
485
599
  if (estimateProviders === null) {
600
+ return ([]);
601
+ }
602
+ return (await Promise.all(estimateProviders.map(async (provider) => {
603
+ try {
604
+ const quote = await provider.getQuote();
605
+ return ({ provider, quote: new KeetaFXAnchorQuoteWithProvider(provider, quote) });
606
+ }
607
+ catch (error) {
608
+ return ({ provider, quote: null, error });
609
+ }
610
+ })));
611
+ }
612
+ async getQuotes(request, options = {}, sharedCriteria) {
613
+ const quotes = await this.#multiRequestQuotes(request, options, sharedCriteria);
614
+ const results = quotes
615
+ .map(function (quote) {
616
+ return (quote.quote);
617
+ })
618
+ .filter(function (quote) {
619
+ return (quote !== null);
620
+ });
621
+ if (results.length === 0) {
486
622
  return (null);
487
623
  }
488
- const quotes = await Promise.allSettled(estimateProviders.map(async (provider) => {
489
- const quote = await provider.getQuote();
490
- return (new KeetaFXAnchorQuoteWithProvider(provider, quote));
624
+ return (results);
625
+ }
626
+ async getQuotesOrEstimates(request, options = {}, sharedCriteria) {
627
+ const quotesAndEstimates = await this.#multiRequestQuotes(request, options, sharedCriteria);
628
+ const results = await Promise.allSettled(quotesAndEstimates.map(async (provider) => {
629
+ if (provider.quote) {
630
+ return (provider.quote);
631
+ }
632
+ else {
633
+ if (!(FXErrors.QuoteIssuanceDisabled.isInstance(provider.error))) {
634
+ throw (provider.error);
635
+ }
636
+ const estimate = await provider.provider.getEstimate();
637
+ return (new KeetaFXAnchorEstimateWithProvider(provider.provider, estimate));
638
+ }
491
639
  }));
492
- const results = quotes.filter(function (result) {
640
+ const filtered = results.filter(function (result) {
493
641
  return (result.status === 'fulfilled');
494
642
  }).map(function (result) {
495
643
  return (result.value);
496
644
  });
497
- if (results.length === 0) {
498
- return (null);
499
- }
500
- return (results);
645
+ return (filtered);
501
646
  }
502
647
  /** @internal */
503
648
  _internals(accessToken) {
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/services/fx/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAOrD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EACN,kCAAkC,EAClC,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAyD1D,SAAS,qBAAqB,CAAmB,GAAM;IACtD,yEAAyE;IACzE,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAA6B,CAAC;AACxD,CAAC;AAiBD,MAAM,8BAA8B,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAEhF,KAAK,UAAU,YAAY,CAAC,QAAkB,EAAE,OAA+D,EAAE,gBAA0D;IAC1K,MAAM,QAAQ,GAAgC,EAAE,CAAC;IACjD,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,QAAQ,CAAC,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;IACjE,CAAC;IACD,IAA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B,OAAM,CAAC,IAAI,CAAC,CAAC;QACd,CAAC;QAED,OAAM,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED,gBAAgB;IAChB,UAAU,CAAC,WAAmB;QAC7B,IAAI,WAAW,KAAK,8BAA8B,EAAE,CAAC;YACpD,MAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,OAAM,CAAC;YACN,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO,EAAE,IAAI,CAAC,QAAQ;SACtB,CAAC,CAAC;IAEJ,CAAC;CACD;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\nimport { getDefaultResolver } from '../../config.js';\nimport type {\n\tUserClient as KeetaNetUserClient\n} from '@keetanetwork/keetanet-client';\nimport type { Logger } from '../../lib/log/index.ts';\nimport type Resolver from '../../lib/resolver.ts';\nimport type { ServiceMetadata, ServiceSearchCriteria } from '../../lib/resolver.ts';\nimport { Buffer } from '../../lib/utils/buffer.js';\nimport crypto from '../../lib/utils/crypto.js';\nimport { validateURL } from '../../lib/utils/url.js';\nimport type { BrandedString } from '../../lib/utils/brand.ts';\nimport {\n\tassertKeetaNetTokenPublicKeyString,\n\tisKeetaFXAnchorEstimateResponse,\n\tisKeetaFXAnchorExchangeResponse,\n\tisKeetaFXAnchorQuoteResponse\n} from './common.js';\nimport type {\n\tConversionInput,\n\tConversionInputCanonical,\n\tConversionInputCanonicalJSON,\n\tKeetaFXAnchorEstimate,\n\tKeetaFXAnchorExchange,\n\tKeetaFXAnchorQuote,\n\tKeetaNetTokenPublicKeyString\n} from './common.ts';\nimport { KeetaAnchorUserError } from '../../lib/error.js';\n\n/**\n * An opaque type that represents a provider ID.\n */\ntype ProviderID = BrandedString<'FXProviderID'>;\n\ntype AccountOptions = {\n\t/**\n\t * The account to use for signing requests. If not provided, the\n\t * account associated with the provided client will be used. If there\n\t * is no account associated with the client, an error occurs.\n\t */\n\tsigner?: InstanceType<typeof KeetaNetLib.Account>;\n\t/**\n\t * Account to perform changes on. If not provided, the account\n\t * associated with the provided client will be used. If there is no\n\t * account associated with the client, an error occurs.\n\t */\n\taccount?: InstanceType<typeof KeetaNetLib.Account>;\n};\n\n/**\n * The configuration options for the FX Anchor client.\n */\nexport type KeetaFXAnchorClientConfig = {\n\t/**\n\t * The ID of the client. This is used to identify the client in logs.\n\t * If not provided, a random ID will be generated.\n\t */\n\tid?: string;\n\t/**\n\t * The logger to use for logging messages. If not provided, no logging\n\t * will be done.\n\t */\n\tlogger?: Logger | undefined;\n\t/**\n\t * The resolver to use for resolving FX Anchor services. If not\n\t * provided, a default resolver will be created using the provided\n\t * client and network (if the network is also not provided and the\n\t * client is not a UserClient, an error occurs).\n\t */\n\tresolver?: Resolver;\n\t/**\n\t * The account to use for signing requests. If not provided, the\n\t * account associated with the provided client will be used. If there\n\t * is no account associated with the client, an error occurs.\n\t */\n\tsigner?: InstanceType<typeof KeetaNetLib.Account>;\n\t/**\n\t * Account to perform changes on. If not provided, the account\n\t * associated with the provided client will be used. If there is no\n\t * account associated with the client, an error occurs.\n\t */\n\taccount?: InstanceType<typeof KeetaNetLib.Account>;\n} & Omit<NonNullable<Parameters<typeof getDefaultResolver>[1]>, 'client'> & AccountOptions;\n\nfunction typedFxServiceEntries<T extends object>(obj: T): [keyof T, T[keyof T]][] {\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\treturn(Object.entries(obj) as [keyof T, T[keyof T]][]);\n}\n\ntype KeetaFXAnchorOperations = {\n\t[operation in keyof NonNullable<ServiceMetadata['services']['fx']>[string]['operations']]: (params?: { [key: string]: string; }) => URL;\n};\n\ntype KeetaFXServiceInfo = {\n\toperations: {\n\t\t[operation in keyof KeetaFXAnchorOperations]: Promise<KeetaFXAnchorOperations[operation]>;\n\t},\n\tfrom: NonNullable<ServiceMetadata['services']['fx']>[string]['from'];\n}\n\ntype GetEndpointsResult = {\n\t[providerID: ProviderID]: KeetaFXServiceInfo;\n};\n\nconst KeetaFXAnchorClientAccessToken = Symbol('KeetaFXAnchorClientAccessToken');\n\nasync function getEndpoints(resolver: Resolver, request: Partial<Pick<ConversionInputCanonical, 'from' | 'to'>>, _ignored_account: InstanceType<typeof KeetaNetLib.Account>): Promise<GetEndpointsResult | null> {\n\tconst criteria: ServiceSearchCriteria<'fx'> = {};\n\tif (request.from !== undefined) {\n\t\tcriteria.inputCurrencyCode = request.from.publicKeyString.get();\n\t}\n\tif (request.to !== undefined) {\n\t\tcriteria.outputCurrencyCode = request.to.publicKeyString.get();\n\t}\n\tconst response = await resolver.lookup('fx', {\n\t\t...criteria\n\t\t// kycProviders: 'TODO' XXX:TODO\n\t});\n\n\tif (response === undefined) {\n\t\treturn(null);\n\t}\n\n\tconst serviceInfoPromises = Object.entries(response).map(async function([id, serviceInfo]): Promise<[ProviderID, KeetaFXServiceInfo]> {\n\t\tconst operations = await serviceInfo.operations('object');\n\t\tconst operationsFunctions: Partial<KeetaFXServiceInfo['operations']> = {};\n\t\tfor (const [key, operation] of Object.entries(operations)) {\n\t\t\tif (operation === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tObject.defineProperty(operationsFunctions, key, {\n\t\t\t\tget: async function() {\n\t\t\t\t\tconst url = await operation('string');\n\t\t\t\t\treturn(function(params?: { [key: string]: string; }): URL {\n\t\t\t\t\t\tlet substitutedURL = url;\n\t\t\t\t\t\tfor (const [paramKey, paramValue] of Object.entries(params ?? {})) {\n\t\t\t\t\t\t\tsubstitutedURL = substitutedURL.replace(`{${paramKey}}`, encodeURIComponent(paramValue));\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn(validateURL(substitutedURL));\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true\n\t\t\t});\n\t\t}\n\n\t\tconst fromInfo = await serviceInfo.from('array');\n\t\tconst allFrom = await Promise.all(fromInfo.map(async function(fromFn) {\n\t\t\tconst from = await fromFn('object');\n\n\t\t\tconst currencyCodes = await Promise.all((await from.currencyCodes('array')).map(async (currencyCode) => {\n\t\t\t\tconst code = await currencyCode('string');\n\t\t\t\treturn(assertKeetaNetTokenPublicKeyString(code));\n\t\t\t}));\n\n\t\t\tconst to = await Promise.all((await from.to('array')).map(async (currencyCode) => {\n\t\t\t\tconst code = await currencyCode('string');\n\t\t\t\treturn(assertKeetaNetTokenPublicKeyString(code));\n\t\t\t}));\n\n\t\t\tconst kycProvidersEntry = (await from.kycProviders?.('array'))?.map(async (providerFn) => {\n\t\t\t\tconst provider = await providerFn('string');\n\t\t\t\treturn(provider);\n\t\t\t});\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-empty-object-type\n\t\t\tlet kycProviders: { kycProviders: string[] } | {} = {};\n\t\t\tif (kycProvidersEntry && kycProvidersEntry.length > 0) {\n\t\t\t\tkycProviders = { kycProviders: await Promise.all(kycProvidersEntry) }\n\t\t\t}\n\n\t\t\treturn({ currencyCodes, to, ...kycProviders });\n\t\t}));\n\t\treturn([\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tid as unknown as ProviderID,\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\toperations: operationsFunctions as KeetaFXServiceInfo['operations'],\n\t\t\t\tfrom: allFrom\n\t\t\t}\n\t\t]);\n\t});\n\n\tif (serviceInfoPromises.length === 0) {\n\t\treturn(null);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tconst retval = Object.fromEntries(await Promise.all(serviceInfoPromises)) satisfies GetEndpointsResult as GetEndpointsResult;\n\n\treturn(retval);\n}\n\ninterface KeetaFXAnchorBaseConfig {\n\tclient: KeetaNetUserClient;\n\tlogger?: Logger | undefined;\n}\n\nclass KeetaFXAnchorBase {\n\tprotected readonly logger?: Logger | undefined;\n\tprotected readonly client: KeetaNetUserClient;\n\n\tconstructor(config: KeetaFXAnchorBaseConfig) {\n\t\tthis.client = config.client;\n\t\tthis.logger = config.logger;\n\t}\n}\n\nclass KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {\n\treadonly serviceInfo: KeetaFXServiceInfo;\n\treadonly providerID: ProviderID;\n\treadonly conversion: ConversionInputCanonical;\n\tprivate readonly parent: KeetaFXAnchorClient;\n\n\tconstructor(serviceInfo: KeetaFXServiceInfo, providerID: ProviderID, conversion: ConversionInputCanonical, parent: KeetaFXAnchorClient) {\n\t\tconst parentPrivate = parent._internals(KeetaFXAnchorClientAccessToken);\n\t\tsuper(parentPrivate);\n\n\t\tthis.serviceInfo = serviceInfo;\n\t\tthis.providerID = providerID;\n\t\tthis.conversion = conversion;\n\t\tthis.parent = parent;\n\t}\n\n\t#parseConversionRequest(input: ConversionInputCanonicalJSON): ConversionInputCanonical {\n\t\treturn({\n\t\t\tfrom: KeetaNetLib.Account.fromPublicKeyString(input.from),\n\t\t\tto: KeetaNetLib.Account.fromPublicKeyString(input.to),\n\t\t\tamount: BigInt(input.amount),\n\t\t\taffinity: input.affinity\n\t\t});\n\t}\n\n\tasync getEstimate(): Promise<KeetaFXAnchorEstimate> {\n\t\tconst serviceURL = await this.serviceInfo.operations.getEstimate;\n\t\tif (serviceURL !== undefined) {\n\t\t\tconst estimateURL = serviceURL();\n\t\t\tconst requestInformation = await fetch(estimateURL, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t'Accept': 'application/json'\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\trequest: KeetaNetLib.Utils.Conversion.toJSONSerializable(this.conversion)\n\t\t\t\t})\n\t\t\t});\n\n\t\t\tconst requestInformationJSON: unknown = await requestInformation.json();\n\t\t\tif (!isKeetaFXAnchorEstimateResponse(requestInformationJSON)) {\n\t\t\t\tthrow(new Error(`Invalid response from FX estimate service: ${JSON.stringify(requestInformationJSON)}`));\n\t\t\t}\n\n\t\t\tif (!requestInformationJSON.ok) {\n\t\t\t\tthrow(new Error(`FX estimate request failed: ${requestInformationJSON.error}`));\n\t\t\t}\n\n\t\t\tthis.logger?.debug(`FX estimate request successful, to provider ${estimateURL} for ${JSON.stringify(KeetaNetLib.Utils.Conversion.toJSONSerializable(this.conversion))}`);\n\t\t\tconst estimateJSON = requestInformationJSON.estimate;\n\t\t\treturn({\n\t\t\t\trequest: this.#parseConversionRequest(estimateJSON.request),\n\t\t\t\tconvertedAmount: BigInt(estimateJSON.convertedAmount),\n\t\t\t\texpectedCost: {\n\t\t\t\t\tmin: BigInt(estimateJSON.expectedCost.min),\n\t\t\t\t\tmax: BigInt(estimateJSON.expectedCost.max),\n\t\t\t\t\ttoken: KeetaNetLib.Account.fromPublicKeyString(estimateJSON.expectedCost.token)\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tthrow(new Error('Service getEstimate does not exist'));\n\t\t}\n\t}\n\n\t/**\n\t * Get a quote from the provider. If an estimate is provided, it will\n\t * be used to validate the quote is within the tolerance range.\n\t *\n\t * @param estimate An optional estimate to validate the quote against\n\t * @param tolerance The tolerance, in percentage points, to allow the\n\t * quote to vary from the estimate. For example, a\n\t * tolerance of 1.0 allows the quote to be 100% more\n\t * or less than the estimate. The default is 0.10\n\t * (10%).\n\t * @returns A promise that resolves to the quote response\n\t */\n\tasync getQuote(estimate?: KeetaFXAnchorEstimate, tolerance: number = 0.1): Promise<KeetaFXAnchorQuote> {\n\t\tconst serviceURL = (await this.serviceInfo.operations.getQuote)();\n\t\tconst requestInformation = await fetch(serviceURL, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'Accept': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\trequest: KeetaNetLib.Utils.Conversion.toJSONSerializable(this.conversion)\n\t\t\t})\n\t\t});\n\n\t\tconst requestInformationJSON: unknown = await requestInformation.json();\n\t\tif (!isKeetaFXAnchorQuoteResponse(requestInformationJSON)) {\n\t\t\tthrow(new Error(`Invalid response from FX quote service: ${JSON.stringify(requestInformationJSON)}`));\n\t\t}\n\n\t\tif (!requestInformationJSON.ok) {\n\t\t\tthrow(new Error(`FX quote request failed: ${requestInformationJSON.error}`));\n\t\t}\n\n\t\tif (estimate !== undefined && tolerance !== undefined) {\n\t\t\tconst quoteAmount = BigInt(requestInformationJSON.quote.convertedAmount);\n\t\t\tconst estimateAmount = BigInt(estimate.convertedAmount);\n\t\t\tconst lowerBound = estimateAmount * BigInt(Math.round((1 - tolerance) * 100)) / 100n;\n\t\t\tconst upperBound = estimateAmount * BigInt(Math.round((1 + tolerance) * 100)) / 100n;\n\t\t\tif (quoteAmount > upperBound || quoteAmount < lowerBound) {\n\t\t\t\tthrow(new Error(`FX Quote amount: ${requestInformationJSON.quote.convertedAmount} differs more than tolerance limit: ${tolerance} from estimate`));\n\t\t\t}\n\t\t}\n\n\t\tthis.logger?.debug(`FX quote request successful, to provider ${serviceURL} for ${JSON.stringify(KeetaNetLib.Utils.Conversion.toJSONSerializable(this.conversion))}`);\n\t\tconst quoteJSON = requestInformationJSON.quote;\n\t\treturn({\n\t\t\trequest: this.#parseConversionRequest(quoteJSON.request),\n\t\t\taccount: KeetaNetLib.Account.fromPublicKeyString(quoteJSON.account),\n\t\t\tconvertedAmount: BigInt(quoteJSON.convertedAmount),\n\t\t\tcost: {\n\t\t\t\tamount: BigInt(quoteJSON.cost.amount),\n\t\t\t\ttoken: KeetaNetLib.Account.fromPublicKeyString(quoteJSON.cost.token)\n\t\t\t},\n\t\t\tsigned: quoteJSON.signed\n\t\t});\n\t}\n\n\tasync createExchange(quote: KeetaFXAnchorQuote, block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchange> {\n\t\tlet swapBlock = block;\n\t\tif (swapBlock === undefined) {\n\t\t\t/* Liquidity Provider that will complete the swap */\n\t\t\tconst liquidityProvider = quote.account;\n\n\t\t\t/* Assume affinity is 'from' and assign appropriate variables */\n\t\t\tlet sendAmount = quote.request.amount;\n\t\t\tlet receiveAmount = quote.convertedAmount;\n\n\t\t\t/* If affinity is 'to' then reverse amounts */\n\t\t\tif (quote.request.affinity === 'to') {\n\t\t\t\tsendAmount = quote.convertedAmount;\n\t\t\t\treceiveAmount = quote.request.amount;\n\t\t\t}\n\n\t\t\t/* Construct the required operations for the swap request */\n\t\t\tconst builder = this.client.initBuilder();\n\t\t\tbuilder.send(liquidityProvider, sendAmount, quote.request.from);\n\t\t\tbuilder.receive(liquidityProvider, receiveAmount, quote.request.to, true);\n\n\t\t\t/* If cost is required then send the required amount as well */\n\t\t\tif (quote.cost.amount > 0) {\n\t\t\t\tbuilder.send(liquidityProvider, quote.cost.amount, quote.cost.token);\n\t\t\t}\n\n\t\t\tconst blocks = await builder.computeBlocks();\n\t\t\tif (blocks.blocks.length !== 1) {\n\t\t\t\tthrow(new Error('Creating Swap Generated more than 1 block'));\n\t\t\t}\n\t\t\tswapBlock = blocks.blocks[0];\n\t\t}\n\n\t\tif (swapBlock == undefined) {\n\t\t\tthrow(new Error('User Swap Block is undefined'));\n\t\t}\n\n\t\tconst serviceURL = (await this.serviceInfo.operations.createExchange)();\n\t\tconst requestInformation = await fetch(serviceURL, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'Accept': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\trequest: {\n\t\t\t\t\tquote: KeetaNetLib.Utils.Conversion.toJSONSerializable(quote),\n\t\t\t\t\tblock: Buffer.from(swapBlock.toBytes()).toString('base64')\n\t\t\t\t}\n\t\t\t})\n\t\t});\n\n\t\tconst requestInformationJSON: unknown = await requestInformation.json();\n\t\tif (!isKeetaFXAnchorExchangeResponse(requestInformationJSON)) {\n\t\t\tthrow(new Error(`Invalid response from FX exchange service: ${JSON.stringify(requestInformationJSON)}`));\n\t\t}\n\n\t\tif (!requestInformationJSON.ok) {\n\t\t\tthrow(new Error(`FX exchange request failed: ${requestInformationJSON.error}`));\n\t\t}\n\n\t\tthis.logger?.debug(`FX exchange request successful, to provider ${serviceURL} for ${swapBlock.hash.toString()}`);\n\t\treturn(requestInformationJSON);\n\t}\n\n\tasync getExchangeStatus(exchangeID: string): Promise<KeetaFXAnchorExchange> {\n\t\tconst serviceURL = (await this.serviceInfo.operations.getExchangeStatus)({ exchangeID });\n\t\tconst requestInformation = await fetch(serviceURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t'Accept': 'application/json'\n\t\t\t}\n\t\t});\n\n\t\tconst requestInformationJSON: unknown = await requestInformation.json();\n\t\tif (!isKeetaFXAnchorExchangeResponse(requestInformationJSON)) {\n\t\t\tthrow(new Error(`Invalid response from FX exchange status service: ${JSON.stringify(requestInformationJSON)}`));\n\t\t}\n\n\t\tif (!requestInformationJSON.ok) {\n\t\t\tthrow(new Error(`FX exchange status failed: ${requestInformationJSON.error}`));\n\t\t}\n\n\t\tthis.logger?.debug(`FX exchange status request successful, to provider ${serviceURL} for ${exchangeID}`);\n\t\treturn(requestInformationJSON);\n\t}\n\n\t/** @internal */\n\t_internals(accessToken: symbol) {\n\t\tif (accessToken !== KeetaFXAnchorClientAccessToken) {\n\t\t\tthrow(new Error('invalid access token'));\n\t\t}\n\n\t\treturn({\n\t\t\tparent: this.parent\n\t\t});\n\n\t}\n}\n\n/*\n * Various classes for the state machine:\n * Estimate(optional) -> Quote(optional) -> Exchange -> ExchangeStatus\n */\nclass KeetaFXAnchorExchangeWithProvider {\n\tprivate readonly provider: KeetaFXAnchorProviderBase;\n\treadonly exchange: KeetaFXAnchorExchange\n\n\tconstructor(provider: KeetaFXAnchorProviderBase, exchange: KeetaFXAnchorExchange) {\n\t\tthis.provider = provider;\n\t\tthis.exchange = exchange;\n\t}\n\n\tasync getExchangeStatus(): Promise<KeetaFXAnchorExchange> {\n\t\t/* XXX:TODO: This should return something useful -- right now it just returns the exchange ID... */\n\t\treturn(await this.provider.getExchangeStatus(this.exchange.exchangeID));\n\t}\n}\n\nclass KeetaFXAnchorQuoteWithProvider {\n\tprivate readonly provider: KeetaFXAnchorProviderBase;\n\treadonly quote: KeetaFXAnchorQuote;\n\n\tconstructor(provider: KeetaFXAnchorProviderBase, quote: KeetaFXAnchorQuote) {\n\t\tthis.provider = provider;\n\t\tthis.quote = quote;\n\t}\n\n\tasync createExchange(block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchangeWithProvider> {\n\t\tconst exchange = await this.provider.createExchange(this.quote, block);\n\t\treturn(new KeetaFXAnchorExchangeWithProvider(this.provider, exchange));\n\t}\n}\n\nclass KeetaFXAnchorEstimateWithProvider {\n\tprivate readonly provider: KeetaFXAnchorProviderBase;\n\treadonly estimate: KeetaFXAnchorEstimate;\n\n\tconstructor(provider: KeetaFXAnchorProviderBase, estimate: KeetaFXAnchorEstimate) {\n\t\tthis.provider = provider;\n\t\tthis.estimate = estimate;\n\t}\n\n\tasync getQuote(tolerance?: number): Promise<KeetaFXAnchorQuoteWithProvider> {\n\t\tconst quote = await this.provider.getQuote(this.estimate, tolerance);\n\t\treturn(new KeetaFXAnchorQuoteWithProvider(this.provider, quote));\n\t}\n}\n\nclass KeetaFXAnchorClient extends KeetaFXAnchorBase {\n\treadonly resolver: Resolver;\n\treadonly id: string;\n\treadonly #signer: InstanceType<typeof KeetaNetLib.Account>;\n\treadonly #account: InstanceType<typeof KeetaNetLib.Account>;\n\n\tconstructor(client: KeetaNetUserClient, config: KeetaFXAnchorClientConfig = {}) {\n\t\tsuper({ client, logger: config.logger });\n\t\tthis.resolver = config.resolver ?? getDefaultResolver(client, config);\n\t\tthis.id = config.id ?? crypto.randomUUID();\n\n\t\tif (config.signer) {\n\t\t\tthis.#signer = config.signer;\n\t\t} else if ('signer' in client && client.signer !== null) {\n\t\t\tthis.#signer = client.signer;\n\t\t} else if ('account' in client && client.account.hasPrivateKey) {\n\t\t\tthis.#signer = client.account;\n\t\t} else {\n\t\t\tthrow(new Error('KeetaFXAnchorClient requires a Signer or a UserClient with an associated Signer'));\n\t\t}\n\n\t\tif (config.account) {\n\t\t\tthis.#account = config.account;\n\t\t} else if ('account' in client) {\n\t\t\tthis.#account = client.account;\n\t\t} else {\n\t\t\tthrow(new Error('KeetaFXAnchorClient requires an Account or a UserClient with an associated Account'));\n\t\t}\n\t}\n\n\tprivate async canonicalizeConversionTokens(input: Partial<ConversionInput>): Promise<Partial<Pick<ConversionInputCanonical, 'from' | 'to'>>> {\n\t\tlet from = {}\n\t\tif (input.from !== undefined) {\n\t\t\tlet fromToken: ConversionInputCanonical['from'];\n\t\t\tif (KeetaNetLib.Account.isInstance(input.from) && input.from.isToken()) {\n\t\t\t\tfromToken = input.from;\n\t\t\t} else {\n\t\t\t\tconst tokenLookup = await this.resolver.lookupToken(input.from);\n\t\t\t\tif (tokenLookup === null) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\t\tthrow(new Error(`Could not convert from: ${input.from} to a token address`));\n\t\t\t\t}\n\t\t\t\tfromToken = KeetaNetLib.Account.fromPublicKeyString(tokenLookup.token);\n\t\t\t}\n\t\t\tfrom = { from: fromToken };\n\t\t}\n\n\t\tlet to = {};\n\t\tif (input.to !== undefined) {\n\t\t\tlet toToken: ConversionInputCanonical['to'];\n\t\t\tif (KeetaNetLib.Account.isInstance(input.to) && input.to.isToken()) {\n\t\t\t\ttoToken = input.to;\n\t\t\t} else {\n\t\t\t\tconst tokenLookup = await this.resolver.lookupToken(input.to);\n\t\t\t\tif (tokenLookup === null) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\t\tthrow(new Error(`Could not convert to: ${input.to} to a token address`));\n\t\t\t\t}\n\t\t\t\ttoToken = KeetaNetLib.Account.fromPublicKeyString(tokenLookup.token);\n\t\t\t}\n\t\t\tto = { to: toToken };\n\t\t}\n\t\treturn({ ...from, ...to });\n\t}\n\n\tprivate async canonicalizeConversionInput(input: ConversionInput): Promise<ConversionInputCanonical> {\n\t\tconst amount = BigInt(input.amount);\n\t\tif (amount < 0) {\n\t\t\tthrow(new Error('Invalid Conversion Amount'));\n\t\t}\n\n\t\tconst { from, to } = await this.canonicalizeConversionTokens(input);\n\n\t\tif (from === undefined || to === undefined) {\n\t\t\tthrow(new Error('From and To are both required for a conversion'));\n\t\t}\n\n\t\treturn({\n\t\t\tfrom,\n\t\t\tto,\n\t\t\tamount: amount,\n\t\t\taffinity: input.affinity\n\t\t});\n\t}\n\n\tasync listPossibleConversions(input: Partial<Pick<ConversionInput, 'from' | 'to'>>, options: AccountOptions = {}): Promise<{ conversions: KeetaNetTokenPublicKeyString[] } | null> {\n\t\tif (input.from !== undefined && input.to !== undefined) {\n\t\t\tthrow(new KeetaAnchorUserError('Only one of from or two should be provided'));\n\t\t}\n\t\tif (input.from === undefined && input.to === undefined) {\n\t\t\tthrow(new KeetaAnchorUserError('At least one of from or two should be provided'));\n\t\t}\n\t\tconst conversion = await this.canonicalizeConversionTokens(input);\n\t\tconst account = options.account ?? this.#account;\n\t\tconst providerEndpoints = await getEndpoints(this.resolver, conversion, account);\n\t\tif (providerEndpoints === null) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst conversions = new Set<KeetaNetTokenPublicKeyString>();\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\tfor (const [_ignored_providerID, serviceInfo] of typedFxServiceEntries(providerEndpoints)) {\n\t\t\tfor (const conversionPair of serviceInfo.from) {\n\t\t\t\tif (conversion.from !== undefined) {\n\t\t\t\t\tif (conversionPair.currencyCodes.includes(conversion.from.publicKeyString.get())) {\n\t\t\t\t\t\tconversionPair.to.forEach((token) => {\n\t\t\t\t\t\t\tif (conversion.from?.publicKeyString.get() !== token) {\n\t\t\t\t\t\t\t\tconversions.add(token);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else if (conversion.to !== undefined) {\n\t\t\t\t\tif (conversionPair.to.includes(conversion.to.publicKeyString.get())) {\n\t\t\t\t\t\tconversionPair.currencyCodes.forEach((token) => {\n\t\t\t\t\t\t\tif (conversion.to?.publicKeyString.get() !== token) {\n\t\t\t\t\t\t\t\tconversions.add(token);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\treturn({ conversions: [...conversions] });\n\t}\n\n\tasync getBaseProvidersForConversion(request: ConversionInput, options: AccountOptions = {}): Promise<KeetaFXAnchorProviderBase[] | null> {\n\t\tconst conversion = await this.canonicalizeConversionInput(request);\n\t\tconst account = options.account ?? this.#account;\n\t\tconst providerEndpoints = await getEndpoints(this.resolver, conversion, account);\n\t\tif (providerEndpoints === null) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst providers = typedFxServiceEntries(providerEndpoints).map(([providerID, serviceInfo]) => {\n\t\t\treturn(new KeetaFXAnchorProviderBase(serviceInfo, providerID, conversion, this));\n\t\t});\n\n\t\treturn(providers);\n\t}\n\n\tasync getEstimates(request: ConversionInput, options: AccountOptions = {}): Promise<KeetaFXAnchorEstimateWithProvider[] | null> {\n\t\tconst estimateProviders = await this.getBaseProvidersForConversion(request, options);\n\t\tif (estimateProviders === null) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst estimates = await Promise.allSettled(estimateProviders.map(async (provider) => {\n\t\t\tconst estimate = await provider.getEstimate();\n\n\t\t\treturn(new KeetaFXAnchorEstimateWithProvider(provider, estimate));\n\t\t}));\n\n\t\tconst results = estimates.filter(function(result) {\n\t\t\treturn(result.status === 'fulfilled');\n\t\t}).map(function(result) {\n\t\t\treturn(result.value);\n\t\t});\n\n\t\tif (results.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\treturn(results);\n\t}\n\n\tasync getQuotes(request: ConversionInput, options: AccountOptions = {}): Promise<KeetaFXAnchorQuoteWithProvider[] | null> {\n\t\tconst estimateProviders = await this.getBaseProvidersForConversion(request, options);\n\t\tif (estimateProviders === null) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst quotes = await Promise.allSettled(estimateProviders.map(async (provider) => {\n\t\t\tconst quote = await provider.getQuote();\n\n\t\t\treturn(new KeetaFXAnchorQuoteWithProvider(provider, quote));\n\t\t}));\n\n\t\tconst results = quotes.filter(function(result) {\n\t\t\treturn(result.status === 'fulfilled');\n\t\t}).map(function(result) {\n\t\t\treturn(result.value);\n\t\t});\n\n\t\tif (results.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\treturn(results);\n\t}\n\n\t/** @internal */\n\t_internals(accessToken: symbol) {\n\t\tif (accessToken !== KeetaFXAnchorClientAccessToken) {\n\t\t\tthrow(new Error('invalid access token'));\n\t\t}\n\n\t\treturn({\n\t\t\tresolver: this.resolver,\n\t\t\tlogger: this.logger,\n\t\t\tclient: this.client,\n\t\t\tsigner: this.#signer,\n\t\t\taccount: this.#account\n\t\t});\n\n\t}\n}\n\nexport default KeetaFXAnchorClient;\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/services/fx/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAOrD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EACN,kCAAkC,EAClC,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,MAAM,IAAI,QAAQ,EAClB,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAE,gBAAgB,EA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AAI,iCAAiC,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC5E,CAAC;QACF,CAAC,CAAC,CAAC,CAAC;QAEJ,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,UAAS,MAAM;YAC9C,OAAM,CAAC,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAS,MAAM;YACrB,OAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,OAAM,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;IAED,gBAAgB;IAChB,UAAU,CAAC,WAAmB;QAC7B,IAAI,WAAW,KAAK,8BAA8B,EAAE,CAAC;YACpD,MAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,OAAM,CAAC;YACN,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO,EAAE,IAAI,CAAC,QAAQ;SACtB,CAAC,CAAC;IAEJ,CAAC;CACD;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\nimport { getDefaultResolver } from '../../config.js';\nimport type {\n\tUserClient as KeetaNetUserClient\n} from '@keetanetwork/keetanet-client';\nimport type { Logger } from '../../lib/log/index.ts';\nimport type Resolver from '../../lib/resolver.ts';\nimport type { ServiceMetadata, ServiceSearchCriteria, SharedLookupCriteria } from '../../lib/resolver.ts';\nimport { Buffer } from '../../lib/utils/buffer.js';\nimport crypto from '../../lib/utils/crypto.js';\nimport { validateURL } from '../../lib/utils/url.js';\nimport type { BrandedString } from '../../lib/utils/brand.ts';\nimport {\n\tassertKeetaNetTokenPublicKeyString,\n\tisKeetaFXAnchorEstimateResponse,\n\tisKeetaFXAnchorExchangeResponse,\n\tisKeetaFXAnchorQuoteResponse,\n\tErrors as FXErrors\n} from './common.js';\nimport type {\n\tConversionInput,\n\tConversionInputCanonical,\n\tConversionInputCanonicalJSON,\n\tKeetaFXAnchorEstimate,\n\tKeetaFXAnchorExchange,\n\tKeetaFXAnchorQuote,\n\tKeetaNetTokenPublicKeyString\n} from './common.ts';\nimport { KeetaAnchorError, KeetaAnchorUserError } from '../../lib/error.js';\n\n/**\n * An opaque type that represents a provider ID.\n */\ntype ProviderID = BrandedString<'FXProviderID'>;\n\ntype AccountOptions = {\n\t/**\n\t * The account to use for signing requests. If not provided, the\n\t * account associated with the provided client will be used. If there\n\t * is no account associated with the client, an error occurs.\n\t */\n\tsigner?: InstanceType<typeof KeetaNetLib.Account>;\n\t/**\n\t * Account to perform changes on. If not provided, the account\n\t * associated with the provided client will be used. If there is no\n\t * account associated with the client, an error occurs.\n\t */\n\taccount?: InstanceType<typeof KeetaNetLib.Account>;\n};\n\n/**\n * The configuration options for the FX Anchor client.\n */\nexport type KeetaFXAnchorClientConfig = {\n\t/**\n\t * The ID of the client. This is used to identify the client in logs.\n\t * If not provided, a random ID will be generated.\n\t */\n\tid?: string;\n\t/**\n\t * The logger to use for logging messages. If not provided, no logging\n\t * will be done.\n\t */\n\tlogger?: Logger | undefined;\n\t/**\n\t * The resolver to use for resolving FX Anchor services. If not\n\t * provided, a default resolver will be created using the provided\n\t * client and network (if the network is also not provided and the\n\t * client is not a UserClient, an error occurs).\n\t */\n\tresolver?: Resolver;\n\t/**\n\t * The account to use for signing requests. If not provided, the\n\t * account associated with the provided client will be used. If there\n\t * is no account associated with the client, an error occurs.\n\t */\n\tsigner?: InstanceType<typeof KeetaNetLib.Account>;\n\t/**\n\t * Account to perform changes on. If not provided, the account\n\t * associated with the provided client will be used. If there is no\n\t * account associated with the client, an error occurs.\n\t */\n\taccount?: InstanceType<typeof KeetaNetLib.Account>;\n} & Omit<NonNullable<Parameters<typeof getDefaultResolver>[1]>, 'client'> & AccountOptions;\n\nfunction typedFxServiceEntries<T extends object>(obj: T): [keyof T, T[keyof T]][] {\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\treturn(Object.entries(obj) as [keyof T, T[keyof T]][]);\n}\n\ntype KeetaFXAnchorOperations = {\n\t[operation in keyof NonNullable<ServiceMetadata['services']['fx']>[string]['operations']]: (params?: { [key: string]: string; }) => URL;\n};\n\ntype KeetaFXServiceInfo = {\n\toperations: {\n\t\t[operation in keyof KeetaFXAnchorOperations]: Promise<KeetaFXAnchorOperations[operation]>;\n\t},\n\tfrom: NonNullable<ServiceMetadata['services']['fx']>[string]['from'];\n}\n\ntype GetEndpointsResult = {\n\t[providerID: ProviderID]: KeetaFXServiceInfo;\n};\n\nconst KeetaFXAnchorClientAccessToken = Symbol('KeetaFXAnchorClientAccessToken');\n\nasync function getEndpoints(resolver: Resolver, request: Partial<Pick<ConversionInputCanonical, 'from' | 'to'>>, _ignored_account: InstanceType<typeof KeetaNetLib.Account>, sharedCriteria?: SharedLookupCriteria): Promise<GetEndpointsResult | null> {\n\tconst criteria: ServiceSearchCriteria<'fx'> = {};\n\tif (request.from !== undefined) {\n\t\tcriteria.inputCurrencyCode = request.from.publicKeyString.get();\n\t}\n\tif (request.to !== undefined) {\n\t\tcriteria.outputCurrencyCode = request.to.publicKeyString.get();\n\t}\n\tconst response = await resolver.lookup('fx', {\n\t\t...criteria\n\t\t// kycProviders: 'TODO' XXX:TODO\n\t}, sharedCriteria);\n\n\tif (response === undefined) {\n\t\treturn(null);\n\t}\n\n\tconst serviceInfoPromises = Object.entries(response).map(async function([id, serviceInfo]): Promise<[ProviderID, KeetaFXServiceInfo]> {\n\t\tconst operations = await serviceInfo.operations('object');\n\t\tconst operationsFunctions: Partial<KeetaFXServiceInfo['operations']> = {};\n\t\tfor (const [key, operation] of Object.entries(operations)) {\n\t\t\tif (operation === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tObject.defineProperty(operationsFunctions, key, {\n\t\t\t\tget: async function() {\n\t\t\t\t\tconst url = await operation('string');\n\t\t\t\t\treturn(function(params?: { [key: string]: string; }): URL {\n\t\t\t\t\t\tlet substitutedURL = url;\n\t\t\t\t\t\tfor (const [paramKey, paramValue] of Object.entries(params ?? {})) {\n\t\t\t\t\t\t\tsubstitutedURL = substitutedURL.replace(`{${paramKey}}`, encodeURIComponent(paramValue));\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn(validateURL(substitutedURL));\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true\n\t\t\t});\n\t\t}\n\n\t\tconst fromInfo = await serviceInfo.from('array');\n\t\tconst allFrom = await Promise.all(fromInfo.map(async function(fromFn) {\n\t\t\tconst from = await fromFn('object');\n\n\t\t\tconst currencyCodes = await Promise.all((await from.currencyCodes('array')).map(async (currencyCode) => {\n\t\t\t\tconst code = await currencyCode('string');\n\t\t\t\treturn(assertKeetaNetTokenPublicKeyString(code));\n\t\t\t}));\n\n\t\t\tconst to = await Promise.all((await from.to('array')).map(async (currencyCode) => {\n\t\t\t\tconst code = await currencyCode('string');\n\t\t\t\treturn(assertKeetaNetTokenPublicKeyString(code));\n\t\t\t}));\n\n\t\t\tconst kycProvidersEntry = (await from.kycProviders?.('array'))?.map(async (providerFn) => {\n\t\t\t\tconst provider = await providerFn('string');\n\t\t\t\treturn(provider);\n\t\t\t});\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-empty-object-type\n\t\t\tlet kycProviders: { kycProviders: string[] } | {} = {};\n\t\t\tif (kycProvidersEntry && kycProvidersEntry.length > 0) {\n\t\t\t\tkycProviders = { kycProviders: await Promise.all(kycProvidersEntry) }\n\t\t\t}\n\n\t\t\treturn({ currencyCodes, to, ...kycProviders });\n\t\t}));\n\t\treturn([\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tid as unknown as ProviderID,\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\toperations: operationsFunctions as KeetaFXServiceInfo['operations'],\n\t\t\t\tfrom: allFrom\n\t\t\t}\n\t\t]);\n\t});\n\n\tif (serviceInfoPromises.length === 0) {\n\t\treturn(null);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tconst retval = Object.fromEntries(await Promise.all(serviceInfoPromises)) satisfies GetEndpointsResult as GetEndpointsResult;\n\n\treturn(retval);\n}\n\ninterface KeetaFXAnchorBaseConfig {\n\tclient: KeetaNetUserClient;\n\tlogger?: Logger | undefined;\n}\n\nclass KeetaFXAnchorBase {\n\tprotected readonly logger?: Logger | undefined;\n\tprotected readonly client: KeetaNetUserClient;\n\n\tconstructor(config: KeetaFXAnchorBaseConfig) {\n\t\tthis.client = config.client;\n\t\tthis.logger = config.logger;\n\t}\n}\n\nclass KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {\n\treadonly serviceInfo: KeetaFXServiceInfo;\n\treadonly providerID: ProviderID;\n\treadonly conversion: ConversionInputCanonical;\n\tprivate readonly parent: KeetaFXAnchorClient;\n\n\tconstructor(serviceInfo: KeetaFXServiceInfo, providerID: ProviderID, conversion: ConversionInputCanonical, parent: KeetaFXAnchorClient) {\n\t\tconst parentPrivate = parent._internals(KeetaFXAnchorClientAccessToken);\n\t\tsuper(parentPrivate);\n\n\t\tthis.serviceInfo = serviceInfo;\n\t\tthis.providerID = providerID;\n\t\tthis.conversion = conversion;\n\t\tthis.parent = parent;\n\t}\n\n\t#parseConversionRequest(input: ConversionInputCanonicalJSON): ConversionInputCanonical {\n\t\treturn({\n\t\t\tfrom: KeetaNetLib.Account.fromPublicKeyString(input.from),\n\t\t\tto: KeetaNetLib.Account.fromPublicKeyString(input.to),\n\t\t\tamount: BigInt(input.amount),\n\t\t\taffinity: input.affinity\n\t\t});\n\t}\n\n\tasync #parseResponseError(data: { ok: false }) {\n\t\tif (typeof data !== 'object' || data === null) {\n\t\t\tthrow(new Error('Response is not an error'));\n\t\t}\n\n\t\tif (!('ok' in data) || data.ok) {\n\t\t\tthrow(new Error('Response is not an error'));\n\t\t}\n\n\t\tlet errorStr;\n\n\t\ttry {\n\t\t\treturn(await KeetaAnchorError.fromJSON(data));\n\t\t} catch (error: unknown) {\n\t\t\tthis.logger?.debug('Failed to parse error response as KeetaAnchorError', error, data);\n\t\t}\n\n\t\tif ('error' in data && typeof data.error === 'string') {\n\t\t\terrorStr = data.error;\n\t\t} else {\n\t\t\terrorStr = 'Unknown error';\n\t\t}\n\n\t\treturn(new Error(`FX request failed: ${errorStr}`));\n\t}\n\n\tasync getEstimate(): Promise<KeetaFXAnchorEstimate> {\n\t\tconst serviceURL = await this.serviceInfo.operations.getEstimate;\n\t\tif (serviceURL !== undefined) {\n\t\t\tconst estimateURL = serviceURL();\n\t\t\tconst requestInformation = await fetch(estimateURL, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t'Accept': 'application/json'\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\trequest: KeetaNetLib.Utils.Conversion.toJSONSerializable(this.conversion)\n\t\t\t\t})\n\t\t\t});\n\n\t\t\tconst requestInformationJSON: unknown = await requestInformation.json();\n\t\t\tif (!isKeetaFXAnchorEstimateResponse(requestInformationJSON)) {\n\t\t\t\tthrow(new Error(`Invalid response from FX estimate service: ${JSON.stringify(requestInformationJSON)}`));\n\t\t\t}\n\n\t\t\tif (!requestInformationJSON.ok) {\n\t\t\t\tthrow(await this.#parseResponseError(requestInformationJSON));\n\t\t\t}\n\n\t\t\tthis.logger?.debug(`FX estimate request successful, to provider ${estimateURL} for ${JSON.stringify(KeetaNetLib.Utils.Conversion.toJSONSerializable(this.conversion))}`);\n\t\t\tconst estimateJSON = requestInformationJSON.estimate;\n\t\t\treturn({\n\t\t\t\trequest: this.#parseConversionRequest(estimateJSON.request),\n\t\t\t\tconvertedAmount: BigInt(estimateJSON.convertedAmount),\n\t\t\t\texpectedCost: {\n\t\t\t\t\tmin: BigInt(estimateJSON.expectedCost.min),\n\t\t\t\t\tmax: BigInt(estimateJSON.expectedCost.max),\n\t\t\t\t\ttoken: KeetaNetLib.Account.fromPublicKeyString(estimateJSON.expectedCost.token)\n\t\t\t\t},\n\t\t\t\t...(estimateJSON.convertedAmountBound !== undefined ? { convertedAmountBound: BigInt(estimateJSON.convertedAmountBound) } : {}),\n\t\t\t\t...(() => {\n\t\t\t\t\tif (estimateJSON.requiresQuote === undefined) {\n\t\t\t\t\t\treturn({})\n\t\t\t\t\t} else if (estimateJSON.requiresQuote) {\n\t\t\t\t\t\treturn({ requiresQuote: true });\n\t\t\t\t\t// We have to disable this as doing !estimateJSON.requiresQuote breaks the compiler, and that is what eslint wants us to do\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare\n\t\t\t\t\t} else if (estimateJSON.requiresQuote === false) {\n\t\t\t\t\t\treturn({\n\t\t\t\t\t\t\trequiresQuote: false,\n\t\t\t\t\t\t\taccount: KeetaNetLib.Account.fromPublicKeyString(estimateJSON.account)\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t})()\n\t\t\t});\n\t\t} else {\n\t\t\tthrow(new Error('Service getEstimate does not exist'));\n\t\t}\n\t}\n\n\t/**\n\t * Get a quote from the provider. If an estimate is provided, it will\n\t * be used to validate the quote is within the tolerance range.\n\t *\n\t * @param estimate An optional estimate to validate the quote against\n\t * @param tolerance The tolerance, in percentage points, to allow the\n\t * quote to vary from the estimate. For example, a\n\t * tolerance of 1.0 allows the quote to be 100% more\n\t * or less than the estimate. The default is 0.10\n\t * (10%).\n\t * @returns A promise that resolves to the quote response\n\t */\n\tasync getQuote(estimate?: KeetaFXAnchorEstimate, tolerance: number = 0.1): Promise<KeetaFXAnchorQuote> {\n\t\tconst serviceURL = (await this.serviceInfo.operations.getQuote)();\n\t\tconst requestInformation = await fetch(serviceURL, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'Accept': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\trequest: KeetaNetLib.Utils.Conversion.toJSONSerializable(this.conversion)\n\t\t\t})\n\t\t});\n\n\t\tconst requestInformationJSON: unknown = await requestInformation.json();\n\t\tif (!isKeetaFXAnchorQuoteResponse(requestInformationJSON)) {\n\t\t\tthrow(new Error(`Invalid response from FX quote service: ${JSON.stringify(requestInformationJSON)}`));\n\t\t}\n\n\t\tif (!requestInformationJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(requestInformationJSON));\n\t\t}\n\n\t\tif (estimate !== undefined && tolerance !== undefined) {\n\t\t\tconst quoteAmount = BigInt(requestInformationJSON.quote.convertedAmount);\n\t\t\tconst estimateAmount = BigInt(estimate.convertedAmount);\n\t\t\tconst lowerBound = estimateAmount * BigInt(Math.round((1 - tolerance) * 100)) / 100n;\n\t\t\tconst upperBound = estimateAmount * BigInt(Math.round((1 + tolerance) * 100)) / 100n;\n\t\t\tif (quoteAmount > upperBound || quoteAmount < lowerBound) {\n\t\t\t\tthrow(new Error(`FX Quote amount: ${requestInformationJSON.quote.convertedAmount} differs more than tolerance limit: ${tolerance} from estimate`));\n\t\t\t}\n\t\t}\n\n\t\tthis.logger?.debug(`FX quote request successful, to provider ${serviceURL} for ${JSON.stringify(KeetaNetLib.Utils.Conversion.toJSONSerializable(this.conversion))}`);\n\t\tconst quoteJSON = requestInformationJSON.quote;\n\t\treturn({\n\t\t\trequest: this.#parseConversionRequest(quoteJSON.request),\n\t\t\taccount: KeetaNetLib.Account.fromPublicKeyString(quoteJSON.account),\n\t\t\tconvertedAmount: BigInt(quoteJSON.convertedAmount),\n\t\t\tcost: {\n\t\t\t\tamount: BigInt(quoteJSON.cost.amount),\n\t\t\t\ttoken: KeetaNetLib.Account.fromPublicKeyString(quoteJSON.cost.token)\n\t\t\t},\n\t\t\tsigned: quoteJSON.signed\n\t\t});\n\t}\n\n\tasync createExchange(input: { quote: KeetaFXAnchorQuote } | { estimate: KeetaFXAnchorEstimate; }, block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchange> {\n\t\tlet swapBlock = block;\n\t\tif (swapBlock === undefined) {\n\t\t\t/* Liquidity Provider that will complete the swap */\n\t\t\tlet liquidityProvider;\n\t\t\tlet request;\n\t\t\tlet convertedAmountBound: bigint;\n\n\t\t\tif ('estimate' in input) {\n\t\t\t\tif (input.estimate.requiresQuote !== false) {\n\t\t\t\t\tthrow(new FXErrors.QuoteRequired());\n\t\t\t\t}\n\n\t\t\t\tliquidityProvider = input.estimate.account;\n\t\t\t\trequest = input.estimate.request;\n\t\t\t\tif (input.estimate.convertedAmountBound !== undefined) {\n\t\t\t\t\tconvertedAmountBound = input.estimate.convertedAmountBound;\n\t\t\t\t} else {\n\t\t\t\t\tconvertedAmountBound = input.estimate.convertedAmount;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tliquidityProvider = input.quote.account;\n\t\t\t\trequest = input.quote.request;\n\t\t\t\tconvertedAmountBound = input.quote.convertedAmount;\n\t\t\t}\n\n\n\t\t\tlet sendAmount;\n\t\t\tlet receiveAmount;\n\n\t\t\tif (request.affinity === 'to') {\n\t\t\t\tsendAmount = convertedAmountBound;\n\t\t\t\treceiveAmount = request.amount;\n\t\t\t} else if (request.affinity === 'from') {\n\t\t\t\tsendAmount = request.amount;\n\t\t\t\treceiveAmount = convertedAmountBound;\n\t\t\t} else {\n\t\t\t\tthrow(new Error('Invalid affinity in conversion request'));\n\t\t\t}\n\n\t\t\t/* Construct the required operations for the swap request */\n\t\t\tconst builder = this.client.initBuilder();\n\n\t\t\tif ('quote' in input) {\n\t\t\t\t/* If cost is required then send the required amount as well */\n\t\t\t\tif (input.quote.cost.amount > 0) {\n\t\t\t\t\tbuilder.send(liquidityProvider, input.quote.cost.amount, input.quote.cost.token);\n\t\t\t\t}\n\t\t\t} else if ('estimate' in input) {\n\t\t\t\tif (input.estimate.expectedCost.max > 0) {\n\t\t\t\t\tbuilder.send(liquidityProvider, input.estimate.expectedCost.max, input.estimate.expectedCost.token);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbuilder.receive(liquidityProvider, receiveAmount, request.to, request.affinity === 'to');\n\t\t\tbuilder.send(liquidityProvider, sendAmount, request.from);\n\n\t\t\tconst blocks = await builder.computeBlocks();\n\t\t\tif (blocks.blocks.length !== 1) {\n\t\t\t\tthrow(new Error('Creating Swap Generated more than 1 block'));\n\t\t\t}\n\t\t\tswapBlock = blocks.blocks[0];\n\t\t}\n\n\t\tif (swapBlock == undefined) {\n\t\t\tthrow(new Error('User Swap Block is undefined'));\n\t\t}\n\n\t\tlet bodyAdditionalData: { quote: KeetaFXAnchorQuote; } | { request: ConversionInputCanonical; };\n\n\t\tif ('quote' in input) {\n\t\t\tbodyAdditionalData = { quote: input.quote };\n\t\t} else {\n\t\t\tbodyAdditionalData = { request: input.estimate.request };\n\t\t}\n\n\t\tconst serviceURL = (await this.serviceInfo.operations.createExchange)();\n\t\tconst requestInformation = await fetch(serviceURL, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'Accept': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\trequest: {\n\t\t\t\t\t...(KeetaNetLib.Utils.Conversion.toJSONSerializable(bodyAdditionalData)),\n\t\t\t\t\tblock: Buffer.from(swapBlock.toBytes()).toString('base64')\n\t\t\t\t}\n\t\t\t})\n\t\t});\n\n\t\tconst requestInformationJSON: unknown = await requestInformation.json();\n\n\t\t// Ensure status defaults to 'completed' if not provided (for backward compatibility)\n\t\tif (typeof requestInformationJSON === 'object' && requestInformationJSON !== null && !('status' in requestInformationJSON)) {\n\t\t\tObject.assign(requestInformationJSON, { status: 'completed' });\n\t\t\tObject.assign(requestInformationJSON, { blockhash: swapBlock.hash.toString() });\n\t\t}\n\n\t\t// Validate response\n\t\tif (!isKeetaFXAnchorExchangeResponse(requestInformationJSON)) {\n\t\t\tthrow(new Error(`Invalid response from FX exchange service: ${JSON.stringify(requestInformationJSON)}`));\n\t\t}\n\n\t\tif (!requestInformationJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(requestInformationJSON));\n\t\t}\n\n\t\tthis.logger?.debug(`FX exchange request successful, to provider ${serviceURL} for ${swapBlock.hash.toString()}`);\n\t\treturn(requestInformationJSON);\n\t}\n\n\tasync getExchangeStatus(exchangeID: string): Promise<KeetaFXAnchorExchange> {\n\t\tconst serviceURL = (await this.serviceInfo.operations.getExchangeStatus)({ id: exchangeID });\n\t\tconst requestInformation = await fetch(serviceURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t'Accept': 'application/json'\n\t\t\t}\n\t\t});\n\n\t\tconst requestInformationJSON: unknown = await requestInformation.json();\n\t\tif (!isKeetaFXAnchorExchangeResponse(requestInformationJSON)) {\n\t\t\tthrow(new Error(`Invalid response from FX exchange status service: ${JSON.stringify(requestInformationJSON)}`));\n\t\t}\n\n\t\tif (!requestInformationJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(requestInformationJSON));\n\t\t}\n\n\t\tthis.logger?.debug(`FX exchange status request successful, to provider ${serviceURL} for ${exchangeID}`);\n\t\treturn(requestInformationJSON);\n\t}\n\n\t/** @internal */\n\t_internals(accessToken: symbol) {\n\t\tif (accessToken !== KeetaFXAnchorClientAccessToken) {\n\t\t\tthrow(new Error('invalid access token'));\n\t\t}\n\n\t\treturn({\n\t\t\tparent: this.parent\n\t\t});\n\n\t}\n}\n\n/*\n * Various classes for the state machine:\n * Estimate(optional) -> Quote(optional) -> Exchange -> ExchangeStatus\n */\nclass KeetaFXAnchorExchangeWithProvider {\n\treadonly provider: KeetaFXAnchorProviderBase;\n\treadonly exchange: KeetaFXAnchorExchange\n\n\tconstructor(provider: KeetaFXAnchorProviderBase, exchange: KeetaFXAnchorExchange) {\n\t\tthis.provider = provider;\n\t\tthis.exchange = exchange;\n\t}\n\n\tasync getExchangeStatus(): Promise<KeetaFXAnchorExchange> {\n\t\t/* XXX:TODO: This should return something useful -- right now it just returns the exchange ID... */\n\t\treturn(await this.provider.getExchangeStatus(this.exchange.exchangeID));\n\t}\n}\n\ninterface CanCreateExchange {\n\treadonly isQuote: boolean;\n\n\tget request(): ConversionInputCanonical;\n\n\tcreateExchange(block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchangeWithProvider>;\n}\n\nclass KeetaFXAnchorQuoteWithProvider implements CanCreateExchange {\n\treadonly provider: KeetaFXAnchorProviderBase;\n\treadonly quote: KeetaFXAnchorQuote;\n\treadonly isQuote = true as const;\n\n\tconstructor(provider: KeetaFXAnchorProviderBase, quote: KeetaFXAnchorQuote) {\n\t\tthis.provider = provider;\n\t\tthis.quote = quote;\n\t}\n\n\tget request(): ConversionInputCanonical {\n\t\treturn(this.quote.request);\n\t}\n\n\tasync createExchange(block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchangeWithProvider> {\n\t\tconst exchange = await this.provider.createExchange({ quote: this.quote }, block);\n\t\treturn(new KeetaFXAnchorExchangeWithProvider(this.provider, exchange));\n\t}\n\n\t/**\n\t * Re-fetch the quote from the provider.\n\t *\n\t * @returns a new KeetaFXAnchorQuoteWithProvider with the updated quote\n\t */\n\tasync refetch(): Promise<KeetaFXAnchorQuoteWithProvider> {\n\t\tconst quote = await this.provider.getQuote();\n\t\treturn(new KeetaFXAnchorQuoteWithProvider(this.provider, quote));\n\t}\n}\n\nclass KeetaFXAnchorEstimateWithProvider implements CanCreateExchange {\n\treadonly provider: KeetaFXAnchorProviderBase;\n\treadonly estimate: KeetaFXAnchorEstimate;\n\treadonly isQuote = false as const;\n\n\tconstructor(provider: KeetaFXAnchorProviderBase, estimate: KeetaFXAnchorEstimate) {\n\t\tthis.provider = provider;\n\t\tthis.estimate = estimate;\n\t}\n\n\tget request(): ConversionInputCanonical {\n\t\treturn(this.estimate.request);\n\t}\n\n\tasync getQuote(tolerance?: number): Promise<KeetaFXAnchorQuoteWithProvider> {\n\t\tconst quote = await this.provider.getQuote(this.estimate, tolerance);\n\t\treturn(new KeetaFXAnchorQuoteWithProvider(this.provider, quote));\n\t}\n\n\tasync createExchange(block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchangeWithProvider> {\n\t\tconst exchange = await this.provider.createExchange({ estimate: this.estimate }, block);\n\t\treturn(new KeetaFXAnchorExchangeWithProvider(this.provider, exchange));\n\t}\n\n\t/**\n\t * Re-fetch the estimate from the provider.\n\t *\n\t * @returns a new KeetaFXAnchorEstimateWithProvider with the updated estimate\n\t */\n\tasync refetch(): Promise<KeetaFXAnchorEstimateWithProvider> {\n\t\tconst estimate = await this.provider.getEstimate();\n\t\treturn(new KeetaFXAnchorEstimateWithProvider(this.provider, estimate));\n\t}\n}\n\nclass KeetaFXAnchorClient extends KeetaFXAnchorBase {\n\treadonly resolver: Resolver;\n\treadonly id: string;\n\treadonly #signer: InstanceType<typeof KeetaNetLib.Account>;\n\treadonly #account: InstanceType<typeof KeetaNetLib.Account>;\n\n\tconstructor(client: KeetaNetUserClient, config: KeetaFXAnchorClientConfig = {}) {\n\t\tsuper({ client, logger: config.logger });\n\t\tthis.resolver = config.resolver ?? getDefaultResolver(client, config);\n\t\tthis.id = config.id ?? crypto.randomUUID();\n\n\t\tif (config.signer) {\n\t\t\tthis.#signer = config.signer;\n\t\t} else if ('signer' in client && client.signer !== null) {\n\t\t\tthis.#signer = client.signer;\n\t\t} else if ('account' in client && client.account.hasPrivateKey) {\n\t\t\tthis.#signer = client.account;\n\t\t} else {\n\t\t\tthrow(new Error('KeetaFXAnchorClient requires a Signer or a UserClient with an associated Signer'));\n\t\t}\n\n\t\tif (config.account) {\n\t\t\tthis.#account = config.account;\n\t\t} else if ('account' in client) {\n\t\t\tthis.#account = client.account;\n\t\t} else {\n\t\t\tthrow(new Error('KeetaFXAnchorClient requires an Account or a UserClient with an associated Account'));\n\t\t}\n\t}\n\n\tprivate async canonicalizeConversionTokens(input: Partial<ConversionInput>): Promise<Partial<Pick<ConversionInputCanonical, 'from' | 'to'>>> {\n\t\tlet from = {}\n\t\tif (input.from !== undefined) {\n\t\t\tlet fromToken: ConversionInputCanonical['from'];\n\t\t\tif (KeetaNetLib.Account.isInstance(input.from) && input.from.isToken()) {\n\t\t\t\tfromToken = input.from;\n\t\t\t} else {\n\t\t\t\tconst tokenLookup = await this.resolver.lookupToken(input.from);\n\t\t\t\tif (tokenLookup === null) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\t\tthrow(new Error(`Could not convert from: ${input.from} to a token address`));\n\t\t\t\t}\n\t\t\t\tfromToken = KeetaNetLib.Account.fromPublicKeyString(tokenLookup.token);\n\t\t\t}\n\t\t\tfrom = { from: fromToken };\n\t\t}\n\n\t\tlet to = {};\n\t\tif (input.to !== undefined) {\n\t\t\tlet toToken: ConversionInputCanonical['to'];\n\t\t\tif (KeetaNetLib.Account.isInstance(input.to) && input.to.isToken()) {\n\t\t\t\ttoToken = input.to;\n\t\t\t} else {\n\t\t\t\tconst tokenLookup = await this.resolver.lookupToken(input.to);\n\t\t\t\tif (tokenLookup === null) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\t\tthrow(new Error(`Could not convert to: ${input.to} to a token address`));\n\t\t\t\t}\n\t\t\t\ttoToken = KeetaNetLib.Account.fromPublicKeyString(tokenLookup.token);\n\t\t\t}\n\t\t\tto = { to: toToken };\n\t\t}\n\t\treturn({ ...from, ...to });\n\t}\n\n\tprivate async canonicalizeConversionInput(input: ConversionInput): Promise<ConversionInputCanonical> {\n\t\tconst amount = BigInt(input.amount);\n\t\tif (amount < 0) {\n\t\t\tthrow(new Error('Invalid Conversion Amount'));\n\t\t}\n\n\t\tconst { from, to } = await this.canonicalizeConversionTokens(input);\n\n\t\tif (from === undefined || to === undefined) {\n\t\t\tthrow(new Error('From and To are both required for a conversion'));\n\t\t}\n\n\t\treturn({\n\t\t\tfrom,\n\t\t\tto,\n\t\t\tamount: amount,\n\t\t\taffinity: input.affinity\n\t\t});\n\t}\n\n\tasync listPossibleConversions(input: Partial<Pick<ConversionInput, 'from' | 'to'>>, options: AccountOptions = {}, sharedCriteria?: SharedLookupCriteria): Promise<{ conversions: KeetaNetTokenPublicKeyString[] } | null> {\n\t\tif (input.from !== undefined && input.to !== undefined) {\n\t\t\tthrow(new KeetaAnchorUserError('Only one of from or two should be provided'));\n\t\t}\n\t\tif (input.from === undefined && input.to === undefined) {\n\t\t\tthrow(new KeetaAnchorUserError('At least one of from or two should be provided'));\n\t\t}\n\t\tconst conversion = await this.canonicalizeConversionTokens(input);\n\t\tconst account = options.account ?? this.#account;\n\t\tconst providerEndpoints = await getEndpoints(this.resolver, conversion, account, sharedCriteria);\n\t\tif (providerEndpoints === null) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst conversions = new Set<KeetaNetTokenPublicKeyString>();\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\tfor (const [_ignored_providerID, serviceInfo] of typedFxServiceEntries(providerEndpoints)) {\n\t\t\tfor (const conversionPair of serviceInfo.from) {\n\t\t\t\tif (conversion.from !== undefined) {\n\t\t\t\t\tif (conversionPair.currencyCodes.includes(conversion.from.publicKeyString.get())) {\n\t\t\t\t\t\tconversionPair.to.forEach((token) => {\n\t\t\t\t\t\t\tif (conversion.from?.publicKeyString.get() !== token) {\n\t\t\t\t\t\t\t\tconversions.add(token);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else if (conversion.to !== undefined) {\n\t\t\t\t\tif (conversionPair.to.includes(conversion.to.publicKeyString.get())) {\n\t\t\t\t\t\tconversionPair.currencyCodes.forEach((token) => {\n\t\t\t\t\t\t\tif (conversion.to?.publicKeyString.get() !== token) {\n\t\t\t\t\t\t\t\tconversions.add(token);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\treturn({ conversions: [...conversions] });\n\t}\n\n\tasync getBaseProvidersForConversion(request: ConversionInput, options: AccountOptions = {}, sharedCriteria?: SharedLookupCriteria): Promise<KeetaFXAnchorProviderBase[] | null> {\n\t\tconst conversion = await this.canonicalizeConversionInput(request);\n\t\tconst account = options.account ?? this.#account;\n\t\tconst providerEndpoints = await getEndpoints(this.resolver, conversion, account, sharedCriteria);\n\t\tif (providerEndpoints === null) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst providers = typedFxServiceEntries(providerEndpoints).map(([providerID, serviceInfo]) => {\n\t\t\treturn(new KeetaFXAnchorProviderBase(serviceInfo, providerID, conversion, this));\n\t\t});\n\n\t\treturn(providers);\n\t}\n\n\tasync getEstimates(request: ConversionInput, options: AccountOptions = {}, sharedCriteria?: SharedLookupCriteria): Promise<KeetaFXAnchorEstimateWithProvider[] | null> {\n\t\tconst estimateProviders = await this.getBaseProvidersForConversion(request, options, sharedCriteria);\n\t\tif (estimateProviders === null) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst estimates = await Promise.allSettled(estimateProviders.map(async (provider) => {\n\t\t\tconst estimate = await provider.getEstimate();\n\n\t\t\treturn(new KeetaFXAnchorEstimateWithProvider(provider, estimate));\n\t\t}));\n\n\t\tconst results = estimates.filter(function(result) {\n\t\t\treturn(result.status === 'fulfilled');\n\t\t}).map(function(result) {\n\t\t\treturn(result.value);\n\t\t});\n\n\t\tif (results.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\treturn(results);\n\t}\n\n\tasync #multiRequestQuotes(request: ConversionInput, options: AccountOptions = {}, sharedCriteria?: SharedLookupCriteria): Promise<({\n\t\tprovider: KeetaFXAnchorProviderBase;\n\t} & ({\n\t\tquote: KeetaFXAnchorQuoteWithProvider;\n\t} | {\n\t\tquote: null;\n\t\terror: unknown;\n\t}))[]> {\n\t\tconst estimateProviders = await this.getBaseProvidersForConversion(request, options, sharedCriteria);\n\t\tif (estimateProviders === null) {\n\t\t\treturn([]);\n\t\t}\n\n\t\treturn(await Promise.all(estimateProviders.map(async (provider) => {\n\t\t\ttry {\n\t\t\t\tconst quote = await provider.getQuote();\n\t\t\t\treturn({ provider, quote: new KeetaFXAnchorQuoteWithProvider(provider, quote) });\n\t\t\t} catch (error) {\n\t\t\t\treturn({ provider, quote: null, error });\n\t\t\t}\n\t\t})));\n\t}\n\n\tasync getQuotes(request: ConversionInput, options: AccountOptions = {}, sharedCriteria?: SharedLookupCriteria): Promise<KeetaFXAnchorQuoteWithProvider[] | null> {\n\t\tconst quotes = await this.#multiRequestQuotes(request, options, sharedCriteria);\n\n\t\tconst results = quotes\n\t\t\t.map(function(quote) {\n\t\t\t\treturn(quote.quote);\n\t\t\t})\n\t\t\t.filter(function(quote): quote is KeetaFXAnchorQuoteWithProvider {\n\t\t\t\treturn(quote !== null);\n\t\t\t});\n\n\t\tif (results.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\treturn(results);\n\t}\n\n\tasync getQuotesOrEstimates(request: ConversionInput, options: AccountOptions = {}, sharedCriteria?: SharedLookupCriteria): Promise<(KeetaFXAnchorQuoteWithProvider | KeetaFXAnchorEstimateWithProvider)[] | null> {\n\t\tconst quotesAndEstimates = await this.#multiRequestQuotes(request, options, sharedCriteria);\n\n\t\tconst results = await Promise.allSettled(quotesAndEstimates.map(async (provider) => {\n\t\t\tif (provider.quote) {\n\t\t\t\treturn(provider.quote);\n\t\t\t} else {\n\t\t\t\tif (!(FXErrors.QuoteIssuanceDisabled.isInstance(provider.error))) {\n\t\t\t\t\tthrow(provider.error);\n\t\t\t\t}\n\n\t\t\t\tconst estimate = await provider.provider.getEstimate();\n\t\t\t\treturn(new KeetaFXAnchorEstimateWithProvider(provider.provider, estimate));\n\t\t\t}\n\t\t}));\n\n\t\tconst filtered = results.filter(function(result) {\n\t\t\treturn(result.status === 'fulfilled');\n\t\t}).map(function(result) {\n\t\t\treturn(result.value);\n\t\t});\n\n\t\treturn(filtered);\n\t}\n\n\t/** @internal */\n\t_internals(accessToken: symbol) {\n\t\tif (accessToken !== KeetaFXAnchorClientAccessToken) {\n\t\t\tthrow(new Error('invalid access token'));\n\t\t}\n\n\t\treturn({\n\t\t\tresolver: this.resolver,\n\t\t\tlogger: this.logger,\n\t\t\tclient: this.client,\n\t\t\tsigner: this.#signer,\n\t\t\taccount: this.#account\n\t\t});\n\n\t}\n}\n\nexport default KeetaFXAnchorClient;\n"]}