@skip-go/client 1.6.0-alpha.3 → 1.6.0-alpha.4

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 (158) 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/postSubmitTransaction.cjs +12 -0
  14. package/dist/cjs/api/postTrackTransaction.cjs +12 -0
  15. package/dist/cjs/api/postTransactionStatus.cjs +12 -0
  16. package/dist/cjs/chunk-25TA7Z7R.cjs +460 -0
  17. package/dist/cjs/chunk-2QPPD3BB.cjs +210 -0
  18. package/dist/cjs/chunk-2SA3OAIJ.cjs +18 -0
  19. package/dist/cjs/chunk-3KO2DHFX.cjs +1495 -0
  20. package/dist/cjs/chunk-477CU2G2.cjs +280 -0
  21. package/dist/cjs/chunk-4BWE7SOV.cjs +68 -0
  22. package/dist/cjs/chunk-4GHUZDDP.cjs +16 -0
  23. package/dist/cjs/chunk-4ZIVDKQN.cjs +387 -0
  24. package/dist/cjs/chunk-6T4SBY5H.cjs +214 -0
  25. package/dist/cjs/chunk-A3UNNRKD.cjs +574 -0
  26. package/dist/cjs/chunk-A5S6SIYN.cjs +12 -0
  27. package/dist/cjs/chunk-ASDMDYTC.cjs +11 -0
  28. package/dist/cjs/chunk-ATW6UNT5.cjs +136 -0
  29. package/dist/cjs/chunk-AUTOIM57.cjs +22 -0
  30. package/dist/cjs/chunk-AVWWCQ5P.cjs +2264 -0
  31. package/dist/cjs/chunk-CIZTNJ3K.cjs +24 -0
  32. package/dist/cjs/chunk-CK6CQWQU.cjs +49 -0
  33. package/dist/cjs/chunk-EAZQ2ECA.cjs +185 -0
  34. package/dist/cjs/chunk-F3EB2AQG.cjs +28 -0
  35. package/dist/cjs/chunk-FCTBCHOT.cjs +12 -0
  36. package/dist/cjs/chunk-IJIBMN2F.cjs +12 -0
  37. package/dist/cjs/chunk-IUMMXFGP.cjs +189 -0
  38. package/dist/cjs/chunk-JRXPJ45U.cjs +12 -0
  39. package/dist/cjs/chunk-LJV45UGL.cjs +582 -0
  40. package/dist/cjs/chunk-MUJBB64F.cjs +291 -0
  41. package/dist/cjs/chunk-NCFH5MGF.cjs +39 -0
  42. package/dist/cjs/chunk-NM4PISTQ.cjs +3359 -0
  43. package/dist/cjs/chunk-OJISEAMX.cjs +13 -0
  44. package/dist/cjs/chunk-OVKHTOBP.cjs +99 -0
  45. package/dist/cjs/chunk-PDNKS5R2.cjs +13 -0
  46. package/dist/cjs/chunk-TELXDMYL.cjs +55 -0
  47. package/dist/cjs/chunk-UXW4XVHF.cjs +15 -0
  48. package/dist/cjs/index.cjs +349 -0
  49. package/dist/cjs/public-functions/executeMultipleRoutes.cjs +27 -0
  50. package/dist/cjs/public-functions/executeRoute.cjs +27 -0
  51. package/dist/cjs/public-functions/getCosmosGasAmountForMessage.cjs +16 -0
  52. package/dist/cjs/public-functions/getEvmGasAmountForMessage.cjs +11 -0
  53. package/dist/cjs/public-functions/getFeeInfoForChain.cjs +14 -0
  54. package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +15 -0
  55. package/dist/cjs/public-functions/getRouteWithGasOnReceive.cjs +41 -0
  56. package/dist/cjs/public-functions/getSigningStargateClient.cjs +15 -0
  57. package/dist/cjs/public-functions/setApiOptions.cjs +12 -0
  58. package/dist/cjs/public-functions/setClientOptions.cjs +16 -0
  59. package/dist/cjs/public-functions/subscribeToRouteStatus.cjs +26 -0
  60. package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +18 -0
  61. package/dist/cjs/public-functions/waitForTransaction.cjs +18 -0
  62. package/dist/esm/api/getAssets.d.ts +19 -0
  63. package/dist/esm/api/getAssets.js +3 -0
  64. package/dist/esm/api/getAssetsBetweenChains.d.ts +56 -0
  65. package/dist/esm/api/getAssetsBetweenChains.js +3 -0
  66. package/dist/esm/api/getBridges.d.ts +55 -0
  67. package/dist/esm/api/getBridges.js +3 -0
  68. package/dist/esm/api/getChains.d.ts +41 -0
  69. package/dist/esm/api/getChains.js +3 -0
  70. package/dist/esm/api/getVenues.d.ts +13 -0
  71. package/dist/esm/api/getVenues.js +3 -0
  72. package/dist/esm/api/postAssetsFromSource.d.ts +22 -0
  73. package/dist/esm/api/postAssetsFromSource.js +4 -0
  74. package/dist/esm/api/postBalances.d.ts +35 -0
  75. package/dist/esm/api/postBalances.js +3 -0
  76. package/dist/esm/api/postIbcOriginAssets.d.ts +32 -0
  77. package/dist/esm/api/postIbcOriginAssets.js +3 -0
  78. package/dist/esm/api/postMessages.d.ts +101 -0
  79. package/dist/esm/api/postMessages.js +3 -0
  80. package/dist/esm/api/postMessagesDirect.d.ts +640 -0
  81. package/dist/esm/api/postMessagesDirect.js +3 -0
  82. package/dist/esm/api/postRecommendAssets.d.ts +40 -0
  83. package/dist/esm/api/postRecommendAssets.js +3 -0
  84. package/dist/esm/api/postRoute.d.ts +530 -0
  85. package/dist/esm/api/postRoute.js +3 -0
  86. package/dist/esm/api/postSubmitTransaction.d.ts +17 -0
  87. package/dist/esm/api/postSubmitTransaction.js +3 -0
  88. package/dist/esm/api/postTrackTransaction.d.ts +12 -0
  89. package/dist/esm/api/postTrackTransaction.js +3 -0
  90. package/dist/esm/api/postTransactionStatus.d.ts +639 -0
  91. package/dist/esm/api/postTransactionStatus.js +3 -0
  92. package/dist/esm/apiState-1VvikVK-.d.ts +8 -0
  93. package/dist/esm/callbacks-DdC6QMlE.d.ts +158 -0
  94. package/dist/esm/chunk-3DIX6KRJ.js +566 -0
  95. package/dist/esm/chunk-3JHLVPRG.js +10 -0
  96. package/dist/esm/chunk-5WYMRZIO.js +97 -0
  97. package/dist/esm/chunk-A5NZMSTI.js +10 -0
  98. package/dist/esm/chunk-BU5RCZQH.js +187 -0
  99. package/dist/esm/chunk-CGJRRAFS.js +22 -0
  100. package/dist/esm/chunk-DMJMN4J3.js +379 -0
  101. package/dist/esm/chunk-E4NRDAVO.js +65 -0
  102. package/dist/esm/chunk-ETBJVFQP.js +10 -0
  103. package/dist/esm/chunk-F2LQB2DP.js +3323 -0
  104. package/dist/esm/chunk-F66EKL3W.js +203 -0
  105. package/dist/esm/chunk-G665WTT3.js +212 -0
  106. package/dist/esm/chunk-GPEO2I4P.js +272 -0
  107. package/dist/esm/chunk-GV2QOWB4.js +26 -0
  108. package/dist/esm/chunk-GZJLX2CP.js +2258 -0
  109. package/dist/esm/chunk-HNU2Y3JI.js +13 -0
  110. package/dist/esm/chunk-IZUHXTBP.js +53 -0
  111. package/dist/esm/chunk-J24LYWJE.js +130 -0
  112. package/dist/esm/chunk-KZKAL5ZN.js +16 -0
  113. package/dist/esm/chunk-N4PTRCNT.js +11 -0
  114. package/dist/esm/chunk-NUHMTWHP.js +180 -0
  115. package/dist/esm/chunk-P36PE4CR.js +37 -0
  116. package/dist/esm/chunk-QYXGDTUU.js +47 -0
  117. package/dist/esm/chunk-RH7PDDI5.js +433 -0
  118. package/dist/esm/chunk-RTDD7HZ3.js +275 -0
  119. package/dist/esm/chunk-SXBG57J3.js +20 -0
  120. package/dist/esm/chunk-TGTOO2ZQ.js +14 -0
  121. package/dist/esm/chunk-UHCKOKBM.js +9 -0
  122. package/dist/esm/chunk-ULUX2CVU.js +557 -0
  123. package/dist/esm/chunk-UN46DUOV.js +11 -0
  124. package/dist/esm/chunk-XIVAEU6S.js +1492 -0
  125. package/dist/esm/chunk-XNU3TKKM.js +10 -0
  126. package/dist/esm/client-types-D03Tellv.d.ts +114 -0
  127. package/dist/esm/generateApi-Bv02Xt5y.d.ts +56 -0
  128. package/dist/esm/index.d.ts +1859 -0
  129. package/dist/esm/index.js +32 -0
  130. package/dist/esm/public-functions/executeMultipleRoutes.d.ts +80 -0
  131. package/dist/esm/public-functions/executeMultipleRoutes.js +18 -0
  132. package/dist/esm/public-functions/executeRoute.d.ts +12 -0
  133. package/dist/esm/public-functions/executeRoute.js +18 -0
  134. package/dist/esm/public-functions/getCosmosGasAmountForMessage.d.ts +8 -0
  135. package/dist/esm/public-functions/getCosmosGasAmountForMessage.js +3 -0
  136. package/dist/esm/public-functions/getEvmGasAmountForMessage.d.ts +14 -0
  137. package/dist/esm/public-functions/getEvmGasAmountForMessage.js +2 -0
  138. package/dist/esm/public-functions/getFeeInfoForChain.d.ts +9 -0
  139. package/dist/esm/public-functions/getFeeInfoForChain.js +5 -0
  140. package/dist/esm/public-functions/getRecommendedGasPrice.d.ts +9 -0
  141. package/dist/esm/public-functions/getRecommendedGasPrice.js +6 -0
  142. package/dist/esm/public-functions/getRouteWithGasOnReceive.d.ts +20 -0
  143. package/dist/esm/public-functions/getRouteWithGasOnReceive.js +32 -0
  144. package/dist/esm/public-functions/getSigningStargateClient.d.ts +13 -0
  145. package/dist/esm/public-functions/getSigningStargateClient.js +6 -0
  146. package/dist/esm/public-functions/setApiOptions.d.ts +9 -0
  147. package/dist/esm/public-functions/setApiOptions.js +3 -0
  148. package/dist/esm/public-functions/setClientOptions.d.ts +11 -0
  149. package/dist/esm/public-functions/setClientOptions.js +7 -0
  150. package/dist/esm/public-functions/subscribeToRouteStatus.d.ts +12 -0
  151. package/dist/esm/public-functions/subscribeToRouteStatus.js +5 -0
  152. package/dist/esm/public-functions/validateCosmosGasBalance.d.ts +44 -0
  153. package/dist/esm/public-functions/validateCosmosGasBalance.js +9 -0
  154. package/dist/esm/public-functions/waitForTransaction.d.ts +1279 -0
  155. package/dist/esm/public-functions/waitForTransaction.js +5 -0
  156. package/dist/esm/setClientOptions-CTwe8YVX.d.ts +76 -0
  157. package/dist/esm/swaggerTypes-CzGbnX_b.d.ts +2067 -0
  158. package/package.json +1 -1
@@ -0,0 +1,210 @@
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
+ const error = new Error(message);
51
+ if (body?.code) {
52
+ error.code = body.code;
53
+ }
54
+ if (body?.details) {
55
+ error.details = body.details;
56
+ }
57
+ throw error;
58
+ }
59
+ return body;
60
+ };
61
+ const get = async (path, params, signal) => {
62
+ if (path?.startsWith("/")) {
63
+ 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");
64
+ }
65
+ const url = new URL(path ?? "", apiUrl);
66
+ if (params && typeof params === "object") {
67
+ Object.entries(params).forEach(([key, value]) => {
68
+ if (value !== void 0 && value !== null) {
69
+ if (Array.isArray(value)) {
70
+ value.forEach((item) => {
71
+ url.searchParams.append(key, String(item));
72
+ });
73
+ } else {
74
+ url.searchParams.append(key, String(value));
75
+ }
76
+ }
77
+ });
78
+ }
79
+ const response = await fetch(url.toString(), {
80
+ method: "GET",
81
+ headers,
82
+ signal
83
+ });
84
+ return handleResponse(response);
85
+ };
86
+ const post = async (path, data = {}, signal) => {
87
+ if (path?.startsWith("/")) {
88
+ 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");
89
+ }
90
+ const response = await fetch(new URL(path, apiUrl).toString(), {
91
+ method: "POST",
92
+ headers,
93
+ body: JSON.stringify(data),
94
+ signal
95
+ });
96
+ return handleResponse(response);
97
+ };
98
+ return { get, post };
99
+ };
100
+ function createRequest({
101
+ path,
102
+ method = "get",
103
+ onSuccess,
104
+ transformResponse
105
+ }) {
106
+ let controller = null;
107
+ const request = async (options) => {
108
+ const { apiKey, apiUrl, apiHeaders, abortDuplicateRequests, ...requestParams } = options ?? {};
109
+ let fetchClient = ApiState.client;
110
+ if (apiKey || apiUrl || apiHeaders || fetchClient === void 0) {
111
+ fetchClient = createRequestClient({
112
+ apiUrl: apiUrl || "https://api.skip.build",
113
+ apiKey,
114
+ apiHeaders
115
+ });
116
+ }
117
+ ApiState.apiCalled = true;
118
+ if (abortDuplicateRequests && controller && !controller?.signal?.aborted) {
119
+ controller?.abort();
120
+ }
121
+ controller = new AbortController();
122
+ try {
123
+ const response = await fetchClient[method](
124
+ path,
125
+ requestParams ? toSnake(requestParams) : void 0,
126
+ controller.signal
127
+ );
128
+ const camelCased = toCamel(response ?? {});
129
+ const finalResponse = transformResponse ? transformResponse(camelCased) : camelCased;
130
+ onSuccess?.(finalResponse, requestParams);
131
+ return finalResponse;
132
+ } catch (error) {
133
+ if (error.name === "AbortError") {
134
+ console.log("Request was cancelled");
135
+ } else {
136
+ console.error("Error:", error);
137
+ throw error;
138
+ }
139
+ }
140
+ };
141
+ return request;
142
+ }
143
+ function api({
144
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
145
+ methodName,
146
+ path,
147
+ onSuccess,
148
+ method = "get",
149
+ transformResponse
150
+ }) {
151
+ return createRequest({
152
+ path,
153
+ method,
154
+ onSuccess,
155
+ transformResponse
156
+ });
157
+ }
158
+ function pollingApi({
159
+ methodName,
160
+ path,
161
+ method = "get",
162
+ onSuccess,
163
+ onError,
164
+ isSuccess = () => true,
165
+ maxRetries = 10,
166
+ retryInterval = 1e3,
167
+ backoffMultiplier = 2,
168
+ throwOnError = false
169
+ }) {
170
+ const request = async (requestParams) => {
171
+ let attempt = 0;
172
+ let lastError;
173
+ while (attempt < maxRetries) {
174
+ try {
175
+ const result = await api({ methodName, path, method })(requestParams);
176
+ if (result && isSuccess(result)) {
177
+ onSuccess?.(result, attempt);
178
+ return result;
179
+ }
180
+ } catch (err) {
181
+ lastError = err;
182
+ onError?.(err, attempt);
183
+ if (throwOnError) {
184
+ throw err;
185
+ }
186
+ }
187
+ const delay = retryInterval * Math.pow(backoffMultiplier, attempt);
188
+ await wait(delay);
189
+ attempt++;
190
+ }
191
+ throw lastError ?? new Error("pollingApi: max retries exceeded");
192
+ };
193
+ return (params) => request(params);
194
+ }
195
+
196
+ // src/state/apiState.ts
197
+ var ApiState = class {
198
+ static client;
199
+ static chainIdsToAffiliates;
200
+ static cumulativeAffiliateFeeBPS = "0";
201
+ static initialized = false;
202
+ static apiCalled = false;
203
+ };
204
+
205
+ exports.ApiState = ApiState;
206
+ exports.api = api;
207
+ exports.createRequestClient = createRequestClient;
208
+ exports.pollingApi = pollingApi;
209
+ exports.toCamel = toCamel;
210
+ exports.wait = wait;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var chunk2QPPD3BB_cjs = require('./chunk-2QPPD3BB.cjs');
4
+
5
+ // src/api/postRoute.ts
6
+ var route = async (request) => {
7
+ const requestWithAffiliateFeeBps = {
8
+ ...request,
9
+ cumulativeAffiliateFeeBps: chunk2QPPD3BB_cjs.ApiState.cumulativeAffiliateFeeBPS
10
+ };
11
+ return chunk2QPPD3BB_cjs.api({
12
+ methodName: "route",
13
+ method: "post",
14
+ path: "v2/fungible/route"
15
+ })(requestWithAffiliateFeeBps);
16
+ };
17
+
18
+ exports.route = route;