@keetanetwork/anchor 0.0.3 → 0.0.5

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 (45) hide show
  1. package/client/index.d.ts +6 -0
  2. package/client/index.d.ts.map +1 -1
  3. package/client/index.js +7 -0
  4. package/client/index.js.map +1 -1
  5. package/lib/error.d.ts +14 -0
  6. package/lib/error.d.ts.map +1 -0
  7. package/lib/error.js +38 -0
  8. package/lib/error.js.map +1 -0
  9. package/lib/resolver.d.ts +159 -60
  10. package/lib/resolver.d.ts.map +1 -1
  11. package/lib/resolver.js +3519 -384
  12. package/lib/resolver.js.map +1 -1
  13. package/lib/utils/brand.d.ts +12 -0
  14. package/lib/utils/brand.d.ts.map +1 -0
  15. package/lib/utils/brand.js +2 -0
  16. package/lib/utils/brand.js.map +1 -0
  17. package/lib/utils/never.d.ts +4 -0
  18. package/lib/utils/never.d.ts.map +1 -1
  19. package/lib/utils/never.js.map +1 -1
  20. package/lib/utils/signing.d.ts +17 -0
  21. package/lib/utils/signing.d.ts.map +1 -0
  22. package/lib/utils/signing.js +73 -0
  23. package/lib/utils/signing.js.map +1 -0
  24. package/lib/utils/url.d.ts +2 -0
  25. package/lib/utils/url.d.ts.map +1 -0
  26. package/lib/utils/url.js +8 -0
  27. package/lib/utils/url.js.map +1 -0
  28. package/npm-shrinkwrap.json +13 -6
  29. package/package.json +4 -2
  30. package/services/fx/client.d.ts +137 -0
  31. package/services/fx/client.d.ts.map +1 -0
  32. package/services/fx/client.js +519 -0
  33. package/services/fx/client.js.map +1 -0
  34. package/services/fx/common.d.ts +133 -0
  35. package/services/fx/common.d.ts.map +1 -0
  36. package/services/fx/common.js +45 -0
  37. package/services/fx/common.js.map +1 -0
  38. package/services/fx/server.d.ts +77 -0
  39. package/services/fx/server.d.ts.map +1 -0
  40. package/services/fx/server.js +693 -0
  41. package/services/fx/server.js.map +1 -0
  42. package/services/kyc/client.d.ts +1 -1
  43. package/services/kyc/client.d.ts.map +1 -1
  44. package/services/kyc/client.js +7 -53
  45. package/services/kyc/client.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keetanetwork/anchor",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "KeetaNetwork Network Anchor",
5
5
  "main": "client/index.js",
6
6
  "scripts": {
@@ -20,6 +20,7 @@
20
20
  "author": "LFG Payments, Inc",
21
21
  "license": "SEE LICENSE IN LICENSE",
22
22
  "type": "module",
23
+ "sideEffects": false,
23
24
  "devDependencies": {
24
25
  "@keetanetwork/eslint-config-typescript": "1.4.7",
25
26
  "@keetanetwork/keetanet-node": "0.14.2",
@@ -32,8 +33,9 @@
32
33
  "vitest": "3.2.4"
33
34
  },
34
35
  "dependencies": {
35
- "@keetanetwork/currency-info": "1.1.1",
36
+ "@keetanetwork/currency-info": "1.2.5",
36
37
  "@keetanetwork/keetanet-client": "0.14.2",
38
+ "decimal.js": "10.6.0",
37
39
  "typia": "9.5.0"
38
40
  },
39
41
  "engines": {
@@ -0,0 +1,137 @@
1
+ import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';
2
+ import { getDefaultResolver } from '../../config.js';
3
+ import type { UserClient as KeetaNetUserClient } from '@keetanetwork/keetanet-client';
4
+ import type { Logger } from '../../lib/log/index.ts';
5
+ import type Resolver from '../../lib/resolver.ts';
6
+ import type { ServiceMetadata } from '../../lib/resolver.ts';
7
+ import type { BrandedString } from '../../lib/utils/brand.ts';
8
+ import type { ConversionInput, ConversionInputCanonical, KeetaFXAnchorEstimate, KeetaFXAnchorExchange, KeetaFXAnchorQuote, KeetaNetTokenPublicKeyString } from './common.ts';
9
+ /**
10
+ * An opaque type that represents a provider ID.
11
+ */
12
+ type ProviderID = BrandedString<'FXProviderID'>;
13
+ type AccountOptions = {
14
+ /**
15
+ * The account to use for signing requests. If not provided, the
16
+ * account associated with the provided client will be used. If there
17
+ * is no account associated with the client, an error occurs.
18
+ */
19
+ signer?: InstanceType<typeof KeetaNetLib.Account>;
20
+ /**
21
+ * Account to perform changes on. If not provided, the account
22
+ * associated with the provided client will be used. If there is no
23
+ * account associated with the client, an error occurs.
24
+ */
25
+ account?: InstanceType<typeof KeetaNetLib.Account>;
26
+ };
27
+ /**
28
+ * The configuration options for the FX Anchor client.
29
+ */
30
+ export type KeetaFXAnchorClientConfig = {
31
+ /**
32
+ * The ID of the client. This is used to identify the client in logs.
33
+ * If not provided, a random ID will be generated.
34
+ */
35
+ id?: string;
36
+ /**
37
+ * The logger to use for logging messages. If not provided, no logging
38
+ * will be done.
39
+ */
40
+ logger?: Logger;
41
+ /**
42
+ * The resolver to use for resolving FX Anchor services. If not
43
+ * provided, a default resolver will be created using the provided
44
+ * client and network (if the network is also not provided and the
45
+ * client is not a UserClient, an error occurs).
46
+ */
47
+ resolver?: Resolver;
48
+ /**
49
+ * The account to use for signing requests. If not provided, the
50
+ * account associated with the provided client will be used. If there
51
+ * is no account associated with the client, an error occurs.
52
+ */
53
+ signer?: InstanceType<typeof KeetaNetLib.Account>;
54
+ /**
55
+ * Account to perform changes on. If not provided, the account
56
+ * associated with the provided client will be used. If there is no
57
+ * account associated with the client, an error occurs.
58
+ */
59
+ account?: InstanceType<typeof KeetaNetLib.Account>;
60
+ } & Omit<NonNullable<Parameters<typeof getDefaultResolver>[1]>, 'client'> & AccountOptions;
61
+ type KeetaFXAnchorOperations = {
62
+ [operation in keyof NonNullable<ServiceMetadata['services']['fx']>[string]['operations']]: (params?: {
63
+ [key: string]: string;
64
+ }) => URL;
65
+ };
66
+ type KeetaFXServiceInfo = {
67
+ operations: {
68
+ [operation in keyof KeetaFXAnchorOperations]: Promise<KeetaFXAnchorOperations[operation]>;
69
+ };
70
+ from: NonNullable<ServiceMetadata['services']['fx']>[string]['from'];
71
+ };
72
+ interface KeetaFXAnchorBaseConfig {
73
+ client: KeetaNetUserClient;
74
+ logger?: Logger | undefined;
75
+ }
76
+ declare class KeetaFXAnchorBase {
77
+ protected readonly logger?: Logger | undefined;
78
+ protected readonly client: KeetaNetUserClient;
79
+ constructor(config: KeetaFXAnchorBaseConfig);
80
+ }
81
+ declare class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
82
+ readonly serviceInfo: KeetaFXServiceInfo;
83
+ readonly providerID: ProviderID;
84
+ readonly conversion: ConversionInputCanonical;
85
+ private readonly parent;
86
+ constructor(serviceInfo: KeetaFXServiceInfo, providerID: ProviderID, conversion: ConversionInputCanonical, parent: KeetaFXAnchorClient);
87
+ getEstimate(): Promise<KeetaFXAnchorEstimate>;
88
+ /**
89
+ * Get a quote from the provider. If an estimate is provided, it will
90
+ * be used to validate the quote is within the tolerance range.
91
+ *
92
+ * @param estimate An optional estimate to validate the quote against
93
+ * @param tolerance The tolerance, in percentage points, to allow the
94
+ * quote to vary from the estimate. For example, a
95
+ * tolerance of 1.0 allows the quote to be 100% more
96
+ * or less than the estimate. The default is 0.10
97
+ * (10%).
98
+ * @returns A promise that resolves to the quote response
99
+ */
100
+ getQuote(estimate?: KeetaFXAnchorEstimate, tolerance?: number): Promise<KeetaFXAnchorQuote>;
101
+ createExchange(quote: KeetaFXAnchorQuote, block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchange>;
102
+ getExchangeStatus(exchangeID: string): Promise<KeetaFXAnchorExchange>;
103
+ }
104
+ declare class KeetaFXAnchorExchangeWithProvider {
105
+ private readonly provider;
106
+ readonly exchange: KeetaFXAnchorExchange;
107
+ constructor(provider: KeetaFXAnchorProviderBase, exchange: KeetaFXAnchorExchange);
108
+ getExchangeStatus(): Promise<KeetaFXAnchorExchange>;
109
+ }
110
+ declare class KeetaFXAnchorQuoteWithProvider {
111
+ private readonly provider;
112
+ readonly quote: KeetaFXAnchorQuote;
113
+ constructor(provider: KeetaFXAnchorProviderBase, quote: KeetaFXAnchorQuote);
114
+ createExchange(block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchangeWithProvider>;
115
+ }
116
+ declare class KeetaFXAnchorEstimateWithProvider {
117
+ private readonly provider;
118
+ readonly estimate: KeetaFXAnchorEstimate;
119
+ constructor(provider: KeetaFXAnchorProviderBase, estimate: KeetaFXAnchorEstimate);
120
+ getQuote(tolerance?: number): Promise<KeetaFXAnchorQuoteWithProvider>;
121
+ }
122
+ declare class KeetaFXAnchorClient extends KeetaFXAnchorBase {
123
+ #private;
124
+ readonly resolver: Resolver;
125
+ readonly id: string;
126
+ constructor(client: KeetaNetUserClient, config?: KeetaFXAnchorClientConfig);
127
+ private canonicalizeConversionTokens;
128
+ private canonicalizeConversionInput;
129
+ listPossibleConversions(input: Partial<Pick<ConversionInput, 'from' | 'to'>>, options?: AccountOptions): Promise<{
130
+ conversions: KeetaNetTokenPublicKeyString[];
131
+ } | null>;
132
+ getBaseProvidersForConversion(request: ConversionInput, options?: AccountOptions): Promise<KeetaFXAnchorProviderBase[] | null>;
133
+ getEstimates(request: ConversionInput, options?: AccountOptions): Promise<KeetaFXAnchorEstimateWithProvider[] | null>;
134
+ getQuotes(request: ConversionInput, options?: AccountOptions): Promise<KeetaFXAnchorQuoteWithProvider[] | null>;
135
+ }
136
+ export default KeetaFXAnchorClient;
137
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +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;AAInE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EACX,UAAU,IAAI,kBAAkB,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,uBAAuB,CAAC;AAIpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAA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