@keetanetwork/anchor 0.0.111 → 0.0.113

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 (81) hide show
  1. package/lib/chaining.d.ts +8 -0
  2. package/lib/chaining.d.ts.map +1 -1
  3. package/lib/chaining.js +111 -3
  4. package/lib/chaining.js.map +1 -1
  5. package/lib/http-server/common.d.ts +3 -2
  6. package/lib/http-server/common.d.ts.map +1 -1
  7. package/lib/http-server/common.js +9 -13
  8. package/lib/http-server/common.js.map +1 -1
  9. package/lib/http-server/index.d.ts +21 -1
  10. package/lib/http-server/index.d.ts.map +1 -1
  11. package/lib/http-server/index.js +84 -36
  12. package/lib/http-server/index.js.map +1 -1
  13. package/lib/http-server/replay-guard.d.ts +29 -0
  14. package/lib/http-server/replay-guard.d.ts.map +1 -0
  15. package/lib/http-server/replay-guard.js +58 -0
  16. package/lib/http-server/replay-guard.js.map +1 -0
  17. package/lib/http-server/request-signing.d.ts +53 -0
  18. package/lib/http-server/request-signing.d.ts.map +1 -0
  19. package/lib/http-server/request-signing.js +130 -0
  20. package/lib/http-server/request-signing.js.map +1 -0
  21. package/lib/queue/drivers/queue_postgres.d.ts +7 -1
  22. package/lib/queue/drivers/queue_postgres.d.ts.map +1 -1
  23. package/lib/queue/drivers/queue_postgres.js +12 -4
  24. package/lib/queue/drivers/queue_postgres.js.map +1 -1
  25. package/lib/utils/signing.d.ts +5 -0
  26. package/lib/utils/signing.d.ts.map +1 -1
  27. package/lib/utils/signing.js +6 -1
  28. package/lib/utils/signing.js.map +1 -1
  29. package/npm-shrinkwrap.json +2 -2
  30. package/package.json +1 -1
  31. package/services/asset-movement/client.d.ts +5 -4
  32. package/services/asset-movement/client.d.ts.map +1 -1
  33. package/services/asset-movement/client.js +27 -13
  34. package/services/asset-movement/client.js.map +1 -1
  35. package/services/asset-movement/common.generated.js +1 -1
  36. package/services/asset-movement/common.server.generated.js +50 -50
  37. package/services/asset-movement/server.d.ts.map +1 -1
  38. package/services/asset-movement/server.js +22 -4
  39. package/services/asset-movement/server.js.map +1 -1
  40. package/services/fx/client.d.ts +91 -13
  41. package/services/fx/client.d.ts.map +1 -1
  42. package/services/fx/client.js +328 -98
  43. package/services/fx/client.js.map +1 -1
  44. package/services/fx/common.d.ts +16 -0
  45. package/services/fx/common.d.ts.map +1 -1
  46. package/services/fx/common.js +44 -1
  47. package/services/fx/common.js.map +1 -1
  48. package/services/fx/server.d.ts.map +1 -1
  49. package/services/fx/server.js +45 -38
  50. package/services/fx/server.js.map +1 -1
  51. package/services/kyc/client.d.ts +8 -3
  52. package/services/kyc/client.d.ts.map +1 -1
  53. package/services/kyc/client.js +24 -23
  54. package/services/kyc/client.js.map +1 -1
  55. package/services/kyc/common.d.ts +0 -7
  56. package/services/kyc/common.d.ts.map +1 -1
  57. package/services/kyc/common.js +0 -8
  58. package/services/kyc/common.js.map +1 -1
  59. package/services/kyc/server.d.ts +3 -1
  60. package/services/kyc/server.d.ts.map +1 -1
  61. package/services/kyc/server.js +15 -33
  62. package/services/kyc/server.js.map +1 -1
  63. package/services/notification/client.d.ts.map +1 -1
  64. package/services/notification/client.js +39 -33
  65. package/services/notification/client.js.map +1 -1
  66. package/services/notification/server.js +10 -10
  67. package/services/notification/server.js.map +1 -1
  68. package/services/storage/client.d.ts +3 -0
  69. package/services/storage/client.d.ts.map +1 -1
  70. package/services/storage/client.js +41 -11
  71. package/services/storage/client.js.map +1 -1
  72. package/services/storage/server.d.ts.map +1 -1
  73. package/services/storage/server.js +12 -11
  74. package/services/storage/server.js.map +1 -1
  75. package/services/username/client.d.ts +12 -1
  76. package/services/username/client.d.ts.map +1 -1
  77. package/services/username/client.js +36 -30
  78. package/services/username/client.js.map +1 -1
  79. package/services/username/server.d.ts.map +1 -1
  80. package/services/username/server.js +7 -6
  81. package/services/username/server.js.map +1 -1
@@ -396,6 +396,38 @@ class KeetaFXAnchorQuoteIssuanceDisabledError extends KeetaAnchorUserError {
396
396
  return (error);
397
397
  }
398
398
  }
399
+ class KeetaFXAnchorResponseMismatchError extends KeetaAnchorUserError {
400
+ static name = 'KeetaFXAnchorResponseMismatchError';
401
+ KeetaFXAnchorResponseMismatchErrorObjectTypeID;
402
+ static KeetaFXAnchorResponseMismatchErrorObjectTypeID = '3c6b1e52-8f0d-4a97-b2e4-71d95c0a6f38';
403
+ constructor(message) {
404
+ super(message ?? 'FX provider response does not match the request');
405
+ this.statusCode = 502;
406
+ Object.defineProperty(this, 'KeetaFXAnchorResponseMismatchErrorObjectTypeID', {
407
+ value: KeetaFXAnchorResponseMismatchError.KeetaFXAnchorResponseMismatchErrorObjectTypeID,
408
+ enumerable: false
409
+ });
410
+ }
411
+ static isInstance(input) {
412
+ return (this.hasPropWithValue(input, 'KeetaFXAnchorResponseMismatchErrorObjectTypeID', KeetaFXAnchorResponseMismatchError.KeetaFXAnchorResponseMismatchErrorObjectTypeID));
413
+ }
414
+ }
415
+ class KeetaFXAnchorExchangeLimitExceededError extends KeetaAnchorUserError {
416
+ static name = 'KeetaFXAnchorExchangeLimitExceededError';
417
+ KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID;
418
+ static KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID = 'd2a47f90-5c1b-4e38-9a6d-0b8e3f71c5a4';
419
+ constructor(message) {
420
+ super(message ?? 'FX exchange exceeds the limits set by the caller');
421
+ this.statusCode = 400;
422
+ Object.defineProperty(this, 'KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID', {
423
+ value: KeetaFXAnchorExchangeLimitExceededError.KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID,
424
+ enumerable: false
425
+ });
426
+ }
427
+ static isInstance(input) {
428
+ return (this.hasPropWithValue(input, 'KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID', KeetaFXAnchorExchangeLimitExceededError.KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID));
429
+ }
430
+ }
399
431
  export const Errors = {
400
432
  /**
401
433
  * The quote validation failed
@@ -408,6 +440,17 @@ export const Errors = {
408
440
  /**
409
441
  * The anchor cannot issue quotes
410
442
  */
411
- QuoteIssuanceDisabled: KeetaFXAnchorQuoteIssuanceDisabledError
443
+ QuoteIssuanceDisabled: KeetaFXAnchorQuoteIssuanceDisabledError,
444
+ /**
445
+ * The FX provider answered with terms that do not match the request:
446
+ * another conversion, a fee in a token the client does not accept, or
447
+ * an estimate bound on the wrong side of its converted amount
448
+ */
449
+ ResponseMismatch: KeetaFXAnchorResponseMismatchError,
450
+ /**
451
+ * The exchange would send, receive, or charge more than the limits the
452
+ * caller gave to `createExchange`
453
+ */
454
+ ExchangeLimitExceeded: KeetaFXAnchorExchangeLimitExceededError
412
455
  };
413
456
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/services/fx/common.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAInE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAgB5B;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA6B;IAC7D,IAAI,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAM,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED,OAAM,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;AACrH,CAAC;AAgRD,MAAM,CAAC,MAAM,+BAA+B;;;;;;;;;;;;;;sFAAwG,CAAC;AACrJ,MAAM,CAAC,MAAM,4BAA4B;;;;;;;sFAAkG,CAAC;AAC5I,MAAM,CAAC,MAAM,+BAA+B;;;;;;;;;;sFAAwG,CAAC;AACrJ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C3B,KAAK,CAAC,OAAO,IAAI,4BAA4B,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QAEtB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qDAAqD,EAAE;YAClF,KAAK,EAAE,uCAAuC,CAAC,mDAAmD;YAClG,UAAU,EAAE,KAAK;SACjB,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,KAAc;QAC/B,OAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,qDAAqD,EAAE,uCAAuC,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAC1L,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAc;QACnC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACpE,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAM,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;;AAGF,MAAM,CAAC,MAAM,MAAM,GAIf;IACH;;OAEG;IACH,qBAAqB,EAAE,uCAAuC;IAE9D;;OAEG;IACH,aAAa,EAAE,+BAA+B;IAE9C;;OAEG;IACH,qBAAqB,EAAE,uCAAuC;CAC9D,CAAC","sourcesContent":["import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\n\nimport type { ServiceSearchCriteria } from '../../lib/resolver.js';\nimport type { ToJSONSerializable } from '../../lib/utils/json.js';\nimport { createAssert, createIs } from 'typia';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport type { HTTPSignedField } from '../../lib/http-server/common.js';\nimport type {\n\tKeetaNetAccount,\n\tKeetaNetStorageAccount,\n\tKeetaNetToken,\n\tKeetaNetTokenPublicKeyString\n} from '../../lib/asset.js';\n\nexport type {\n\tKeetaNetAccount,\n\tKeetaNetStorageAccount,\n\tKeetaNetToken,\n\tKeetaNetTokenPublicKeyString\n} from '../../lib/asset.js';\n\n/**\n * Parses a cost token from its serialized public key string form,\n * reconstituting a KeetaNetToken instance.\n */\nexport function parseFXCostToken(input: KeetaNetToken | string): KeetaNetToken {\n\tif (KeetaNetLib.Account.isInstance(input)) {\n\t\treturn(input);\n\t}\n\n\treturn(KeetaNetLib.Account.fromPublicKeyString(input).assertKeyType(KeetaNetLib.Account.AccountKeyAlgorithm.TOKEN));\n}\n\nexport type ConversionInput = {\n\t/**\n\t * The currency code to convert from (i.e., what the user has).\n\t */\n\tfrom: ServiceSearchCriteria<'fx'>['inputCurrencyCode'] | KeetaNetToken;\n\t/**\n\t * The currency code to convert to (i.e., what the user wants).\n\t */\n\tto: ServiceSearchCriteria<'fx'>['outputCurrencyCode'] | KeetaNetToken;\n\t/**\n\t * The amount to convert. This is a bigint representing the\n\t * amount in the currency specified by either `from` or `to`, as\n\t * specified by the `affinity` property.\n\t */\n\tamount: bigint;\n\t/**\n\t * Indicates whether the amount specified is in terms of the `from`\n\t * currency (i.e., the user has this much) or the `to` currency\n\t * (i.e., the user wants this much).\n\t */\n\taffinity: 'from' | 'to';\n\n\t/**\n\t * Optional preferred token in which the fee/cost should be\n\t * denominated. Must be one of the operator's advertised\n\t * acceptedCostAssets, if specified.\n\t */\n\tpreferredCostAsset?: KeetaNetTokenPublicKeyString;\n};\n\nexport type ConversionInputCanonical = {\n\t[k in keyof ConversionInput]: k extends 'amount' ? bigint : k extends 'from' ? KeetaNetToken : k extends 'to' ? KeetaNetToken : ConversionInput[k] extends undefined ? never : ConversionInput[k];\n};\n\nexport type ConversionInputCanonicalJSON = ToJSONSerializable<ConversionInputCanonical>;\n\nexport type KeetaFXAnchorClientCreateExchangeRequest = {\n\tblock: InstanceType<typeof KeetaNetLib.Block>;\n} & ({\n\tquote: KeetaFXAnchorQuote;\n} | {\n\trequest: ConversionInputCanonical;\n});\n\nexport type KeetaFXAnchorClientCreateExchangeRequestJSON = {\n\tblock: string;\n} & ({\n\tquote: KeetaFXAnchorQuoteJSON;\n\trequest?: undefined;\n} | {\n\tquote?: undefined;\n\trequest: ConversionInputCanonicalJSON;\n})\n\nexport type KeetaFXAnchorEstimate = {\n\t/**\n\t * Conversion request that was provided\n\t */\n\trequest: ConversionInputCanonical;\n\n\t/**\n\t * Amount after the conversion as specified by either `from` or `to`, as specified by the `affinity` property in the request.\n\t */\n\tconvertedAmount: bigint;\n\n\t/**\n\t * Outer bound of the converted amount.\n\t * if affinity is 'to', this is the maximum amount the user would need to send, if its 'from', this is the minimum amount the user would receive.\n\t */\n\tconvertedAmountBound?: bigint;\n\n\t/**\n\t * The expected cost of the fx request, in the form of a\n\t * token and a range of minimum and maximum expected costs\n\t */\n\texpectedCost: {\n\t\tmin: bigint;\n\t\tmax: bigint;\n\t\ttoken: KeetaNetToken;\n\t};\n} & (\n\t{\n\t\t/**\n\t\t * Indicates that the exchange cannot be performed if false, and no quote can be issued\n\t\t */\n\t\tcanPerformExchange: false;\n\t} | ({\n\t\t/**\n\t\t * Indicates that the exchange can be performed if true or undefined, but a quote may or may not be required before proceeding with the exchange\n\t\t */\n\t\tcanPerformExchange?: true;\n\t} & ({\n\t\t/**\n\t\t * Indicates that a quote is required before proceeding with the exchange\n\t\t */\n\t\trequiresQuote: false;\n\n\t\t/**\n\t\t * Liquidity provider account if the user is not going to request a quote before the exchange\n\t\t */\n\t\taccount: KeetaNetAccount | KeetaNetStorageAccount;\n\t} | {\n\t\t/**\n\t\t * Indicates that a quote is required before proceeding with the exchange, defaults to true\n\t\t */\n\t\trequiresQuote?: true;\n\t}))\n);\n\nexport type KeetaFXAnchorEstimateResponse = ({\n\tok: true;\n\testimate: ToJSONSerializable<KeetaFXAnchorEstimate>;\n} | {\n\tok: false;\n\terror: string;\n});\n\nexport type KeetaFXAnchorMarketPriceRatio = {\n\t/**\n\t * Amount of the base (destination) token in the price ratio\n\t */\n\tbase: string;\n\t/**\n\t * Amount of the quote (source) token in the price ratio\n\t */\n\tquote: string;\n};\n\nexport type KeetaFXAnchorMarketPricesRequest = {\n\t/**\n\t * Source tokens to price against the base asset\n\t */\n\tquoteAssets: KeetaNetTokenPublicKeyString[];\n\t/**\n\t * Destination token against which quote asset prices are expressed\n\t */\n\tbase: KeetaNetTokenPublicKeyString;\n};\n\nexport type KeetaFXAnchorMarketPrices = {\n\t/**\n\t * The destination token against which quote asset prices are expressed\n\t */\n\tbase: KeetaNetTokenPublicKeyString;\n\t/**\n\t * Current market prices for each requested quote asset, keyed by token public key\n\t */\n\tquoteAssets: {\n\t\t[quoteAsset in KeetaNetTokenPublicKeyString]?: {\n\t\t\tvalueRatio: KeetaFXAnchorMarketPriceRatio;\n\t\t};\n\t};\n};\n\nexport type KeetaFXAnchorMarketPricesResponse = ({\n\tok: true;\n} & KeetaFXAnchorMarketPrices) | {\n\tok: false;\n\terror: string;\n};\n\nexport type KeetaFXAnchorQuote = {\n\t/**\n\t * Conversion request that was provided\n\t */\n\trequest: ConversionInputCanonical;\n\n\t/**\n\t * The public key of the liquidity provider account\n\t */\n\taccount: KeetaNetAccount | KeetaNetStorageAccount;\n\n\t/**\n\t * Amount after the conversion as specified by either `from` or `to`, as specified by the `affinity` property in the request.\n\t */\n\tconvertedAmount: bigint;\n\n\t/**\n\t * The cost of the fx request, in the form of a\n\t * token and amount that should be included with the swap\n\t */\n\tcost: {\n\t\tamount: bigint;\n\t\ttoken: KeetaNetToken;\n\t};\n\n\t/**\n\t * Signature information to verify the quote\n\t */\n\tsigned: HTTPSignedField;\n};\n\nexport type KeetaFXAnchorQuoteJSON = ToJSONSerializable<KeetaFXAnchorQuote>;\n\nexport type KeetaFXAnchorQuoteResponse = ({\n\tok: true;\n\tquote: ToJSONSerializable<KeetaFXAnchorQuote>\n} | {\n\tok: false;\n\terror: string;\n});\n\n/**\n * Transport summary of a completed exchange's conversion, sufficient to\n * reconstruct the swap without re-reading the on-chain blocks.\n */\nexport type KeetaFXAnchorConversionSummary = {\n\t/**\n\t * Token and amount the user sent (the principal being converted from).\n\t */\n\tfrom: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n\t/**\n\t * Token and amount the user received (the converted-to currency).\n\t */\n\tto: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n\t/**\n\t * Liquidity provider account that settled the exchange.\n\t */\n\tliquidityProvider: string;\n\t/**\n\t * Fee charged for the exchange, when the server computed it.\n\t */\n\tcost?: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n};\n\nexport type KeetaFXAnchorExchange = {\n\t/**\n\t * ID used to identify the conversion request\n\t */\n\texchangeID: string\n} & ({\n\t/**\n\t * Status of the exchange request\n\t */\n\tstatus: 'pending' | 'failed';\n} | {\n\t/**\n\t * Status of the exchange request\n\t */\n\tstatus: 'completed';\n\t/**\n\t * Blockhash where the exchange was completed -- the user-supplied\n\t * blockhash for their portion of the exchange transaction can be\n\t * used to look up the transaction on-chain as well, but we return\n\t * a value here so that it can be looked up without needing to store\n\t * that initial block.\n\t */\n\tblockhash: string;\n\t/**\n\t * Summary of the conversion that settled, when the server recorded it.\n\t */\n\tconversion?: KeetaFXAnchorConversionSummary;\n});\n\nexport type KeetaFXAnchorExchangeResponse = (KeetaFXAnchorExchange & {\n\tok: true;\n}) | (Partial<KeetaFXAnchorExchange> & {\n\tok: false;\n\terror: string;\n});\n\nexport const isKeetaFXAnchorEstimateResponse: (input: unknown) => input is KeetaFXAnchorEstimateResponse = createIs<KeetaFXAnchorEstimateResponse>();\nexport const isKeetaFXAnchorQuoteResponse: (input: unknown) => input is KeetaFXAnchorQuoteResponse = createIs<KeetaFXAnchorQuoteResponse>();\nexport const isKeetaFXAnchorExchangeResponse: (input: unknown) => input is KeetaFXAnchorExchangeResponse = createIs<KeetaFXAnchorExchangeResponse>();\nexport const isKeetaFXAnchorMarketPricesResponse: (input: unknown) => input is KeetaFXAnchorMarketPricesResponse = createIs<KeetaFXAnchorMarketPricesResponse>();\nexport const assertKeetaNetTokenPublicKeyString: (input: unknown) => KeetaNetTokenPublicKeyString = createAssert<KeetaNetTokenPublicKeyString>();\nexport const assertConversionInputCanonicalJSON: (input: unknown) => ConversionInputCanonicalJSON = createAssert<ConversionInputCanonicalJSON>();\nexport const assertKeetaFXAnchorClientCreateExchangeRequestJSON: (input: unknown) => KeetaFXAnchorClientCreateExchangeRequestJSON = createAssert<KeetaFXAnchorClientCreateExchangeRequestJSON>();\n\nclass KeetaFXAnchorQuoteValidationFailedError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteValidationFailedError';\n\tprivate readonly KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID = 'a8f3c2d1-9b4e-4f2a-8c1d-5e6f7a8b9c0d';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Quote validation failed');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteValidationFailedError.KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteValidationFailedError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID', KeetaFXAnchorQuoteValidationFailedError.KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorQuoteRequiredError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteRequiredError';\n\tprivate readonly KeetaFXAnchorQuoteRequiredErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteRequiredErrorObjectTypeID = '9f22067f-52b3-40f2-84c1-ad9285260980';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Quote required to perform exchange');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteRequiredErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteRequiredError.KeetaFXAnchorQuoteRequiredErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteRequiredError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteRequiredErrorObjectTypeID', KeetaFXAnchorQuoteRequiredError.KeetaFXAnchorQuoteRequiredErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorQuoteIssuanceDisabledError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteIssuanceDisabledError';\n\tprivate readonly KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID = 'a0f70c0b-6e17-41f0-825a-d086983209e1';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Anchor cannot issue quotes');\n\t\tthis.statusCode = 501;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteIssuanceDisabledError.KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteIssuanceDisabledError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID', KeetaFXAnchorQuoteIssuanceDisabledError.KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nexport const Errors: {\n\tQuoteValidationFailed: typeof KeetaFXAnchorQuoteValidationFailedError;\n\tQuoteRequired: typeof KeetaFXAnchorQuoteRequiredError;\n\tQuoteIssuanceDisabled: typeof KeetaFXAnchorQuoteIssuanceDisabledError;\n} = {\n\t/**\n\t * The quote validation failed\n\t */\n\tQuoteValidationFailed: KeetaFXAnchorQuoteValidationFailedError,\n\n\t/**\n\t * Quote is required to perform the exchange\n\t */\n\tQuoteRequired: KeetaFXAnchorQuoteRequiredError,\n\n\t/**\n\t * The anchor cannot issue quotes\n\t */\n\tQuoteIssuanceDisabled: KeetaFXAnchorQuoteIssuanceDisabledError\n};\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/services/fx/common.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAInE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAgB5B;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA6B;IAC7D,IAAI,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAM,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED,OAAM,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,a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SearchCriteria } from '../../lib/resolver.js';\nimport type { ToJSONSerializable } from '../../lib/utils/json.js';\nimport { createAssert, createIs } from 'typia';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport type { HTTPSignedField } from '../../lib/http-server/common.js';\nimport type {\n\tKeetaNetAccount,\n\tKeetaNetStorageAccount,\n\tKeetaNetToken,\n\tKeetaNetTokenPublicKeyString\n} from '../../lib/asset.js';\n\nexport type {\n\tKeetaNetAccount,\n\tKeetaNetStorageAccount,\n\tKeetaNetToken,\n\tKeetaNetTokenPublicKeyString\n} from '../../lib/asset.js';\n\n/**\n * Parses a cost token from its serialized public key string form,\n * reconstituting a KeetaNetToken instance.\n */\nexport function parseFXCostToken(input: KeetaNetToken | string): KeetaNetToken {\n\tif (KeetaNetLib.Account.isInstance(input)) {\n\t\treturn(input);\n\t}\n\n\treturn(KeetaNetLib.Account.fromPublicKeyString(input).assertKeyType(KeetaNetLib.Account.AccountKeyAlgorithm.TOKEN));\n}\n\nexport type ConversionInput = {\n\t/**\n\t * The currency code to convert from (i.e., what the user has).\n\t */\n\tfrom: ServiceSearchCriteria<'fx'>['inputCurrencyCode'] | KeetaNetToken;\n\t/**\n\t * The currency code to convert to (i.e., what the user wants).\n\t */\n\tto: ServiceSearchCriteria<'fx'>['outputCurrencyCode'] | KeetaNetToken;\n\t/**\n\t * The amount to convert. This is a bigint representing the\n\t * amount in the currency specified by either `from` or `to`, as\n\t * specified by the `affinity` property.\n\t */\n\tamount: bigint;\n\t/**\n\t * Indicates whether the amount specified is in terms of the `from`\n\t * currency (i.e., the user has this much) or the `to` currency\n\t * (i.e., the user wants this much).\n\t */\n\taffinity: 'from' | 'to';\n\n\t/**\n\t * Optional preferred token in which the fee/cost should be\n\t * denominated. Must be one of the operator's advertised\n\t * acceptedCostAssets, if specified.\n\t */\n\tpreferredCostAsset?: KeetaNetTokenPublicKeyString;\n};\n\nexport type ConversionInputCanonical = {\n\t[k in keyof ConversionInput]: k extends 'amount' ? bigint : k extends 'from' ? KeetaNetToken : k extends 'to' ? KeetaNetToken : ConversionInput[k] extends undefined ? never : ConversionInput[k];\n};\n\nexport type ConversionInputCanonicalJSON = ToJSONSerializable<ConversionInputCanonical>;\n\nexport type KeetaFXAnchorClientCreateExchangeRequest = {\n\tblock: InstanceType<typeof KeetaNetLib.Block>;\n} & ({\n\tquote: KeetaFXAnchorQuote;\n} | {\n\trequest: ConversionInputCanonical;\n});\n\nexport type KeetaFXAnchorClientCreateExchangeRequestJSON = {\n\tblock: string;\n} & ({\n\tquote: KeetaFXAnchorQuoteJSON;\n\trequest?: undefined;\n} | {\n\tquote?: undefined;\n\trequest: ConversionInputCanonicalJSON;\n})\n\nexport type KeetaFXAnchorEstimate = {\n\t/**\n\t * Conversion request that was provided\n\t */\n\trequest: ConversionInputCanonical;\n\n\t/**\n\t * Amount after the conversion as specified by either `from` or `to`, as specified by the `affinity` property in the request.\n\t */\n\tconvertedAmount: bigint;\n\n\t/**\n\t * Outer bound of the converted amount.\n\t * if affinity is 'to', this is the maximum amount the user would need to send, if its 'from', this is the minimum amount the user would receive.\n\t */\n\tconvertedAmountBound?: bigint;\n\n\t/**\n\t * The expected cost of the fx request, in the form of a\n\t * token and a range of minimum and maximum expected costs\n\t */\n\texpectedCost: {\n\t\tmin: bigint;\n\t\tmax: bigint;\n\t\ttoken: KeetaNetToken;\n\t};\n} & (\n\t{\n\t\t/**\n\t\t * Indicates that the exchange cannot be performed if false, and no quote can be issued\n\t\t */\n\t\tcanPerformExchange: false;\n\t} | ({\n\t\t/**\n\t\t * Indicates that the exchange can be performed if true or undefined, but a quote may or may not be required before proceeding with the exchange\n\t\t */\n\t\tcanPerformExchange?: true;\n\t} & ({\n\t\t/**\n\t\t * Indicates that a quote is required before proceeding with the exchange\n\t\t */\n\t\trequiresQuote: false;\n\n\t\t/**\n\t\t * Liquidity provider account if the user is not going to request a quote before the exchange\n\t\t */\n\t\taccount: KeetaNetAccount | KeetaNetStorageAccount;\n\t} | {\n\t\t/**\n\t\t * Indicates that a quote is required before proceeding with the exchange, defaults to true\n\t\t */\n\t\trequiresQuote?: true;\n\t}))\n);\n\nexport type KeetaFXAnchorEstimateResponse = ({\n\tok: true;\n\testimate: ToJSONSerializable<KeetaFXAnchorEstimate>;\n} | {\n\tok: false;\n\terror: string;\n});\n\nexport type KeetaFXAnchorMarketPriceRatio = {\n\t/**\n\t * Amount of the base (destination) token in the price ratio\n\t */\n\tbase: string;\n\t/**\n\t * Amount of the quote (source) token in the price ratio\n\t */\n\tquote: string;\n};\n\nexport type KeetaFXAnchorMarketPricesRequest = {\n\t/**\n\t * Source tokens to price against the base asset\n\t */\n\tquoteAssets: KeetaNetTokenPublicKeyString[];\n\t/**\n\t * Destination token against which quote asset prices are expressed\n\t */\n\tbase: KeetaNetTokenPublicKeyString;\n};\n\nexport type KeetaFXAnchorMarketPrices = {\n\t/**\n\t * The destination token against which quote asset prices are expressed\n\t */\n\tbase: KeetaNetTokenPublicKeyString;\n\t/**\n\t * Current market prices for each requested quote asset, keyed by token public key\n\t */\n\tquoteAssets: {\n\t\t[quoteAsset in KeetaNetTokenPublicKeyString]?: {\n\t\t\tvalueRatio: KeetaFXAnchorMarketPriceRatio;\n\t\t};\n\t};\n};\n\nexport type KeetaFXAnchorMarketPricesResponse = ({\n\tok: true;\n} & KeetaFXAnchorMarketPrices) | {\n\tok: false;\n\terror: string;\n};\n\nexport type KeetaFXAnchorQuote = {\n\t/**\n\t * Conversion request that was provided\n\t */\n\trequest: ConversionInputCanonical;\n\n\t/**\n\t * The public key of the liquidity provider account\n\t */\n\taccount: KeetaNetAccount | KeetaNetStorageAccount;\n\n\t/**\n\t * Amount after the conversion as specified by either `from` or `to`, as specified by the `affinity` property in the request.\n\t */\n\tconvertedAmount: bigint;\n\n\t/**\n\t * The cost of the fx request, in the form of a\n\t * token and amount that should be included with the swap\n\t */\n\tcost: {\n\t\tamount: bigint;\n\t\ttoken: KeetaNetToken;\n\t};\n\n\t/**\n\t * Signature information to verify the quote\n\t */\n\tsigned: HTTPSignedField;\n};\n\nexport type KeetaFXAnchorQuoteJSON = ToJSONSerializable<KeetaFXAnchorQuote>;\n\nexport type KeetaFXAnchorQuoteResponse = ({\n\tok: true;\n\tquote: ToJSONSerializable<KeetaFXAnchorQuote>\n} | {\n\tok: false;\n\terror: string;\n});\n\n/**\n * Transport summary of a completed exchange's conversion, sufficient to\n * reconstruct the swap without re-reading the on-chain blocks.\n */\nexport type KeetaFXAnchorConversionSummary = {\n\t/**\n\t * Token and amount the user sent (the principal being converted from).\n\t */\n\tfrom: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n\t/**\n\t * Token and amount the user received (the converted-to currency).\n\t */\n\tto: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n\t/**\n\t * Liquidity provider account that settled the exchange.\n\t */\n\tliquidityProvider: string;\n\t/**\n\t * Fee charged for the exchange, when the server computed it.\n\t */\n\tcost?: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n};\n\nexport type KeetaFXAnchorExchange = {\n\t/**\n\t * ID used to identify the conversion request\n\t */\n\texchangeID: string\n} & ({\n\t/**\n\t * Status of the exchange request\n\t */\n\tstatus: 'pending' | 'failed';\n} | {\n\t/**\n\t * Status of the exchange request\n\t */\n\tstatus: 'completed';\n\t/**\n\t * Blockhash where the exchange was completed -- the user-supplied\n\t * blockhash for their portion of the exchange transaction can be\n\t * used to look up the transaction on-chain as well, but we return\n\t * a value here so that it can be looked up without needing to store\n\t * that initial block.\n\t */\n\tblockhash: string;\n\t/**\n\t * Summary of the conversion that settled, when the server recorded it.\n\t */\n\tconversion?: KeetaFXAnchorConversionSummary;\n});\n\nexport type KeetaFXAnchorExchangeResponse = (KeetaFXAnchorExchange & {\n\tok: true;\n}) | (Partial<KeetaFXAnchorExchange> & {\n\tok: false;\n\terror: string;\n});\n\nexport const isKeetaFXAnchorEstimateResponse: (input: unknown) => input is KeetaFXAnchorEstimateResponse = createIs<KeetaFXAnchorEstimateResponse>();\nexport const isKeetaFXAnchorQuoteResponse: (input: unknown) => input is KeetaFXAnchorQuoteResponse = createIs<KeetaFXAnchorQuoteResponse>();\nexport const isKeetaFXAnchorExchangeResponse: (input: unknown) => input is KeetaFXAnchorExchangeResponse = createIs<KeetaFXAnchorExchangeResponse>();\nexport const isKeetaFXAnchorMarketPricesResponse: (input: unknown) => input is KeetaFXAnchorMarketPricesResponse = createIs<KeetaFXAnchorMarketPricesResponse>();\nexport const assertKeetaNetTokenPublicKeyString: (input: unknown) => KeetaNetTokenPublicKeyString = createAssert<KeetaNetTokenPublicKeyString>();\nexport const assertConversionInputCanonicalJSON: (input: unknown) => ConversionInputCanonicalJSON = createAssert<ConversionInputCanonicalJSON>();\nexport const assertKeetaFXAnchorClientCreateExchangeRequestJSON: (input: unknown) => KeetaFXAnchorClientCreateExchangeRequestJSON = createAssert<KeetaFXAnchorClientCreateExchangeRequestJSON>();\n\nclass KeetaFXAnchorQuoteValidationFailedError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteValidationFailedError';\n\tprivate readonly KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID = 'a8f3c2d1-9b4e-4f2a-8c1d-5e6f7a8b9c0d';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Quote validation failed');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteValidationFailedError.KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteValidationFailedError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID', KeetaFXAnchorQuoteValidationFailedError.KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorQuoteRequiredError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteRequiredError';\n\tprivate readonly KeetaFXAnchorQuoteRequiredErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteRequiredErrorObjectTypeID = '9f22067f-52b3-40f2-84c1-ad9285260980';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Quote required to perform exchange');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteRequiredErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteRequiredError.KeetaFXAnchorQuoteRequiredErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteRequiredError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteRequiredErrorObjectTypeID', KeetaFXAnchorQuoteRequiredError.KeetaFXAnchorQuoteRequiredErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorQuoteIssuanceDisabledError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteIssuanceDisabledError';\n\tprivate readonly KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID = 'a0f70c0b-6e17-41f0-825a-d086983209e1';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Anchor cannot issue quotes');\n\t\tthis.statusCode = 501;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteIssuanceDisabledError.KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteIssuanceDisabledError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID', KeetaFXAnchorQuoteIssuanceDisabledError.KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorResponseMismatchError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorResponseMismatchError';\n\tprivate readonly KeetaFXAnchorResponseMismatchErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorResponseMismatchErrorObjectTypeID = '3c6b1e52-8f0d-4a97-b2e4-71d95c0a6f38';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'FX provider response does not match the request');\n\t\tthis.statusCode = 502;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorResponseMismatchErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorResponseMismatchError.KeetaFXAnchorResponseMismatchErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorResponseMismatchError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorResponseMismatchErrorObjectTypeID', KeetaFXAnchorResponseMismatchError.KeetaFXAnchorResponseMismatchErrorObjectTypeID));\n\t}\n}\n\nclass KeetaFXAnchorExchangeLimitExceededError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorExchangeLimitExceededError';\n\tprivate readonly KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID = 'd2a47f90-5c1b-4e38-9a6d-0b8e3f71c5a4';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'FX exchange exceeds the limits set by the caller');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorExchangeLimitExceededError.KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorExchangeLimitExceededError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID', KeetaFXAnchorExchangeLimitExceededError.KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID));\n\t}\n}\n\nexport const Errors: {\n\tQuoteValidationFailed: typeof KeetaFXAnchorQuoteValidationFailedError;\n\tQuoteRequired: typeof KeetaFXAnchorQuoteRequiredError;\n\tQuoteIssuanceDisabled: typeof KeetaFXAnchorQuoteIssuanceDisabledError;\n\tResponseMismatch: typeof KeetaFXAnchorResponseMismatchError;\n\tExchangeLimitExceeded: typeof KeetaFXAnchorExchangeLimitExceededError;\n} = {\n\t/**\n\t * The quote validation failed\n\t */\n\tQuoteValidationFailed: KeetaFXAnchorQuoteValidationFailedError,\n\n\t/**\n\t * Quote is required to perform the exchange\n\t */\n\tQuoteRequired: KeetaFXAnchorQuoteRequiredError,\n\n\t/**\n\t * The anchor cannot issue quotes\n\t */\n\tQuoteIssuanceDisabled: KeetaFXAnchorQuoteIssuanceDisabledError,\n\n\t/**\n\t * The FX provider answered with terms that do not match the request:\n\t * another conversion, a fee in a token the client does not accept, or\n\t * an estimate bound on the wrong side of its converted amount\n\t */\n\tResponseMismatch: KeetaFXAnchorResponseMismatchError,\n\n\t/**\n\t * The exchange would send, receive, or charge more than the limits the\n\t * caller gave to `createExchange`\n\t */\n\tExchangeLimitExceeded: KeetaFXAnchorExchangeLimitExceededError\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/services/fx/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,qBAAqB,MAAM,gCAAgC,CAAC;AAC7E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAW1D,OAAO,KAAK,EACX,4BAA4B,EAC5B,8BAA8B,EAC9B,qBAAqB,EAGrB,yBAAyB,EACzB,gCAAgC,EAEhC,kBAAkB,EAClB,sBAAsB,EAEtB,eAAe,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAuC,MAAM,0BAA0B,CAAC;AAGvG,OAAO,KAAK,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,yCAAyC,EAAE,MAAM,0BAA0B,CAAC;AACpJ,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,yBAAyB,CAAC;AAEpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAM7D,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,6BAA6B,CAAC;AAetF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IACnD;;OAEG;IACH,MAAM,EAAE;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,CAAC,QAAQ,EAAE,WAAW,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAAC;IACtE,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAa;IACnE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,yBAAyB,CAAC,aAAa,CAAC,CAAC;IAC/D,QAAQ,CAAC,EAAE,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,0BAA0B,CAAC;IAC9C,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC,yBAAyB,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IAEjG,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,cAAc,UAAS;gBAErB,MAAM,EAAE,yBAAyB;cAqE7B,UAAU,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC;cA2U3E,oBAAoB,IAAI,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAa1G,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK3B"}
@@ -55,6 +55,37 @@ async function verifySignedData(signedBy, quote) {
55
55
  const signableQuote = await formatQuoteSignable(quote);
56
56
  return (await Signing.VerifySignedData(signedBy, signableQuote, quote.signed));
57
57
  }
58
+ /**
59
+ * Whether `block` can be published on top of `headHash`, the hash of its
60
+ * account's head block (null when the account has no blocks): it must
61
+ * extend the head, or open the account.
62
+ */
63
+ function blockExtendsHead(headHash, block) {
64
+ if (headHash === null) {
65
+ return (block['$opening']);
66
+ }
67
+ return (headHash.compare(block.previous));
68
+ }
69
+ /**
70
+ * Refuse an exchange block that cannot be published now.
71
+ */
72
+ async function assertBlockExtendsHead(client, block) {
73
+ const head = await client.getHeadBlock(block.account);
74
+ if (!blockExtendsHead(head?.hash ?? null, block)) {
75
+ throw (new KeetaAnchorUserError('Exchange block does not extend the account head'));
76
+ }
77
+ }
78
+ /**
79
+ * Spend a verified quote, so it pays for one exchange only. The claim
80
+ * lasts as long as the quote signature is valid.
81
+ */
82
+ async function claimQuote(replayGuard, quoteSigner, quote) {
83
+ const expiresAt = new Date(new Date(quote.signed.timestamp).valueOf() + Signing.DEFAULT_MAX_SKEW_MS);
84
+ const claimed = await replayGuard.claim(`quote:${quoteSigner.publicKeyString.get()}:${quote.signed.nonce}`, expiresAt);
85
+ if (!claimed) {
86
+ throw (new Errors.QuoteValidationFailed());
87
+ }
88
+ }
58
89
  async function requestToAccounts(config, request) {
59
90
  let account;
60
91
  // eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -366,26 +397,11 @@ class KeetaFXAnchorQueuePipelineStage1 extends KeetaAnchorQueueRunner {
366
397
  }
367
398
  /* Get the current head block of the account in the block */
368
399
  const accountHead = await userClient.head({ account: block.account });
369
- let isHeadBlock = false;
370
- if (accountHead !== null) {
371
- isHeadBlock = accountHead.compare(block.previous);
372
- }
373
- else {
374
- isHeadBlock = block['$opening'];
375
- }
376
- /* If the account's head block is not the block's previous, see if the block's previous exists on the network */
377
- if (!isHeadBlock) {
378
- let previousBlockOnNetwork = false;
379
- if (block['$opening']) {
380
- /* Opening block means that there is no previous block, so we are free to proceed */
381
- previousBlockOnNetwork = true;
382
- }
383
- else {
384
- const previousBlock = await userClient.block(block.previous);
385
- if (previousBlock !== null) {
386
- previousBlockOnNetwork = true;
387
- }
388
- }
400
+ /*
401
+ * createExchange queues only blocks that extend the head, so a
402
+ * block that no longer does lost a race and can never run
403
+ */
404
+ if (!blockExtendsHead(accountHead, block)) {
389
405
  let blockPreviousString;
390
406
  if (block['$opening']) {
391
407
  blockPreviousString = '<opening>';
@@ -393,24 +409,11 @@ class KeetaFXAnchorQueuePipelineStage1 extends KeetaAnchorQueueRunner {
393
409
  else {
394
410
  blockPreviousString = block.previous.toString();
395
411
  }
396
- /* If block.previous exists on the network, and it's not the account head block we can mark this job as failed_permanently */
397
- if (previousBlockOnNetwork) {
398
- /* Block's previous exists on the network, but is not the account head -- mark as failed_permanently */
399
- return ({
400
- status: 'failed_permanently',
401
- output: null,
402
- error: `Block previous (${blockPreviousString}) exists on the network but is not the account head`
403
- });
404
- }
405
- else {
406
- /* If block.previous does not exist on the network we can mark this job as failed_temporarily -- it can't process until the missing block is added */
407
- /* Block's previous does not exist on the network -- mark as failed_temporarily */
408
- return ({
409
- status: 'failed_temporarily',
410
- output: null,
411
- error: `Block previous (${blockPreviousString}) does not exist on the network`
412
- });
413
- }
412
+ return ({
413
+ status: 'failed_permanently',
414
+ output: null,
415
+ error: `Block previous (${blockPreviousString}) is not the account head`
416
+ });
414
417
  }
415
418
  /* We are clear to attempt the swap now */
416
419
  const builder = userClient.initBuilder();
@@ -1249,6 +1252,10 @@ export class KeetaNetFXAnchorHTTPServer extends BaseKeetaNetFXAnchorHTTPServer {
1249
1252
  checks: { quote: parsedQuote, request: conversionInput },
1250
1253
  isQuoteBasedExchange: isQuoteBasedExchange
1251
1254
  });
1255
+ await assertBlockExtendsHead(config.client.client, block);
1256
+ if (isQuoteBasedExchange && config.quoteSigner !== null && 'signed' in quoteInput) {
1257
+ await claimQuote(this.replayGuard, config.quoteSigner, quoteInput);
1258
+ }
1252
1259
  /* Enqueue the exchange request */
1253
1260
  const exchangeID = await instance.pipeline.add({
1254
1261
  account: liquidityAccountInstance,