@swapkit/api-sdk-typescript 1.0.3 → 1.1.0-nightly.20260701161042
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/README.md +6 -0
- package/dist/index.cjs +148 -164
- package/dist/index.d.cts +1661 -1455
- package/dist/index.d.ts +1661 -1455
- package/dist/index.js +139 -155
- package/package.json +4 -2
- package/src/client.ts +3 -3
- package/src/core/auth.ts +7 -0
- package/src/core/bodySerializer.ts +6 -8
- package/src/core/params.ts +24 -15
- package/src/core/pathSerializer.ts +6 -6
- package/src/core/queryKeySerializer.ts +1 -1
- package/src/core/serverSentEvents.ts +4 -5
- package/src/core/types.ts +7 -1
- package/src/core/utils.ts +5 -5
- package/src/http/client.ts +129 -140
- package/src/http/index.ts +2 -0
- package/src/http/types.ts +10 -6
- package/src/http/utils.ts +13 -13
- package/src/index.ts +28 -28
- package/src/sdk.ts +18 -18
- package/src/types.ts +1597 -1387
package/src/index.ts
CHANGED
|
@@ -14,33 +14,33 @@ export * from "./sdk";
|
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
|
|
16
16
|
import {
|
|
17
|
+
createBrokerChannel,
|
|
18
|
+
executeSwap,
|
|
19
|
+
getCachedPrice,
|
|
20
|
+
getGasHistory,
|
|
21
|
+
getGasPrices,
|
|
17
22
|
getProviders,
|
|
23
|
+
getQuote,
|
|
24
|
+
getSwapFromAssets,
|
|
25
|
+
getSwapToAssets,
|
|
18
26
|
getTokens,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
postV3Quote,
|
|
22
|
-
postV3Swap,
|
|
23
|
-
postTrack,
|
|
24
|
-
postScreen,
|
|
25
|
-
getGas,
|
|
26
|
-
getGasHistory,
|
|
27
|
-
postPriceCachedPrice,
|
|
28
|
-
postChainflipBrokerChannel,
|
|
27
|
+
screenAddress,
|
|
28
|
+
trackTransaction,
|
|
29
29
|
} from "./sdk";
|
|
30
30
|
|
|
31
31
|
export class SwapKitService {
|
|
32
32
|
static getProviders = getProviders;
|
|
33
33
|
static getTokens = getTokens;
|
|
34
|
-
static getSwapTo =
|
|
35
|
-
static getSwapFrom =
|
|
36
|
-
static getQuote =
|
|
37
|
-
static getSwap =
|
|
38
|
-
static trackTransaction =
|
|
39
|
-
static screenAddress =
|
|
40
|
-
static getGasPrices =
|
|
34
|
+
static getSwapTo = getSwapToAssets;
|
|
35
|
+
static getSwapFrom = getSwapFromAssets;
|
|
36
|
+
static getQuote = getQuote;
|
|
37
|
+
static getSwap = executeSwap;
|
|
38
|
+
static trackTransaction = trackTransaction;
|
|
39
|
+
static screenAddress = screenAddress;
|
|
40
|
+
static getGasPrices = getGasPrices;
|
|
41
41
|
static getGasHistory = getGasHistory;
|
|
42
|
-
static getCachedPrice =
|
|
43
|
-
static createBrokerChannel =
|
|
42
|
+
static getCachedPrice = getCachedPrice;
|
|
43
|
+
static createBrokerChannel = createBrokerChannel;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
// ---------------------------------------------------------------------------
|
|
@@ -51,42 +51,42 @@ export class SwapKitService {
|
|
|
51
51
|
export const TokenlistService = {
|
|
52
52
|
getProviders,
|
|
53
53
|
getTokens,
|
|
54
|
-
getSwapTo,
|
|
55
|
-
getSwapFrom,
|
|
54
|
+
getSwapTo: getSwapToAssets,
|
|
55
|
+
getSwapFrom: getSwapFromAssets,
|
|
56
56
|
} as const;
|
|
57
57
|
|
|
58
58
|
/** @deprecated Use `SwapKitService` instead */
|
|
59
59
|
export const QuoteService = {
|
|
60
|
-
getQuote
|
|
60
|
+
getQuote,
|
|
61
61
|
} as const;
|
|
62
62
|
|
|
63
63
|
/** @deprecated Use `SwapKitService` instead */
|
|
64
64
|
export const SwapService = {
|
|
65
|
-
getSwap:
|
|
65
|
+
getSwap: executeSwap,
|
|
66
66
|
} as const;
|
|
67
67
|
|
|
68
68
|
/** @deprecated Use `SwapKitService` instead */
|
|
69
69
|
export const TrackService = {
|
|
70
|
-
trackTransaction
|
|
70
|
+
trackTransaction,
|
|
71
71
|
} as const;
|
|
72
72
|
|
|
73
73
|
/** @deprecated Use `SwapKitService` instead */
|
|
74
74
|
export const ScreenService = {
|
|
75
|
-
screenAddress
|
|
75
|
+
screenAddress,
|
|
76
76
|
} as const;
|
|
77
77
|
|
|
78
78
|
/** @deprecated Use `SwapKitService` instead */
|
|
79
79
|
export const GasService = {
|
|
80
|
-
getGasPrices
|
|
80
|
+
getGasPrices,
|
|
81
81
|
getGasHistory,
|
|
82
82
|
} as const;
|
|
83
83
|
|
|
84
84
|
/** @deprecated Use `SwapKitService` instead */
|
|
85
85
|
export const PriceService = {
|
|
86
|
-
getCachedPrice
|
|
86
|
+
getCachedPrice,
|
|
87
87
|
} as const;
|
|
88
88
|
|
|
89
89
|
/** @deprecated Use `SwapKitService` instead */
|
|
90
90
|
export const ChainflipService = {
|
|
91
|
-
createBrokerChannel
|
|
91
|
+
createBrokerChannel,
|
|
92
92
|
} as const;
|
package/src/sdk.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
|
-
import type { Client, Options as Options2, TDataShape } from './http';
|
|
3
|
+
import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './http';
|
|
4
4
|
import { client } from './client';
|
|
5
|
-
import type {
|
|
5
|
+
import type { CreateBrokerChannelData, CreateBrokerChannelResponses, ExecuteSwapData, ExecuteSwapErrors, ExecuteSwapResponses, GetCachedPriceData, GetCachedPriceResponses, GetGasHistoryData, GetGasHistoryResponses, GetGasPricesData, GetGasPricesResponses, GetProvidersData, GetProvidersErrors, GetProvidersResponses, GetQuoteData, GetQuoteErrors, GetQuoteResponses, GetSwapFromAssetsData, GetSwapFromAssetsErrors, GetSwapFromAssetsResponses, GetSwapToAssetsData, GetSwapToAssetsErrors, GetSwapToAssetsResponses, GetTokensData, GetTokensErrors, GetTokensResponses, ScreenAddressData, ScreenAddressErrors, ScreenAddressResponses, TrackTransactionData, TrackTransactionErrors, TrackTransactionResponses } from './types';
|
|
6
6
|
|
|
7
|
-
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
|
|
7
|
+
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
|
|
8
8
|
/**
|
|
9
9
|
* You can provide a client instance returned by `createClient()` instead of
|
|
10
10
|
* individual options. This might be also useful if you want to implement a
|
|
@@ -15,34 +15,34 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
|
|
|
15
15
|
* You can pass arbitrary values through the `meta` object. This can be
|
|
16
16
|
* used to access values that aren't defined as part of the SDK function.
|
|
17
17
|
*/
|
|
18
|
-
meta?: Record<string, unknown
|
|
18
|
+
meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const getProviders = <ThrowOnError extends boolean = false>(options?: Options<GetProvidersData, ThrowOnError>) => (options?.client ?? client).get<GetProvidersResponses, GetProvidersErrors, ThrowOnError>({
|
|
21
|
+
export const getProviders = <ThrowOnError extends boolean = false>(options?: Options<GetProvidersData, ThrowOnError>): RequestResult<GetProvidersResponses, GetProvidersErrors, ThrowOnError> => (options?.client ?? client).get<GetProvidersResponses, GetProvidersErrors, ThrowOnError>({
|
|
22
22
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
23
23
|
url: '/providers',
|
|
24
24
|
...options
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
export const getTokens = <ThrowOnError extends boolean = false>(options?: Options<GetTokensData, ThrowOnError>) => (options?.client ?? client).get<GetTokensResponses, GetTokensErrors, ThrowOnError>({
|
|
27
|
+
export const getTokens = <ThrowOnError extends boolean = false>(options?: Options<GetTokensData, ThrowOnError>): RequestResult<GetTokensResponses, GetTokensErrors, ThrowOnError> => (options?.client ?? client).get<GetTokensResponses, GetTokensErrors, ThrowOnError>({
|
|
28
28
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
29
29
|
url: '/tokens',
|
|
30
30
|
...options
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
export const
|
|
33
|
+
export const getSwapToAssets = <ThrowOnError extends boolean = false>(options: Options<GetSwapToAssetsData, ThrowOnError>): RequestResult<GetSwapToAssetsResponses, GetSwapToAssetsErrors, ThrowOnError> => (options.client ?? client).get<GetSwapToAssetsResponses, GetSwapToAssetsErrors, ThrowOnError>({
|
|
34
34
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
35
35
|
url: '/swapTo',
|
|
36
36
|
...options
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
export const
|
|
39
|
+
export const getSwapFromAssets = <ThrowOnError extends boolean = false>(options: Options<GetSwapFromAssetsData, ThrowOnError>): RequestResult<GetSwapFromAssetsResponses, GetSwapFromAssetsErrors, ThrowOnError> => (options.client ?? client).get<GetSwapFromAssetsResponses, GetSwapFromAssetsErrors, ThrowOnError>({
|
|
40
40
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
41
41
|
url: '/swapFrom',
|
|
42
42
|
...options
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
export const
|
|
45
|
+
export const createBrokerChannel = <ThrowOnError extends boolean = false>(options: Options<CreateBrokerChannelData, ThrowOnError>): RequestResult<CreateBrokerChannelResponses, unknown, ThrowOnError> => (options.client ?? client).post<CreateBrokerChannelResponses, unknown, ThrowOnError>({
|
|
46
46
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
47
47
|
url: '/chainflip/broker/channel',
|
|
48
48
|
...options,
|
|
@@ -52,7 +52,7 @@ export const postChainflipBrokerChannel = <ThrowOnError extends boolean = false>
|
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
export const
|
|
55
|
+
export const trackTransaction = <ThrowOnError extends boolean = false>(options?: Options<TrackTransactionData, ThrowOnError>): RequestResult<TrackTransactionResponses, TrackTransactionErrors, ThrowOnError> => (options?.client ?? client).post<TrackTransactionResponses, TrackTransactionErrors, ThrowOnError>({
|
|
56
56
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
57
57
|
url: '/track',
|
|
58
58
|
...options,
|
|
@@ -62,7 +62,7 @@ export const postTrack = <ThrowOnError extends boolean = false>(options?: Option
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
export const
|
|
65
|
+
export const screenAddress = <ThrowOnError extends boolean = false>(options: Options<ScreenAddressData, ThrowOnError>): RequestResult<ScreenAddressResponses, ScreenAddressErrors, ThrowOnError> => (options.client ?? client).post<ScreenAddressResponses, ScreenAddressErrors, ThrowOnError>({
|
|
66
66
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
67
67
|
url: '/screen',
|
|
68
68
|
...options,
|
|
@@ -72,19 +72,19 @@ export const postScreen = <ThrowOnError extends boolean = false>(options: Option
|
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
export const
|
|
75
|
+
export const getGasPrices = <ThrowOnError extends boolean = false>(options?: Options<GetGasPricesData, ThrowOnError>): RequestResult<GetGasPricesResponses, unknown, ThrowOnError> => (options?.client ?? client).get<GetGasPricesResponses, unknown, ThrowOnError>({
|
|
76
76
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
77
|
-
url: '/gas
|
|
77
|
+
url: '/gas',
|
|
78
78
|
...options
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
export const
|
|
81
|
+
export const getGasHistory = <ThrowOnError extends boolean = false>(options?: Options<GetGasHistoryData, ThrowOnError>): RequestResult<GetGasHistoryResponses, unknown, ThrowOnError> => (options?.client ?? client).get<GetGasHistoryResponses, unknown, ThrowOnError>({
|
|
82
82
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
83
|
-
url: '/gas',
|
|
83
|
+
url: '/gas/history',
|
|
84
84
|
...options
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
export const
|
|
87
|
+
export const getCachedPrice = <ThrowOnError extends boolean = false>(options: Options<GetCachedPriceData, ThrowOnError>): RequestResult<GetCachedPriceResponses, unknown, ThrowOnError> => (options.client ?? client).post<GetCachedPriceResponses, unknown, ThrowOnError>({
|
|
88
88
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
89
89
|
url: '/price/cached-price',
|
|
90
90
|
...options,
|
|
@@ -94,7 +94,7 @@ export const postPriceCachedPrice = <ThrowOnError extends boolean = false>(optio
|
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
export const
|
|
97
|
+
export const getQuote = <ThrowOnError extends boolean = false>(options: Options<GetQuoteData, ThrowOnError>): RequestResult<GetQuoteResponses, GetQuoteErrors, ThrowOnError> => (options.client ?? client).post<GetQuoteResponses, GetQuoteErrors, ThrowOnError>({
|
|
98
98
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
99
99
|
url: '/v3/quote',
|
|
100
100
|
...options,
|
|
@@ -104,7 +104,7 @@ export const postV3Quote = <ThrowOnError extends boolean = false>(options: Optio
|
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
export const
|
|
107
|
+
export const executeSwap = <ThrowOnError extends boolean = false>(options: Options<ExecuteSwapData, ThrowOnError>): RequestResult<ExecuteSwapResponses, ExecuteSwapErrors, ThrowOnError> => (options.client ?? client).post<ExecuteSwapResponses, ExecuteSwapErrors, ThrowOnError>({
|
|
108
108
|
security: [{ name: 'x-api-key', type: 'apiKey' }],
|
|
109
109
|
url: '/v3/swap',
|
|
110
110
|
...options,
|