@keetanetwork/anchor 0.0.33 → 0.0.35

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 (61) hide show
  1. package/lib/http-server/index.d.ts +7 -1
  2. package/lib/http-server/index.d.ts.map +1 -1
  3. package/lib/http-server/index.js +2 -0
  4. package/lib/http-server/index.js.map +1 -1
  5. package/lib/queue/common.d.ts +26 -0
  6. package/lib/queue/common.d.ts.map +1 -0
  7. package/lib/queue/common.js +47 -0
  8. package/lib/queue/common.js.map +1 -0
  9. package/lib/queue/drivers/queue_file.d.ts +17 -0
  10. package/lib/queue/drivers/queue_file.d.ts.map +1 -0
  11. package/lib/queue/drivers/queue_file.js +100 -0
  12. package/lib/queue/drivers/queue_file.js.map +1 -0
  13. package/lib/queue/drivers/queue_postgres.d.ts +28 -0
  14. package/lib/queue/drivers/queue_postgres.d.ts.map +1 -0
  15. package/lib/queue/drivers/queue_postgres.js +360 -0
  16. package/lib/queue/drivers/queue_postgres.js.map +1 -0
  17. package/lib/queue/drivers/queue_redis.d.ts +27 -0
  18. package/lib/queue/drivers/queue_redis.d.ts.map +1 -0
  19. package/lib/queue/drivers/queue_redis.js +359 -0
  20. package/lib/queue/drivers/queue_redis.js.map +1 -0
  21. package/lib/queue/drivers/queue_sqlite3.d.ts +28 -0
  22. package/lib/queue/drivers/queue_sqlite3.d.ts.map +1 -0
  23. package/lib/queue/drivers/queue_sqlite3.js +378 -0
  24. package/lib/queue/drivers/queue_sqlite3.js.map +1 -0
  25. package/lib/queue/index.d.ts +341 -0
  26. package/lib/queue/index.d.ts.map +1 -0
  27. package/lib/queue/index.js +946 -0
  28. package/lib/queue/index.js.map +1 -0
  29. package/lib/queue/internal.d.ts +20 -0
  30. package/lib/queue/internal.d.ts.map +1 -0
  31. package/lib/queue/internal.js +66 -0
  32. package/lib/queue/internal.js.map +1 -0
  33. package/lib/queue/pipeline.d.ts +152 -0
  34. package/lib/queue/pipeline.d.ts.map +1 -0
  35. package/lib/queue/pipeline.js +296 -0
  36. package/lib/queue/pipeline.js.map +1 -0
  37. package/lib/resolver.d.ts +1 -1
  38. package/lib/resolver.d.ts.map +1 -1
  39. package/lib/resolver.js.map +1 -1
  40. package/lib/utils/asleep.d.ts +2 -0
  41. package/lib/utils/asleep.d.ts.map +1 -0
  42. package/lib/utils/asleep.js +3 -0
  43. package/lib/utils/asleep.js.map +1 -0
  44. package/lib/utils/defer.d.ts +4 -0
  45. package/lib/utils/defer.d.ts.map +1 -0
  46. package/lib/utils/defer.js +3 -0
  47. package/lib/utils/defer.js.map +1 -0
  48. package/npm-shrinkwrap.json +2 -2
  49. package/package.json +1 -1
  50. package/services/fx/client.d.ts +1 -1
  51. package/services/fx/client.d.ts.map +1 -1
  52. package/services/fx/client.js +2 -2
  53. package/services/fx/client.js.map +1 -1
  54. package/services/fx/common.d.ts +19 -4
  55. package/services/fx/common.d.ts.map +1 -1
  56. package/services/fx/common.js +8 -5
  57. package/services/fx/common.js.map +1 -1
  58. package/services/fx/server.d.ts +105 -8
  59. package/services/fx/server.d.ts.map +1 -1
  60. package/services/fx/server.js +609 -43
  61. package/services/fx/server.js.map +1 -1
@@ -0,0 +1,2 @@
1
+ export declare const asleep: (ms: number) => Promise<void>;
2
+ //# sourceMappingURL=asleep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asleep.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/asleep.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAkE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';
2
+ export const asleep = KeetaNetLib.Utils.Helper.asleep.bind(KeetaNetLib.Utils.Helper);
3
+ //# sourceMappingURL=asleep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asleep.js","sourceRoot":"","sources":["../../../src/lib/utils/asleep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEnE,MAAM,CAAC,MAAM,MAAM,GAAkC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC","sourcesContent":["import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\n\nexport const asleep: (ms: number) => Promise<void> = KeetaNetLib.Utils.Helper.asleep.bind(KeetaNetLib.Utils.Helper);\n"]}
@@ -0,0 +1,4 @@
1
+ import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';
2
+ export declare const AsyncDisposableStack: typeof KeetaNetLib.Utils.Helper.AsyncDisposableStack;
3
+ export type AsyncDisposableStack = InstanceType<typeof AsyncDisposableStack>;
4
+ //# sourceMappingURL=defer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defer.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/defer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEnE,eAAO,MAAM,oBAAoB,EAAE,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoE,CAAC;AACxI,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';
2
+ export const AsyncDisposableStack = KeetaNetLib.Utils.Helper.AsyncDisposableStack;
3
+ //# sourceMappingURL=defer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defer.js","sourceRoot":"","sources":["../../../src/lib/utils/defer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEnE,MAAM,CAAC,MAAM,oBAAoB,GAAyD,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC","sourcesContent":["import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\n\nexport const AsyncDisposableStack: typeof KeetaNetLib.Utils.Helper.AsyncDisposableStack = KeetaNetLib.Utils.Helper.AsyncDisposableStack;\nexport type AsyncDisposableStack = InstanceType<typeof AsyncDisposableStack>;\n"]}
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@keetanetwork/anchor",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@keetanetwork/anchor",
9
- "version": "0.0.33",
9
+ "version": "0.0.35",
10
10
  "license": "SEE LICENSE IN LICENSE",
11
11
  "dependencies": {
12
12
  "@keetanetwork/currency-info": "1.2.5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keetanetwork/anchor",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "KeetaNetwork Network Anchor",
5
5
  "main": "client/index.js",
6
6
  "scripts": {
@@ -37,7 +37,7 @@ export type KeetaFXAnchorClientConfig = {
37
37
  * The logger to use for logging messages. If not provided, no logging
38
38
  * will be done.
39
39
  */
40
- logger?: Logger;
40
+ logger?: Logger | undefined;
41
41
  /**
42
42
  * The resolver to use for resolving FX Anchor services. If not
43
43
  * provided, a default resolver will be created using the provided
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","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;AACrD,OAAO,KAAK,EACX,UAAU,IAAI,kBAAkB,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,QAAQ,M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H;AAED,eAAe,mBAAmB,CAAC"}
@@ -257,7 +257,7 @@ class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
257
257
  throw (new Error(`FX exchange request failed: ${requestInformationJSON.error}`));
258
258
  }
259
259
  this.logger?.debug(`FX exchange request successful, to provider ${serviceURL} for ${swapBlock.hash.toString()}`);
260
- return ({ exchangeID: requestInformationJSON.exchangeID });
260
+ return (requestInformationJSON);
261
261
  }
262
262
  async getExchangeStatus(exchangeID) {
263
263
  const serviceURL = (await this.serviceInfo.operations.getExchangeStatus)({ exchangeID });
@@ -275,7 +275,7 @@ class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
275
275
  throw (new Error(`FX exchange status failed: ${requestInformationJSON.error}`));
276
276
  }
277
277
  this.logger?.debug(`FX exchange status request successful, to provider ${serviceURL} for ${exchangeID}`);
278
- return ({ exchangeID: requestInformationJSON.exchangeID });
278
+ return (requestInformationJSON);
279
279
  }
280
280
  /** @internal */
281
281
  _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,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AAC,IAAI,8BAA8B,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC,CAAC;QAEJ,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,UAAS,MAAM;YAC5C,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,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,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;\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({ exchangeID: requestInformationJSON.exchangeID });\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({ exchangeID: requestInformationJSON.exchangeID });\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"],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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"]}
@@ -37,9 +37,6 @@ export type KeetaFXAnchorClientCreateExchangeRequest = {
37
37
  quote: KeetaFXAnchorQuote;
38
38
  block: InstanceType<typeof KeetaNetLib.Block>;
39
39
  };
40
- export type KeetaFXAnchorClientGetExchangeStatusRequest = {
41
- exchangeID: string;
42
- };
43
40
  export type KeetaFXAnchorEstimate = {
44
41
  /**
45
42
  * Conversion request that was provided
@@ -105,7 +102,25 @@ export type KeetaFXAnchorExchange = {
105
102
  * ID used to identify the conversion request
106
103
  */
107
104
  exchangeID: string;
108
- };
105
+ } & ({
106
+ /**
107
+ * Status of the exchange request
108
+ */
109
+ status: 'pending' | 'failed';
110
+ } | {
111
+ /**
112
+ * Status of the exchange request
113
+ */
114
+ status: 'completed';
115
+ /**
116
+ * Blockhash where the exchange was completed -- the user-supplied
117
+ * blockhash for their portion of the exchange transaction can be
118
+ * used to look up the transaction on-chain as well, but we return
119
+ * a value here so that it can be looked up without needing to store
120
+ * that initial block.
121
+ */
122
+ blockhash: string;
123
+ });
109
124
  export type KeetaFXAnchorExchangeResponse = KeetaFXAnchorExchange & ({
110
125
  ok: true;
111
126
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/services/fx/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,IAAI,WAAW,EAAE,MAAO,+BAA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,EAAE,OAAO,KAAK,KAAK,IAAI,6BAAyE,CAAC;AACrJ,eAAO,MAAM,kCAAkC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAM,4BAA2E,CAAC;AAClJ,eAAO,MAAM,kCAAkC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,4BAA2E,CAAC;AACjJ,eAAO,MAAM,yBAAyB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,sBAA8D,CAAC;AAE3H,cAAM,uCAAwC,SAAQ,oBAAoB;IACzE,gBAAyB,IAAI,EAAE,MAAM,CAA6C;IAClF,OAAO,CAAC,QAAQ,CAAC,mDAAmD,CAAU;IAC9E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mDAAmD,CAA0C;gBAEzG,OAAO,CAAC,EAAE,MAAM;IAU5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uCAAuC;WAItE,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,IAAI,CAAC,CAAC;CAMzE;AAED,eAAO,MAAM,MAAM,EAAE;IACpB,qBAAqB,EAAE,OAAO,uCAAuC,CAAC;CAMtE,CAAC"}
@@ -17,13 +17,16 @@ export const isKeetaFXAnchorQuoteResponse = (() => { const _io0 = input => true
17
17
  else
18
18
  return false;
19
19
  })(); return input => "object" === typeof input && null !== input && _iu0(input); })();
20
- export const isKeetaFXAnchorExchangeResponse = (() => { const _io0 = input => "string" === typeof input.exchangeID && true === input.ok; const _io1 = input => "string" === typeof input.exchangeID && false === input.ok && "string" === typeof input.error; const _iu0 = input => (() => {
21
- if (true === input.ok)
20
+ export const isKeetaFXAnchorExchangeResponse = (() => { const _io0 = input => "string" === typeof input.exchangeID && ("pending" === input.status || "failed" === input.status) && true === input.ok; const _io1 = input => "string" === typeof input.exchangeID && ("pending" === input.status || "failed" === input.status) && false === input.ok && "string" === typeof input.error; const _io2 = input => "string" === typeof input.exchangeID && "completed" === input.status && "string" === typeof input.blockhash && true === input.ok; const _io3 = input => "string" === typeof input.exchangeID && "completed" === input.status && "string" === typeof input.blockhash && false === input.ok && "string" === typeof input.error; const _iu0 = input => (() => {
21
+ if (_io0(input))
22
22
  return _io0(input);
23
- else if (false === input.ok)
23
+ if (_io1(input))
24
24
  return _io1(input);
25
- else
26
- return false;
25
+ if (_io2(input))
26
+ return _io2(input);
27
+ if (_io3(input))
28
+ return _io3(input);
29
+ return false;
27
30
  })(); return input => "object" === typeof input && null !== input && _iu0(input); })();
28
31
  export const assertKeetaNetTokenPublicKeyString = (() => { const __is = input => "string" === typeof input && (RegExp(/^keeta_am(.*)/).test(input) || RegExp(/^keeta_an(.*)/).test(input) || RegExp(/^keeta_ao(.*)/).test(input) || RegExp(/^keeta_ap(.*)/).test(input) || RegExp(/^tyblocks_am(.*)/).test(input) || RegExp(/^tyblocks_an(.*)/).test(input) || RegExp(/^tyblocks_ao(.*)/).test(input) || RegExp(/^tyblocks_ap(.*)/).test(input)); let _errorFactory; return (input, errorFactory) => {
29
32
  if (false === __is(input)) {
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/services/fx/common.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAqI5B,MAAM,CAAC,MAAM,+BAA+B;;;;;;;sFAAwG,CAAC;AACrJ,MAAM,CAAC,MAAM,4BAA4B;;;;;;;sFAAkG,CAAC;AAC5I,MAAM,CAAC,MAAM,+BAA+B;;;;;;;sFAAwG,CAAC;AACrJ,MAAM,CAAC,MAAM,kCAAkC;;;;;;;;;;;OAAkG,CAAC;AAClJ,MAAM,CAAC,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAiG,CAAC;AACjJ,MAAM,CAAC,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAoF,CAAC;AAE3H,MAAM,uCAAwC,SAAQ,oBAAoB;IACzE,MAAM,CAAmB,IAAI,GAAW,yCAAyC,CAAC;IACjE,mDAAmD,CAAU;IACtE,MAAM,CAAU,mDAAmD,GAAG,sCAAsC,CAAC;IAErH,YAAY,OAAgB;QAC3B,KAAK,CAAC,OAAO,IAAI,yBAAyB,CAAC,CAAC;QAC5C,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,GAEf;IACH;;OAEG;IACH,qBAAqB,EAAE,uCAAuC;CAC9D,CAAC","sourcesContent":["import type { 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';\n\nexport type KeetaNetAccount = InstanceType<typeof KeetaNetLib.Account>;\nexport type KeetaNetStorageAccount = InstanceType<typeof KeetaNetLib.Account<typeof KeetaNetLib.Account.AccountKeyAlgorithm.STORAGE>>;\nexport type KeetaNetToken = InstanceType<typeof KeetaNetLib.Account<typeof KeetaNetLib.Account.AccountKeyAlgorithm.TOKEN>>;\nexport type KeetaNetTokenPublicKeyString = ReturnType<InstanceType<typeof KeetaNetLib.Account<typeof KeetaNetLib.Account.AccountKeyAlgorithm.TOKEN>>['publicKeyString']['get']>;\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\nexport type ConversionInputCanonical = {\n\t[k in keyof ConversionInput]: k extends 'amount' ? bigint : k extends 'from' ? KeetaNetToken : k extends 'to' ? KeetaNetToken : ConversionInput[k];\n};\n\nexport type ConversionInputCanonicalJSON = ToJSONSerializable<ConversionInputCanonical>;\n\nexport type KeetaFXAnchorClientCreateExchangeRequest = {\n\tquote: KeetaFXAnchorQuote;\n\tblock: InstanceType<typeof KeetaNetLib.Block>;\n};\n\nexport type KeetaFXAnchorClientGetExchangeStatusRequest = {\n\texchangeID: string\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 * 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\nexport type KeetaFXAnchorEstimateResponse = ({\n\tok: true;\n\testimate: ToJSONSerializable<KeetaFXAnchorEstimate>;\n} | {\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\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\nexport type KeetaFXAnchorExchange = {\n\t/**\n\t * ID used to identify the conversion request\n\t */\n\texchangeID: string\n}\n\nexport type KeetaFXAnchorExchangeResponse = KeetaFXAnchorExchange &\n({\n\tok: true;\n} | {\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 assertKeetaNetTokenPublicKeyString: (input: unknown) => KeetaNetTokenPublicKeyString = createAssert<KeetaNetTokenPublicKeyString>();\nexport const assertConversionInputCanonicalJSON: (input: unknown) => ConversionInputCanonicalJSON = createAssert<ConversionInputCanonicalJSON>();\nexport const assertConversionQuoteJSON: (input: unknown) => KeetaFXAnchorQuoteJSON= createAssert<KeetaFXAnchorQuoteJSON>();\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\nexport const Errors: {\n\tQuoteValidationFailed: typeof KeetaFXAnchorQuoteValidationFailedError;\n} = {\n\t/**\n\t * The quote validation failed\n\t */\n\tQuoteValidationFailed: KeetaFXAnchorQuoteValidationFailedError\n};\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/services/fx/common.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAkJ5B,MAAM,CAAC,MAAM,+BAA+B;;;;;;;sFAAwG,CAAC;AACrJ,MAAM,CAAC,MAAM,4BAA4B;;;;;;;sFAAkG,CAAC;AAC5I,MAAM,CAAC,MAAM,+BAA+B;;;;;;;;;;sFAAwG,CAAC;AACrJ,MAAM,CAAC,MAAM,kCAAkC;;;;;;;;;;;OAAkG,CAAC;AAClJ,MAAM,CAAC,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAiG,CAAC;AACjJ,MAAM,CAAC,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAoF,CAAC;AAE3H,MAAM,uCAAwC,SAAQ,oBAAoB;IACzE,MAAM,CAAmB,IAAI,GAAW,yCAAyC,CAAC;IACjE,mDAAmD,CAAU;IACtE,MAAM,CAAU,mDAAmD,GAAG,sCAAsC,CAAC;IAErH,YAAY,OAAgB;QAC3B,KAAK,CAAC,OAAO,IAAI,yBAAyB,CAAC,CAAC;QAC5C,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,GAEf;IACH;;OAEG;IACH,qBAAqB,EAAE,uCAAuC;CAC9D,CAAC","sourcesContent":["import type { 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';\n\nexport type KeetaNetAccount = InstanceType<typeof KeetaNetLib.Account>;\nexport type KeetaNetStorageAccount = InstanceType<typeof KeetaNetLib.Account<typeof KeetaNetLib.Account.AccountKeyAlgorithm.STORAGE>>;\nexport type KeetaNetToken = InstanceType<typeof KeetaNetLib.Account<typeof KeetaNetLib.Account.AccountKeyAlgorithm.TOKEN>>;\nexport type KeetaNetTokenPublicKeyString = ReturnType<InstanceType<typeof KeetaNetLib.Account<typeof KeetaNetLib.Account.AccountKeyAlgorithm.TOKEN>>['publicKeyString']['get']>;\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\nexport type ConversionInputCanonical = {\n\t[k in keyof ConversionInput]: k extends 'amount' ? bigint : k extends 'from' ? KeetaNetToken : k extends 'to' ? KeetaNetToken : ConversionInput[k];\n};\n\nexport type ConversionInputCanonicalJSON = ToJSONSerializable<ConversionInputCanonical>;\n\nexport type KeetaFXAnchorClientCreateExchangeRequest = {\n\tquote: KeetaFXAnchorQuote;\n\tblock: InstanceType<typeof KeetaNetLib.Block>;\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 * 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\nexport type KeetaFXAnchorEstimateResponse = ({\n\tok: true;\n\testimate: ToJSONSerializable<KeetaFXAnchorEstimate>;\n} | {\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\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\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});\n\nexport type KeetaFXAnchorExchangeResponse = KeetaFXAnchorExchange & ({\n\tok: true;\n} | {\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 assertKeetaNetTokenPublicKeyString: (input: unknown) => KeetaNetTokenPublicKeyString = createAssert<KeetaNetTokenPublicKeyString>();\nexport const assertConversionInputCanonicalJSON: (input: unknown) => ConversionInputCanonicalJSON = createAssert<ConversionInputCanonicalJSON>();\nexport const assertConversionQuoteJSON: (input: unknown) => KeetaFXAnchorQuoteJSON= createAssert<KeetaFXAnchorQuoteJSON>();\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\nexport const Errors: {\n\tQuoteValidationFailed: typeof KeetaFXAnchorQuoteValidationFailedError;\n} = {\n\t/**\n\t * The quote validation failed\n\t */\n\tQuoteValidationFailed: KeetaFXAnchorQuoteValidationFailedError\n};\n"]}