@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.cjs CHANGED
@@ -31,18 +31,18 @@ __export(index_exports, {
31
31
  TrackService: () => TrackService,
32
32
  client: () => client,
33
33
  configureSwapKit: () => configureSwapKit,
34
- getGas: () => getGas,
34
+ createBrokerChannel: () => createBrokerChannel,
35
+ executeSwap: () => executeSwap,
36
+ getCachedPrice: () => getCachedPrice,
35
37
  getGasHistory: () => getGasHistory,
38
+ getGasPrices: () => getGasPrices,
36
39
  getProviders: () => getProviders,
37
- getSwapFrom: () => getSwapFrom,
38
- getSwapTo: () => getSwapTo,
40
+ getQuote: () => getQuote,
41
+ getSwapFromAssets: () => getSwapFromAssets,
42
+ getSwapToAssets: () => getSwapToAssets,
39
43
  getTokens: () => getTokens,
40
- postChainflipBrokerChannel: () => postChainflipBrokerChannel,
41
- postPriceCachedPrice: () => postPriceCachedPrice,
42
- postScreen: () => postScreen,
43
- postTrack: () => postTrack,
44
- postV3Quote: () => postV3Quote,
45
- postV3Swap: () => postV3Swap
44
+ screenAddress: () => screenAddress,
45
+ trackTransaction: () => trackTransaction
46
46
  });
47
47
  module.exports = __toCommonJS(index_exports);
48
48
 
@@ -61,7 +61,7 @@ var extraPrefixesMap = {
61
61
  var extraPrefixes = Object.entries(extraPrefixesMap);
62
62
 
63
63
  // src/core/serverSentEvents.ts
64
- var createSseClient = ({
64
+ function createSseClient({
65
65
  onRequest,
66
66
  onSseError,
67
67
  onSseEvent,
@@ -73,7 +73,7 @@ var createSseClient = ({
73
73
  sseSleepFn,
74
74
  url,
75
75
  ...options
76
- }) => {
76
+ }) {
77
77
  let lastEventId;
78
78
  const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
79
79
  const createStream = async function* () {
@@ -117,7 +117,7 @@ var createSseClient = ({
117
117
  const { done, value } = await reader.read();
118
118
  if (done) break;
119
119
  buffer += value;
120
- buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
120
+ buffer = buffer.replace(/\r\n?/g, "\n");
121
121
  const chunks = buffer.split("\n\n");
122
122
  buffer = chunks.pop() ?? "";
123
123
  for (const chunk of chunks) {
@@ -185,7 +185,7 @@ var createSseClient = ({
185
185
  };
186
186
  const stream = createStream();
187
187
  return { stream };
188
- };
188
+ }
189
189
 
190
190
  // src/core/pathSerializer.ts
191
191
  var separatorArrayExplode = (style) => {
@@ -673,8 +673,9 @@ var createClient = (config = {}) => {
673
673
  if (opts.body === void 0 || opts.serializedBody === "") {
674
674
  opts.headers.delete("Content-Type");
675
675
  }
676
- const url = buildUrl(opts);
677
- return { opts, url };
676
+ const resolvedOpts = opts;
677
+ const url = buildUrl(resolvedOpts);
678
+ return { opts: resolvedOpts, url };
678
679
  };
679
680
  const request = async (options) => {
680
681
  const { opts, url } = await beforeRequest(options);
@@ -820,8 +821,9 @@ var createClient = (config = {}) => {
820
821
  url
821
822
  });
822
823
  };
824
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
823
825
  return {
824
- buildUrl,
826
+ buildUrl: _buildUrl,
825
827
  connect: makeMethodFn("CONNECT"),
826
828
  delete: makeMethodFn("DELETE"),
827
829
  get: makeMethodFn("GET"),
@@ -850,7 +852,7 @@ var createClient = (config = {}) => {
850
852
  };
851
853
 
852
854
  // src/client.ts
853
- var client = createClient(createConfig({ baseUrl: "http://localhost:8080" }));
855
+ var client = createClient(createConfig({ baseUrl: "http://localhost:0" }));
854
856
 
855
857
  // src/config.ts
856
858
  function configureSwapKit(options) {
@@ -872,17 +874,17 @@ var getTokens = (options) => (options?.client ?? client).get({
872
874
  url: "/tokens",
873
875
  ...options
874
876
  });
875
- var getSwapTo = (options) => (options.client ?? client).get({
877
+ var getSwapToAssets = (options) => (options.client ?? client).get({
876
878
  security: [{ name: "x-api-key", type: "apiKey" }],
877
879
  url: "/swapTo",
878
880
  ...options
879
881
  });
880
- var getSwapFrom = (options) => (options.client ?? client).get({
882
+ var getSwapFromAssets = (options) => (options.client ?? client).get({
881
883
  security: [{ name: "x-api-key", type: "apiKey" }],
882
884
  url: "/swapFrom",
883
885
  ...options
884
886
  });
885
- var postChainflipBrokerChannel = (options) => (options.client ?? client).post({
887
+ var createBrokerChannel = (options) => (options.client ?? client).post({
886
888
  security: [{ name: "x-api-key", type: "apiKey" }],
887
889
  url: "/chainflip/broker/channel",
888
890
  ...options,
@@ -891,7 +893,7 @@ var postChainflipBrokerChannel = (options) => (options.client ?? client).post({
891
893
  ...options.headers
892
894
  }
893
895
  });
894
- var postTrack = (options) => (options?.client ?? client).post({
896
+ var trackTransaction = (options) => (options?.client ?? client).post({
895
897
  security: [{ name: "x-api-key", type: "apiKey" }],
896
898
  url: "/track",
897
899
  ...options,
@@ -900,7 +902,7 @@ var postTrack = (options) => (options?.client ?? client).post({
900
902
  ...options?.headers
901
903
  }
902
904
  });
903
- var postScreen = (options) => (options.client ?? client).post({
905
+ var screenAddress = (options) => (options.client ?? client).post({
904
906
  security: [{ name: "x-api-key", type: "apiKey" }],
905
907
  url: "/screen",
906
908
  ...options,
@@ -909,17 +911,17 @@ var postScreen = (options) => (options.client ?? client).post({
909
911
  ...options.headers
910
912
  }
911
913
  });
912
- var getGasHistory = (options) => (options?.client ?? client).get({
914
+ var getGasPrices = (options) => (options?.client ?? client).get({
913
915
  security: [{ name: "x-api-key", type: "apiKey" }],
914
- url: "/gas/history",
916
+ url: "/gas",
915
917
  ...options
916
918
  });
917
- var getGas = (options) => (options?.client ?? client).get({
919
+ var getGasHistory = (options) => (options?.client ?? client).get({
918
920
  security: [{ name: "x-api-key", type: "apiKey" }],
919
- url: "/gas",
921
+ url: "/gas/history",
920
922
  ...options
921
923
  });
922
- var postPriceCachedPrice = (options) => (options.client ?? client).post({
924
+ var getCachedPrice = (options) => (options.client ?? client).post({
923
925
  security: [{ name: "x-api-key", type: "apiKey" }],
924
926
  url: "/price/cached-price",
925
927
  ...options,
@@ -928,7 +930,7 @@ var postPriceCachedPrice = (options) => (options.client ?? client).post({
928
930
  ...options.headers
929
931
  }
930
932
  });
931
- var postV3Quote = (options) => (options.client ?? client).post({
933
+ var getQuote = (options) => (options.client ?? client).post({
932
934
  security: [{ name: "x-api-key", type: "apiKey" }],
933
935
  url: "/v3/quote",
934
936
  ...options,
@@ -937,7 +939,7 @@ var postV3Quote = (options) => (options.client ?? client).post({
937
939
  ...options.headers
938
940
  }
939
941
  });
940
- var postV3Swap = (options) => (options.client ?? client).post({
942
+ var executeSwap = (options) => (options.client ?? client).post({
941
943
  security: [{ name: "x-api-key", type: "apiKey" }],
942
944
  url: "/v3/swap",
943
945
  ...options,
@@ -952,43 +954,43 @@ var SwapKitService = class {
952
954
  };
953
955
  SwapKitService.getProviders = getProviders;
954
956
  SwapKitService.getTokens = getTokens;
955
- SwapKitService.getSwapTo = getSwapTo;
956
- SwapKitService.getSwapFrom = getSwapFrom;
957
- SwapKitService.getQuote = postV3Quote;
958
- SwapKitService.getSwap = postV3Swap;
959
- SwapKitService.trackTransaction = postTrack;
960
- SwapKitService.screenAddress = postScreen;
961
- SwapKitService.getGasPrices = getGas;
957
+ SwapKitService.getSwapTo = getSwapToAssets;
958
+ SwapKitService.getSwapFrom = getSwapFromAssets;
959
+ SwapKitService.getQuote = getQuote;
960
+ SwapKitService.getSwap = executeSwap;
961
+ SwapKitService.trackTransaction = trackTransaction;
962
+ SwapKitService.screenAddress = screenAddress;
963
+ SwapKitService.getGasPrices = getGasPrices;
962
964
  SwapKitService.getGasHistory = getGasHistory;
963
- SwapKitService.getCachedPrice = postPriceCachedPrice;
964
- SwapKitService.createBrokerChannel = postChainflipBrokerChannel;
965
+ SwapKitService.getCachedPrice = getCachedPrice;
966
+ SwapKitService.createBrokerChannel = createBrokerChannel;
965
967
  var TokenlistService = {
966
968
  getProviders,
967
969
  getTokens,
968
- getSwapTo,
969
- getSwapFrom
970
+ getSwapTo: getSwapToAssets,
971
+ getSwapFrom: getSwapFromAssets
970
972
  };
971
973
  var QuoteService = {
972
- getQuote: postV3Quote
974
+ getQuote
973
975
  };
974
976
  var SwapService = {
975
- getSwap: postV3Swap
977
+ getSwap: executeSwap
976
978
  };
977
979
  var TrackService = {
978
- trackTransaction: postTrack
980
+ trackTransaction
979
981
  };
980
982
  var ScreenService = {
981
- screenAddress: postScreen
983
+ screenAddress
982
984
  };
983
985
  var GasService = {
984
- getGasPrices: getGas,
986
+ getGasPrices,
985
987
  getGasHistory
986
988
  };
987
989
  var PriceService = {
988
- getCachedPrice: postPriceCachedPrice
990
+ getCachedPrice
989
991
  };
990
992
  var ChainflipService = {
991
- createBrokerChannel: postChainflipBrokerChannel
993
+ createBrokerChannel
992
994
  };
993
995
  // Annotate the CommonJS export names for ESM import in node:
994
996
  0 && (module.exports = {
@@ -1003,16 +1005,16 @@ var ChainflipService = {
1003
1005
  TrackService,
1004
1006
  client,
1005
1007
  configureSwapKit,
1006
- getGas,
1008
+ createBrokerChannel,
1009
+ executeSwap,
1010
+ getCachedPrice,
1007
1011
  getGasHistory,
1012
+ getGasPrices,
1008
1013
  getProviders,
1009
- getSwapFrom,
1010
- getSwapTo,
1014
+ getQuote,
1015
+ getSwapFromAssets,
1016
+ getSwapToAssets,
1011
1017
  getTokens,
1012
- postChainflipBrokerChannel,
1013
- postPriceCachedPrice,
1014
- postScreen,
1015
- postTrack,
1016
- postV3Quote,
1017
- postV3Swap
1018
+ screenAddress,
1019
+ trackTransaction
1018
1020
  });