@swapkit/api-sdk-typescript 1.0.3 → 1.0.5

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/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var extraPrefixesMap = {
13
13
  var extraPrefixes = Object.entries(extraPrefixesMap);
14
14
 
15
15
  // src/core/serverSentEvents.ts
16
- var createSseClient = ({
16
+ function createSseClient({
17
17
  onRequest,
18
18
  onSseError,
19
19
  onSseEvent,
@@ -25,7 +25,7 @@ var createSseClient = ({
25
25
  sseSleepFn,
26
26
  url,
27
27
  ...options
28
- }) => {
28
+ }) {
29
29
  let lastEventId;
30
30
  const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
31
31
  const createStream = async function* () {
@@ -69,7 +69,7 @@ var createSseClient = ({
69
69
  const { done, value } = await reader.read();
70
70
  if (done) break;
71
71
  buffer += value;
72
- buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
72
+ buffer = buffer.replace(/\r\n?/g, "\n");
73
73
  const chunks = buffer.split("\n\n");
74
74
  buffer = chunks.pop() ?? "";
75
75
  for (const chunk of chunks) {
@@ -137,7 +137,7 @@ var createSseClient = ({
137
137
  };
138
138
  const stream = createStream();
139
139
  return { stream };
140
- };
140
+ }
141
141
 
142
142
  // src/core/pathSerializer.ts
143
143
  var separatorArrayExplode = (style) => {
@@ -625,8 +625,9 @@ var createClient = (config = {}) => {
625
625
  if (opts.body === void 0 || opts.serializedBody === "") {
626
626
  opts.headers.delete("Content-Type");
627
627
  }
628
- const url = buildUrl(opts);
629
- return { opts, url };
628
+ const resolvedOpts = opts;
629
+ const url = buildUrl(resolvedOpts);
630
+ return { opts: resolvedOpts, url };
630
631
  };
631
632
  const request = async (options) => {
632
633
  const { opts, url } = await beforeRequest(options);
@@ -772,8 +773,9 @@ var createClient = (config = {}) => {
772
773
  url
773
774
  });
774
775
  };
776
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
775
777
  return {
776
- buildUrl,
778
+ buildUrl: _buildUrl,
777
779
  connect: makeMethodFn("CONNECT"),
778
780
  delete: makeMethodFn("DELETE"),
779
781
  get: makeMethodFn("GET"),
@@ -802,7 +804,7 @@ var createClient = (config = {}) => {
802
804
  };
803
805
 
804
806
  // src/client.ts
805
- var client = createClient(createConfig({ baseUrl: "http://localhost:8080" }));
807
+ var client = createClient(createConfig({ baseUrl: "http://localhost:0" }));
806
808
 
807
809
  // src/config.ts
808
810
  function configureSwapKit(options) {
@@ -824,17 +826,17 @@ var getTokens = (options) => (options?.client ?? client).get({
824
826
  url: "/tokens",
825
827
  ...options
826
828
  });
827
- var getSwapTo = (options) => (options.client ?? client).get({
829
+ var getSwapToAssets = (options) => (options.client ?? client).get({
828
830
  security: [{ name: "x-api-key", type: "apiKey" }],
829
831
  url: "/swapTo",
830
832
  ...options
831
833
  });
832
- var getSwapFrom = (options) => (options.client ?? client).get({
834
+ var getSwapFromAssets = (options) => (options.client ?? client).get({
833
835
  security: [{ name: "x-api-key", type: "apiKey" }],
834
836
  url: "/swapFrom",
835
837
  ...options
836
838
  });
837
- var postChainflipBrokerChannel = (options) => (options.client ?? client).post({
839
+ var createBrokerChannel = (options) => (options.client ?? client).post({
838
840
  security: [{ name: "x-api-key", type: "apiKey" }],
839
841
  url: "/chainflip/broker/channel",
840
842
  ...options,
@@ -843,7 +845,7 @@ var postChainflipBrokerChannel = (options) => (options.client ?? client).post({
843
845
  ...options.headers
844
846
  }
845
847
  });
846
- var postTrack = (options) => (options?.client ?? client).post({
848
+ var trackTransaction = (options) => (options?.client ?? client).post({
847
849
  security: [{ name: "x-api-key", type: "apiKey" }],
848
850
  url: "/track",
849
851
  ...options,
@@ -852,7 +854,7 @@ var postTrack = (options) => (options?.client ?? client).post({
852
854
  ...options?.headers
853
855
  }
854
856
  });
855
- var postScreen = (options) => (options.client ?? client).post({
857
+ var screenAddress = (options) => (options.client ?? client).post({
856
858
  security: [{ name: "x-api-key", type: "apiKey" }],
857
859
  url: "/screen",
858
860
  ...options,
@@ -861,17 +863,17 @@ var postScreen = (options) => (options.client ?? client).post({
861
863
  ...options.headers
862
864
  }
863
865
  });
864
- var getGasHistory = (options) => (options?.client ?? client).get({
866
+ var getGasPrices = (options) => (options?.client ?? client).get({
865
867
  security: [{ name: "x-api-key", type: "apiKey" }],
866
- url: "/gas/history",
868
+ url: "/gas",
867
869
  ...options
868
870
  });
869
- var getGas = (options) => (options?.client ?? client).get({
871
+ var getGasHistory = (options) => (options?.client ?? client).get({
870
872
  security: [{ name: "x-api-key", type: "apiKey" }],
871
- url: "/gas",
873
+ url: "/gas/history",
872
874
  ...options
873
875
  });
874
- var postPriceCachedPrice = (options) => (options.client ?? client).post({
876
+ var getCachedPrice = (options) => (options.client ?? client).post({
875
877
  security: [{ name: "x-api-key", type: "apiKey" }],
876
878
  url: "/price/cached-price",
877
879
  ...options,
@@ -880,7 +882,7 @@ var postPriceCachedPrice = (options) => (options.client ?? client).post({
880
882
  ...options.headers
881
883
  }
882
884
  });
883
- var postV3Quote = (options) => (options.client ?? client).post({
885
+ var getQuote = (options) => (options.client ?? client).post({
884
886
  security: [{ name: "x-api-key", type: "apiKey" }],
885
887
  url: "/v3/quote",
886
888
  ...options,
@@ -889,7 +891,7 @@ var postV3Quote = (options) => (options.client ?? client).post({
889
891
  ...options.headers
890
892
  }
891
893
  });
892
- var postV3Swap = (options) => (options.client ?? client).post({
894
+ var executeSwap = (options) => (options.client ?? client).post({
893
895
  security: [{ name: "x-api-key", type: "apiKey" }],
894
896
  url: "/v3/swap",
895
897
  ...options,
@@ -904,43 +906,43 @@ var SwapKitService = class {
904
906
  };
905
907
  SwapKitService.getProviders = getProviders;
906
908
  SwapKitService.getTokens = getTokens;
907
- SwapKitService.getSwapTo = getSwapTo;
908
- SwapKitService.getSwapFrom = getSwapFrom;
909
- SwapKitService.getQuote = postV3Quote;
910
- SwapKitService.getSwap = postV3Swap;
911
- SwapKitService.trackTransaction = postTrack;
912
- SwapKitService.screenAddress = postScreen;
913
- SwapKitService.getGasPrices = getGas;
909
+ SwapKitService.getSwapTo = getSwapToAssets;
910
+ SwapKitService.getSwapFrom = getSwapFromAssets;
911
+ SwapKitService.getQuote = getQuote;
912
+ SwapKitService.getSwap = executeSwap;
913
+ SwapKitService.trackTransaction = trackTransaction;
914
+ SwapKitService.screenAddress = screenAddress;
915
+ SwapKitService.getGasPrices = getGasPrices;
914
916
  SwapKitService.getGasHistory = getGasHistory;
915
- SwapKitService.getCachedPrice = postPriceCachedPrice;
916
- SwapKitService.createBrokerChannel = postChainflipBrokerChannel;
917
+ SwapKitService.getCachedPrice = getCachedPrice;
918
+ SwapKitService.createBrokerChannel = createBrokerChannel;
917
919
  var TokenlistService = {
918
920
  getProviders,
919
921
  getTokens,
920
- getSwapTo,
921
- getSwapFrom
922
+ getSwapTo: getSwapToAssets,
923
+ getSwapFrom: getSwapFromAssets
922
924
  };
923
925
  var QuoteService = {
924
- getQuote: postV3Quote
926
+ getQuote
925
927
  };
926
928
  var SwapService = {
927
- getSwap: postV3Swap
929
+ getSwap: executeSwap
928
930
  };
929
931
  var TrackService = {
930
- trackTransaction: postTrack
932
+ trackTransaction
931
933
  };
932
934
  var ScreenService = {
933
- screenAddress: postScreen
935
+ screenAddress
934
936
  };
935
937
  var GasService = {
936
- getGasPrices: getGas,
938
+ getGasPrices,
937
939
  getGasHistory
938
940
  };
939
941
  var PriceService = {
940
- getCachedPrice: postPriceCachedPrice
942
+ getCachedPrice
941
943
  };
942
944
  var ChainflipService = {
943
- createBrokerChannel: postChainflipBrokerChannel
945
+ createBrokerChannel
944
946
  };
945
947
  export {
946
948
  ChainflipService,
@@ -954,16 +956,16 @@ export {
954
956
  TrackService,
955
957
  client,
956
958
  configureSwapKit,
957
- getGas,
959
+ createBrokerChannel,
960
+ executeSwap,
961
+ getCachedPrice,
958
962
  getGasHistory,
963
+ getGasPrices,
959
964
  getProviders,
960
- getSwapFrom,
961
- getSwapTo,
965
+ getQuote,
966
+ getSwapFromAssets,
967
+ getSwapToAssets,
962
968
  getTokens,
963
- postChainflipBrokerChannel,
964
- postPriceCachedPrice,
965
- postScreen,
966
- postTrack,
967
- postV3Quote,
968
- postV3Swap
969
+ screenAddress,
970
+ trackTransaction
969
971
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swapkit/api-sdk-typescript",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Type-safe TypeScript SDK for the SwapKit API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,7 +19,9 @@
19
19
  "access": "public"
20
20
  },
21
21
  "scripts": {
22
- "build": "tsup src/index.ts --format cjs,esm --dts"
22
+ "build": "tsup src/index.ts --format cjs,esm --dts",
23
+ "typecheck": "tsc --noEmit",
24
+ "release:check": "npm run typecheck && npm run build && npm pack --dry-run"
23
25
  },
24
26
  "dependencies": {},
25
27
  "devDependencies": {
package/src/client.ts CHANGED
@@ -11,6 +11,6 @@ import type { ClientOptions as ClientOptions2 } from './types';
11
11
  * `setConfig()`. This is useful for example if you're using Next.js
12
12
  * to ensure your client always has the correct values.
13
13
  */
14
- export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T> | Promise<Config<Required<ClientOptions> & T>>;
14
+ export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
15
15
 
16
- export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:8080' }));
16
+ export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:0' }));
@@ -4,7 +4,7 @@ import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerialize
4
4
 
5
5
  export type QuerySerializer = (query: Record<string, unknown>) => string;
6
6
 
7
- export type BodySerializer = (body: any) => any;
7
+ export type BodySerializer = (body: unknown) => unknown;
8
8
 
9
9
  type QuerySerializerOptionsObject = {
10
10
  allowReserved?: boolean;
@@ -39,12 +39,10 @@ const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value:
39
39
  };
40
40
 
41
41
  export const formDataBodySerializer = {
42
- bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
43
- body: T,
44
- ): FormData => {
42
+ bodySerializer: (body: unknown): FormData => {
45
43
  const data = new FormData();
46
44
 
47
- Object.entries(body).forEach(([key, value]) => {
45
+ Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {
48
46
  if (value === undefined || value === null) {
49
47
  return;
50
48
  }
@@ -60,15 +58,15 @@ export const formDataBodySerializer = {
60
58
  };
61
59
 
62
60
  export const jsonBodySerializer = {
63
- bodySerializer: <T>(body: T): string =>
61
+ bodySerializer: (body: unknown): string =>
64
62
  JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)),
65
63
  };
66
64
 
67
65
  export const urlSearchParamsBodySerializer = {
68
- bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): string => {
66
+ bodySerializer: (body: unknown): string => {
69
67
  const data = new URLSearchParams();
70
68
 
71
- Object.entries(body).forEach(([key, value]) => {
69
+ Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {
72
70
  if (value === undefined || value === null) {
73
71
  return;
74
72
  }
@@ -79,7 +79,7 @@ export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unkn
79
79
  >;
80
80
  };
81
81
 
82
- export const createSseClient = <TData = unknown>({
82
+ export function createSseClient<TData = unknown>({
83
83
  onRequest,
84
84
  onSseError,
85
85
  onSseEvent,
@@ -91,7 +91,7 @@ export const createSseClient = <TData = unknown>({
91
91
  sseSleepFn,
92
92
  url,
93
93
  ...options
94
- }: ServerSentEventsOptions): ServerSentEventsResult<TData> => {
94
+ }: ServerSentEventsOptions): ServerSentEventsResult<TData> {
95
95
  let lastEventId: string | undefined;
96
96
 
97
97
  const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)));
@@ -155,8 +155,7 @@ export const createSseClient = <TData = unknown>({
155
155
  const { done, value } = await reader.read();
156
156
  if (done) break;
157
157
  buffer += value;
158
- // Normalize line endings: CRLF -> LF, then CR -> LF
159
- buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
158
+ buffer = buffer.replace(/\r\n?/g, '\n'); // normalize line endings
160
159
 
161
160
  const chunks = buffer.split('\n\n');
162
161
  buffer = chunks.pop() ?? '';
@@ -240,4 +239,4 @@ export const createSseClient = <TData = unknown>({
240
239
  const stream = createStream();
241
240
 
242
241
  return { stream };
243
- };
242
+ }
package/src/core/types.ts CHANGED
@@ -80,7 +80,7 @@ export interface Config {
80
80
  requestValidator?: (data: unknown) => Promise<unknown>;
81
81
  /**
82
82
  * A function transforming response data before it's returned. This is useful
83
- * for post-processing data, e.g. converting ISO strings into Date objects.
83
+ * for post-processing data, e.g., converting ISO strings into Date objects.
84
84
  */
85
85
  responseTransformer?: (data: unknown) => Promise<unknown>;
86
86
  /**
package/src/core/utils.ts CHANGED
@@ -126,7 +126,7 @@ export function getValidRequestBody(options: {
126
126
  return hasSerializedBody ? options.serializedBody : null;
127
127
  }
128
128
 
129
- // not all clients implement a serializedBody property (i.e. client-axios)
129
+ // not all clients implement a serializedBody property (i.e., client-axios)
130
130
  return options.body !== '' ? options.body : null;
131
131
  }
132
132
 
@@ -31,13 +31,20 @@ export const createClient = (config: Config = {}): Client => {
31
31
 
32
32
  const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>();
33
33
 
34
- const beforeRequest = async (options: RequestOptions) => {
34
+ const beforeRequest = async <
35
+ TData = unknown,
36
+ TResponseStyle extends 'data' | 'fields' = 'fields',
37
+ ThrowOnError extends boolean = boolean,
38
+ Url extends string = string,
39
+ >(
40
+ options: RequestOptions<TData, TResponseStyle, ThrowOnError, Url>,
41
+ ) => {
35
42
  const opts = {
36
43
  ..._config,
37
44
  ...options,
38
45
  fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
39
46
  headers: mergeHeaders(_config.headers, options.headers),
40
- serializedBody: undefined,
47
+ serializedBody: undefined as string | undefined,
41
48
  };
42
49
 
43
50
  if (opts.security) {
@@ -52,7 +59,7 @@ export const createClient = (config: Config = {}): Client => {
52
59
  }
53
60
 
54
61
  if (opts.body !== undefined && opts.bodySerializer) {
55
- opts.serializedBody = opts.bodySerializer(opts.body);
62
+ opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined;
56
63
  }
57
64
 
58
65
  // remove Content-Type header if body is empty to avoid sending invalid requests
@@ -60,13 +67,14 @@ export const createClient = (config: Config = {}): Client => {
60
67
  opts.headers.delete('Content-Type');
61
68
  }
62
69
 
63
- const url = buildUrl(opts);
70
+ const resolvedOpts = opts as typeof opts &
71
+ ResolvedRequestOptions<TResponseStyle, ThrowOnError, Url>;
72
+ const url = buildUrl(resolvedOpts);
64
73
 
65
- return { opts, url };
74
+ return { opts: resolvedOpts, url };
66
75
  };
67
76
 
68
77
  const request: Client['request'] = async (options) => {
69
- // @ts-expect-error
70
78
  const { opts, url } = await beforeRequest(options);
71
79
  const requestInit: ReqInit = {
72
80
  redirect: 'follow',
@@ -258,8 +266,10 @@ export const createClient = (config: Config = {}): Client => {
258
266
  });
259
267
  };
260
268
 
269
+ const _buildUrl: Client['buildUrl'] = (options) => buildUrl({ ..._config, ...options });
270
+
261
271
  return {
262
- buildUrl,
272
+ buildUrl: _buildUrl,
263
273
  connect: makeMethodFn('CONNECT'),
264
274
  delete: makeMethodFn('DELETE'),
265
275
  get: makeMethodFn('GET'),
package/src/http/types.ts CHANGED
@@ -93,6 +93,7 @@ export interface ResolvedRequestOptions<
93
93
  ThrowOnError extends boolean = boolean,
94
94
  Url extends string = string,
95
95
  > extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
96
+ headers: Headers;
96
97
  serializedBody?: string;
97
98
  }
98
99
 
@@ -152,7 +153,7 @@ type SseFn = <
152
153
  ThrowOnError extends boolean = false,
153
154
  TResponseStyle extends ResponseStyle = 'fields',
154
155
  >(
155
- options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
156
+ options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>,
156
157
  ) => Promise<ServerSentEventsResult<TData, TError>>;
157
158
 
158
159
  type RequestFn = <
@@ -190,7 +191,7 @@ export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn>
190
191
  */
191
192
  export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
192
193
  override?: Config<ClientOptions & T>,
193
- ) => Config<Required<ClientOptions> & T> | Promise<Config<Required<ClientOptions> & T>>;
194
+ ) => Config<Required<ClientOptions> & T>;
194
195
 
195
196
  export interface TDataShape {
196
197
  body?: unknown;
package/src/http/utils.ts CHANGED
@@ -204,7 +204,7 @@ export const mergeHeaders = (
204
204
  mergedHeaders.append(key, v as string);
205
205
  }
206
206
  } else if (value !== undefined) {
207
- // assume object headers are meant to be JSON stringified, i.e. their
207
+ // assume object headers are meant to be JSON stringified, i.e., their
208
208
  // content value in OpenAPI specification is 'application/json'
209
209
  mergedHeaders.set(
210
210
  key,
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
- getSwapTo,
20
- getSwapFrom,
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 = getSwapTo;
35
- static getSwapFrom = getSwapFrom;
36
- static getQuote = postV3Quote;
37
- static getSwap = postV3Swap;
38
- static trackTransaction = postTrack;
39
- static screenAddress = postScreen;
40
- static getGasPrices = getGas;
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 = postPriceCachedPrice;
43
- static createBrokerChannel = postChainflipBrokerChannel;
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: postV3Quote,
60
+ getQuote,
61
61
  } as const;
62
62
 
63
63
  /** @deprecated Use `SwapKitService` instead */
64
64
  export const SwapService = {
65
- getSwap: postV3Swap,
65
+ getSwap: executeSwap,
66
66
  } as const;
67
67
 
68
68
  /** @deprecated Use `SwapKitService` instead */
69
69
  export const TrackService = {
70
- trackTransaction: postTrack,
70
+ trackTransaction,
71
71
  } as const;
72
72
 
73
73
  /** @deprecated Use `SwapKitService` instead */
74
74
  export const ScreenService = {
75
- screenAddress: postScreen,
75
+ screenAddress,
76
76
  } as const;
77
77
 
78
78
  /** @deprecated Use `SwapKitService` instead */
79
79
  export const GasService = {
80
- getGasPrices: getGas,
80
+ getGasPrices,
81
81
  getGasHistory,
82
82
  } as const;
83
83
 
84
84
  /** @deprecated Use `SwapKitService` instead */
85
85
  export const PriceService = {
86
- getCachedPrice: postPriceCachedPrice,
86
+ getCachedPrice,
87
87
  } as const;
88
88
 
89
89
  /** @deprecated Use `SwapKitService` instead */
90
90
  export const ChainflipService = {
91
- createBrokerChannel: postChainflipBrokerChannel,
91
+ createBrokerChannel,
92
92
  } as const;
package/src/sdk.ts CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  import type { Client, Options as Options2, TDataShape } from './http';
4
4
  import { client } from './client';
5
- import type { GetGasData, GetGasHistoryData, GetGasHistoryResponses, GetGasResponses, GetProvidersData, GetProvidersErrors, GetProvidersResponses, GetSwapFromData, GetSwapFromErrors, GetSwapFromResponses, GetSwapToData, GetSwapToErrors, GetSwapToResponses, GetTokensData, GetTokensErrors, GetTokensResponses, PostChainflipBrokerChannelData, PostChainflipBrokerChannelResponses, PostPriceCachedPriceData, PostPriceCachedPriceResponses, PostScreenData, PostScreenErrors, PostScreenResponses, PostTrackData, PostTrackResponses, PostV3QuoteData, PostV3QuoteErrors, PostV3QuoteResponses, PostV3SwapData, PostV3SwapErrors, PostV3SwapResponses } from './types';
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
@@ -30,19 +30,19 @@ export const getTokens = <ThrowOnError extends boolean = false>(options?: Option
30
30
  ...options
31
31
  });
32
32
 
33
- export const getSwapTo = <ThrowOnError extends boolean = false>(options: Options<GetSwapToData, ThrowOnError>) => (options.client ?? client).get<GetSwapToResponses, GetSwapToErrors, ThrowOnError>({
33
+ export const getSwapToAssets = <ThrowOnError extends boolean = false>(options: Options<GetSwapToAssetsData, 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 getSwapFrom = <ThrowOnError extends boolean = false>(options: Options<GetSwapFromData, ThrowOnError>) => (options.client ?? client).get<GetSwapFromResponses, GetSwapFromErrors, ThrowOnError>({
39
+ export const getSwapFromAssets = <ThrowOnError extends boolean = false>(options: Options<GetSwapFromAssetsData, 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 postChainflipBrokerChannel = <ThrowOnError extends boolean = false>(options: Options<PostChainflipBrokerChannelData, ThrowOnError>) => (options.client ?? client).post<PostChainflipBrokerChannelResponses, unknown, ThrowOnError>({
45
+ export const createBrokerChannel = <ThrowOnError extends boolean = false>(options: Options<CreateBrokerChannelData, 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 postTrack = <ThrowOnError extends boolean = false>(options?: Options<PostTrackData, ThrowOnError>) => (options?.client ?? client).post<PostTrackResponses, unknown, ThrowOnError>({
55
+ export const trackTransaction = <ThrowOnError extends boolean = false>(options?: Options<TrackTransactionData, 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 postScreen = <ThrowOnError extends boolean = false>(options: Options<PostScreenData, ThrowOnError>) => (options.client ?? client).post<PostScreenResponses, PostScreenErrors, ThrowOnError>({
65
+ export const screenAddress = <ThrowOnError extends boolean = false>(options: Options<ScreenAddressData, 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 getGasHistory = <ThrowOnError extends boolean = false>(options?: Options<GetGasHistoryData, ThrowOnError>) => (options?.client ?? client).get<GetGasHistoryResponses, unknown, ThrowOnError>({
75
+ export const getGasPrices = <ThrowOnError extends boolean = false>(options?: Options<GetGasPricesData, ThrowOnError>) => (options?.client ?? client).get<GetGasPricesResponses, unknown, ThrowOnError>({
76
76
  security: [{ name: 'x-api-key', type: 'apiKey' }],
77
- url: '/gas/history',
77
+ url: '/gas',
78
78
  ...options
79
79
  });
80
80
 
81
- export const getGas = <ThrowOnError extends boolean = false>(options?: Options<GetGasData, ThrowOnError>) => (options?.client ?? client).get<GetGasResponses, unknown, ThrowOnError>({
81
+ export const getGasHistory = <ThrowOnError extends boolean = false>(options?: Options<GetGasHistoryData, 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 postPriceCachedPrice = <ThrowOnError extends boolean = false>(options: Options<PostPriceCachedPriceData, ThrowOnError>) => (options.client ?? client).post<PostPriceCachedPriceResponses, unknown, ThrowOnError>({
87
+ export const getCachedPrice = <ThrowOnError extends boolean = false>(options: Options<GetCachedPriceData, 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 postV3Quote = <ThrowOnError extends boolean = false>(options: Options<PostV3QuoteData, ThrowOnError>) => (options.client ?? client).post<PostV3QuoteResponses, PostV3QuoteErrors, ThrowOnError>({
97
+ export const getQuote = <ThrowOnError extends boolean = false>(options: Options<GetQuoteData, 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 postV3Swap = <ThrowOnError extends boolean = false>(options: Options<PostV3SwapData, ThrowOnError>) => (options.client ?? client).post<PostV3SwapResponses, PostV3SwapErrors, ThrowOnError>({
107
+ export const executeSwap = <ThrowOnError extends boolean = false>(options: Options<ExecuteSwapData, 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,