@skip-go/client 1.2.3 → 1.3.1

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 (173) hide show
  1. package/dist/cjs/api/getAssets.cjs +16 -0
  2. package/dist/cjs/api/getAssetsBetweenChains.cjs +12 -0
  3. package/dist/cjs/api/getBridges.cjs +12 -0
  4. package/dist/cjs/api/getChains.cjs +12 -0
  5. package/dist/cjs/api/getVenues.cjs +12 -0
  6. package/dist/cjs/api/postAssetsFromSource.cjs +13 -0
  7. package/dist/cjs/api/postBalances.cjs +12 -0
  8. package/dist/cjs/api/postIbcOriginAssets.cjs +12 -0
  9. package/dist/cjs/api/postMessages.cjs +12 -0
  10. package/dist/cjs/api/postMessagesDirect.cjs +12 -0
  11. package/dist/cjs/api/postRecommendAssets.cjs +12 -0
  12. package/dist/cjs/api/postRoute.cjs +12 -0
  13. package/dist/cjs/api/postSubmit.cjs +12 -0
  14. package/dist/cjs/api/postSubmitTransaction.cjs +12 -0
  15. package/dist/cjs/api/postTrackTransaction.cjs +12 -0
  16. package/dist/cjs/api/postTransactionStatus.cjs +12 -0
  17. package/dist/cjs/chunk-4R6OCWRR.cjs +1346 -0
  18. package/dist/cjs/chunk-5FR25GF5.cjs +209 -0
  19. package/dist/cjs/chunk-AHRSARNR.cjs +38 -0
  20. package/dist/cjs/chunk-CPTNOPWI.cjs +566 -0
  21. package/dist/cjs/chunk-CWUD7UGL.cjs +13 -0
  22. package/dist/cjs/chunk-D2W4UBJB.cjs +136 -0
  23. package/dist/cjs/chunk-DUJSZRFD.cjs +1445 -0
  24. package/dist/cjs/chunk-EINQFLWN.cjs +12 -0
  25. package/dist/cjs/chunk-EQBTNGJJ.cjs +11 -0
  26. package/dist/cjs/chunk-F3EB2AQG.cjs +28 -0
  27. package/dist/cjs/chunk-G3G6PBIF.cjs +47 -0
  28. package/dist/cjs/chunk-HDKNPB2J.cjs +182 -0
  29. package/dist/cjs/chunk-KMDNP6DN.cjs +24 -0
  30. package/dist/cjs/chunk-KZOSEIWH.cjs +10 -0
  31. package/dist/cjs/chunk-MGYSCMET.cjs +273 -0
  32. package/dist/cjs/chunk-N3LR7KTI.cjs +304 -0
  33. package/dist/cjs/chunk-NQR3EPN2.cjs +12 -0
  34. package/dist/cjs/chunk-OA5PE7TW.cjs +18 -0
  35. package/dist/cjs/chunk-PFCGKAXF.cjs +15 -0
  36. package/dist/cjs/chunk-PG7RVHOU.cjs +12 -0
  37. package/dist/cjs/chunk-RFBDXALX.cjs +12 -0
  38. package/dist/cjs/chunk-SIY2K7TT.cjs +13 -0
  39. package/dist/cjs/chunk-SLZCWA4K.cjs +2234 -0
  40. package/dist/cjs/chunk-T5LPU5A2.cjs +188 -0
  41. package/dist/cjs/chunk-TCQMGBFL.cjs +38 -0
  42. package/dist/cjs/chunk-TFL5E5A6.cjs +12 -0
  43. package/dist/cjs/chunk-TWPLCFOH.cjs +16 -0
  44. package/dist/cjs/chunk-W2DPDT3Y.cjs +22 -0
  45. package/dist/cjs/chunk-WE7KICKO.cjs +95 -0
  46. package/dist/cjs/chunk-WMXUOVHN.cjs +3642 -0
  47. package/dist/cjs/index.cjs +401 -0
  48. package/dist/cjs/public-functions/executeRoute.cjs +28 -0
  49. package/dist/cjs/public-functions/getCosmosGasAmountForMessage.cjs +15 -0
  50. package/dist/cjs/public-functions/getEvmGasAmountForMessage.cjs +11 -0
  51. package/dist/cjs/public-functions/getFeeInfoForChain.cjs +15 -0
  52. package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +17 -0
  53. package/dist/cjs/public-functions/getSigningStargateClient.cjs +14 -0
  54. package/dist/cjs/public-functions/setApiOptions.cjs +12 -0
  55. package/dist/cjs/public-functions/setClientOptions.cjs +14 -0
  56. package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +18 -0
  57. package/dist/cjs/public-functions/waitForTransaction.cjs +14 -0
  58. package/dist/{api → esm/api}/getAssets.d.ts +1 -1
  59. package/dist/esm/api/getAssets.js +3 -0
  60. package/dist/{api → esm/api}/getAssetsBetweenChains.d.ts +1 -1
  61. package/dist/esm/api/getAssetsBetweenChains.js +3 -0
  62. package/dist/{api → esm/api}/getBridges.d.ts +3 -2
  63. package/dist/esm/api/getBridges.js +3 -0
  64. package/dist/{api → esm/api}/getChains.d.ts +1 -1
  65. package/dist/esm/api/getChains.js +3 -0
  66. package/dist/esm/api/getVenues.js +3 -0
  67. package/dist/{api → esm/api}/postAssetsFromSource.d.ts +1 -1
  68. package/dist/esm/api/postAssetsFromSource.js +4 -0
  69. package/dist/{api → esm/api}/postBalances.d.ts +2 -2
  70. package/dist/esm/api/postBalances.js +3 -0
  71. package/dist/esm/api/postIbcOriginAssets.js +3 -0
  72. package/dist/{api → esm/api}/postMessages.d.ts +3 -2
  73. package/dist/esm/api/postMessages.js +3 -0
  74. package/dist/{api → esm/api}/postMessagesDirect.d.ts +196 -194
  75. package/dist/esm/api/postMessagesDirect.js +3 -0
  76. package/dist/{api → esm/api}/postRecommendAssets.d.ts +1 -1
  77. package/dist/esm/api/postRecommendAssets.js +3 -0
  78. package/dist/{api → esm/api}/postRoute.d.ts +191 -190
  79. package/dist/esm/api/postRoute.js +3 -0
  80. package/dist/{api → esm/api}/postSubmit.d.ts +2 -2
  81. package/dist/esm/api/postSubmit.js +3 -0
  82. package/dist/esm/api/postSubmitTransaction.js +3 -0
  83. package/dist/{api → esm/api}/postTrackTransaction.d.ts +2 -2
  84. package/dist/esm/api/postTrackTransaction.js +3 -0
  85. package/dist/{api → esm/api}/postTransactionStatus.d.ts +14 -2
  86. package/dist/esm/api/postTransactionStatus.js +3 -0
  87. package/dist/{callbacks-CPh0dr86.d.ts → esm/callbacks-C2lXb0AH.d.ts} +6 -1
  88. package/dist/{chunk-4CXSWHQ6.js → esm/chunk-2R5COFPS.js} +1 -1
  89. package/dist/esm/chunk-43P4WRGN.js +183 -0
  90. package/dist/{chunk-UCUUIQHV.js → esm/chunk-4DI7G6TH.js} +1 -1
  91. package/dist/{chunk-4XUWIG3Z.js → esm/chunk-6ULKULTX.js} +1 -1
  92. package/dist/{chunk-OFBEDG4X.js → esm/chunk-6UMMVC2P.js} +1 -1
  93. package/dist/{chunk-5GWNR2CV.js → esm/chunk-7ZG7HNNC.js} +2 -2
  94. package/dist/{chunk-A4M35XLF.js → esm/chunk-C6NHVJ3R.js} +2 -2
  95. package/dist/{chunk-GQXA3DGV.js → esm/chunk-CGZ5DA2T.js} +1 -1
  96. package/dist/{chunk-COJAW7OW.js → esm/chunk-ERPZHRBM.js} +3 -3
  97. package/dist/{chunk-EHKR7I66.js → esm/chunk-F65QOYUA.js} +2 -2
  98. package/dist/{chunk-TKLDJEAS.js → esm/chunk-GOD6ESBZ.js} +14 -14
  99. package/dist/{chunk-S4LIRB4Q.js → esm/chunk-HAGMHUOI.js} +30 -14
  100. package/dist/{chunk-2YOWXBHH.js → esm/chunk-HS2D6FKN.js} +1 -1
  101. package/dist/{chunk-XZV42PVV.js → esm/chunk-I4AMZAHH.js} +3 -2
  102. package/dist/{chunk-UXUJNZOA.js → esm/chunk-KYLULQOS.js} +7 -1
  103. package/dist/{chunk-CXFOPLGZ.js → esm/chunk-MAOMQHG5.js} +1 -1
  104. package/dist/{chunk-A7FWC5OX.js → esm/chunk-NZVZH6OA.js} +1 -1
  105. package/dist/{chunk-DF3WCTFB.js → esm/chunk-PIQZD2VE.js} +1 -1
  106. package/dist/{chunk-NQZYCFAA.js → esm/chunk-QPJEHGY7.js} +1 -1
  107. package/dist/{chunk-YABXOO3H.js → esm/chunk-SS5LQKBL.js} +5 -1
  108. package/dist/{chunk-U6NXCWXE.js → esm/chunk-UZKIIX6A.js} +1 -1
  109. package/dist/{chunk-Z3Z7A3YS.js → esm/chunk-VUOOTNLG.js} +1 -1
  110. package/dist/{chunk-7MWYHGMD.js → esm/chunk-YLMQS52U.js} +2 -2
  111. package/dist/{chunk-RE4YYQCE.js → esm/chunk-YYXOIRHZ.js} +1 -1
  112. package/dist/{chunk-THUBVEVZ.js → esm/chunk-ZTDLGX7X.js} +1 -1
  113. package/dist/{client-types-DRmsTfeT.d.ts → esm/client-types-DuWWc2_J.d.ts} +1 -1
  114. package/dist/{generateApi-D7KXciAd.d.ts → esm/generateApi-DvFEIUee.d.ts} +2 -1
  115. package/dist/{index.d.ts → esm/index.d.ts} +21 -6
  116. package/dist/{index.js → esm/index.js} +32 -26
  117. package/dist/{public-functions → esm/public-functions}/executeRoute.d.ts +4 -4
  118. package/dist/esm/public-functions/executeRoute.js +19 -0
  119. package/dist/{public-functions → esm/public-functions}/getCosmosGasAmountForMessage.d.ts +1 -1
  120. package/dist/{public-functions → esm/public-functions}/getEvmGasAmountForMessage.d.ts +2 -2
  121. package/dist/{public-functions → esm/public-functions}/getEvmGasAmountForMessage.js +1 -1
  122. package/dist/{public-functions → esm/public-functions}/getFeeInfoForChain.d.ts +1 -1
  123. package/dist/esm/public-functions/getFeeInfoForChain.js +6 -0
  124. package/dist/esm/public-functions/getRecommendedGasPrice.js +8 -0
  125. package/dist/esm/public-functions/getSigningStargateClient.js +5 -0
  126. package/dist/{public-functions → esm/public-functions}/setApiOptions.d.ts +1 -1
  127. package/dist/esm/public-functions/setApiOptions.js +3 -0
  128. package/dist/{public-functions → esm/public-functions}/setClientOptions.d.ts +3 -3
  129. package/dist/esm/public-functions/setClientOptions.js +5 -0
  130. package/dist/{public-functions → esm/public-functions}/validateCosmosGasBalance.d.ts +4 -4
  131. package/dist/esm/public-functions/validateCosmosGasBalance.js +9 -0
  132. package/dist/{public-functions → esm/public-functions}/waitForTransaction.d.ts +15 -3
  133. package/dist/esm/public-functions/waitForTransaction.js +5 -0
  134. package/dist/{setClientOptions-CwcM5Ps9.d.ts → esm/setClientOptions-B27lt_6h.d.ts} +1 -1
  135. package/dist/{swaggerTypes-BpJPRbC3.d.ts → esm/swaggerTypes-BrC-ZYnx.d.ts} +20 -1
  136. package/package.json +19 -7
  137. package/dist/api/getAssets.js +0 -3
  138. package/dist/api/getAssetsBetweenChains.js +0 -3
  139. package/dist/api/getBridges.js +0 -3
  140. package/dist/api/getChains.js +0 -3
  141. package/dist/api/getVenues.js +0 -3
  142. package/dist/api/postAssetsFromSource.js +0 -4
  143. package/dist/api/postBalances.js +0 -3
  144. package/dist/api/postIbcOriginAssets.js +0 -3
  145. package/dist/api/postMessages.js +0 -3
  146. package/dist/api/postMessagesDirect.js +0 -3
  147. package/dist/api/postRecommendAssets.js +0 -3
  148. package/dist/api/postRoute.js +0 -3
  149. package/dist/api/postSubmit.js +0 -3
  150. package/dist/api/postSubmitTransaction.js +0 -3
  151. package/dist/api/postTrackTransaction.js +0 -3
  152. package/dist/api/postTransactionStatus.js +0 -3
  153. package/dist/chunk-6AKLNBEL.js +0 -183
  154. package/dist/public-functions/executeRoute.js +0 -19
  155. package/dist/public-functions/getFeeInfoForChain.js +0 -6
  156. package/dist/public-functions/getRecommendedGasPrice.js +0 -8
  157. package/dist/public-functions/getSigningStargateClient.js +0 -5
  158. package/dist/public-functions/setApiOptions.js +0 -3
  159. package/dist/public-functions/setClientOptions.js +0 -5
  160. package/dist/public-functions/validateCosmosGasBalance.js +0 -9
  161. package/dist/public-functions/waitForTransaction.js +0 -5
  162. /package/dist/{api → esm/api}/getVenues.d.ts +0 -0
  163. /package/dist/{api → esm/api}/postIbcOriginAssets.d.ts +0 -0
  164. /package/dist/{api → esm/api}/postSubmitTransaction.d.ts +0 -0
  165. /package/dist/{apiState-DwZhwVul.d.ts → esm/apiState-DwZhwVul.d.ts} +0 -0
  166. /package/dist/{chunk-GV2QOWB4.js → esm/chunk-GV2QOWB4.js} +0 -0
  167. /package/dist/{chunk-SWYON2RG.js → esm/chunk-SWYON2RG.js} +0 -0
  168. /package/dist/{chunk-TD63P2AG.js → esm/chunk-TD63P2AG.js} +0 -0
  169. /package/dist/{chunk-TV2XPAIF.js → esm/chunk-TV2XPAIF.js} +0 -0
  170. /package/dist/{chunk-VQ5SIQWU.js → esm/chunk-VQ5SIQWU.js} +0 -0
  171. /package/dist/{public-functions → esm/public-functions}/getCosmosGasAmountForMessage.js +0 -0
  172. /package/dist/{public-functions → esm/public-functions}/getRecommendedGasPrice.d.ts +0 -0
  173. /package/dist/{public-functions → esm/public-functions}/getSigningStargateClient.d.ts +0 -0
@@ -0,0 +1,209 @@
1
+ 'use strict';
2
+
3
+ // src/utils/timer.ts
4
+ var wait = (ms) => {
5
+ return new Promise((resolve) => setTimeout(resolve, ms));
6
+ };
7
+
8
+ // src/utils/convert.ts
9
+ function toSnake(obj) {
10
+ return convertKeys(obj, (key) => key.replace(/([A-Z])/g, "_$1").toLowerCase());
11
+ }
12
+ function toCamel(obj) {
13
+ return convertKeys(obj, (key) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()));
14
+ }
15
+ function convertKeys(obj, convertKey) {
16
+ if (Array.isArray(obj)) {
17
+ return obj.map((item) => convertKeys(item, convertKey));
18
+ } else if (obj !== null && typeof obj === "object") {
19
+ return Object.keys(obj).reduce((acc, key) => {
20
+ acc[convertKey(key)] = convertKeys(obj[key], convertKey);
21
+ return acc;
22
+ }, {});
23
+ } else {
24
+ return obj;
25
+ }
26
+ }
27
+
28
+ // src/utils/generateApi.ts
29
+ var createRequestClient = ({ apiUrl, apiKey, apiHeaders }) => {
30
+ if (!apiUrl?.endsWith("/")) {
31
+ apiUrl += "/";
32
+ }
33
+ const headers = new Headers({
34
+ "content-type": "application/json"
35
+ });
36
+ if (apiKey) {
37
+ headers.set("authorization", apiKey);
38
+ }
39
+ if (apiHeaders) {
40
+ new Headers(apiHeaders).forEach((value, key) => {
41
+ headers.set(key, value);
42
+ });
43
+ }
44
+ const handleResponse = async (response) => {
45
+ const contentType = response.headers.get("content-type");
46
+ const isJson = contentType?.includes("application/json");
47
+ const body = isJson ? await response.json() : await response.text();
48
+ if (!response.ok) {
49
+ const message = typeof body === "object" && body?.message ? body.message : response.statusText;
50
+ throw new Error(message);
51
+ }
52
+ return body;
53
+ };
54
+ const get = async (path, params, signal) => {
55
+ if (path?.startsWith("/")) {
56
+ console.warn("paths that start with / are treated as absolute paths, please remove the leading / if this path is intended to be a relative path");
57
+ }
58
+ const url = new URL(path ?? "", apiUrl);
59
+ if (params && typeof params === "object") {
60
+ Object.entries(params).forEach(([key, value]) => {
61
+ if (value !== void 0 && value !== null) {
62
+ url.searchParams.append(key, String(value));
63
+ }
64
+ });
65
+ }
66
+ const response = await fetch(url.toString(), {
67
+ method: "GET",
68
+ headers,
69
+ signal
70
+ });
71
+ return handleResponse(response);
72
+ };
73
+ const post = async (path, data = {}, signal) => {
74
+ if (path?.startsWith("/")) {
75
+ console.warn("paths that start with / are treated as absolute paths, please remove the leading / if this path is intended to be a relative path");
76
+ }
77
+ const response = await fetch(new URL(path, apiUrl).toString(), {
78
+ method: "POST",
79
+ headers,
80
+ body: JSON.stringify(data),
81
+ signal
82
+ });
83
+ return handleResponse(response);
84
+ };
85
+ return { get, post };
86
+ };
87
+ function createRequest({
88
+ path,
89
+ method = "get",
90
+ onSuccess,
91
+ transformResponse
92
+ }) {
93
+ let controller = null;
94
+ const request = async (options) => {
95
+ const { apiKey, apiUrl, apiHeaders, abortDuplicateRequests, ...requestParams } = options ?? {};
96
+ let fetchClient = ApiState.client;
97
+ if (apiUrl || apiKey) {
98
+ fetchClient = createRequestClient({
99
+ apiUrl: apiUrl || "https://api.skip.build",
100
+ apiKey,
101
+ apiHeaders
102
+ });
103
+ } else {
104
+ await ApiState.clientInitialized;
105
+ }
106
+ if (abortDuplicateRequests && controller && !controller?.signal?.aborted) {
107
+ controller?.abort();
108
+ }
109
+ controller = new AbortController();
110
+ try {
111
+ const response = await fetchClient[method](
112
+ path,
113
+ requestParams ? toSnake(requestParams) : void 0,
114
+ controller.signal
115
+ );
116
+ const camelCased = toCamel(response ?? {});
117
+ const finalResponse = transformResponse ? transformResponse(camelCased) : camelCased;
118
+ onSuccess?.(finalResponse, requestParams);
119
+ return finalResponse;
120
+ } catch (error) {
121
+ if (error.name === "AbortError") {
122
+ console.log("Request was cancelled");
123
+ } else {
124
+ console.error("Error:", error);
125
+ throw error;
126
+ }
127
+ }
128
+ };
129
+ return request;
130
+ }
131
+ function api({
132
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
133
+ methodName,
134
+ path,
135
+ onSuccess,
136
+ method = "get",
137
+ transformResponse
138
+ }) {
139
+ return createRequest({
140
+ path,
141
+ method,
142
+ onSuccess,
143
+ transformResponse
144
+ });
145
+ }
146
+ function pollingApi({
147
+ methodName,
148
+ path,
149
+ method = "get",
150
+ onSuccess,
151
+ onError,
152
+ isSuccess = () => true,
153
+ maxRetries = 5,
154
+ retryInterval = 1e3,
155
+ backoffMultiplier = 2,
156
+ throwOnError = false
157
+ }) {
158
+ const request = async (requestParams) => {
159
+ let attempt = 0;
160
+ let lastError;
161
+ while (attempt < maxRetries) {
162
+ try {
163
+ const result = await api({ methodName, path, method })(requestParams);
164
+ if (result && isSuccess(result)) {
165
+ onSuccess?.(result, attempt);
166
+ return result;
167
+ }
168
+ } catch (err) {
169
+ lastError = err;
170
+ onError?.(err, attempt);
171
+ if (throwOnError) {
172
+ throw err;
173
+ }
174
+ }
175
+ const delay = retryInterval * Math.pow(backoffMultiplier, attempt);
176
+ await wait(delay);
177
+ attempt++;
178
+ }
179
+ throw lastError ?? new Error("pollingApi: max retries exceeded");
180
+ };
181
+ return (params) => request(params);
182
+ }
183
+
184
+ // src/state/apiState.ts
185
+ var ApiState = class _ApiState {
186
+ static client;
187
+ static chainIdsToAffiliates;
188
+ static cumulativeAffiliateFeeBPS = "0";
189
+ static isInitialized = false;
190
+ static resolveInitialization;
191
+ static clientInitialized = new Promise((resolve) => {
192
+ _ApiState.resolveInitialization = () => {
193
+ if (!_ApiState.isInitialized) {
194
+ _ApiState.isInitialized = true;
195
+ resolve();
196
+ }
197
+ };
198
+ });
199
+ static setClientInitialized() {
200
+ _ApiState.resolveInitialization();
201
+ }
202
+ };
203
+
204
+ exports.ApiState = ApiState;
205
+ exports.api = api;
206
+ exports.createRequestClient = createRequestClient;
207
+ exports.pollingApi = pollingApi;
208
+ exports.toCamel = toCamel;
209
+ exports.wait = wait;
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ var chunk5FR25GF5_cjs = require('./chunk-5FR25GF5.cjs');
4
+
5
+ // src/utils/filterMessagesRequest.ts
6
+ var filterMessagesRequest = (request) => {
7
+ const messagesRequest = {
8
+ sourceAssetDenom: request.sourceAssetDenom,
9
+ sourceAssetChainId: request.sourceAssetChainId,
10
+ destAssetDenom: request.destAssetDenom,
11
+ destAssetChainId: request.destAssetChainId,
12
+ amountIn: request.amountIn,
13
+ amountOut: request.amountOut,
14
+ addressList: request.addressList,
15
+ operations: request.operations,
16
+ estimatedAmountOut: request.estimatedAmountOut,
17
+ slippageTolerancePercent: request.slippageTolerancePercent,
18
+ timeoutSeconds: request.timeoutSeconds,
19
+ postRouteHandler: request.postRouteHandler,
20
+ chainIdsToAffiliates: request.chainIdsToAffiliates,
21
+ enableGasWarnings: request.enableGasWarnings,
22
+ apiUrl: request.apiUrl,
23
+ apiKey: request.apiKey,
24
+ abortDuplicateRequests: request.abortDuplicateRequests
25
+ };
26
+ return messagesRequest;
27
+ };
28
+
29
+ // src/api/postMessages.ts
30
+ var messages = async (request) => {
31
+ return chunk5FR25GF5_cjs.api({
32
+ methodName: "msgs",
33
+ method: "post",
34
+ path: "v2/fungible/msgs"
35
+ })(filterMessagesRequest(request));
36
+ };
37
+
38
+ exports.messages = messages;