@keetanetwork/anchor 0.0.12 → 0.0.14
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.
- package/lib/certificates.d.ts +83 -21
- package/lib/certificates.d.ts.map +1 -1
- package/lib/certificates.generated.d.ts +3 -0
- package/lib/certificates.generated.d.ts.map +1 -0
- package/lib/certificates.generated.js +120 -0
- package/lib/certificates.generated.js.map +1 -0
- package/lib/certificates.js +579 -117
- package/lib/certificates.js.map +1 -1
- package/lib/http-server.d.ts +2 -1
- package/lib/http-server.d.ts.map +1 -1
- package/lib/http-server.js +4 -4
- package/lib/http-server.js.map +1 -1
- package/lib/resolver.d.ts +2 -1
- package/lib/resolver.d.ts.map +1 -1
- package/lib/resolver.js.map +1 -1
- package/lib/utils/asn1.d.ts +2 -1
- package/lib/utils/asn1.d.ts.map +1 -1
- package/lib/utils/asn1.js.map +1 -1
- package/lib/utils/buffer.d.ts +3 -0
- package/lib/utils/buffer.d.ts.map +1 -1
- package/lib/utils/buffer.js +26 -0
- package/lib/utils/buffer.js.map +1 -1
- package/lib/utils/guards.d.ts +14 -0
- package/lib/utils/guards.d.ts.map +1 -0
- package/lib/utils/guards.js +31 -0
- package/lib/utils/guards.js.map +1 -0
- package/lib/utils/index.d.ts +3 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +3 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/json.d.ts +2 -2
- package/lib/utils/json.d.ts.map +1 -1
- package/lib/utils/json.js.map +1 -1
- package/lib/utils/oid.d.ts +7 -0
- package/lib/utils/oid.d.ts.map +1 -0
- package/lib/utils/oid.js +22 -0
- package/lib/utils/oid.js.map +1 -0
- package/lib/utils/signing.d.ts.map +1 -1
- package/lib/utils/signing.js +26 -2
- package/lib/utils/signing.js.map +1 -1
- package/npm-shrinkwrap.json +2 -8
- package/package.json +1 -2
- package/services/fx/client.d.ts +1 -0
- package/services/fx/client.d.ts.map +1 -1
- package/services/fx/client.js +72 -72
- package/services/fx/client.js.map +1 -1
- package/services/fx/common.d.ts +23 -14
- package/services/fx/common.d.ts.map +1 -1
- package/services/fx/common.js +177 -1
- package/services/fx/common.js.map +1 -1
- package/services/fx/server.d.ts +13 -4
- package/services/fx/server.d.ts.map +1 -1
- package/services/fx/server.js +58 -151
- package/services/fx/server.js.map +1 -1
- package/services/kyc/client.d.ts.map +1 -1
- package/services/kyc/client.js +1 -8
- package/services/kyc/client.js.map +1 -1
- package/services/kyc/common.d.ts +39 -3
- package/services/kyc/common.d.ts.map +1 -1
- package/services/kyc/common.generated.d.ts +5 -0
- package/services/kyc/common.generated.d.ts.map +1 -0
- package/services/kyc/common.generated.js +241 -0
- package/services/kyc/common.generated.js.map +1 -0
- package/services/kyc/common.js +68 -1
- package/services/kyc/common.js.map +1 -1
- package/services/kyc/iso20022.generated.d.ts +285 -0
- package/services/kyc/iso20022.generated.d.ts.map +1 -0
- package/services/kyc/iso20022.generated.js +205 -0
- package/services/kyc/iso20022.generated.js.map +1 -0
- package/services/kyc/oids.generated.d.ts +83 -0
- package/services/kyc/oids.generated.d.ts.map +1 -0
- package/services/kyc/oids.generated.js +130 -0
- package/services/kyc/oids.generated.js.map +1 -0
- package/services/kyc/server.d.ts +141 -0
- package/services/kyc/server.d.ts.map +1 -0
- package/services/kyc/server.js +183 -0
- package/services/kyc/server.js.map +1 -0
- package/services/kyc/utils/generate-kyc-schema.d.ts +3 -0
- package/services/kyc/utils/generate-kyc-schema.d.ts.map +1 -0
- package/services/kyc/utils/generate-kyc-schema.js +1154 -0
- package/services/kyc/utils/generate-kyc-schema.js.map +1 -0
package/services/fx/common.js
CHANGED
|
@@ -1,2 +1,178 @@
|
|
|
1
|
-
|
|
1
|
+
import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js";
|
|
2
|
+
import { createAssert, createIs } from 'typia';
|
|
3
|
+
export const isKeetaFXAnchorEstimateResponse = (() => { const _io0 = input => true === input.ok && ("object" === typeof input.estimate && null !== input.estimate && _io1(input.estimate)); const _io1 = input => "object" === typeof input.request && null !== input.request && _io2(input.request) && "string" === typeof input.convertedAmount && ("object" === typeof input.expectedCost && null !== input.expectedCost && _io3(input.expectedCost)); const _io2 = input => "string" === typeof input.from && (RegExp(/^keeta_am(.*)/).test(input.from) || RegExp(/^keeta_an(.*)/).test(input.from) || RegExp(/^keeta_ao(.*)/).test(input.from) || RegExp(/^keeta_ap(.*)/).test(input.from) || RegExp(/^tyblocks_am(.*)/).test(input.from) || RegExp(/^tyblocks_an(.*)/).test(input.from) || RegExp(/^tyblocks_ao(.*)/).test(input.from) || RegExp(/^tyblocks_ap(.*)/).test(input.from)) && ("string" === typeof input.to && (RegExp(/^keeta_am(.*)/).test(input.to) || RegExp(/^keeta_an(.*)/).test(input.to) || RegExp(/^keeta_ao(.*)/).test(input.to) || RegExp(/^keeta_ap(.*)/).test(input.to) || RegExp(/^tyblocks_am(.*)/).test(input.to) || RegExp(/^tyblocks_an(.*)/).test(input.to) || RegExp(/^tyblocks_ao(.*)/).test(input.to) || RegExp(/^tyblocks_ap(.*)/).test(input.to))) && "string" === typeof input.amount && ("from" === input.affinity || "to" === input.affinity); const _io3 = input => "string" === typeof input.min && "string" === typeof input.max && ("string" === typeof input.token && (RegExp(/^keeta_am(.*)/).test(input.token) || RegExp(/^keeta_an(.*)/).test(input.token) || RegExp(/^keeta_ao(.*)/).test(input.token) || RegExp(/^keeta_ap(.*)/).test(input.token) || RegExp(/^tyblocks_am(.*)/).test(input.token) || RegExp(/^tyblocks_an(.*)/).test(input.token) || RegExp(/^tyblocks_ao(.*)/).test(input.token) || RegExp(/^tyblocks_ap(.*)/).test(input.token))); const _io4 = input => false === input.ok && "string" === typeof input.error; const _iu0 = input => (() => {
|
|
4
|
+
if (true === input.ok)
|
|
5
|
+
return _io0(input);
|
|
6
|
+
else if (false === input.ok)
|
|
7
|
+
return _io4(input);
|
|
8
|
+
else
|
|
9
|
+
return false;
|
|
10
|
+
})(); return input => "object" === typeof input && null !== input && _iu0(input); })();
|
|
11
|
+
export const isKeetaFXAnchorQuoteResponse = (() => { const _io0 = input => true === input.ok && ("object" === typeof input.quote && null !== input.quote && _io1(input.quote)); const _io1 = input => "object" === typeof input.request && null !== input.request && _io2(input.request) && ("string" === typeof input.account && (RegExp(/^keeta_am(.*)/).test(input.account) || RegExp(/^keeta_an(.*)/).test(input.account) || RegExp(/^keeta_ao(.*)/).test(input.account) || RegExp(/^keeta_ap(.*)/).test(input.account) || RegExp(/^tyblocks_am(.*)/).test(input.account) || RegExp(/^tyblocks_an(.*)/).test(input.account) || RegExp(/^tyblocks_ao(.*)/).test(input.account) || RegExp(/^tyblocks_ap(.*)/).test(input.account) || RegExp(/^keeta_ai(.*)/).test(input.account) || RegExp(/^keeta_aj(.*)/).test(input.account) || RegExp(/^keeta_ak(.*)/).test(input.account) || RegExp(/^keeta_al(.*)/).test(input.account) || RegExp(/^tyblocks_ai(.*)/).test(input.account) || RegExp(/^tyblocks_aj(.*)/).test(input.account) || RegExp(/^tyblocks_ak(.*)/).test(input.account) || RegExp(/^tyblocks_al(.*)/).test(input.account) || RegExp(/^keeta_at(.*)/).test(input.account) || RegExp(/^keeta_aq(.*)/).test(input.account) || RegExp(/^keeta_ar(.*)/).test(input.account) || RegExp(/^keeta_as(.*)/).test(input.account) || RegExp(/^tyblocks_at(.*)/).test(input.account) || RegExp(/^tyblocks_aq(.*)/).test(input.account) || RegExp(/^tyblocks_ar(.*)/).test(input.account) || RegExp(/^tyblocks_as(.*)/).test(input.account) || RegExp(/^keeta_a4(.*)/).test(input.account) || RegExp(/^keeta_a5(.*)/).test(input.account) || RegExp(/^keeta_a6(.*)/).test(input.account) || RegExp(/^keeta_a7(.*)/).test(input.account) || RegExp(/^tyblocks_a4(.*)/).test(input.account) || RegExp(/^tyblocks_a5(.*)/).test(input.account) || RegExp(/^tyblocks_a6(.*)/).test(input.account) || RegExp(/^tyblocks_a7(.*)/).test(input.account) || RegExp(/^keeta_aa(.*)/).test(input.account) || RegExp(/^keeta_ab(.*)/).test(input.account) || RegExp(/^keeta_ac(.*)/).test(input.account) || RegExp(/^keeta_ad(.*)/).test(input.account) || RegExp(/^tyblocks_aa(.*)/).test(input.account) || RegExp(/^tyblocks_ab(.*)/).test(input.account) || RegExp(/^tyblocks_ac(.*)/).test(input.account) || RegExp(/^tyblocks_ad(.*)/).test(input.account) || RegExp(/^keeta_ay(.*)/).test(input.account) || RegExp(/^keeta_az(.*)/).test(input.account) || RegExp(/^keeta_a2(.*)/).test(input.account) || RegExp(/^keeta_a3(.*)/).test(input.account) || RegExp(/^tyblocks_ay(.*)/).test(input.account) || RegExp(/^tyblocks_az(.*)/).test(input.account) || RegExp(/^tyblocks_a2(.*)/).test(input.account) || RegExp(/^tyblocks_a3(.*)/).test(input.account) || RegExp(/^keeta_ae(.*)/).test(input.account) || RegExp(/^keeta_af(.*)/).test(input.account) || RegExp(/^keeta_ag(.*)/).test(input.account) || RegExp(/^keeta_ah(.*)/).test(input.account) || RegExp(/^tyblocks_ae(.*)/).test(input.account) || RegExp(/^tyblocks_af(.*)/).test(input.account) || RegExp(/^tyblocks_ag(.*)/).test(input.account) || RegExp(/^tyblocks_ah(.*)/).test(input.account))) && "string" === typeof input.convertedAmount && ("object" === typeof input.cost && null !== input.cost && _io3(input.cost)) && ("object" === typeof input.signed && null !== input.signed && _io4(input.signed)); const _io2 = input => "string" === typeof input.from && (RegExp(/^keeta_am(.*)/).test(input.from) || RegExp(/^keeta_an(.*)/).test(input.from) || RegExp(/^keeta_ao(.*)/).test(input.from) || RegExp(/^keeta_ap(.*)/).test(input.from) || RegExp(/^tyblocks_am(.*)/).test(input.from) || RegExp(/^tyblocks_an(.*)/).test(input.from) || RegExp(/^tyblocks_ao(.*)/).test(input.from) || RegExp(/^tyblocks_ap(.*)/).test(input.from)) && ("string" === typeof input.to && (RegExp(/^keeta_am(.*)/).test(input.to) || RegExp(/^keeta_an(.*)/).test(input.to) || RegExp(/^keeta_ao(.*)/).test(input.to) || RegExp(/^keeta_ap(.*)/).test(input.to) || RegExp(/^tyblocks_am(.*)/).test(input.to) || RegExp(/^tyblocks_an(.*)/).test(input.to) || RegExp(/^tyblocks_ao(.*)/).test(input.to) || RegExp(/^tyblocks_ap(.*)/).test(input.to))) && "string" === typeof input.amount && ("from" === input.affinity || "to" === input.affinity); const _io3 = input => "string" === typeof input.amount && ("string" === typeof input.token && (RegExp(/^keeta_am(.*)/).test(input.token) || RegExp(/^keeta_an(.*)/).test(input.token) || RegExp(/^keeta_ao(.*)/).test(input.token) || RegExp(/^keeta_ap(.*)/).test(input.token) || RegExp(/^tyblocks_am(.*)/).test(input.token) || RegExp(/^tyblocks_an(.*)/).test(input.token) || RegExp(/^tyblocks_ao(.*)/).test(input.token) || RegExp(/^tyblocks_ap(.*)/).test(input.token))); const _io4 = input => "string" === typeof input.nonce && "string" === typeof input.timestamp && "string" === typeof input.signature; const _io5 = input => false === input.ok && "string" === typeof input.error; const _iu0 = input => (() => {
|
|
12
|
+
if (true === input.ok)
|
|
13
|
+
return _io0(input);
|
|
14
|
+
else if (false === input.ok)
|
|
15
|
+
return _io5(input);
|
|
16
|
+
else
|
|
17
|
+
return false;
|
|
18
|
+
})(); return input => "object" === typeof input && null !== input && _iu0(input); })();
|
|
19
|
+
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 => (() => {
|
|
20
|
+
if (true === input.ok)
|
|
21
|
+
return _io0(input);
|
|
22
|
+
else if (false === input.ok)
|
|
23
|
+
return _io1(input);
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
})(); return input => "object" === typeof input && null !== input && _iu0(input); })();
|
|
27
|
+
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) => {
|
|
28
|
+
if (false === __is(input)) {
|
|
29
|
+
_errorFactory = errorFactory;
|
|
30
|
+
((input, _path, _exceptionable = true) => "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)) || __typia_transform__assertGuard._assertGuard(true, {
|
|
31
|
+
method: "createAssert",
|
|
32
|
+
path: _path + "",
|
|
33
|
+
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
34
|
+
value: input
|
|
35
|
+
}, _errorFactory))(input, "$input", true);
|
|
36
|
+
}
|
|
37
|
+
return input;
|
|
38
|
+
}; })();
|
|
39
|
+
export const assertConversionInputCanonicalJSON = (() => { const _io0 = input => "string" === typeof input.from && (RegExp(/^keeta_am(.*)/).test(input.from) || RegExp(/^keeta_an(.*)/).test(input.from) || RegExp(/^keeta_ao(.*)/).test(input.from) || RegExp(/^keeta_ap(.*)/).test(input.from) || RegExp(/^tyblocks_am(.*)/).test(input.from) || RegExp(/^tyblocks_an(.*)/).test(input.from) || RegExp(/^tyblocks_ao(.*)/).test(input.from) || RegExp(/^tyblocks_ap(.*)/).test(input.from)) && ("string" === typeof input.to && (RegExp(/^keeta_am(.*)/).test(input.to) || RegExp(/^keeta_an(.*)/).test(input.to) || RegExp(/^keeta_ao(.*)/).test(input.to) || RegExp(/^keeta_ap(.*)/).test(input.to) || RegExp(/^tyblocks_am(.*)/).test(input.to) || RegExp(/^tyblocks_an(.*)/).test(input.to) || RegExp(/^tyblocks_ao(.*)/).test(input.to) || RegExp(/^tyblocks_ap(.*)/).test(input.to))) && "string" === typeof input.amount && ("from" === input.affinity || "to" === input.affinity); const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.from && (RegExp(/^keeta_am(.*)/).test(input.from) || RegExp(/^keeta_an(.*)/).test(input.from) || RegExp(/^keeta_ao(.*)/).test(input.from) || RegExp(/^keeta_ap(.*)/).test(input.from) || RegExp(/^tyblocks_am(.*)/).test(input.from) || RegExp(/^tyblocks_an(.*)/).test(input.from) || RegExp(/^tyblocks_ao(.*)/).test(input.from) || RegExp(/^tyblocks_ap(.*)/).test(input.from)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
40
|
+
method: "createAssert",
|
|
41
|
+
path: _path + ".from",
|
|
42
|
+
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
43
|
+
value: input.from
|
|
44
|
+
}, _errorFactory)) && ("string" === typeof input.to && (RegExp(/^keeta_am(.*)/).test(input.to) || RegExp(/^keeta_an(.*)/).test(input.to) || RegExp(/^keeta_ao(.*)/).test(input.to) || RegExp(/^keeta_ap(.*)/).test(input.to) || RegExp(/^tyblocks_am(.*)/).test(input.to) || RegExp(/^tyblocks_an(.*)/).test(input.to) || RegExp(/^tyblocks_ao(.*)/).test(input.to) || RegExp(/^tyblocks_ap(.*)/).test(input.to)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
45
|
+
method: "createAssert",
|
|
46
|
+
path: _path + ".to",
|
|
47
|
+
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
48
|
+
value: input.to
|
|
49
|
+
}, _errorFactory)) && ("string" === typeof input.amount || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
50
|
+
method: "createAssert",
|
|
51
|
+
path: _path + ".amount",
|
|
52
|
+
expected: "string",
|
|
53
|
+
value: input.amount
|
|
54
|
+
}, _errorFactory)) && ("from" === input.affinity || "to" === input.affinity || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
55
|
+
method: "createAssert",
|
|
56
|
+
path: _path + ".affinity",
|
|
57
|
+
expected: "(\"from\" | \"to\")",
|
|
58
|
+
value: input.affinity
|
|
59
|
+
}, _errorFactory)); const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; return (input, errorFactory) => {
|
|
60
|
+
if (false === __is(input)) {
|
|
61
|
+
_errorFactory = errorFactory;
|
|
62
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __typia_transform__assertGuard._assertGuard(true, {
|
|
63
|
+
method: "createAssert",
|
|
64
|
+
path: _path + "",
|
|
65
|
+
expected: "__type",
|
|
66
|
+
value: input
|
|
67
|
+
}, _errorFactory)) && _ao0(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
|
|
68
|
+
method: "createAssert",
|
|
69
|
+
path: _path + "",
|
|
70
|
+
expected: "__type",
|
|
71
|
+
value: input
|
|
72
|
+
}, _errorFactory))(input, "$input", true);
|
|
73
|
+
}
|
|
74
|
+
return input;
|
|
75
|
+
}; })();
|
|
76
|
+
export const assertConversionQuoteJSON = (() => { const _io0 = input => "object" === typeof input.request && null !== input.request && _io1(input.request) && ("string" === typeof input.account && (RegExp(/^keeta_am(.*)/).test(input.account) || RegExp(/^keeta_an(.*)/).test(input.account) || RegExp(/^keeta_ao(.*)/).test(input.account) || RegExp(/^keeta_ap(.*)/).test(input.account) || RegExp(/^tyblocks_am(.*)/).test(input.account) || RegExp(/^tyblocks_an(.*)/).test(input.account) || RegExp(/^tyblocks_ao(.*)/).test(input.account) || RegExp(/^tyblocks_ap(.*)/).test(input.account) || RegExp(/^keeta_ai(.*)/).test(input.account) || RegExp(/^keeta_aj(.*)/).test(input.account) || RegExp(/^keeta_ak(.*)/).test(input.account) || RegExp(/^keeta_al(.*)/).test(input.account) || RegExp(/^tyblocks_ai(.*)/).test(input.account) || RegExp(/^tyblocks_aj(.*)/).test(input.account) || RegExp(/^tyblocks_ak(.*)/).test(input.account) || RegExp(/^tyblocks_al(.*)/).test(input.account) || RegExp(/^keeta_at(.*)/).test(input.account) || RegExp(/^keeta_aq(.*)/).test(input.account) || RegExp(/^keeta_ar(.*)/).test(input.account) || RegExp(/^keeta_as(.*)/).test(input.account) || RegExp(/^tyblocks_at(.*)/).test(input.account) || RegExp(/^tyblocks_aq(.*)/).test(input.account) || RegExp(/^tyblocks_ar(.*)/).test(input.account) || RegExp(/^tyblocks_as(.*)/).test(input.account) || RegExp(/^keeta_a4(.*)/).test(input.account) || RegExp(/^keeta_a5(.*)/).test(input.account) || RegExp(/^keeta_a6(.*)/).test(input.account) || RegExp(/^keeta_a7(.*)/).test(input.account) || RegExp(/^tyblocks_a4(.*)/).test(input.account) || RegExp(/^tyblocks_a5(.*)/).test(input.account) || RegExp(/^tyblocks_a6(.*)/).test(input.account) || RegExp(/^tyblocks_a7(.*)/).test(input.account) || RegExp(/^keeta_aa(.*)/).test(input.account) || RegExp(/^keeta_ab(.*)/).test(input.account) || RegExp(/^keeta_ac(.*)/).test(input.account) || RegExp(/^keeta_ad(.*)/).test(input.account) || RegExp(/^tyblocks_aa(.*)/).test(input.account) || RegExp(/^tyblocks_ab(.*)/).test(input.account) || RegExp(/^tyblocks_ac(.*)/).test(input.account) || RegExp(/^tyblocks_ad(.*)/).test(input.account) || RegExp(/^keeta_ay(.*)/).test(input.account) || RegExp(/^keeta_az(.*)/).test(input.account) || RegExp(/^keeta_a2(.*)/).test(input.account) || RegExp(/^keeta_a3(.*)/).test(input.account) || RegExp(/^tyblocks_ay(.*)/).test(input.account) || RegExp(/^tyblocks_az(.*)/).test(input.account) || RegExp(/^tyblocks_a2(.*)/).test(input.account) || RegExp(/^tyblocks_a3(.*)/).test(input.account) || RegExp(/^keeta_ae(.*)/).test(input.account) || RegExp(/^keeta_af(.*)/).test(input.account) || RegExp(/^keeta_ag(.*)/).test(input.account) || RegExp(/^keeta_ah(.*)/).test(input.account) || RegExp(/^tyblocks_ae(.*)/).test(input.account) || RegExp(/^tyblocks_af(.*)/).test(input.account) || RegExp(/^tyblocks_ag(.*)/).test(input.account) || RegExp(/^tyblocks_ah(.*)/).test(input.account))) && "string" === typeof input.convertedAmount && ("object" === typeof input.cost && null !== input.cost && _io2(input.cost)) && ("object" === typeof input.signed && null !== input.signed && _io3(input.signed)); const _io1 = input => "string" === typeof input.from && (RegExp(/^keeta_am(.*)/).test(input.from) || RegExp(/^keeta_an(.*)/).test(input.from) || RegExp(/^keeta_ao(.*)/).test(input.from) || RegExp(/^keeta_ap(.*)/).test(input.from) || RegExp(/^tyblocks_am(.*)/).test(input.from) || RegExp(/^tyblocks_an(.*)/).test(input.from) || RegExp(/^tyblocks_ao(.*)/).test(input.from) || RegExp(/^tyblocks_ap(.*)/).test(input.from)) && ("string" === typeof input.to && (RegExp(/^keeta_am(.*)/).test(input.to) || RegExp(/^keeta_an(.*)/).test(input.to) || RegExp(/^keeta_ao(.*)/).test(input.to) || RegExp(/^keeta_ap(.*)/).test(input.to) || RegExp(/^tyblocks_am(.*)/).test(input.to) || RegExp(/^tyblocks_an(.*)/).test(input.to) || RegExp(/^tyblocks_ao(.*)/).test(input.to) || RegExp(/^tyblocks_ap(.*)/).test(input.to))) && "string" === typeof input.amount && ("from" === input.affinity || "to" === input.affinity); const _io2 = input => "string" === typeof input.amount && ("string" === typeof input.token && (RegExp(/^keeta_am(.*)/).test(input.token) || RegExp(/^keeta_an(.*)/).test(input.token) || RegExp(/^keeta_ao(.*)/).test(input.token) || RegExp(/^keeta_ap(.*)/).test(input.token) || RegExp(/^tyblocks_am(.*)/).test(input.token) || RegExp(/^tyblocks_an(.*)/).test(input.token) || RegExp(/^tyblocks_ao(.*)/).test(input.token) || RegExp(/^tyblocks_ap(.*)/).test(input.token))); const _io3 = input => "string" === typeof input.nonce && "string" === typeof input.timestamp && "string" === typeof input.signature; const _ao0 = (input, _path, _exceptionable = true) => (("object" === typeof input.request && null !== input.request || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
77
|
+
method: "createAssert",
|
|
78
|
+
path: _path + ".request",
|
|
79
|
+
expected: "__type.o1",
|
|
80
|
+
value: input.request
|
|
81
|
+
}, _errorFactory)) && _ao1(input.request, _path + ".request", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
82
|
+
method: "createAssert",
|
|
83
|
+
path: _path + ".request",
|
|
84
|
+
expected: "__type.o1",
|
|
85
|
+
value: input.request
|
|
86
|
+
}, _errorFactory)) && ("string" === typeof input.account && (RegExp(/^keeta_am(.*)/).test(input.account) || RegExp(/^keeta_an(.*)/).test(input.account) || RegExp(/^keeta_ao(.*)/).test(input.account) || RegExp(/^keeta_ap(.*)/).test(input.account) || RegExp(/^tyblocks_am(.*)/).test(input.account) || RegExp(/^tyblocks_an(.*)/).test(input.account) || RegExp(/^tyblocks_ao(.*)/).test(input.account) || RegExp(/^tyblocks_ap(.*)/).test(input.account) || RegExp(/^keeta_ai(.*)/).test(input.account) || RegExp(/^keeta_aj(.*)/).test(input.account) || RegExp(/^keeta_ak(.*)/).test(input.account) || RegExp(/^keeta_al(.*)/).test(input.account) || RegExp(/^tyblocks_ai(.*)/).test(input.account) || RegExp(/^tyblocks_aj(.*)/).test(input.account) || RegExp(/^tyblocks_ak(.*)/).test(input.account) || RegExp(/^tyblocks_al(.*)/).test(input.account) || RegExp(/^keeta_at(.*)/).test(input.account) || RegExp(/^keeta_aq(.*)/).test(input.account) || RegExp(/^keeta_ar(.*)/).test(input.account) || RegExp(/^keeta_as(.*)/).test(input.account) || RegExp(/^tyblocks_at(.*)/).test(input.account) || RegExp(/^tyblocks_aq(.*)/).test(input.account) || RegExp(/^tyblocks_ar(.*)/).test(input.account) || RegExp(/^tyblocks_as(.*)/).test(input.account) || RegExp(/^keeta_a4(.*)/).test(input.account) || RegExp(/^keeta_a5(.*)/).test(input.account) || RegExp(/^keeta_a6(.*)/).test(input.account) || RegExp(/^keeta_a7(.*)/).test(input.account) || RegExp(/^tyblocks_a4(.*)/).test(input.account) || RegExp(/^tyblocks_a5(.*)/).test(input.account) || RegExp(/^tyblocks_a6(.*)/).test(input.account) || RegExp(/^tyblocks_a7(.*)/).test(input.account) || RegExp(/^keeta_aa(.*)/).test(input.account) || RegExp(/^keeta_ab(.*)/).test(input.account) || RegExp(/^keeta_ac(.*)/).test(input.account) || RegExp(/^keeta_ad(.*)/).test(input.account) || RegExp(/^tyblocks_aa(.*)/).test(input.account) || RegExp(/^tyblocks_ab(.*)/).test(input.account) || RegExp(/^tyblocks_ac(.*)/).test(input.account) || RegExp(/^tyblocks_ad(.*)/).test(input.account) || RegExp(/^keeta_ay(.*)/).test(input.account) || RegExp(/^keeta_az(.*)/).test(input.account) || RegExp(/^keeta_a2(.*)/).test(input.account) || RegExp(/^keeta_a3(.*)/).test(input.account) || RegExp(/^tyblocks_ay(.*)/).test(input.account) || RegExp(/^tyblocks_az(.*)/).test(input.account) || RegExp(/^tyblocks_a2(.*)/).test(input.account) || RegExp(/^tyblocks_a3(.*)/).test(input.account) || RegExp(/^keeta_ae(.*)/).test(input.account) || RegExp(/^keeta_af(.*)/).test(input.account) || RegExp(/^keeta_ag(.*)/).test(input.account) || RegExp(/^keeta_ah(.*)/).test(input.account) || RegExp(/^tyblocks_ae(.*)/).test(input.account) || RegExp(/^tyblocks_af(.*)/).test(input.account) || RegExp(/^tyblocks_ag(.*)/).test(input.account) || RegExp(/^tyblocks_ah(.*)/).test(input.account)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
87
|
+
method: "createAssert",
|
|
88
|
+
path: _path + ".account",
|
|
89
|
+
expected: "(`keeta_a2${string}` | `keeta_a3${string}` | `keeta_a4${string}` | `keeta_a5${string}` | `keeta_a6${string}` | `keeta_a7${string}` | `keeta_aa${string}` | `keeta_ab${string}` | `keeta_ac${string}` | `keeta_ad${string}` | `keeta_ae${string}` | `keeta_af${string}` | `keeta_ag${string}` | `keeta_ah${string}` | `keeta_ai${string}` | `keeta_aj${string}` | `keeta_ak${string}` | `keeta_al${string}` | `keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `keeta_aq${string}` | `keeta_ar${string}` | `keeta_as${string}` | `keeta_at${string}` | `keeta_ay${string}` | `keeta_az${string}` | `tyblocks_a2${string}` | `tyblocks_a3${string}` | `tyblocks_a4${string}` | `tyblocks_a5${string}` | `tyblocks_a6${string}` | `tyblocks_a7${string}` | `tyblocks_aa${string}` | `tyblocks_ab${string}` | `tyblocks_ac${string}` | `tyblocks_ad${string}` | `tyblocks_ae${string}` | `tyblocks_af${string}` | `tyblocks_ag${string}` | `tyblocks_ah${string}` | `tyblocks_ai${string}` | `tyblocks_aj${string}` | `tyblocks_ak${string}` | `tyblocks_al${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}` | `tyblocks_aq${string}` | `tyblocks_ar${string}` | `tyblocks_as${string}` | `tyblocks_at${string}` | `tyblocks_ay${string}` | `tyblocks_az${string}`)",
|
|
90
|
+
value: input.account
|
|
91
|
+
}, _errorFactory)) && ("string" === typeof input.convertedAmount || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
92
|
+
method: "createAssert",
|
|
93
|
+
path: _path + ".convertedAmount",
|
|
94
|
+
expected: "string",
|
|
95
|
+
value: input.convertedAmount
|
|
96
|
+
}, _errorFactory)) && (("object" === typeof input.cost && null !== input.cost || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
97
|
+
method: "createAssert",
|
|
98
|
+
path: _path + ".cost",
|
|
99
|
+
expected: "__type.o2",
|
|
100
|
+
value: input.cost
|
|
101
|
+
}, _errorFactory)) && _ao2(input.cost, _path + ".cost", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
102
|
+
method: "createAssert",
|
|
103
|
+
path: _path + ".cost",
|
|
104
|
+
expected: "__type.o2",
|
|
105
|
+
value: input.cost
|
|
106
|
+
}, _errorFactory)) && (("object" === typeof input.signed && null !== input.signed || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
107
|
+
method: "createAssert",
|
|
108
|
+
path: _path + ".signed",
|
|
109
|
+
expected: "__type.o3",
|
|
110
|
+
value: input.signed
|
|
111
|
+
}, _errorFactory)) && _ao3(input.signed, _path + ".signed", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
112
|
+
method: "createAssert",
|
|
113
|
+
path: _path + ".signed",
|
|
114
|
+
expected: "__type.o3",
|
|
115
|
+
value: input.signed
|
|
116
|
+
}, _errorFactory)); const _ao1 = (input, _path, _exceptionable = true) => ("string" === typeof input.from && (RegExp(/^keeta_am(.*)/).test(input.from) || RegExp(/^keeta_an(.*)/).test(input.from) || RegExp(/^keeta_ao(.*)/).test(input.from) || RegExp(/^keeta_ap(.*)/).test(input.from) || RegExp(/^tyblocks_am(.*)/).test(input.from) || RegExp(/^tyblocks_an(.*)/).test(input.from) || RegExp(/^tyblocks_ao(.*)/).test(input.from) || RegExp(/^tyblocks_ap(.*)/).test(input.from)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
117
|
+
method: "createAssert",
|
|
118
|
+
path: _path + ".from",
|
|
119
|
+
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
120
|
+
value: input.from
|
|
121
|
+
}, _errorFactory)) && ("string" === typeof input.to && (RegExp(/^keeta_am(.*)/).test(input.to) || RegExp(/^keeta_an(.*)/).test(input.to) || RegExp(/^keeta_ao(.*)/).test(input.to) || RegExp(/^keeta_ap(.*)/).test(input.to) || RegExp(/^tyblocks_am(.*)/).test(input.to) || RegExp(/^tyblocks_an(.*)/).test(input.to) || RegExp(/^tyblocks_ao(.*)/).test(input.to) || RegExp(/^tyblocks_ap(.*)/).test(input.to)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
122
|
+
method: "createAssert",
|
|
123
|
+
path: _path + ".to",
|
|
124
|
+
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
125
|
+
value: input.to
|
|
126
|
+
}, _errorFactory)) && ("string" === typeof input.amount || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
127
|
+
method: "createAssert",
|
|
128
|
+
path: _path + ".amount",
|
|
129
|
+
expected: "string",
|
|
130
|
+
value: input.amount
|
|
131
|
+
}, _errorFactory)) && ("from" === input.affinity || "to" === input.affinity || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
132
|
+
method: "createAssert",
|
|
133
|
+
path: _path + ".affinity",
|
|
134
|
+
expected: "(\"from\" | \"to\")",
|
|
135
|
+
value: input.affinity
|
|
136
|
+
}, _errorFactory)); const _ao2 = (input, _path, _exceptionable = true) => ("string" === typeof input.amount || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
137
|
+
method: "createAssert",
|
|
138
|
+
path: _path + ".amount",
|
|
139
|
+
expected: "string",
|
|
140
|
+
value: input.amount
|
|
141
|
+
}, _errorFactory)) && ("string" === typeof input.token && (RegExp(/^keeta_am(.*)/).test(input.token) || RegExp(/^keeta_an(.*)/).test(input.token) || RegExp(/^keeta_ao(.*)/).test(input.token) || RegExp(/^keeta_ap(.*)/).test(input.token) || RegExp(/^tyblocks_am(.*)/).test(input.token) || RegExp(/^tyblocks_an(.*)/).test(input.token) || RegExp(/^tyblocks_ao(.*)/).test(input.token) || RegExp(/^tyblocks_ap(.*)/).test(input.token)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
142
|
+
method: "createAssert",
|
|
143
|
+
path: _path + ".token",
|
|
144
|
+
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
145
|
+
value: input.token
|
|
146
|
+
}, _errorFactory)); const _ao3 = (input, _path, _exceptionable = true) => ("string" === typeof input.nonce || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
147
|
+
method: "createAssert",
|
|
148
|
+
path: _path + ".nonce",
|
|
149
|
+
expected: "string",
|
|
150
|
+
value: input.nonce
|
|
151
|
+
}, _errorFactory)) && ("string" === typeof input.timestamp || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
152
|
+
method: "createAssert",
|
|
153
|
+
path: _path + ".timestamp",
|
|
154
|
+
expected: "string",
|
|
155
|
+
value: input.timestamp
|
|
156
|
+
}, _errorFactory)) && ("string" === typeof input.signature || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
157
|
+
method: "createAssert",
|
|
158
|
+
path: _path + ".signature",
|
|
159
|
+
expected: "string",
|
|
160
|
+
value: input.signature
|
|
161
|
+
}, _errorFactory)); const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; return (input, errorFactory) => {
|
|
162
|
+
if (false === __is(input)) {
|
|
163
|
+
_errorFactory = errorFactory;
|
|
164
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __typia_transform__assertGuard._assertGuard(true, {
|
|
165
|
+
method: "createAssert",
|
|
166
|
+
path: _path + "",
|
|
167
|
+
expected: "__type",
|
|
168
|
+
value: input
|
|
169
|
+
}, _errorFactory)) && _ao0(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
|
|
170
|
+
method: "createAssert",
|
|
171
|
+
path: _path + "",
|
|
172
|
+
expected: "__type",
|
|
173
|
+
value: input
|
|
174
|
+
}, _errorFactory))(input, "$input", true);
|
|
175
|
+
}
|
|
176
|
+
return input;
|
|
177
|
+
}; })();
|
|
2
178
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/services/fx/common.ts"],"names":[],"mappings":"","sourcesContent":["import type { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\nimport type {
|
|
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;AA0I/C,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","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';\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: {\n\t\tnonce: string;\n\t\t/* Date and time of the request in ISO 8601 format */\n\t\ttimestamp: string;\n\t\t/* Signature of the account public key and the nonce as an ASN.1 Sequence, Base64 DER */\n\t\tsignature: string;\n\t}\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"]}
|
package/services/fx/server.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as KeetaAnchorHTTPServer from '../../lib/http-server.js';
|
|
2
2
|
import KeetaNet from '@keetanetwork/keetanet-client';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ConversionInputCanonicalJSON, KeetaFXAnchorQuote, KeetaNetAccount, KeetaNetStorageAccount } from './common.ts';
|
|
4
4
|
import * as Signing from '../../lib/utils/signing.js';
|
|
5
|
+
import type { ServiceMetadata } from '../../lib/resolver.js';
|
|
5
6
|
export interface KeetaAnchorFXServerConfig extends KeetaAnchorHTTPServer.KeetaAnchorHTTPServerConfig {
|
|
6
7
|
/**
|
|
7
8
|
* The data to use for the index page (optional)
|
|
@@ -12,7 +13,7 @@ export interface KeetaAnchorFXServerConfig extends KeetaAnchorHTTPServer.KeetaAn
|
|
|
12
13
|
*
|
|
13
14
|
* This may be either a function or a KeetaNet Account instance.
|
|
14
15
|
*/
|
|
15
|
-
account:
|
|
16
|
+
account: KeetaNetAccount | KeetaNetStorageAccount | ((request: ConversionInputCanonicalJSON) => Promise<KeetaNetAccount | KeetaNetStorageAccount> | KeetaNetAccount | KeetaNetStorageAccount);
|
|
16
17
|
/**
|
|
17
18
|
* Account which can be used to sign transactions
|
|
18
19
|
* for the account above (if not supplied the
|
|
@@ -20,7 +21,7 @@ export interface KeetaAnchorFXServerConfig extends KeetaAnchorHTTPServer.KeetaAn
|
|
|
20
21
|
*
|
|
21
22
|
* This may be either a function or a KeetaNet Account instance.
|
|
22
23
|
*/
|
|
23
|
-
signer?: InstanceType<typeof KeetaNet.lib.Account> | ((request:
|
|
24
|
+
signer?: InstanceType<typeof KeetaNet.lib.Account> | ((request: ConversionInputCanonicalJSON) => Promise<InstanceType<typeof KeetaNet.lib.Account>> | InstanceType<typeof KeetaNet.lib.Account>);
|
|
24
25
|
/**
|
|
25
26
|
* Account which performs the signing and validation of quotes
|
|
26
27
|
*/
|
|
@@ -29,12 +30,16 @@ export interface KeetaAnchorFXServerConfig extends KeetaAnchorHTTPServer.KeetaAn
|
|
|
29
30
|
* Configuration for FX handling
|
|
30
31
|
*/
|
|
31
32
|
fx: {
|
|
33
|
+
/**
|
|
34
|
+
* Supported conversions
|
|
35
|
+
*/
|
|
36
|
+
from?: NonNullable<ServiceMetadata['services']['fx']>[string]['from'];
|
|
32
37
|
/**
|
|
33
38
|
* Handle the conversion request of one token to another
|
|
34
39
|
*
|
|
35
40
|
* This is used to handle quotes and estimates
|
|
36
41
|
*/
|
|
37
|
-
getConversionRateAndFee: (request:
|
|
42
|
+
getConversionRateAndFee: (request: ConversionInputCanonicalJSON) => Promise<Omit<KeetaFXAnchorQuote, 'request' | 'signed'>>;
|
|
38
43
|
};
|
|
39
44
|
/**
|
|
40
45
|
* The network client to use for submitting blocks
|
|
@@ -54,5 +59,9 @@ export declare class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.Ke
|
|
|
54
59
|
readonly fx: KeetaAnchorFXServerConfig['fx'];
|
|
55
60
|
constructor(config: KeetaAnchorFXServerConfig);
|
|
56
61
|
protected initRoutes(config: KeetaAnchorFXServerConfig): Promise<KeetaAnchorHTTPServer.Routes>;
|
|
62
|
+
/**
|
|
63
|
+
* Return the servers endpoints and possible currency conversions metadata
|
|
64
|
+
*/
|
|
65
|
+
serviceMetadata(): Promise<NonNullable<ServiceMetadata['services']['fx']>[string]>;
|
|
57
66
|
}
|
|
58
67
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/services/fx/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,QAAQ,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/services/fx/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,QAAQ,MAAM,+BAA+B,CAAC;AAQrD,OAAO,KAAK,EACX,4BAA4B,EAG5B,kBAAkB,EAGlB,eAAe,EACf,sBAAsB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB,CAAC,2BAA2B;IACnG;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IAErD;;;;OAIG;IACH,OAAO,EAAE,eAAe,GAAG,sBAAsB,GAAG,CAAC,CAAC,OAAO,EAAE,4BAA4B,KAAK,OAAO,CAAC,eAAe,GAAG,sBAAsB,CAAC,GAAG,eAAe,GAAG,sBAAsB,CAAC,CAAC;IAC9L;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,4BAA4B,KAAK,OAAO,CAAC,YAAY,CAAC,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAEjM;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,eAAe,CAAC;IAErC;;OAEG;IACH,EAAE,EAAE;QACH;;WAEG;QACH,IAAI,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;QACtE;;;;WAIG;QACH,uBAAuB,EAAE,CAAC,OAAO,EAAE,4BAA4B,KAAK,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,QAAQ,CAAE,CAAC,CAAC;KAC7H,CAAC;IAEF;;OAEG;IACH,MAAM,EAAE;QAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;KAAE,GAAG,QAAQ,CAAC,UAAU,CAAC;CAC9I;AAqED,qBAAa,0BAA2B,SAAQ,qBAAqB,CAAC,wBAAwB,CAAC,yBAAyB,CAAE,YAAW,QAAQ,CAAC,yBAAyB,CAAC;IACvK,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAAC;IACtE,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC;IACrD,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAC;IACvD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,yBAAyB,CAAC,aAAa,CAAC,CAAC;IAC/D,QAAQ,CAAC,EAAE,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;gBAEjC,MAAM,EAAE,yBAAyB;cAW7B,UAAU,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC;IAsMpG;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;CAaxF"}
|
package/services/fx/server.js
CHANGED
|
@@ -1,148 +1,8 @@
|
|
|
1
|
-
import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js";
|
|
2
1
|
import * as KeetaAnchorHTTPServer from '../../lib/http-server.js';
|
|
3
2
|
import KeetaNet from '@keetanetwork/keetanet-client';
|
|
4
|
-
import { createAssert } from 'typia';
|
|
5
3
|
import { KeetaAnchorUserError } from '../../lib/error.js';
|
|
4
|
+
import { assertConversionInputCanonicalJSON, assertConversionQuoteJSON } from './common.js';
|
|
6
5
|
import * as Signing from '../../lib/utils/signing.js';
|
|
7
|
-
const assertConversionInputCanonical = (() => { const _io0 = input => "string" === typeof input.from && (RegExp(/^keeta_am(.*)/).test(input.from) || RegExp(/^keeta_an(.*)/).test(input.from) || RegExp(/^keeta_ao(.*)/).test(input.from) || RegExp(/^keeta_ap(.*)/).test(input.from) || RegExp(/^tyblocks_am(.*)/).test(input.from) || RegExp(/^tyblocks_an(.*)/).test(input.from) || RegExp(/^tyblocks_ao(.*)/).test(input.from) || RegExp(/^tyblocks_ap(.*)/).test(input.from)) && ("string" === typeof input.to && (RegExp(/^keeta_am(.*)/).test(input.to) || RegExp(/^keeta_an(.*)/).test(input.to) || RegExp(/^keeta_ao(.*)/).test(input.to) || RegExp(/^keeta_ap(.*)/).test(input.to) || RegExp(/^tyblocks_am(.*)/).test(input.to) || RegExp(/^tyblocks_an(.*)/).test(input.to) || RegExp(/^tyblocks_ao(.*)/).test(input.to) || RegExp(/^tyblocks_ap(.*)/).test(input.to))) && "string" === typeof input.amount && ("from" === input.affinity || "to" === input.affinity); const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.from && (RegExp(/^keeta_am(.*)/).test(input.from) || RegExp(/^keeta_an(.*)/).test(input.from) || RegExp(/^keeta_ao(.*)/).test(input.from) || RegExp(/^keeta_ap(.*)/).test(input.from) || RegExp(/^tyblocks_am(.*)/).test(input.from) || RegExp(/^tyblocks_an(.*)/).test(input.from) || RegExp(/^tyblocks_ao(.*)/).test(input.from) || RegExp(/^tyblocks_ap(.*)/).test(input.from)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
8
|
-
method: "createAssert",
|
|
9
|
-
path: _path + ".from",
|
|
10
|
-
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
11
|
-
value: input.from
|
|
12
|
-
}, _errorFactory)) && ("string" === typeof input.to && (RegExp(/^keeta_am(.*)/).test(input.to) || RegExp(/^keeta_an(.*)/).test(input.to) || RegExp(/^keeta_ao(.*)/).test(input.to) || RegExp(/^keeta_ap(.*)/).test(input.to) || RegExp(/^tyblocks_am(.*)/).test(input.to) || RegExp(/^tyblocks_an(.*)/).test(input.to) || RegExp(/^tyblocks_ao(.*)/).test(input.to) || RegExp(/^tyblocks_ap(.*)/).test(input.to)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
13
|
-
method: "createAssert",
|
|
14
|
-
path: _path + ".to",
|
|
15
|
-
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
16
|
-
value: input.to
|
|
17
|
-
}, _errorFactory)) && ("string" === typeof input.amount || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
18
|
-
method: "createAssert",
|
|
19
|
-
path: _path + ".amount",
|
|
20
|
-
expected: "string",
|
|
21
|
-
value: input.amount
|
|
22
|
-
}, _errorFactory)) && ("from" === input.affinity || "to" === input.affinity || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
23
|
-
method: "createAssert",
|
|
24
|
-
path: _path + ".affinity",
|
|
25
|
-
expected: "(\"from\" | \"to\")",
|
|
26
|
-
value: input.affinity
|
|
27
|
-
}, _errorFactory)); const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; return (input, errorFactory) => {
|
|
28
|
-
if (false === __is(input)) {
|
|
29
|
-
_errorFactory = errorFactory;
|
|
30
|
-
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __typia_transform__assertGuard._assertGuard(true, {
|
|
31
|
-
method: "createAssert",
|
|
32
|
-
path: _path + "",
|
|
33
|
-
expected: "ConversionInputCanonical",
|
|
34
|
-
value: input
|
|
35
|
-
}, _errorFactory)) && _ao0(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
|
|
36
|
-
method: "createAssert",
|
|
37
|
-
path: _path + "",
|
|
38
|
-
expected: "ConversionInputCanonical",
|
|
39
|
-
value: input
|
|
40
|
-
}, _errorFactory))(input, "$input", true);
|
|
41
|
-
}
|
|
42
|
-
return input;
|
|
43
|
-
}; })();
|
|
44
|
-
const assertConversionQuote = (() => { const _io0 = input => "object" === typeof input.request && null !== input.request && _io1(input.request) && "string" === typeof input.account && "string" === typeof input.convertedAmount && ("object" === typeof input.cost && null !== input.cost && _io2(input.cost)) && ("object" === typeof input.signed && null !== input.signed && _io3(input.signed)); const _io1 = input => "string" === typeof input.from && (RegExp(/^keeta_am(.*)/).test(input.from) || RegExp(/^keeta_an(.*)/).test(input.from) || RegExp(/^keeta_ao(.*)/).test(input.from) || RegExp(/^keeta_ap(.*)/).test(input.from) || RegExp(/^tyblocks_am(.*)/).test(input.from) || RegExp(/^tyblocks_an(.*)/).test(input.from) || RegExp(/^tyblocks_ao(.*)/).test(input.from) || RegExp(/^tyblocks_ap(.*)/).test(input.from)) && ("string" === typeof input.to && (RegExp(/^keeta_am(.*)/).test(input.to) || RegExp(/^keeta_an(.*)/).test(input.to) || RegExp(/^keeta_ao(.*)/).test(input.to) || RegExp(/^keeta_ap(.*)/).test(input.to) || RegExp(/^tyblocks_am(.*)/).test(input.to) || RegExp(/^tyblocks_an(.*)/).test(input.to) || RegExp(/^tyblocks_ao(.*)/).test(input.to) || RegExp(/^tyblocks_ap(.*)/).test(input.to))) && "string" === typeof input.amount && ("from" === input.affinity || "to" === input.affinity); const _io2 = input => "string" === typeof input.amount && ("string" === typeof input.token && (RegExp(/^keeta_am(.*)/).test(input.token) || RegExp(/^keeta_an(.*)/).test(input.token) || RegExp(/^keeta_ao(.*)/).test(input.token) || RegExp(/^keeta_ap(.*)/).test(input.token) || RegExp(/^tyblocks_am(.*)/).test(input.token) || RegExp(/^tyblocks_an(.*)/).test(input.token) || RegExp(/^tyblocks_ao(.*)/).test(input.token) || RegExp(/^tyblocks_ap(.*)/).test(input.token))); const _io3 = input => "string" === typeof input.nonce && "string" === typeof input.timestamp && "string" === typeof input.signature; const _ao0 = (input, _path, _exceptionable = true) => (("object" === typeof input.request && null !== input.request || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
45
|
-
method: "createAssert",
|
|
46
|
-
path: _path + ".request",
|
|
47
|
-
expected: "ConversionInputCanonical",
|
|
48
|
-
value: input.request
|
|
49
|
-
}, _errorFactory)) && _ao1(input.request, _path + ".request", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
50
|
-
method: "createAssert",
|
|
51
|
-
path: _path + ".request",
|
|
52
|
-
expected: "ConversionInputCanonical",
|
|
53
|
-
value: input.request
|
|
54
|
-
}, _errorFactory)) && ("string" === typeof input.account || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
55
|
-
method: "createAssert",
|
|
56
|
-
path: _path + ".account",
|
|
57
|
-
expected: "string",
|
|
58
|
-
value: input.account
|
|
59
|
-
}, _errorFactory)) && ("string" === typeof input.convertedAmount || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
60
|
-
method: "createAssert",
|
|
61
|
-
path: _path + ".convertedAmount",
|
|
62
|
-
expected: "string",
|
|
63
|
-
value: input.convertedAmount
|
|
64
|
-
}, _errorFactory)) && (("object" === typeof input.cost && null !== input.cost || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
65
|
-
method: "createAssert",
|
|
66
|
-
path: _path + ".cost",
|
|
67
|
-
expected: "__type",
|
|
68
|
-
value: input.cost
|
|
69
|
-
}, _errorFactory)) && _ao2(input.cost, _path + ".cost", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
70
|
-
method: "createAssert",
|
|
71
|
-
path: _path + ".cost",
|
|
72
|
-
expected: "__type",
|
|
73
|
-
value: input.cost
|
|
74
|
-
}, _errorFactory)) && (("object" === typeof input.signed && null !== input.signed || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
75
|
-
method: "createAssert",
|
|
76
|
-
path: _path + ".signed",
|
|
77
|
-
expected: "__type.o1",
|
|
78
|
-
value: input.signed
|
|
79
|
-
}, _errorFactory)) && _ao3(input.signed, _path + ".signed", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
80
|
-
method: "createAssert",
|
|
81
|
-
path: _path + ".signed",
|
|
82
|
-
expected: "__type.o1",
|
|
83
|
-
value: input.signed
|
|
84
|
-
}, _errorFactory)); const _ao1 = (input, _path, _exceptionable = true) => ("string" === typeof input.from && (RegExp(/^keeta_am(.*)/).test(input.from) || RegExp(/^keeta_an(.*)/).test(input.from) || RegExp(/^keeta_ao(.*)/).test(input.from) || RegExp(/^keeta_ap(.*)/).test(input.from) || RegExp(/^tyblocks_am(.*)/).test(input.from) || RegExp(/^tyblocks_an(.*)/).test(input.from) || RegExp(/^tyblocks_ao(.*)/).test(input.from) || RegExp(/^tyblocks_ap(.*)/).test(input.from)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
85
|
-
method: "createAssert",
|
|
86
|
-
path: _path + ".from",
|
|
87
|
-
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
88
|
-
value: input.from
|
|
89
|
-
}, _errorFactory)) && ("string" === typeof input.to && (RegExp(/^keeta_am(.*)/).test(input.to) || RegExp(/^keeta_an(.*)/).test(input.to) || RegExp(/^keeta_ao(.*)/).test(input.to) || RegExp(/^keeta_ap(.*)/).test(input.to) || RegExp(/^tyblocks_am(.*)/).test(input.to) || RegExp(/^tyblocks_an(.*)/).test(input.to) || RegExp(/^tyblocks_ao(.*)/).test(input.to) || RegExp(/^tyblocks_ap(.*)/).test(input.to)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
90
|
-
method: "createAssert",
|
|
91
|
-
path: _path + ".to",
|
|
92
|
-
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
93
|
-
value: input.to
|
|
94
|
-
}, _errorFactory)) && ("string" === typeof input.amount || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
95
|
-
method: "createAssert",
|
|
96
|
-
path: _path + ".amount",
|
|
97
|
-
expected: "string",
|
|
98
|
-
value: input.amount
|
|
99
|
-
}, _errorFactory)) && ("from" === input.affinity || "to" === input.affinity || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
100
|
-
method: "createAssert",
|
|
101
|
-
path: _path + ".affinity",
|
|
102
|
-
expected: "(\"from\" | \"to\")",
|
|
103
|
-
value: input.affinity
|
|
104
|
-
}, _errorFactory)); const _ao2 = (input, _path, _exceptionable = true) => ("string" === typeof input.amount || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
105
|
-
method: "createAssert",
|
|
106
|
-
path: _path + ".amount",
|
|
107
|
-
expected: "string",
|
|
108
|
-
value: input.amount
|
|
109
|
-
}, _errorFactory)) && ("string" === typeof input.token && (RegExp(/^keeta_am(.*)/).test(input.token) || RegExp(/^keeta_an(.*)/).test(input.token) || RegExp(/^keeta_ao(.*)/).test(input.token) || RegExp(/^keeta_ap(.*)/).test(input.token) || RegExp(/^tyblocks_am(.*)/).test(input.token) || RegExp(/^tyblocks_an(.*)/).test(input.token) || RegExp(/^tyblocks_ao(.*)/).test(input.token) || RegExp(/^tyblocks_ap(.*)/).test(input.token)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
110
|
-
method: "createAssert",
|
|
111
|
-
path: _path + ".token",
|
|
112
|
-
expected: "(`keeta_am${string}` | `keeta_an${string}` | `keeta_ao${string}` | `keeta_ap${string}` | `tyblocks_am${string}` | `tyblocks_an${string}` | `tyblocks_ao${string}` | `tyblocks_ap${string}`)",
|
|
113
|
-
value: input.token
|
|
114
|
-
}, _errorFactory)); const _ao3 = (input, _path, _exceptionable = true) => ("string" === typeof input.nonce || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
115
|
-
method: "createAssert",
|
|
116
|
-
path: _path + ".nonce",
|
|
117
|
-
expected: "string",
|
|
118
|
-
value: input.nonce
|
|
119
|
-
}, _errorFactory)) && ("string" === typeof input.timestamp || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
120
|
-
method: "createAssert",
|
|
121
|
-
path: _path + ".timestamp",
|
|
122
|
-
expected: "string",
|
|
123
|
-
value: input.timestamp
|
|
124
|
-
}, _errorFactory)) && ("string" === typeof input.signature || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
125
|
-
method: "createAssert",
|
|
126
|
-
path: _path + ".signature",
|
|
127
|
-
expected: "string",
|
|
128
|
-
value: input.signature
|
|
129
|
-
}, _errorFactory)); const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; return (input, errorFactory) => {
|
|
130
|
-
if (false === __is(input)) {
|
|
131
|
-
_errorFactory = errorFactory;
|
|
132
|
-
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __typia_transform__assertGuard._assertGuard(true, {
|
|
133
|
-
method: "createAssert",
|
|
134
|
-
path: _path + "",
|
|
135
|
-
expected: "KeetaFXAnchorQuote",
|
|
136
|
-
value: input
|
|
137
|
-
}, _errorFactory)) && _ao0(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
|
|
138
|
-
method: "createAssert",
|
|
139
|
-
path: _path + "",
|
|
140
|
-
expected: "KeetaFXAnchorQuote",
|
|
141
|
-
value: input
|
|
142
|
-
}, _errorFactory))(input, "$input", true);
|
|
143
|
-
}
|
|
144
|
-
return input;
|
|
145
|
-
}; })();
|
|
146
6
|
;
|
|
147
7
|
async function formatQuoteSignable(unsignedQuote) {
|
|
148
8
|
const retval = [
|
|
@@ -175,9 +35,15 @@ async function requestToAccounts(config, request) {
|
|
|
175
35
|
if (config.signer !== undefined) {
|
|
176
36
|
signer = (KeetaNet.lib.Account.isInstance(config.signer) ? config.signer : await config.signer(request)).assertAccount();
|
|
177
37
|
}
|
|
38
|
+
if (signer === null) {
|
|
39
|
+
signer = account.assertAccount();
|
|
40
|
+
}
|
|
41
|
+
if (!account.isAccount() && !account.isStorage()) {
|
|
42
|
+
throw (new Error('FX Account should be an Account or Storage Account'));
|
|
43
|
+
}
|
|
178
44
|
return ({
|
|
179
|
-
signer: signer
|
|
180
|
-
account: account
|
|
45
|
+
signer: signer,
|
|
46
|
+
account: account
|
|
181
47
|
});
|
|
182
48
|
}
|
|
183
49
|
export class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAnchorHTTPServer {
|
|
@@ -229,11 +95,11 @@ export class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAn
|
|
|
229
95
|
if (!('request' in postData)) {
|
|
230
96
|
throw (new Error('POST data missing request'));
|
|
231
97
|
}
|
|
232
|
-
const conversion =
|
|
98
|
+
const conversion = assertConversionInputCanonicalJSON(postData.request);
|
|
233
99
|
const rateAndFee = await config.fx.getConversionRateAndFee(conversion);
|
|
234
100
|
const estimateResponse = {
|
|
235
101
|
ok: true,
|
|
236
|
-
estimate: {
|
|
102
|
+
estimate: KeetaNet.lib.Utils.Conversion.toJSONSerializable({
|
|
237
103
|
request: conversion,
|
|
238
104
|
convertedAmount: rateAndFee.convertedAmount,
|
|
239
105
|
expectedCost: {
|
|
@@ -241,7 +107,7 @@ export class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAn
|
|
|
241
107
|
max: rateAndFee.cost.amount,
|
|
242
108
|
token: rateAndFee.cost.token
|
|
243
109
|
}
|
|
244
|
-
}
|
|
110
|
+
})
|
|
245
111
|
};
|
|
246
112
|
return ({
|
|
247
113
|
output: JSON.stringify(estimateResponse)
|
|
@@ -254,12 +120,12 @@ export class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAn
|
|
|
254
120
|
if (!('request' in postData)) {
|
|
255
121
|
throw (new Error('POST data missing request'));
|
|
256
122
|
}
|
|
257
|
-
const conversion =
|
|
123
|
+
const conversion = assertConversionInputCanonicalJSON(postData.request);
|
|
258
124
|
const rateAndFee = await config.fx.getConversionRateAndFee(conversion);
|
|
259
|
-
const unsignedQuote = {
|
|
125
|
+
const unsignedQuote = KeetaNet.lib.Utils.Conversion.toJSONSerializable({
|
|
260
126
|
request: conversion,
|
|
261
127
|
...rateAndFee
|
|
262
|
-
};
|
|
128
|
+
});
|
|
263
129
|
const signedQuote = await generateSignedQuote(config.quoteSigner, unsignedQuote);
|
|
264
130
|
const quoteResponse = {
|
|
265
131
|
ok: true,
|
|
@@ -286,7 +152,7 @@ export class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAn
|
|
|
286
152
|
if (!('block' in request) || typeof request.block !== 'string') {
|
|
287
153
|
throw (new Error('Block was not provided in exchange request'));
|
|
288
154
|
}
|
|
289
|
-
const quote =
|
|
155
|
+
const quote = assertConversionQuoteJSON(request.quote);
|
|
290
156
|
const isValidQuote = await verifySignedData(config.quoteSigner, quote);
|
|
291
157
|
if (!isValidQuote) {
|
|
292
158
|
throw (new Error('Invalid quote signature'));
|
|
@@ -306,8 +172,34 @@ export class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAn
|
|
|
306
172
|
signer: signer
|
|
307
173
|
});
|
|
308
174
|
}
|
|
175
|
+
/* Get Expected Amount and Token to Verify Swap */
|
|
309
176
|
const expectedToken = KeetaNet.lib.Account.fromPublicKeyString(quote.request.from);
|
|
310
|
-
|
|
177
|
+
let expectedAmount = quote.request.affinity === 'from' ? BigInt(quote.request.amount) : BigInt(quote.convertedAmount);
|
|
178
|
+
/* If cost is required verify the amounts and token. */
|
|
179
|
+
if (BigInt(quote.cost.amount) > 0) {
|
|
180
|
+
/* If swap token matches the cost token the add the amount since they should be combined in one block and will be checked in `acceptSwapRequest` */
|
|
181
|
+
if (expectedToken.comparePublicKey(quote.cost.token)) {
|
|
182
|
+
expectedAmount += BigInt(quote.cost.amount);
|
|
183
|
+
/* If token is different then check block operations for matching amount and token */
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
let requestIncludesCost = false;
|
|
187
|
+
for (const operation of block.operations) {
|
|
188
|
+
if (operation.type === KeetaNet.lib.Block.OperationType.SEND) {
|
|
189
|
+
const recipientMatches = operation.to.comparePublicKey(quote.account);
|
|
190
|
+
const tokenMatches = operation.token.comparePublicKey(quote.cost.token);
|
|
191
|
+
const amountMatches = operation.amount === BigInt(quote.cost.amount);
|
|
192
|
+
if (recipientMatches && tokenMatches && amountMatches) {
|
|
193
|
+
requestIncludesCost = true;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (!requestIncludesCost) {
|
|
198
|
+
throw (new Error('Exchange missing required cost'));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/* Verify Request and Generate the Accept Swap Block */
|
|
311
203
|
const swapBlocks = await userClient.acceptSwapRequest({ block, expected: { token: expectedToken, amount: BigInt(expectedAmount) } });
|
|
312
204
|
const publishOptions = {};
|
|
313
205
|
if (userClient.config.generateFeeBlock !== undefined) {
|
|
@@ -347,5 +239,20 @@ export class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAn
|
|
|
347
239
|
};
|
|
348
240
|
return (routes);
|
|
349
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Return the servers endpoints and possible currency conversions metadata
|
|
244
|
+
*/
|
|
245
|
+
async serviceMetadata() {
|
|
246
|
+
const operations = {
|
|
247
|
+
getEstimate: (new URL('/api/getEstimate', this.url)).toString(),
|
|
248
|
+
getQuote: (new URL('/api/getQuote', this.url)).toString(),
|
|
249
|
+
createExchange: (new URL('/api/createExchange', this.url)).toString(),
|
|
250
|
+
getExchangeStatus: (new URL('/api/getExchangeStatus', this.url)).toString() + '/{id}'
|
|
251
|
+
};
|
|
252
|
+
return ({
|
|
253
|
+
from: this.fx.from ?? [],
|
|
254
|
+
operations: operations
|
|
255
|
+
});
|
|
256
|
+
}
|
|
350
257
|
}
|
|
351
258
|
//# sourceMappingURL=server.js.map
|