@xoxno/sdk-js 1.0.141 → 1.0.142

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 (34) hide show
  1. package/dist/cjs/index.d.ts +3 -0
  2. package/dist/cjs/package.json +3 -0
  3. package/dist/cjs/sdk/index.d.ts +4 -0
  4. package/dist/cjs/sdk/parseSwagger.d.ts +1 -0
  5. package/dist/cjs/sdk/stellar/__tests__/admin.test.d.ts +13 -0
  6. package/dist/cjs/sdk/stellar/__tests__/decode.test.d.ts +10 -0
  7. package/dist/cjs/sdk/stellar/__tests__/id.test.d.ts +4 -0
  8. package/dist/cjs/sdk/stellar/__tests__/lending.test.d.ts +21 -0
  9. package/dist/cjs/sdk/stellar/__tests__/swap.test.d.ts +1 -0
  10. package/dist/cjs/sdk/stellar/admin.d.ts +170 -0
  11. package/dist/cjs/sdk/stellar/cctp.d.ts +16 -0
  12. package/dist/cjs/sdk/stellar/contracts.d.ts +70 -0
  13. package/dist/cjs/sdk/stellar/events/decode.d.ts +45 -0
  14. package/dist/cjs/sdk/stellar/events/id.d.ts +40 -0
  15. package/dist/cjs/sdk/stellar/events/index.d.ts +2 -0
  16. package/dist/cjs/sdk/stellar/governance.d.ts +158 -0
  17. package/dist/cjs/sdk/stellar/index.d.ts +11 -0
  18. package/dist/cjs/sdk/stellar/lending.d.ts +171 -0
  19. package/dist/cjs/sdk/stellar/position-mode.d.ts +7 -0
  20. package/dist/cjs/sdk/stellar/prepare.d.ts +25 -0
  21. package/dist/cjs/sdk/stellar/quote.d.ts +58 -0
  22. package/dist/cjs/sdk/stellar/repay-swap.d.ts +7 -0
  23. package/dist/cjs/sdk/stellar/scval-encode.d.ts +115 -0
  24. package/dist/cjs/sdk/stellar/swap.d.ts +70 -0
  25. package/dist/cjs/sdk/swagger.d.ts +1967 -0
  26. package/dist/cjs/sdk/types.d.ts +83 -0
  27. package/dist/cjs/sdk/utils.d.ts +9 -0
  28. package/dist/cjs/utils/api.d.ts +36 -0
  29. package/dist/cjs/utils/const.d.ts +13 -0
  30. package/dist/cjs/utils/errors.d.ts +12 -0
  31. package/dist/cjs/utils/guards.d.ts +7 -0
  32. package/dist/cjs/utils/helpers.d.ts +3 -0
  33. package/dist/cjs/utils/regex.d.ts +2 -0
  34. package/package.json +3 -3
@@ -0,0 +1,83 @@
1
+ import type { OurRequestInit } from '../utils/api';
2
+ import type { endpoints, endpoints as routes } from './swagger';
3
+ type RemoveColon<S extends string> = S extends `:${infer R}` ? R : S;
4
+ type CamelCase<S extends string> = S extends `${infer Head}-${infer Tail}` ? `${Head}${CamelCase<Capitalize<Tail>>}` : S;
5
+ type IsEmptyObj<T> = keyof T extends never ? true : false;
6
+ type NeedsDefault<I, O, _Full> = IsEmptyObj<I> extends true ? IsEmptyObj<O> extends true ? false : true : true;
7
+ type CollectParams<S extends string> = S extends `${string}:${infer P}/${infer R}` ? {
8
+ [K in P]: string;
9
+ } & CollectParams<`/${R}`> : S extends `${string}:${infer P}` ? {
10
+ [K in P]: string;
11
+ } : {};
12
+ type RequireAtLeastOne<T> = {
13
+ [K in keyof T]-?: {
14
+ [P in K]-?: T[P];
15
+ } & Omit<T, K>;
16
+ }[keyof T] & T;
17
+ type BodyBag<VB, Defined extends boolean> = Defined extends true ? IsEmptyObj<VB> extends true ? {
18
+ body?: never;
19
+ } : {
20
+ body: RequireAtLeastOne<VB>;
21
+ } : {
22
+ body?: RequireAtLeastOne<VB>;
23
+ };
24
+ type SecurityModeOf<T> = T extends {
25
+ securityMode: infer S;
26
+ } ? S : undefined;
27
+ type AuthBag<M> = M extends 'optionalAny' ? {
28
+ auth?: string;
29
+ } : M extends 'requiredAny' | 'requiredWeb2' | 'requiredJwt' ? {
30
+ auth: string;
31
+ } : {
32
+ auth?: never;
33
+ };
34
+ type VerbExtras<Full, PBag> = {
35
+ [Verb in keyof Full as Verb extends 'input' | 'body' | 'output' | 'securityMode' ? never : Verb]: Full[Verb] extends {
36
+ input: infer VI;
37
+ output: infer VO;
38
+ } ? (args: VI & PBag & BodyBag<Full[Verb] extends {
39
+ body: infer VB;
40
+ } ? VB : never, 'body' extends keyof Full[Verb] ? true : false> & AuthBag<SecurityModeOf<Full[Verb]>> & OurRequestInit) => Promise<VO> : never;
41
+ };
42
+ type DropKey<T, K extends PropertyKey> = {
43
+ [P in Exclude<keyof T, K>]: T[P];
44
+ };
45
+ type RequiredKeys<T> = {
46
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
47
+ }[keyof T];
48
+ type HasRequiredKeys<T> = [RequiredKeys<T>] extends [never] ? false : true;
49
+ type PathToTree<P extends string, I, O, Full = {
50
+ input: I;
51
+ output: O;
52
+ }, Root extends string = P, Bag extends object = CollectParams<Root>> = P extends `/${infer Head}/${infer Rest}` ? Head extends `:${infer Param}` ? {
53
+ [K in CamelCase<Param>]: (value: string) => PathToTree<`/${Rest}`, I, O, Full, Root, DropKey<Bag, Param>>;
54
+ } : {
55
+ [K in CamelCase<Head>]: PathToTree<`/${Rest}`, I, O, Full, Root, Bag>;
56
+ } : P extends `/:${infer Param}` ? {
57
+ [K in CamelCase<Param>]: (value: string) => (NeedsDefault<I, O, Full> extends true ? HasRequiredKeys<DropKey<Bag, Param> & I & AuthBag<SecurityModeOf<Full>>> extends true ? (args: I & DropKey<Bag, Param> & AuthBag<SecurityModeOf<Full>> & OurRequestInit) => Promise<O> : (args?: I & DropKey<Bag, Param> & AuthBag<SecurityModeOf<Full>> & OurRequestInit) => Promise<O> : {}) & VerbExtras<Full, DropKey<Bag, Param>>;
58
+ } : P extends `/${infer Leaf}` ? {
59
+ [K in CamelCase<RemoveColon<Leaf>>]: (NeedsDefault<I, O, Full> extends true ? HasRequiredKeys<I & Bag & AuthBag<SecurityModeOf<Full>>> extends true ? (args: I & Bag & AuthBag<SecurityModeOf<Full>> & OurRequestInit) => Promise<O> : (args?: I & Bag & AuthBag<SecurityModeOf<Full>> & OurRequestInit) => Promise<O> : {}) & VerbExtras<Full, Bag>;
60
+ } : never;
61
+ type AnyFn = (...a: any[]) => any;
62
+ type IsFn<T> = T extends AnyFn ? true : false;
63
+ type U2I<U> = (U extends any ? (k: U) => 0 : never) extends (k: infer I) => 0 ? I : never;
64
+ type UnionKeys<U> = U extends any ? keyof U : never;
65
+ type CollapseFnUnion<F> = (...a: Parameters<Extract<F, AnyFn>>) => U2I<F extends AnyFn ? ReturnType<F> : never>;
66
+ type ValuesForKey<U, K extends PropertyKey> = Exclude<U extends any ? (K extends keyof U ? U[K] : never) : never, never>;
67
+ type FnUnion<U> = Extract<U, AnyFn>;
68
+ type ObjUnion<U> = Exclude<U, AnyFn>;
69
+ type CollapseFnUnionOrNever<U> = [FnUnion<U>] extends [never] ? {} : CollapseFnUnion<FnUnion<U>>;
70
+ type MergeRec<U> = [U] extends [object] ? {
71
+ [K in UnionKeys<ObjUnion<U>>]: MergeRec<ValuesForKey<ObjUnion<U>, K>>;
72
+ } & CollapseFnUnionOrNever<U> : U;
73
+ type SimplifyDeep<T> = IsFn<T> extends true ? T : T extends object ? {
74
+ [K in keyof T]: SimplifyDeep<T[K]>;
75
+ } : T;
76
+ type SDKUnion = {
77
+ [R in keyof typeof routes]: PathToTree<R, (typeof routes)[R]['input'], (typeof routes)[R]['output'], (typeof routes)[R]>;
78
+ }[keyof typeof routes];
79
+ export type SDK = SimplifyDeep<MergeRec<SDKUnion>>;
80
+ export type SDKTags = {
81
+ [K in keyof typeof endpoints]: IsEmptyObj<(typeof endpoints)[K]['input']> extends true ? IsEmptyObj<(typeof endpoints)[K]['output']> extends true ? never : K : K;
82
+ }[keyof typeof endpoints];
83
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare const coveredMethods: readonly ["PATCH", "POST", "DELETE", "PUT"];
2
+ declare const _nestTypes: readonly ["string", "number", "boolean"];
3
+ declare const _returnTypes: readonly ["application/json", "multipart/form-data"];
4
+ declare const _securityModes: readonly ["requiredAny", "requiredWeb2", "requiredJwt", "optionalAny"];
5
+ export type ICoveredMethods = (typeof coveredMethods)[number];
6
+ export type INestType = (typeof _nestTypes)[number];
7
+ export type IReturnTypes = (typeof _returnTypes)[number];
8
+ export type ISecurityMode = (typeof _securityModes)[number];
9
+ export {};
@@ -0,0 +1,36 @@
1
+ export type SafeHeaders = Record<string, string> & {
2
+ authorization?: never;
3
+ Authorization?: never;
4
+ };
5
+ export type OurRequestInit = Omit<RequestInit, 'body' | 'headers'> & {
6
+ headers?: SafeHeaders;
7
+ debug?: boolean;
8
+ };
9
+ export declare enum Chain {
10
+ MAINNET = "1",
11
+ DEVNET = "D"
12
+ }
13
+ export declare class XOXNOClient {
14
+ apiUrl: string;
15
+ chain: Chain;
16
+ init: OurRequestInit;
17
+ config: {
18
+ mediaUrl: string;
19
+ gatewayUrl: string;
20
+ XO_SC: string;
21
+ FM_SC: string;
22
+ DR_SC: string;
23
+ KG_SC: string;
24
+ Staking_SC: string;
25
+ Manager_SC: string;
26
+ P2P_SC: string;
27
+ };
28
+ constructor({ chain, apiUrl, ...init }?: {
29
+ chain?: Chain;
30
+ apiUrl?: string;
31
+ } & OurRequestInit);
32
+ fetchWithTimeout: <T>(path: string, { params, ...options }?: RequestInit & {
33
+ debug?: boolean;
34
+ params?: Record<string, any>;
35
+ }) => Promise<T>;
36
+ }
@@ -0,0 +1,13 @@
1
+ export declare const API_URL = "https://api.xoxno.com";
2
+ export declare const API_URL_DEV = "https://devnet-api.xoxno.com";
3
+ export declare const XOXNO_SC = "erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8";
4
+ export declare const FM_SC = "erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s";
5
+ export declare const DR_SC = "erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0";
6
+ export declare const KG_SC = "erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e";
7
+ export declare const Staking_SC = "erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z";
8
+ export declare const Manager_SC = "erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7";
9
+ export declare const P2P_SC = "erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6";
10
+ export declare const XOXNO_SC_DEV = "erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4";
11
+ export declare const Staking_SC_DEV = "erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres";
12
+ export declare const Manager_SC_DEV = "erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr";
13
+ export declare const P2P_SC_DEV = "erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv";
@@ -0,0 +1,12 @@
1
+ export declare class CollectionNotFoundError extends Error {
2
+ constructor(item: string);
3
+ }
4
+ export declare class AddressNotFoundError extends Error {
5
+ constructor(item: string);
6
+ }
7
+ export declare class NFTNotFoundError extends Error {
8
+ constructor(item: string);
9
+ }
10
+ export declare class PaginatedTopError extends Error {
11
+ constructor(top: number);
12
+ }
@@ -0,0 +1,7 @@
1
+ export declare function collectionGuard<T>(collection: string, callback: Promise<T>): Promise<T>;
2
+ export declare function addressGuard<T>(address: string, callback: Promise<T>): Promise<T>;
3
+ export declare function nftGuard<T>(identifier: string, callback: Promise<T>): Promise<T>;
4
+ export declare function collectionGuardOnly(collection: string): Promise<void>;
5
+ export declare function paginatedGuard<T extends {
6
+ top?: number;
7
+ }, R>(filter: T, callback: (filter: string) => Promise<R>): Promise<R>;
@@ -0,0 +1,3 @@
1
+ export declare const nonceToHex: (nonce: number) => string;
2
+ export declare const getIdentifierFromColAndNonce: (collection: string, nonce: number) => string;
3
+ export declare const isAddressValid: (address: string) => boolean;
@@ -0,0 +1,2 @@
1
+ export declare const isValidCollectionTicker: (ticker: string) => boolean;
2
+ export declare const isValidNftIdentifier: (identifier: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xoxno/sdk-js",
3
- "version": "1.0.141",
3
+ "version": "1.0.142",
4
4
  "description": "The SDK to interact with the XOXNO Protocol!",
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,7 +10,7 @@
10
10
  "default": "./dist/index.esm.js"
11
11
  },
12
12
  "require": {
13
- "types": "./dist/index.d.ts",
13
+ "types": "./dist/cjs/index.d.ts",
14
14
  "default": "./dist/index.cjs"
15
15
  }
16
16
  }
@@ -25,7 +25,7 @@
25
25
  "scripts": {
26
26
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
27
27
  "build:sdk": "npx bun run src/sdk/parseSwagger.ts && npx oxlint src/sdk/swagger.ts --fix && npx bun run md/extract.ts",
28
- "build:types": "tsc --emitDeclarationOnly",
28
+ "build:types": "tsc --emitDeclarationOnly && node scripts/emit-cjs-dts.mjs",
29
29
  "build:esm": "webpack --config webpack-esm.config.mjs",
30
30
  "build:cjs": "webpack --config webpack-cjs.config.mjs",
31
31
  "build": "npm run build:sdk && npm run build:types && npm run build:esm && npm run build:cjs",