@keetanetwork/anchor 0.0.13 → 0.0.15
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 +508 -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 +5 -5
- package/lib/http-server.js.map +1 -1
- package/lib/log/index.d.ts +6 -57
- package/lib/log/index.d.ts.map +1 -1
- package/lib/log/index.js +5 -205
- package/lib/log/index.js.map +1 -1
- package/lib/log/target_console.d.ts +3 -11
- package/lib/log/target_console.d.ts.map +1 -1
- package/lib/log/target_console.js +3 -42
- package/lib/log/target_console.js.map +1 -1
- package/lib/resolver.d.ts +2 -1
- package/lib/resolver.d.ts.map +1 -1
- package/lib/resolver.js +22 -22
- package/lib/resolver.js.map +1 -1
- package/lib/utils/asn1.d.ts +10 -1
- package/lib/utils/asn1.d.ts.map +1 -1
- package/lib/utils/asn1.js +1413 -0
- 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 +32 -0
- package/lib/utils/buffer.js.map +1 -1
- package/lib/utils/external.d.ts +43 -0
- package/lib/utils/external.d.ts.map +1 -0
- package/lib/utils/external.js +115 -0
- package/lib/utils/external.js.map +1 -0
- 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/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 +76 -216
- package/package.json +2 -2
- package/services/asset-movement/common.js +7 -7
- package/services/fx/server.js +1 -1
- 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 +336 -0
- package/services/kyc/iso20022.generated.d.ts.map +1 -0
- package/services/kyc/iso20022.generated.js +287 -0
- package/services/kyc/iso20022.generated.js.map +1 -0
- package/services/kyc/oids.generated.d.ts +104 -0
- package/services/kyc/oids.generated.d.ts.map +1 -0
- package/services/kyc/oids.generated.js +163 -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 +1342 -0
- package/services/kyc/utils/generate-kyc-schema.js.map +1 -0
- package/lib/log/common.d.ts +0 -35
- package/lib/log/common.d.ts.map +0 -1
- package/lib/log/common.js +0 -19
- package/lib/log/common.js.map +0 -1
|
@@ -369,7 +369,7 @@ export const assertKeetaSupportedAssets = (() => { const _io0 = input => "string
|
|
|
369
369
|
}
|
|
370
370
|
return input;
|
|
371
371
|
}; })();
|
|
372
|
-
export const assertKeetaAssetMovementAnchorCreatePersistentForwardingRequest = (() => { const _iv1 = new Set(["
|
|
372
|
+
export const assertKeetaAssetMovementAnchorCreatePersistentForwardingRequest = (() => { const _iv1 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _iv2 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _av3 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _av4 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _io0 = input => null !== input.asset && undefined !== input.asset && ("string" === typeof input.asset && (RegExp(/^keeta_am(.*)/).test(input.asset) || RegExp(/^keeta_an(.*)/).test(input.asset) || RegExp(/^keeta_ao(.*)/).test(input.asset) || RegExp(/^keeta_ap(.*)/).test(input.asset) || RegExp(/^tyblocks_am(.*)/).test(input.asset) || RegExp(/^tyblocks_an(.*)/).test(input.asset) || RegExp(/^tyblocks_ao(.*)/).test(input.asset) || RegExp(/^tyblocks_ap(.*)/).test(input.asset)) || "object" === typeof input.asset && null !== input.asset && _iu0(input.asset)) && (null !== input.destinationLocation && undefined !== input.destinationLocation && ("string" === typeof input.destinationLocation && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.destinationLocation) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.destinationLocation)) || "object" === typeof input.destinationLocation && null !== input.destinationLocation && _iu1(input.destinationLocation))) && "string" === typeof input.destinationAddress && (null !== input.sourceLocation && undefined !== input.sourceLocation && ("string" === typeof input.sourceLocation && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.sourceLocation) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.sourceLocation)) || "object" === typeof input.sourceLocation && null !== input.sourceLocation && _iu1(input.sourceLocation))); const _io1 = input => true && true === _iv1.has(input.code) && "string" === typeof input.name && "string" === typeof input.precision && true === _iv2.has(input.isoNumber); const _io2 = input => true; const _io3 = input => "chain" === input.type && ("object" === typeof input.chain && null !== input.chain && _iu2(input.chain)); const _io4 = input => "keeta" === input.type && "bigint" === typeof input.networkId; const _io5 = input => "evm" === input.type && "bigint" === typeof input.chainId; const _io6 = input => "bank-account" === input.type && (null !== input.workInProgress && undefined === input.workInProgress); const _iu0 = input => (() => {
|
|
373
373
|
if (undefined !== input.code)
|
|
374
374
|
return _io1(input);
|
|
375
375
|
else
|
|
@@ -663,7 +663,7 @@ export const assertKeetaAssetMovementAnchorCreatePersistentForwardingResponse =
|
|
|
663
663
|
}
|
|
664
664
|
return input;
|
|
665
665
|
}; })();
|
|
666
|
-
export const assertKeetaAssetMovementAnchorInitiateTransferRequest = (() => { const _iv1 = new Set(["
|
|
666
|
+
export const assertKeetaAssetMovementAnchorInitiateTransferRequest = (() => { const _iv1 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _iv2 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _av3 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _av4 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _io0 = input => null !== input.asset && undefined !== input.asset && ("string" === typeof input.asset && (RegExp(/^keeta_am(.*)/).test(input.asset) || RegExp(/^keeta_an(.*)/).test(input.asset) || RegExp(/^keeta_ao(.*)/).test(input.asset) || RegExp(/^keeta_ap(.*)/).test(input.asset) || RegExp(/^tyblocks_am(.*)/).test(input.asset) || RegExp(/^tyblocks_an(.*)/).test(input.asset) || RegExp(/^tyblocks_ao(.*)/).test(input.asset) || RegExp(/^tyblocks_ap(.*)/).test(input.asset)) || "object" === typeof input.asset && null !== input.asset && _iu0(input.asset)) && ("object" === typeof input.from && null !== input.from && _io3(input.from)) && ("object" === typeof input.to && null !== input.to && _io8(input.to)) && "string" === typeof input.value && (undefined === input.allowedRails || Array.isArray(input.allowedRails)); const _io1 = input => true && true === _iv1.has(input.code) && "string" === typeof input.name && "string" === typeof input.precision && true === _iv2.has(input.isoNumber); const _io2 = input => true; const _io3 = input => null !== input.location && undefined !== input.location && ("string" === typeof input.location && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location)) || "object" === typeof input.location && null !== input.location && _iu1(input.location)); const _io4 = input => "chain" === input.type && ("object" === typeof input.chain && null !== input.chain && _iu2(input.chain)); const _io5 = input => "keeta" === input.type && "bigint" === typeof input.networkId; const _io6 = input => "evm" === input.type && "bigint" === typeof input.chainId; const _io7 = input => "bank-account" === input.type && (null !== input.workInProgress && undefined === input.workInProgress); const _io8 = input => null !== input.location && undefined !== input.location && ("string" === typeof input.location && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location)) || "object" === typeof input.location && null !== input.location && _iu1(input.location)) && "string" === typeof input.recipient; const _iu0 = input => (() => {
|
|
667
667
|
if (undefined !== input.code)
|
|
668
668
|
return _io1(input);
|
|
669
669
|
else
|
|
@@ -1423,7 +1423,7 @@ export const assertKeetaAssetMovementAnchorGetTransferStatusRequest = (() => { c
|
|
|
1423
1423
|
}
|
|
1424
1424
|
return input;
|
|
1425
1425
|
}; })();
|
|
1426
|
-
export const assertKeetaAssetMovementAnchorGetTransferStatusResponse = (() => { const _iv1 = new Set(["
|
|
1426
|
+
export const assertKeetaAssetMovementAnchorGetTransferStatusResponse = (() => { const _iv1 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _iv2 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _av3 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _av4 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _io0 = (input, _exceptionable = true) => true === input.ok && ("object" === typeof input.transaction && null !== input.transaction && _io1(input.transaction, true && _exceptionable)) && (2 === Object.keys(input).length || Object.keys(input).every(key => {
|
|
1427
1427
|
if (["ok", "transaction"].some(prop => key === prop))
|
|
1428
1428
|
return true;
|
|
1429
1429
|
const value = input[key];
|
|
@@ -1908,7 +1908,7 @@ export const assertKeetaAssetMovementAnchorGetTransferStatusResponse = (() => {
|
|
|
1908
1908
|
}
|
|
1909
1909
|
return input;
|
|
1910
1910
|
}; })();
|
|
1911
|
-
export const assertKeetaAssetMovementAnchorlistTransactionsRequest = (() => { const _iv2 = new Set(["
|
|
1911
|
+
export const assertKeetaAssetMovementAnchorlistTransactionsRequest = (() => { const _iv2 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _iv3 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _av5 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _av6 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _io0 = input => (undefined === input.persistentAddresses || Array.isArray(input.persistentAddresses) && input.persistentAddresses.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && (undefined === input.from || "object" === typeof input.from && null !== input.from && _io6(input.from)) && (undefined === input.to || "object" === typeof input.to && null !== input.to && _io9(input.to)) && (undefined === input.pagination || "object" === typeof input.pagination && null !== input.pagination && false === Array.isArray(input.pagination) && _io10(input.pagination)); const _io1 = input => null !== input.location && undefined !== input.location && ("string" === typeof input.location && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location)) || "object" === typeof input.location && null !== input.location && _iu0(input.location)) && "string" === typeof input.persistentAddress; const _io2 = input => "chain" === input.type && ("object" === typeof input.chain && null !== input.chain && _iu1(input.chain)); const _io3 = input => "keeta" === input.type && "bigint" === typeof input.networkId; const _io4 = input => "evm" === input.type && "bigint" === typeof input.chainId; const _io5 = input => "bank-account" === input.type && (null !== input.workInProgress && undefined === input.workInProgress); const _io6 = input => null !== input.location && undefined !== input.location && ("string" === typeof input.location && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location)) || "object" === typeof input.location && null !== input.location && _iu0(input.location)) && (undefined === input.userAddress || "string" === typeof input.userAddress) && (null !== input.asset && (undefined === input.asset || "string" === typeof input.asset && (RegExp(/^keeta_am(.*)/).test(input.asset) || RegExp(/^keeta_an(.*)/).test(input.asset) || RegExp(/^keeta_ao(.*)/).test(input.asset) || RegExp(/^keeta_ap(.*)/).test(input.asset) || RegExp(/^tyblocks_am(.*)/).test(input.asset) || RegExp(/^tyblocks_an(.*)/).test(input.asset) || RegExp(/^tyblocks_ao(.*)/).test(input.asset) || RegExp(/^tyblocks_ap(.*)/).test(input.asset)) || "object" === typeof input.asset && null !== input.asset && _iu2(input.asset))); const _io7 = input => true && true === _iv2.has(input.code) && "string" === typeof input.name && "string" === typeof input.precision && true === _iv3.has(input.isoNumber); const _io8 = input => true; const _io9 = input => null !== input.location && undefined !== input.location && ("string" === typeof input.location && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location)) || "object" === typeof input.location && null !== input.location && _iu0(input.location)) && (undefined === input.userAddress || "string" === typeof input.userAddress) && (null !== input.asset && (undefined === input.asset || "string" === typeof input.asset && (RegExp(/^keeta_am(.*)/).test(input.asset) || RegExp(/^keeta_an(.*)/).test(input.asset) || RegExp(/^keeta_ao(.*)/).test(input.asset) || RegExp(/^keeta_ap(.*)/).test(input.asset) || RegExp(/^tyblocks_am(.*)/).test(input.asset) || RegExp(/^tyblocks_an(.*)/).test(input.asset) || RegExp(/^tyblocks_ao(.*)/).test(input.asset) || RegExp(/^tyblocks_ap(.*)/).test(input.asset)) || "object" === typeof input.asset && null !== input.asset && _iu2(input.asset))); const _io10 = input => (undefined === input.limit || "number" === typeof input.limit) && (undefined === input.offset || "number" === typeof input.offset); const _iu0 = input => (() => {
|
|
1912
1912
|
if ("chain" === input.type)
|
|
1913
1913
|
return _io2(input);
|
|
1914
1914
|
else if ("bank-account" === input.type)
|
|
@@ -2208,7 +2208,7 @@ export const assertKeetaAssetMovementAnchorlistTransactionsRequest = (() => { co
|
|
|
2208
2208
|
}
|
|
2209
2209
|
return input;
|
|
2210
2210
|
}; })();
|
|
2211
|
-
export const assertKeetaAssetMovementAnchorlistPersistentForwardingTransactionsResponse = (() => { const _iv2 = new Set(["
|
|
2211
|
+
export const assertKeetaAssetMovementAnchorlistPersistentForwardingTransactionsResponse = (() => { const _iv2 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _iv3 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _av5 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _av6 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _io0 = (input, _exceptionable = true) => true === input.ok && (Array.isArray(input.transactions) && input.transactions.every((elem, _index1) => "object" === typeof elem && null !== elem && _io1(elem, true && _exceptionable))) && "string" === typeof input.total && (3 === Object.keys(input).length || Object.keys(input).every(key => {
|
|
2212
2212
|
if (["ok", "transactions", "total"].some(prop => key === prop))
|
|
2213
2213
|
return true;
|
|
2214
2214
|
const value = input[key];
|
|
@@ -2747,7 +2747,7 @@ export const isKeetaAssetMovementAnchorInitiateTransferResponse = (() => { const
|
|
|
2747
2747
|
else
|
|
2748
2748
|
return false;
|
|
2749
2749
|
})(); return input => "object" === typeof input && null !== input && _iu3(input); })();
|
|
2750
|
-
export const isKeetaAssetMovementAnchorGetExchangeStatusResponse = (() => { const _iv1 = new Set(["
|
|
2750
|
+
export const isKeetaAssetMovementAnchorGetExchangeStatusResponse = (() => { const _iv1 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _iv2 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _io0 = input => true === input.ok && ("object" === typeof input.transaction && null !== input.transaction && _io1(input.transaction)); const _io1 = input => "string" === typeof input.id && "string" === typeof input.status && (null !== input.asset && undefined !== input.asset && ("string" === typeof input.asset && (RegExp(/^keeta_am(.*)/).test(input.asset) || RegExp(/^keeta_an(.*)/).test(input.asset) || RegExp(/^keeta_ao(.*)/).test(input.asset) || RegExp(/^keeta_ap(.*)/).test(input.asset) || RegExp(/^tyblocks_am(.*)/).test(input.asset) || RegExp(/^tyblocks_an(.*)/).test(input.asset) || RegExp(/^tyblocks_ao(.*)/).test(input.asset) || RegExp(/^tyblocks_ap(.*)/).test(input.asset)) || "object" === typeof input.asset && null !== input.asset && _iu0(input.asset))) && ("object" === typeof input.from && null !== input.from && _io4(input.from)) && ("object" === typeof input.to && null !== input.to && _io7(input.to)) && (null === input.fee || "object" === typeof input.fee && null !== input.fee && _io9(input.fee)) && "string" === typeof input.createdAt && "string" === typeof input.updatedAt; const _io2 = input => true && true === _iv1.has(input.code) && "string" === typeof input.name && "string" === typeof input.precision && true === _iv2.has(input.isoNumber); const _io3 = input => true; const _io4 = input => "string" === typeof input.location && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location)) && "string" === typeof input.value && ("object" === typeof input.transactions && null !== input.transactions && _io5(input.transactions)); const _io5 = input => (null === input.persistentForwarding || "object" === typeof input.persistentForwarding && null !== input.persistentForwarding && _io6(input.persistentForwarding)) && (null === input.deposit || "object" === typeof input.deposit && null !== input.deposit && _io6(input.deposit)) && (null === input.finalization || "object" === typeof input.finalization && null !== input.finalization && _io6(input.finalization)); const _io6 = input => "string" === typeof input.id && "string" === typeof input.nonce; const _io7 = input => "string" === typeof input.location && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location)) && "string" === typeof input.value && ("object" === typeof input.transactions && null !== input.transactions && _io8(input.transactions)); const _io8 = input => null === input.withdraw || "object" === typeof input.withdraw && null !== input.withdraw && _io6(input.withdraw); const _io9 = input => null !== input.asset && undefined !== input.asset && ("string" === typeof input.asset && (RegExp(/^keeta_am(.*)/).test(input.asset) || RegExp(/^keeta_an(.*)/).test(input.asset) || RegExp(/^keeta_ao(.*)/).test(input.asset) || RegExp(/^keeta_ap(.*)/).test(input.asset) || RegExp(/^tyblocks_am(.*)/).test(input.asset) || RegExp(/^tyblocks_an(.*)/).test(input.asset) || RegExp(/^tyblocks_ao(.*)/).test(input.asset) || RegExp(/^tyblocks_ap(.*)/).test(input.asset)) || "object" === typeof input.asset && null !== input.asset && _iu0(input.asset)) && "string" === typeof input.value; const _io10 = input => false === input.ok && "string" === typeof input.error; const _iu0 = input => (() => {
|
|
2751
2751
|
if (undefined !== input.code)
|
|
2752
2752
|
return _io2(input);
|
|
2753
2753
|
else
|
|
@@ -2760,7 +2760,7 @@ export const isKeetaAssetMovementAnchorGetExchangeStatusResponse = (() => { cons
|
|
|
2760
2760
|
else
|
|
2761
2761
|
return false;
|
|
2762
2762
|
})(); return input => "object" === typeof input && null !== input && _iu1(input); })();
|
|
2763
|
-
export const isKeetaAssetMovementAnchorlistPersistentForwardingTransactionsResponse = (() => { const _iv2 = new Set(["
|
|
2763
|
+
export const isKeetaAssetMovementAnchorlistPersistentForwardingTransactionsResponse = (() => { const _iv2 = new Set(["AFN", "EUR", "ALL", "DZD", "USD", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "INR", "BTN", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLP", "CLF", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUP", "CUC", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "SZL", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MKD", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLL", "SLE", "SGD", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYU", "UYI", "UYW", "UZS", "VUV", "VES", "VED", "VND", "YER", "ZMW", "ZWL"]); const _iv3 = new Set(["971", "978", "8", "12", "840", "973", "951", "32", "51", "533", "36", "944", "44", "48", "50", "52", "933", "84", "952", "60", "356", "64", "68", "984", "977", "72", "578", "986", "96", "975", "108", "132", "116", "950", "124", "136", "152", "990", "156", "170", "970", "174", "976", "554", "188", "192", "931", "532", "203", "208", "262", "214", "818", "222", "232", "748", "230", "238", "242", "953", "270", "981", "936", "292", "320", "826", "324", "328", "332", "340", "344", "348", "352", "360", "364", "368", "376", "388", "392", "400", "398", "404", "408", "410", "414", "417", "418", "422", "426", "710", "430", "434", "756", "446", "807", "969", "454", "458", "462", "929", "480", "484", "979", "498", "496", "504", "943", "104", "516", "524", "558", "566", "512", "586", "590", "598", "600", "604", "608", "985", "634", "946", "643", "646", "654", "882", "930", "682", "941", "690", "694", "925", "702", "90", "706", "728", "144", "938", "968", "752", "947", "948", "760", "901", "972", "834", "764", "776", "780", "788", "949", "934", "800", "980", "784", "997", "858", "940", "927", "860", "548", "928", "926", "704", "886", "967", "932"]); const _io0 = input => true === input.ok && (Array.isArray(input.transactions) && input.transactions.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && "string" === typeof input.total; const _io1 = input => "string" === typeof input.id && "string" === typeof input.status && (null !== input.asset && undefined !== input.asset && ("string" === typeof input.asset && (RegExp(/^keeta_am(.*)/).test(input.asset) || RegExp(/^keeta_an(.*)/).test(input.asset) || RegExp(/^keeta_ao(.*)/).test(input.asset) || RegExp(/^keeta_ap(.*)/).test(input.asset) || RegExp(/^tyblocks_am(.*)/).test(input.asset) || RegExp(/^tyblocks_an(.*)/).test(input.asset) || RegExp(/^tyblocks_ao(.*)/).test(input.asset) || RegExp(/^tyblocks_ap(.*)/).test(input.asset)) || "object" === typeof input.asset && null !== input.asset && _iu0(input.asset))) && ("object" === typeof input.from && null !== input.from && _io4(input.from)) && ("object" === typeof input.to && null !== input.to && _io7(input.to)) && (null === input.fee || "object" === typeof input.fee && null !== input.fee && _io9(input.fee)) && "string" === typeof input.createdAt && "string" === typeof input.updatedAt; const _io2 = input => true && true === _iv2.has(input.code) && "string" === typeof input.name && "string" === typeof input.precision && true === _iv3.has(input.isoNumber); const _io3 = input => true; const _io4 = input => "string" === typeof input.location && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location)) && "string" === typeof input.value && ("object" === typeof input.transactions && null !== input.transactions && _io5(input.transactions)); const _io5 = input => (null === input.persistentForwarding || "object" === typeof input.persistentForwarding && null !== input.persistentForwarding && _io6(input.persistentForwarding)) && (null === input.deposit || "object" === typeof input.deposit && null !== input.deposit && _io6(input.deposit)) && (null === input.finalization || "object" === typeof input.finalization && null !== input.finalization && _io6(input.finalization)); const _io6 = input => "string" === typeof input.id && "string" === typeof input.nonce; const _io7 = input => "string" === typeof input.location && (RegExp(/^chain:keeta:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location) || RegExp(/^chain:evm:[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.location)) && "string" === typeof input.value && ("object" === typeof input.transactions && null !== input.transactions && _io8(input.transactions)); const _io8 = input => null === input.withdraw || "object" === typeof input.withdraw && null !== input.withdraw && _io6(input.withdraw); const _io9 = input => null !== input.asset && undefined !== input.asset && ("string" === typeof input.asset && (RegExp(/^keeta_am(.*)/).test(input.asset) || RegExp(/^keeta_an(.*)/).test(input.asset) || RegExp(/^keeta_ao(.*)/).test(input.asset) || RegExp(/^keeta_ap(.*)/).test(input.asset) || RegExp(/^tyblocks_am(.*)/).test(input.asset) || RegExp(/^tyblocks_an(.*)/).test(input.asset) || RegExp(/^tyblocks_ao(.*)/).test(input.asset) || RegExp(/^tyblocks_ap(.*)/).test(input.asset)) || "object" === typeof input.asset && null !== input.asset && _iu0(input.asset)) && "string" === typeof input.value; const _io10 = input => false === input.ok && "string" === typeof input.error; const _iu0 = input => (() => {
|
|
2764
2764
|
if (undefined !== input.code)
|
|
2765
2765
|
return _io2(input);
|
|
2766
2766
|
else
|
package/services/fx/server.js
CHANGED
|
@@ -247,7 +247,7 @@ export class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAn
|
|
|
247
247
|
getEstimate: (new URL('/api/getEstimate', this.url)).toString(),
|
|
248
248
|
getQuote: (new URL('/api/getQuote', this.url)).toString(),
|
|
249
249
|
createExchange: (new URL('/api/createExchange', this.url)).toString(),
|
|
250
|
-
getExchangeStatus: (new URL('/api/getExchangeStatus
|
|
250
|
+
getExchangeStatus: (new URL('/api/getExchangeStatus', this.url)).toString() + '/{id}'
|
|
251
251
|
};
|
|
252
252
|
return ({
|
|
253
253
|
from: this.fx.from ?? [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/services/fx/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,QAAQ,MAAM,+BAA+B,CAAC;AACrD,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,kCAAkC,EAClC,yBAAyB,EACzB,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MAAM,gBAAgB,GAAkC;gBACvD,EAAE,EAAE,IAAI;gBACR,UAAU,EAAE,UAAU;aACtB,CAAC;YAEF,OAAM,CAAC;gBACN,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;aACxC,CAAC,CAAC;QACJ,CAAC,CAAA;QAED,OAAM,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe;QACpB,MAAM,UAAU,GAAyE;YACxF,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,kBAAkB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;YAC/D,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;YACzD,cAAc,EAAE,CAAC,IAAI,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;YACrE,iBAAiB,EAAE,CAAC,IAAI,GAAG,CAAC,4BAA4B,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;SAC/E,CAAC;QAEF,OAAM,CAAC;YACN,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,EAAE;YACxB,UAAU,EAAE,UAAU;SACtB,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import * as KeetaAnchorHTTPServer from '../../lib/http-server.js';\nimport KeetaNet from '@keetanetwork/keetanet-client';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport {\n\tassertConversionInputCanonicalJSON,\n\tassertConversionQuoteJSON\n} from './common.js';\nimport type {\n\tConversionInputCanonicalJSON,\n\tKeetaFXAnchorEstimateResponse,\n\tKeetaFXAnchorExchangeResponse,\n\tKeetaFXAnchorQuote,\n\tKeetaFXAnchorQuoteJSON,\n\tKeetaFXAnchorQuoteResponse,\n\tKeetaNetAccount,\n\tKeetaNetStorageAccount\n} from './common.ts';\nimport * as Signing from '../../lib/utils/signing.js';\nimport type { AssertNever } from '../../lib/utils/never.ts';\nimport type { ServiceMetadata } from '../../lib/resolver.js';\n\nexport interface KeetaAnchorFXServerConfig extends KeetaAnchorHTTPServer.KeetaAnchorHTTPServerConfig {\n\t/**\n\t * The data to use for the index page (optional)\n\t */\n\thomepage?: string | (() => Promise<string> | string);\n\n\t/**\n\t * The account to use for performing swaps for a given pair\n\t *\n\t * This may be either a function or a KeetaNet Account instance.\n\t */\n\taccount: KeetaNetAccount | KeetaNetStorageAccount | ((request: ConversionInputCanonicalJSON) => Promise<KeetaNetAccount | KeetaNetStorageAccount> | KeetaNetAccount | KeetaNetStorageAccount);\n\t/**\n\t * Account which can be used to sign transactions\n\t * for the account above (if not supplied the\n\t * account will be used).\n\t *\n\t * This may be either a function or a KeetaNet Account instance.\n\t */\n\tsigner?: InstanceType<typeof KeetaNet.lib.Account> | ((request: ConversionInputCanonicalJSON) => Promise<InstanceType<typeof KeetaNet.lib.Account>> | InstanceType<typeof KeetaNet.lib.Account>);\n\n\t/**\n\t * Account which performs the signing and validation of quotes\n\t */\n\tquoteSigner: Signing.SignableAccount;\n\n\t/**\n\t * Configuration for FX handling\n\t */\n\tfx: {\n\t\t/**\n\t\t * Supported conversions\n\t\t */\n\t\tfrom?: NonNullable<ServiceMetadata['services']['fx']>[string]['from'];\n\t\t/**\n\t\t * Handle the conversion request of one token to another\n\t\t *\n\t\t * This is used to handle quotes and estimates\n\t\t */\n\t\tgetConversionRateAndFee: (request: ConversionInputCanonicalJSON) => Promise<Omit<KeetaFXAnchorQuote, 'request' | 'signed' >>;\n\t};\n\n\t/**\n\t * The network client to use for submitting blocks\n\t */\n\tclient: { client: KeetaNet.Client; network: bigint; networkAlias: typeof KeetaNet.Client.Config.networksArray[number] } | KeetaNet.UserClient;\n};\n\nasync function formatQuoteSignable(unsignedQuote: Omit<KeetaFXAnchorQuoteJSON, 'signed'>): Promise<Signing.Signable> {\n\tconst retval: Signing.Signable = [\n\t\tunsignedQuote.request.from,\n\t\tunsignedQuote.request.to,\n\t\tunsignedQuote.request.amount,\n\t\tunsignedQuote.request.affinity,\n\t\tunsignedQuote.account,\n\t\tunsignedQuote.convertedAmount,\n\t\tunsignedQuote.cost.token,\n\t\tunsignedQuote.cost.amount\n\t];\n\n\treturn(retval);\n\n\t/**\n\t * This is a static assertion to ensure that this function is updated\n\t * if new fields are added to the KeetaFXAnchorQuote type to ensure\n\t * that we are always signing all the fields.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\ttype _ignore_static_assert = AssertNever<\n\t\t// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n\t\tAssertNever<keyof Omit<typeof unsignedQuote['request'], 'from' | 'to' | 'amount' | 'affinity'>> &\n\t\t// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents,@typescript-eslint/no-duplicate-type-constituents\n\t\tAssertNever<keyof Omit<typeof unsignedQuote['cost'], 'token' | 'amount'>> &\n\t\t// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents,@typescript-eslint/no-duplicate-type-constituents\n\t\tAssertNever<keyof Omit<typeof unsignedQuote, 'request' | 'convertedAmount' | 'cost' | 'account'>>\n\t>;\n}\n\nasync function generateSignedQuote(signer: Signing.SignableAccount, unsignedQuote: Omit<KeetaFXAnchorQuoteJSON, 'signed'>): Promise<KeetaFXAnchorQuoteJSON> {\n\tconst signableQuote = await formatQuoteSignable(unsignedQuote);\n\tconst signed = await Signing.SignData(signer, signableQuote);\n\n\treturn({\n\t\t...unsignedQuote,\n\t\tsigned: signed\n\t});\n}\n\nasync function verifySignedData(signedBy: Signing.VerifableAccount, quote: KeetaFXAnchorQuoteJSON): Promise<boolean> {\n\tconst signableQuote = await formatQuoteSignable(quote);\n\n\treturn(await Signing.VerifySignedData(signedBy, signableQuote, quote.signed));\n}\n\nasync function requestToAccounts(config: KeetaAnchorFXServerConfig, request: ConversionInputCanonicalJSON): Promise<{ signer: Signing.SignableAccount; account: KeetaNetAccount | KeetaNetStorageAccount; }> {\n\tconst account = KeetaNet.lib.Account.isInstance(config.account) ? config.account : await config.account(request);\n\tlet signer: Signing.SignableAccount | null = null;\n\tif (config.signer !== undefined) {\n\t\tsigner = (KeetaNet.lib.Account.isInstance(config.signer) ? config.signer : await config.signer(request)).assertAccount();\n\t}\n\n\tif (signer === null) {\n\t\tsigner = account.assertAccount();\n\t}\n\n\tif (!account.isAccount() && !account.isStorage()) {\n\t\tthrow(new Error('FX Account should be an Account or Storage Account'))\n\t}\n\n\treturn({\n\t\tsigner: signer,\n\t\taccount: account\n\t});\n}\n\nexport class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAnchorHTTPServer<KeetaAnchorFXServerConfig> implements Required<KeetaAnchorFXServerConfig> {\n\treadonly homepage: NonNullable<KeetaAnchorFXServerConfig['homepage']>;\n\treadonly client: KeetaAnchorFXServerConfig['client'];\n\treadonly account: KeetaAnchorFXServerConfig['account'];\n\treadonly signer: NonNullable<KeetaAnchorFXServerConfig['signer']>;\n\treadonly quoteSigner: KeetaAnchorFXServerConfig['quoteSigner'];\n\treadonly fx: KeetaAnchorFXServerConfig['fx'];\n\n\tconstructor(config: KeetaAnchorFXServerConfig) {\n\t\tsuper(config);\n\n\t\tthis.homepage = config.homepage ?? '';\n\t\tthis.client = config.client;\n\t\tthis.fx = config.fx;\n\t\tthis.account = config.account;\n\t\tthis.signer = config.signer ?? config.account;\n\t\tthis.quoteSigner = config.quoteSigner;\n\t}\n\n\tprotected async initRoutes(config: KeetaAnchorFXServerConfig): Promise<KeetaAnchorHTTPServer.Routes> {\n\t\tconst routes: KeetaAnchorHTTPServer.Routes = {};\n\n\t\t/**\n\t\t * If a homepage is provided, setup the route for it\n\t\t */\n\t\tif ('homepage' in config) {\n\t\t\troutes['GET /'] = async function() {\n\t\t\t\tlet homepageData: string;\n\t\t\t\tif (typeof config.homepage === 'string') {\n\t\t\t\t\thomepageData = config.homepage;\n\t\t\t\t} else {\n\t\t\t\t\tif (!config.homepage) {\n\t\t\t\t\t\tthrow(new Error('internal error: No homepage function provided'));\n\t\t\t\t\t}\n\n\t\t\t\t\thomepageData = await config.homepage();\n\t\t\t\t}\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: homepageData,\n\t\t\t\t\tcontentType: 'text/html'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Setup the request handler for an estimate request\n\t\t */\n\t\troutes['POST /api/getEstimate'] = async function(_ignore_params, postData) {\n\t\t\tif (!postData || typeof postData !== 'object') {\n\t\t\t\tthrow(new Error('No POST data provided'));\n\t\t\t}\n\t\t\tif (!('request' in postData)) {\n\t\t\t\tthrow(new Error('POST data missing request'));\n\t\t\t}\n\n\t\t\tconst conversion = assertConversionInputCanonicalJSON(postData.request);\n\t\t\tconst rateAndFee = await config.fx.getConversionRateAndFee(conversion);\n\t\t\tconst estimateResponse: KeetaFXAnchorEstimateResponse = {\n\t\t\t\tok: true,\n\t\t\t\testimate: KeetaNet.lib.Utils.Conversion.toJSONSerializable({\n\t\t\t\t\trequest: conversion,\n\t\t\t\t\tconvertedAmount: rateAndFee.convertedAmount,\n\t\t\t\t\texpectedCost: {\n\t\t\t\t\t\tmin: rateAndFee.cost.amount,\n\t\t\t\t\t\tmax: rateAndFee.cost.amount,\n\t\t\t\t\t\ttoken: rateAndFee.cost.token\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(estimateResponse)\n\t\t\t});\n\t\t}\n\n\t\troutes['POST /api/getQuote'] = async function(_ignore_params, postData) {\n\t\t\tif (!postData || typeof postData !== 'object') {\n\t\t\t\tthrow(new Error('No POST data provided'));\n\t\t\t}\n\t\t\tif (!('request' in postData)) {\n\t\t\t\tthrow(new Error('POST data missing request'));\n\t\t\t}\n\n\t\t\tconst conversion = assertConversionInputCanonicalJSON(postData.request);\n\t\t\tconst rateAndFee = await config.fx.getConversionRateAndFee(conversion);\n\n\t\t\tconst unsignedQuote: Omit<KeetaFXAnchorQuoteJSON, 'signed'> = KeetaNet.lib.Utils.Conversion.toJSONSerializable({\n\t\t\t\trequest: conversion,\n\t\t\t\t...rateAndFee\n\t\t\t});\n\n\t\t\tconst signedQuote = await generateSignedQuote(config.quoteSigner, unsignedQuote);\n\t\t\tconst quoteResponse: KeetaFXAnchorQuoteResponse = {\n\t\t\t\tok: true,\n\t\t\t\tquote: signedQuote\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(quoteResponse)\n\t\t\t});\n\t\t}\n\n\t\troutes['POST /api/createExchange'] = async function(_ignore_params, postData) {\n\t\t\tif (!postData || typeof postData !== 'object') {\n\t\t\t\tthrow(new Error('No POST data provided'));\n\t\t\t}\n\n\t\t\tif (!('request' in postData)) {\n\t\t\t\tthrow(new Error('POST data missing request'));\n\t\t\t}\n\t\t\tconst request = postData.request;\n\t\t\tif (!request || typeof request !== 'object') {\n\t\t\t\tthrow(new Error('Request is not an object'));\n\t\t\t}\n\n\t\t\tif (!('quote' in request)) {\n\t\t\t\tthrow(new Error('Quote is missing from request'));\n\t\t\t}\n\t\t\tif (!('block' in request) || typeof request.block !== 'string') {\n\t\t\t\tthrow(new Error('Block was not provided in exchange request'));\n\t\t\t}\n\n\t\t\tconst quote = assertConversionQuoteJSON(request.quote);\n\t\t\tconst isValidQuote = await verifySignedData(config.quoteSigner, quote);\n\t\t\tif (!isValidQuote) {\n\t\t\t\tthrow(new Error('Invalid quote signature'));\n\t\t\t}\n\n\t\t\tconst block = new KeetaNet.lib.Block(request.block);\n\t\t\tlet userClient: KeetaNet.UserClient;\n\t\t\tif (KeetaNet.UserClient.isInstance(config.client)) {\n\t\t\t\tuserClient = config.client;\n\t\t\t} else {\n\t\t\t\tconst { account, signer } = await requestToAccounts(config, quote.request);\n\n\t\t\t\tuserClient = new KeetaNet.UserClient({\n\t\t\t\t\tclient: config.client.client,\n\t\t\t\t\tnetwork: config.client.network,\n\t\t\t\t\tnetworkAlias: config.client.networkAlias,\n\t\t\t\t\taccount: account,\n\t\t\t\t\tsigner: signer\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t/* Get Expected Amount and Token to Verify Swap */\n\t\t\tconst expectedToken = KeetaNet.lib.Account.fromPublicKeyString(quote.request.from);\n\t\t\tlet expectedAmount = quote.request.affinity === 'from' ? BigInt(quote.request.amount) : BigInt(quote.convertedAmount);\n\t\t\t/* If cost is required verify the amounts and token. */\n\t\t\tif (BigInt(quote.cost.amount) > 0) {\n\t\t\t\t/* 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` */\n\t\t\t\tif (expectedToken.comparePublicKey(quote.cost.token)) {\n\t\t\t\t\texpectedAmount += BigInt(quote.cost.amount);\n\t\t\t\t/* If token is different then check block operations for matching amount and token */\n\t\t\t\t} else {\n\t\t\t\t\tlet requestIncludesCost = false;\n\t\t\t\t\tfor (const operation of block.operations) {\n\t\t\t\t\t\tif (operation.type === KeetaNet.lib.Block.OperationType.SEND) {\n\t\t\t\t\t\t\tconst recipientMatches = operation.to.comparePublicKey(quote.account);\n\t\t\t\t\t\t\tconst tokenMatches = operation.token.comparePublicKey(quote.cost.token);\n\t\t\t\t\t\t\tconst amountMatches = operation.amount === BigInt(quote.cost.amount);\n\t\t\t\t\t\t\tif (recipientMatches && tokenMatches && amountMatches) {\n\t\t\t\t\t\t\t\trequestIncludesCost = true;\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\tif (!requestIncludesCost) {\n\t\t\t\t\t\tthrow(new Error('Exchange missing required cost'));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* Verify Request and Generate the Accept Swap Block */\n\t\t\tconst swapBlocks = await userClient.acceptSwapRequest({ block, expected: { token: expectedToken, amount: BigInt(expectedAmount) }});\n\t\t\tconst publishOptions: Parameters<typeof userClient.client.transmit>[1] = {};\n\t\t\tif (userClient.config.generateFeeBlock !== undefined) {\n\t\t\t\tpublishOptions.generateFeeBlock = userClient.config.generateFeeBlock;\n\t\t\t}\n\t\t\tconst publishResult = await userClient.client.transmit(swapBlocks, publishOptions);\n\t\t\tif (!publishResult.publish) {\n\t\t\t\tthrow(new Error('Exchange Publish Failed'));\n\t\t\t}\n\t\t\tconst exchangeResponse: KeetaFXAnchorExchangeResponse = {\n\t\t\t\tok: true,\n\t\t\t\texchangeID: block.hash.toString()\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(exchangeResponse)\n\t\t\t});\n\t\t}\n\n\t\troutes['GET /api/getExchangeStatus/:id'] = async function(params) {\n\t\t\tif (params === undefined || params === null) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Expected params'));\n\t\t\t}\n\t\t\tconst exchangeID = params.get('id');\n\t\t\tif (typeof exchangeID !== 'string') {\n\t\t\t\tthrow(new Error('Missing exchangeID in params'));\n\t\t\t}\n\t\t\tconst blockLookup = await config.client.client.getVoteStaple(exchangeID);\n\t\t\tif (blockLookup === null) {\n\t\t\t\tthrow(new Error('Block Not Found'));\n\t\t\t}\n\t\t\tconst exchangeResponse: KeetaFXAnchorExchangeResponse = {\n\t\t\t\tok: true,\n\t\t\t\texchangeID: exchangeID\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(exchangeResponse)\n\t\t\t});\n\t\t}\n\n\t\treturn(routes);\n\t}\n\n\t/**\n\t * Return the servers endpoints and possible currency conversions metadata\n\t */\n\tasync serviceMetadata(): Promise<NonNullable<ServiceMetadata['services']['fx']>[string]> {\n\t\tconst operations: NonNullable<ServiceMetadata['services']['fx']>[string]['operations'] = {\n\t\t\tgetEstimate: (new URL('/api/getEstimate', this.url)).toString(),\n\t\t\tgetQuote: (new URL('/api/getQuote', this.url)).toString(),\n\t\t\tcreateExchange: (new URL('/api/createExchange', this.url)).toString(),\n\t\t\tgetExchangeStatus: (new URL('/api/getExchangeStatus/:id', this.url)).toString()\n\t\t};\n\n\t\treturn({\n\t\t\tfrom: this.fx.from ?? [],\n\t\t\toperations: operations\n\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/services/fx/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,QAAQ,MAAM,+BAA+B,CAAC;AACrD,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,kCAAkC,EAClC,yBAAyB,EACzB,MAAM,aAAa,CAAC;AAWrB,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAkDrD,CAAC;AAEF,KAAK,UAAU,mBAAmB,CAAC,aAAqD;IACvF,MAAM,MAAM,GAAqB;QAChC,aAAa,CAAC,OAAO,CAAC,IAAI;QAC1B,aAAa,CAAC,OAAO,CAAC,EAAE;QACxB,aAAa,CAAC,OAAO,CAAC,MAAM;QAC5B,aAAa,CAAC,OAAO,CAAC,QAAQ;QAC9B,aAAa,CAAC,OAAO;QACrB,aAAa,CAAC,eAAe;QAC7B,aAAa,CAAC,IAAI,CAAC,KAAK;QACxB,aAAa,CAAC,IAAI,CAAC,MAAM;KACzB,CAAC;IAEF,OAAM,CAAC,MAAM,CAAC,CAAC;AAgBhB,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,MAA+B,EAAE,aAAqD;IACxH,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAE7D,OAAM,CAAC;QACN,GAAG,aAAa;QAChB,MAAM,EAAE,MAAM;KACd,CAAC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,QAAkC,EAAE,KAA6B;IAChG,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,KAAK,CA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ACJ,CAAC;CACD","sourcesContent":["import * as KeetaAnchorHTTPServer from '../../lib/http-server.js';\nimport KeetaNet from '@keetanetwork/keetanet-client';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport {\n\tassertConversionInputCanonicalJSON,\n\tassertConversionQuoteJSON\n} from './common.js';\nimport type {\n\tConversionInputCanonicalJSON,\n\tKeetaFXAnchorEstimateResponse,\n\tKeetaFXAnchorExchangeResponse,\n\tKeetaFXAnchorQuote,\n\tKeetaFXAnchorQuoteJSON,\n\tKeetaFXAnchorQuoteResponse,\n\tKeetaNetAccount,\n\tKeetaNetStorageAccount\n} from './common.ts';\nimport * as Signing from '../../lib/utils/signing.js';\nimport type { AssertNever } from '../../lib/utils/never.ts';\nimport type { ServiceMetadata } from '../../lib/resolver.js';\n\nexport interface KeetaAnchorFXServerConfig extends KeetaAnchorHTTPServer.KeetaAnchorHTTPServerConfig {\n\t/**\n\t * The data to use for the index page (optional)\n\t */\n\thomepage?: string | (() => Promise<string> | string);\n\n\t/**\n\t * The account to use for performing swaps for a given pair\n\t *\n\t * This may be either a function or a KeetaNet Account instance.\n\t */\n\taccount: KeetaNetAccount | KeetaNetStorageAccount | ((request: ConversionInputCanonicalJSON) => Promise<KeetaNetAccount | KeetaNetStorageAccount> | KeetaNetAccount | KeetaNetStorageAccount);\n\t/**\n\t * Account which can be used to sign transactions\n\t * for the account above (if not supplied the\n\t * account will be used).\n\t *\n\t * This may be either a function or a KeetaNet Account instance.\n\t */\n\tsigner?: InstanceType<typeof KeetaNet.lib.Account> | ((request: ConversionInputCanonicalJSON) => Promise<InstanceType<typeof KeetaNet.lib.Account>> | InstanceType<typeof KeetaNet.lib.Account>);\n\n\t/**\n\t * Account which performs the signing and validation of quotes\n\t */\n\tquoteSigner: Signing.SignableAccount;\n\n\t/**\n\t * Configuration for FX handling\n\t */\n\tfx: {\n\t\t/**\n\t\t * Supported conversions\n\t\t */\n\t\tfrom?: NonNullable<ServiceMetadata['services']['fx']>[string]['from'];\n\t\t/**\n\t\t * Handle the conversion request of one token to another\n\t\t *\n\t\t * This is used to handle quotes and estimates\n\t\t */\n\t\tgetConversionRateAndFee: (request: ConversionInputCanonicalJSON) => Promise<Omit<KeetaFXAnchorQuote, 'request' | 'signed' >>;\n\t};\n\n\t/**\n\t * The network client to use for submitting blocks\n\t */\n\tclient: { client: KeetaNet.Client; network: bigint; networkAlias: typeof KeetaNet.Client.Config.networksArray[number] } | KeetaNet.UserClient;\n};\n\nasync function formatQuoteSignable(unsignedQuote: Omit<KeetaFXAnchorQuoteJSON, 'signed'>): Promise<Signing.Signable> {\n\tconst retval: Signing.Signable = [\n\t\tunsignedQuote.request.from,\n\t\tunsignedQuote.request.to,\n\t\tunsignedQuote.request.amount,\n\t\tunsignedQuote.request.affinity,\n\t\tunsignedQuote.account,\n\t\tunsignedQuote.convertedAmount,\n\t\tunsignedQuote.cost.token,\n\t\tunsignedQuote.cost.amount\n\t];\n\n\treturn(retval);\n\n\t/**\n\t * This is a static assertion to ensure that this function is updated\n\t * if new fields are added to the KeetaFXAnchorQuote type to ensure\n\t * that we are always signing all the fields.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\ttype _ignore_static_assert = AssertNever<\n\t\t// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n\t\tAssertNever<keyof Omit<typeof unsignedQuote['request'], 'from' | 'to' | 'amount' | 'affinity'>> &\n\t\t// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents,@typescript-eslint/no-duplicate-type-constituents\n\t\tAssertNever<keyof Omit<typeof unsignedQuote['cost'], 'token' | 'amount'>> &\n\t\t// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents,@typescript-eslint/no-duplicate-type-constituents\n\t\tAssertNever<keyof Omit<typeof unsignedQuote, 'request' | 'convertedAmount' | 'cost' | 'account'>>\n\t>;\n}\n\nasync function generateSignedQuote(signer: Signing.SignableAccount, unsignedQuote: Omit<KeetaFXAnchorQuoteJSON, 'signed'>): Promise<KeetaFXAnchorQuoteJSON> {\n\tconst signableQuote = await formatQuoteSignable(unsignedQuote);\n\tconst signed = await Signing.SignData(signer, signableQuote);\n\n\treturn({\n\t\t...unsignedQuote,\n\t\tsigned: signed\n\t});\n}\n\nasync function verifySignedData(signedBy: Signing.VerifableAccount, quote: KeetaFXAnchorQuoteJSON): Promise<boolean> {\n\tconst signableQuote = await formatQuoteSignable(quote);\n\n\treturn(await Signing.VerifySignedData(signedBy, signableQuote, quote.signed));\n}\n\nasync function requestToAccounts(config: KeetaAnchorFXServerConfig, request: ConversionInputCanonicalJSON): Promise<{ signer: Signing.SignableAccount; account: KeetaNetAccount | KeetaNetStorageAccount; }> {\n\tconst account = KeetaNet.lib.Account.isInstance(config.account) ? config.account : await config.account(request);\n\tlet signer: Signing.SignableAccount | null = null;\n\tif (config.signer !== undefined) {\n\t\tsigner = (KeetaNet.lib.Account.isInstance(config.signer) ? config.signer : await config.signer(request)).assertAccount();\n\t}\n\n\tif (signer === null) {\n\t\tsigner = account.assertAccount();\n\t}\n\n\tif (!account.isAccount() && !account.isStorage()) {\n\t\tthrow(new Error('FX Account should be an Account or Storage Account'))\n\t}\n\n\treturn({\n\t\tsigner: signer,\n\t\taccount: account\n\t});\n}\n\nexport class KeetaNetFXAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAnchorHTTPServer<KeetaAnchorFXServerConfig> implements Required<KeetaAnchorFXServerConfig> {\n\treadonly homepage: NonNullable<KeetaAnchorFXServerConfig['homepage']>;\n\treadonly client: KeetaAnchorFXServerConfig['client'];\n\treadonly account: KeetaAnchorFXServerConfig['account'];\n\treadonly signer: NonNullable<KeetaAnchorFXServerConfig['signer']>;\n\treadonly quoteSigner: KeetaAnchorFXServerConfig['quoteSigner'];\n\treadonly fx: KeetaAnchorFXServerConfig['fx'];\n\n\tconstructor(config: KeetaAnchorFXServerConfig) {\n\t\tsuper(config);\n\n\t\tthis.homepage = config.homepage ?? '';\n\t\tthis.client = config.client;\n\t\tthis.fx = config.fx;\n\t\tthis.account = config.account;\n\t\tthis.signer = config.signer ?? config.account;\n\t\tthis.quoteSigner = config.quoteSigner;\n\t}\n\n\tprotected async initRoutes(config: KeetaAnchorFXServerConfig): Promise<KeetaAnchorHTTPServer.Routes> {\n\t\tconst routes: KeetaAnchorHTTPServer.Routes = {};\n\n\t\t/**\n\t\t * If a homepage is provided, setup the route for it\n\t\t */\n\t\tif ('homepage' in config) {\n\t\t\troutes['GET /'] = async function() {\n\t\t\t\tlet homepageData: string;\n\t\t\t\tif (typeof config.homepage === 'string') {\n\t\t\t\t\thomepageData = config.homepage;\n\t\t\t\t} else {\n\t\t\t\t\tif (!config.homepage) {\n\t\t\t\t\t\tthrow(new Error('internal error: No homepage function provided'));\n\t\t\t\t\t}\n\n\t\t\t\t\thomepageData = await config.homepage();\n\t\t\t\t}\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: homepageData,\n\t\t\t\t\tcontentType: 'text/html'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Setup the request handler for an estimate request\n\t\t */\n\t\troutes['POST /api/getEstimate'] = async function(_ignore_params, postData) {\n\t\t\tif (!postData || typeof postData !== 'object') {\n\t\t\t\tthrow(new Error('No POST data provided'));\n\t\t\t}\n\t\t\tif (!('request' in postData)) {\n\t\t\t\tthrow(new Error('POST data missing request'));\n\t\t\t}\n\n\t\t\tconst conversion = assertConversionInputCanonicalJSON(postData.request);\n\t\t\tconst rateAndFee = await config.fx.getConversionRateAndFee(conversion);\n\t\t\tconst estimateResponse: KeetaFXAnchorEstimateResponse = {\n\t\t\t\tok: true,\n\t\t\t\testimate: KeetaNet.lib.Utils.Conversion.toJSONSerializable({\n\t\t\t\t\trequest: conversion,\n\t\t\t\t\tconvertedAmount: rateAndFee.convertedAmount,\n\t\t\t\t\texpectedCost: {\n\t\t\t\t\t\tmin: rateAndFee.cost.amount,\n\t\t\t\t\t\tmax: rateAndFee.cost.amount,\n\t\t\t\t\t\ttoken: rateAndFee.cost.token\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(estimateResponse)\n\t\t\t});\n\t\t}\n\n\t\troutes['POST /api/getQuote'] = async function(_ignore_params, postData) {\n\t\t\tif (!postData || typeof postData !== 'object') {\n\t\t\t\tthrow(new Error('No POST data provided'));\n\t\t\t}\n\t\t\tif (!('request' in postData)) {\n\t\t\t\tthrow(new Error('POST data missing request'));\n\t\t\t}\n\n\t\t\tconst conversion = assertConversionInputCanonicalJSON(postData.request);\n\t\t\tconst rateAndFee = await config.fx.getConversionRateAndFee(conversion);\n\n\t\t\tconst unsignedQuote: Omit<KeetaFXAnchorQuoteJSON, 'signed'> = KeetaNet.lib.Utils.Conversion.toJSONSerializable({\n\t\t\t\trequest: conversion,\n\t\t\t\t...rateAndFee\n\t\t\t});\n\n\t\t\tconst signedQuote = await generateSignedQuote(config.quoteSigner, unsignedQuote);\n\t\t\tconst quoteResponse: KeetaFXAnchorQuoteResponse = {\n\t\t\t\tok: true,\n\t\t\t\tquote: signedQuote\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(quoteResponse)\n\t\t\t});\n\t\t}\n\n\t\troutes['POST /api/createExchange'] = async function(_ignore_params, postData) {\n\t\t\tif (!postData || typeof postData !== 'object') {\n\t\t\t\tthrow(new Error('No POST data provided'));\n\t\t\t}\n\n\t\t\tif (!('request' in postData)) {\n\t\t\t\tthrow(new Error('POST data missing request'));\n\t\t\t}\n\t\t\tconst request = postData.request;\n\t\t\tif (!request || typeof request !== 'object') {\n\t\t\t\tthrow(new Error('Request is not an object'));\n\t\t\t}\n\n\t\t\tif (!('quote' in request)) {\n\t\t\t\tthrow(new Error('Quote is missing from request'));\n\t\t\t}\n\t\t\tif (!('block' in request) || typeof request.block !== 'string') {\n\t\t\t\tthrow(new Error('Block was not provided in exchange request'));\n\t\t\t}\n\n\t\t\tconst quote = assertConversionQuoteJSON(request.quote);\n\t\t\tconst isValidQuote = await verifySignedData(config.quoteSigner, quote);\n\t\t\tif (!isValidQuote) {\n\t\t\t\tthrow(new Error('Invalid quote signature'));\n\t\t\t}\n\n\t\t\tconst block = new KeetaNet.lib.Block(request.block);\n\t\t\tlet userClient: KeetaNet.UserClient;\n\t\t\tif (KeetaNet.UserClient.isInstance(config.client)) {\n\t\t\t\tuserClient = config.client;\n\t\t\t} else {\n\t\t\t\tconst { account, signer } = await requestToAccounts(config, quote.request);\n\n\t\t\t\tuserClient = new KeetaNet.UserClient({\n\t\t\t\t\tclient: config.client.client,\n\t\t\t\t\tnetwork: config.client.network,\n\t\t\t\t\tnetworkAlias: config.client.networkAlias,\n\t\t\t\t\taccount: account,\n\t\t\t\t\tsigner: signer\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t/* Get Expected Amount and Token to Verify Swap */\n\t\t\tconst expectedToken = KeetaNet.lib.Account.fromPublicKeyString(quote.request.from);\n\t\t\tlet expectedAmount = quote.request.affinity === 'from' ? BigInt(quote.request.amount) : BigInt(quote.convertedAmount);\n\t\t\t/* If cost is required verify the amounts and token. */\n\t\t\tif (BigInt(quote.cost.amount) > 0) {\n\t\t\t\t/* 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` */\n\t\t\t\tif (expectedToken.comparePublicKey(quote.cost.token)) {\n\t\t\t\t\texpectedAmount += BigInt(quote.cost.amount);\n\t\t\t\t/* If token is different then check block operations for matching amount and token */\n\t\t\t\t} else {\n\t\t\t\t\tlet requestIncludesCost = false;\n\t\t\t\t\tfor (const operation of block.operations) {\n\t\t\t\t\t\tif (operation.type === KeetaNet.lib.Block.OperationType.SEND) {\n\t\t\t\t\t\t\tconst recipientMatches = operation.to.comparePublicKey(quote.account);\n\t\t\t\t\t\t\tconst tokenMatches = operation.token.comparePublicKey(quote.cost.token);\n\t\t\t\t\t\t\tconst amountMatches = operation.amount === BigInt(quote.cost.amount);\n\t\t\t\t\t\t\tif (recipientMatches && tokenMatches && amountMatches) {\n\t\t\t\t\t\t\t\trequestIncludesCost = true;\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\tif (!requestIncludesCost) {\n\t\t\t\t\t\tthrow(new Error('Exchange missing required cost'));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* Verify Request and Generate the Accept Swap Block */\n\t\t\tconst swapBlocks = await userClient.acceptSwapRequest({ block, expected: { token: expectedToken, amount: BigInt(expectedAmount) }});\n\t\t\tconst publishOptions: Parameters<typeof userClient.client.transmit>[1] = {};\n\t\t\tif (userClient.config.generateFeeBlock !== undefined) {\n\t\t\t\tpublishOptions.generateFeeBlock = userClient.config.generateFeeBlock;\n\t\t\t}\n\t\t\tconst publishResult = await userClient.client.transmit(swapBlocks, publishOptions);\n\t\t\tif (!publishResult.publish) {\n\t\t\t\tthrow(new Error('Exchange Publish Failed'));\n\t\t\t}\n\t\t\tconst exchangeResponse: KeetaFXAnchorExchangeResponse = {\n\t\t\t\tok: true,\n\t\t\t\texchangeID: block.hash.toString()\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(exchangeResponse)\n\t\t\t});\n\t\t}\n\n\t\troutes['GET /api/getExchangeStatus/:id'] = async function(params) {\n\t\t\tif (params === undefined || params === null) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Expected params'));\n\t\t\t}\n\t\t\tconst exchangeID = params.get('id');\n\t\t\tif (typeof exchangeID !== 'string') {\n\t\t\t\tthrow(new Error('Missing exchangeID in params'));\n\t\t\t}\n\t\t\tconst blockLookup = await config.client.client.getVoteStaple(exchangeID);\n\t\t\tif (blockLookup === null) {\n\t\t\t\tthrow(new Error('Block Not Found'));\n\t\t\t}\n\t\t\tconst exchangeResponse: KeetaFXAnchorExchangeResponse = {\n\t\t\t\tok: true,\n\t\t\t\texchangeID: exchangeID\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(exchangeResponse)\n\t\t\t});\n\t\t}\n\n\t\treturn(routes);\n\t}\n\n\t/**\n\t * Return the servers endpoints and possible currency conversions metadata\n\t */\n\tasync serviceMetadata(): Promise<NonNullable<ServiceMetadata['services']['fx']>[string]> {\n\t\tconst operations: NonNullable<ServiceMetadata['services']['fx']>[string]['operations'] = {\n\t\t\tgetEstimate: (new URL('/api/getEstimate', this.url)).toString(),\n\t\t\tgetQuote: (new URL('/api/getQuote', this.url)).toString(),\n\t\t\tcreateExchange: (new URL('/api/createExchange', this.url)).toString(),\n\t\t\tgetExchangeStatus: (new URL('/api/getExchangeStatus', this.url)).toString() + '/{id}'\n\t\t};\n\n\t\treturn({\n\t\t\tfrom: this.fx.from ?? [],\n\t\t\toperations: operations\n\t\t});\n\t}\n}\n"]}
|