@xoxno/sdk-js 1.0.223 → 1.0.225

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/cjs/sdk/stellar/__tests__/admin.test.d.ts +0 -12
  2. package/dist/cjs/sdk/stellar/__tests__/builders-hubasset.test.d.ts +0 -11
  3. package/dist/cjs/sdk/stellar/__tests__/governance.test.d.ts +0 -4
  4. package/dist/cjs/sdk/stellar/__tests__/lending.test.d.ts +0 -20
  5. package/dist/cjs/sdk/stellar/__tests__/strategy-program.test.d.ts +0 -8
  6. package/dist/cjs/sdk/stellar/__tests__/swap-history.test.d.ts +1 -0
  7. package/dist/cjs/sdk/stellar/index.d.ts +1 -0
  8. package/dist/cjs/sdk/stellar/swap-history.d.ts +25 -0
  9. package/dist/cjs/sdk/stellar/swap-index.d.ts +2 -0
  10. package/dist/cjs/sdk/stellar/xdr-compat.d.ts +11 -0
  11. package/dist/esm/index.js +3 -0
  12. package/dist/esm/sdk/index.js +198 -0
  13. package/dist/esm/sdk/stellar/admin.js +385 -0
  14. package/dist/esm/sdk/stellar/auth-policy.js +310 -0
  15. package/dist/esm/sdk/stellar/cctp.js +23 -0
  16. package/dist/esm/sdk/stellar/contracts.js +49 -0
  17. package/dist/esm/sdk/stellar/events/decode.js +415 -0
  18. package/dist/esm/sdk/stellar/events/id.js +62 -0
  19. package/dist/esm/sdk/stellar/events/index.js +2 -0
  20. package/dist/esm/sdk/stellar/governance.js +403 -0
  21. package/dist/esm/sdk/stellar/index.js +25 -0
  22. package/dist/esm/sdk/stellar/lending-api-types.js +3 -0
  23. package/dist/esm/sdk/stellar/lending-read-types.js +1 -0
  24. package/dist/esm/sdk/stellar/lending-read.js +341 -0
  25. package/dist/esm/sdk/stellar/lending.js +358 -0
  26. package/dist/esm/sdk/stellar/math/account.js +256 -0
  27. package/dist/esm/sdk/stellar/math/index.js +11 -0
  28. package/dist/esm/sdk/stellar/math/limits.js +273 -0
  29. package/dist/esm/sdk/stellar/math/projection.js +130 -0
  30. package/dist/esm/sdk/stellar/math/rates.js +62 -0
  31. package/dist/esm/sdk/stellar/math/scaled.js +156 -0
  32. package/dist/esm/sdk/stellar/position-mode.js +11 -0
  33. package/dist/esm/sdk/stellar/prepare.js +47 -0
  34. package/dist/esm/sdk/stellar/quote.js +87 -0
  35. package/dist/esm/sdk/stellar/repay-swap.js +12 -0
  36. package/dist/esm/sdk/stellar/route-verify.js +285 -0
  37. package/dist/esm/sdk/stellar/scval-encode.js +464 -0
  38. package/dist/esm/sdk/stellar/swap-history.js +46 -0
  39. package/dist/esm/sdk/stellar/swap-index.js +1 -0
  40. package/dist/esm/sdk/stellar/swap.js +117 -0
  41. package/dist/esm/sdk/stellar/xdr-compat.js +17 -0
  42. package/dist/esm/sdk/stellar-schema.js +129 -0
  43. package/dist/esm/sdk/swagger.js +1957 -0
  44. package/dist/esm/sdk/types.js +1 -0
  45. package/dist/esm/sdk/utils.js +21 -0
  46. package/dist/esm/utils/api.js +169 -0
  47. package/dist/esm/utils/const.js +11 -0
  48. package/dist/esm/utils/errors.js +20 -0
  49. package/dist/esm/utils/guards.js +29 -0
  50. package/dist/esm/utils/helpers.js +20 -0
  51. package/dist/esm/utils/regex.js +14 -0
  52. package/dist/esm/utils/soroban-errors.js +149 -0
  53. package/dist/index.cjs +1 -1
  54. package/dist/index.esm.js +1 -2
  55. package/dist/sdk/stellar/__tests__/admin.test.d.ts +0 -12
  56. package/dist/sdk/stellar/__tests__/builders-hubasset.test.d.ts +0 -11
  57. package/dist/sdk/stellar/__tests__/governance.test.d.ts +0 -4
  58. package/dist/sdk/stellar/__tests__/lending.test.d.ts +0 -20
  59. package/dist/sdk/stellar/__tests__/strategy-program.test.d.ts +0 -8
  60. package/dist/sdk/stellar/__tests__/swap-history.test.d.ts +1 -0
  61. package/dist/sdk/stellar/index.cjs +1 -1
  62. package/dist/sdk/stellar/index.d.ts +1 -0
  63. package/dist/sdk/stellar/index.esm.js +1 -1
  64. package/dist/sdk/stellar/swap-history.d.ts +25 -0
  65. package/dist/sdk/stellar/swap-index.cjs +2 -0
  66. package/dist/sdk/stellar/swap-index.d.ts +2 -0
  67. package/dist/sdk/stellar/swap-index.esm.js +2 -0
  68. package/dist/sdk/stellar/swap-index.esm.js.LICENSE.txt +8 -0
  69. package/dist/sdk/stellar/xdr-compat.d.ts +11 -0
  70. package/package.json +16 -5
  71. /package/dist/{index.esm.js.LICENSE.txt → sdk/stellar/swap-index.cjs.LICENSE.txt} +0 -0
@@ -0,0 +1,129 @@
1
+ /** Build-time OpenAPI renderer for the Stellar lending read contracts. */ export function stellarSchemaTypes(source) {
2
+ // Nest emits these existing domain types as unstructured objects. Reuse
3
+ // their precise public definitions instead of weakening them to unknown.
4
+ const schemas = {
5
+ ...source
6
+ };
7
+ const refine = (name, property, schema)=>{
8
+ if (source[name]) schemas[name] = {
9
+ ...schemas[name],
10
+ properties: {
11
+ ...schemas[name].properties,
12
+ [property]: {
13
+ ...schemas[name].properties[property],
14
+ ...schema
15
+ }
16
+ }
17
+ };
18
+ };
19
+ if (source.AssetOracleConfigDto) schemas.AssetOracleConfigDto = {
20
+ 'x-sdk-type': 'StellarDomain.StellarAssetOracle'
21
+ };
22
+ for (const field of [
23
+ 'supplyApyRange',
24
+ 'borrowApyRange'
25
+ ]){
26
+ refine('StellarAssetListItemDto', field, {
27
+ 'x-sdk-type': 'StellarDomain.StellarApyRange'
28
+ });
29
+ }
30
+ refine('StellarAssetListItemDto', 'lpUnderlying', {
31
+ 'x-sdk-type': 'StellarDomain.StellarLpUnderlying'
32
+ });
33
+ for (const name of [
34
+ 'StellarMarketIndexByHub',
35
+ 'StellarDetailedMarketDto'
36
+ ]){
37
+ refine(name, 'chain', {
38
+ 'x-sdk-type': "import('@xoxno/types/enums').ActivityChain"
39
+ });
40
+ }
41
+ for (const [field, typeName] of Object.entries({
42
+ kind: 'StellarGovernanceProposalKind',
43
+ status: 'StellarGovernanceProposalStatus',
44
+ target: 'StellarGovernanceProposalTarget'
45
+ })){
46
+ refine('GovernanceProposalDto', field, {
47
+ 'x-sdk-type': `StellarDomain.${typeName}`
48
+ });
49
+ }
50
+ refine('StellarLendingContextDto', 'reserveDetailsByKey', {
51
+ additionalProperties: {
52
+ $ref: '#/components/schemas/ReserveDto'
53
+ }
54
+ });
55
+ refine('AccountPositionDto', 'initialPaymentMultiplier', {
56
+ 'x-sdk-type': 'StellarDomain.StellarInitialPaymentMultiplier'
57
+ });
58
+ // Older OpenAPI releases describe these token quantities as base units.
59
+ for (const field of [
60
+ 'supplyAmount',
61
+ 'borrowAmount'
62
+ ]){
63
+ refine('AccountPositionDto', field, {
64
+ description: 'Actual token quantity in RAY (1e27), not token base units: floor(scaledBalanceRay * appliedIndexRay / 1e27).'
65
+ });
66
+ }
67
+ refine('AccountPositionDto', 'positionMode', {
68
+ description: 'Stellar position mode: 0 normal, 1 multiply, 2 long, 3 short.'
69
+ });
70
+ refine('GovernanceProposalDto', 'fields', {
71
+ items: {
72
+ 'x-sdk-type': 'StellarDomain.StellarGovernanceProposalField'
73
+ }
74
+ });
75
+ const references = new Set();
76
+ const comment = (description)=>description ? `/** ${description.replace(/\*\//g, '* /').replace(/\r?\n/g, '\n * ')} */\n` : '';
77
+ function type(schema, prefix = '') {
78
+ if (!schema || typeof schema !== 'object') {
79
+ throw new Error('Missing Stellar OpenAPI schema');
80
+ }
81
+ let result;
82
+ if (schema['x-sdk-type']) {
83
+ result = schema['x-sdk-type'];
84
+ } else if (schema.$ref) {
85
+ const name = schema.$ref.split('/').pop();
86
+ if (!schemas[name]) throw new Error(`Missing Stellar schema: ${name}`);
87
+ references.add(name);
88
+ result = `${prefix}${name}`;
89
+ } else if (schema.enum) {
90
+ result = [
91
+ ...new Set(schema.enum.map((v)=>JSON.stringify(v)))
92
+ ].join(' | ');
93
+ } else if (schema.allOf || schema.oneOf || schema.anyOf) {
94
+ const members = schema.allOf ?? schema.oneOf ?? schema.anyOf;
95
+ result = members.map((s)=>`(${type(s, prefix)})`).join(schema.allOf ? ' & ' : ' | ');
96
+ } else if (schema.type === 'array') {
97
+ result = `Array<${type(schema.items, prefix)}>`;
98
+ } else if (schema.type === 'object') {
99
+ const required = new Set(schema.required ?? []);
100
+ const fields = Object.entries(schema.properties ?? {}).map(([key, value])=>`${comment(value.description)}${JSON.stringify(key)}${required.has(key) ? '' : '?'}: ${type(value, prefix)};`);
101
+ if (schema.additionalProperties && schema.additionalProperties !== true) {
102
+ fields.push(`[key: string]: ${type(schema.additionalProperties, prefix)};`);
103
+ }
104
+ result = fields.length ? `{\n${fields.join('\n')}\n}` : 'Record<string, unknown>';
105
+ } else if (schema.type === 'integer' || schema.type === 'number') {
106
+ result = 'number';
107
+ } else if ([
108
+ 'string',
109
+ 'boolean',
110
+ 'null'
111
+ ].includes(schema.type)) {
112
+ result = schema.type;
113
+ } else {
114
+ throw new Error(`Unsupported Stellar schema: ${JSON.stringify(schema)}`);
115
+ }
116
+ return schema.nullable ? `(${result}) | null` : result;
117
+ }
118
+ return {
119
+ type,
120
+ render () {
121
+ const declarations = [];
122
+ // Rendering a referenced schema discovers its nested schemas too.
123
+ for (const name of references){
124
+ declarations.push(`${comment(schemas[name].description)}export type ${name} = ${type(schemas[name])}\n`);
125
+ }
126
+ return '/** @module Stellar lending API types\n * Generated from src/sdk/swagger.json; do not edit by hand.\n */\n\n' + "import type * as StellarDomain from '@xoxno/types/stellar-lending'\n\n" + declarations.join('\n');
127
+ }
128
+ };
129
+ }