@skip-go/client 1.0.1 → 1.0.3-alpha-0

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 (65) hide show
  1. package/dist/api/getAssets.js +2 -15
  2. package/dist/api/getAssetsBetweenChains.js +2 -11
  3. package/dist/api/getBridges.js +2 -11
  4. package/dist/api/getChains.js +2 -11
  5. package/dist/api/getVenues.js +2 -11
  6. package/dist/api/postAssetsFromSource.js +3 -12
  7. package/dist/api/postBalances.js +2 -11
  8. package/dist/api/postIbcOriginAssets.js +2 -11
  9. package/dist/api/postMessages.d.ts +183 -183
  10. package/dist/api/postMessages.js +2 -11
  11. package/dist/api/postMessagesDirect.d.ts +183 -183
  12. package/dist/api/postMessagesDirect.js +2 -11
  13. package/dist/api/postRecommendAssets.js +2 -11
  14. package/dist/api/postRoute.d.ts +160 -160
  15. package/dist/api/postRoute.js +2 -11
  16. package/dist/api/postSubmitTransaction.js +2 -11
  17. package/dist/api/postTrackTransaction.js +2 -11
  18. package/dist/api/postTransactionStatus.js +2 -11
  19. package/dist/chunk-33K6EESX.js +10 -0
  20. package/dist/{chunk-Z4ZKOUGH.js → chunk-4JJWOILI.js} +3 -5
  21. package/dist/chunk-BQTQJQ5E.js +10 -0
  22. package/dist/chunk-BRMONS6A.js +130 -0
  23. package/dist/{chunk-ZG23Z3WY.js → chunk-C2EDPY6J.js} +3 -5
  24. package/dist/chunk-DW4U6YI6.js +10 -0
  25. package/dist/chunk-F75DC5RW.js +1786 -0
  26. package/dist/chunk-GARVPN2H.js +16 -0
  27. package/dist/{chunk-CG5CQQBW.js → chunk-JTIHU43D.js} +33 -42
  28. package/dist/{chunk-5ZJBR5AQ.js → chunk-KNV72XRZ.js} +3 -5
  29. package/dist/chunk-MGVXJ2U4.js +11 -0
  30. package/dist/chunk-MTMPHY3Y.js +9 -0
  31. package/dist/{chunk-GFRPLEJR.js → chunk-PHTQQIAH.js} +278 -311
  32. package/dist/{chunk-RE2QZJWE.js → chunk-PRQ2NHRZ.js} +3 -5
  33. package/dist/chunk-RDRDFJQE.js +10 -0
  34. package/dist/chunk-RMP3HM5N.js +14 -0
  35. package/dist/{chunk-X2YPYBVN.js → chunk-SONZJVQM.js} +59 -68
  36. package/dist/chunk-SWYON2RG.js +1 -4
  37. package/dist/{chunk-RT5TZAMU.js → chunk-TD63P2AG.js} +212 -312
  38. package/dist/{chunk-PKPZTO4H.js → chunk-TW77BXMT.js} +10 -13
  39. package/dist/chunk-UNF72WYO.js +22 -0
  40. package/dist/{chunk-4XWIXR2P.js → chunk-VMPFHQ7U.js} +19 -27
  41. package/dist/chunk-VQ5SIQWU.js +1 -3
  42. package/dist/chunk-W6TBGBV3.js +675 -0
  43. package/dist/index.d.ts +0 -3
  44. package/dist/index.js +24 -209
  45. package/dist/public-functions/executeRoute.js +12 -21
  46. package/dist/public-functions/getFeeInfoForChain.js +5 -14
  47. package/dist/public-functions/getRecommendedGasPrice.d.ts +1 -1
  48. package/dist/public-functions/getRecommendedGasPrice.js +7 -16
  49. package/dist/public-functions/getSigningStargateClient.d.ts +2 -2
  50. package/dist/public-functions/getSigningStargateClient.js +4 -13
  51. package/dist/public-functions/setApiOptions.js +2 -11
  52. package/dist/public-functions/setClientOptions.js +4 -13
  53. package/package.json +12 -3
  54. package/dist/chunk-2WHYWV4Y.js +0 -12
  55. package/dist/chunk-5KVRQLI5.js +0 -17
  56. package/dist/chunk-6BTWKTNM.js +0 -16
  57. package/dist/chunk-6GJEXV5J.js +0 -130
  58. package/dist/chunk-ASPVKNJ7.js +0 -242
  59. package/dist/chunk-EQLA2SEZ.js +0 -2361
  60. package/dist/chunk-FVSSCQ6C.js +0 -12
  61. package/dist/chunk-KYFTM3PI.js +0 -12
  62. package/dist/chunk-L2Q5RP6O.js +0 -25
  63. package/dist/chunk-LRIPQQ4M.js +0 -11
  64. package/dist/chunk-X2E2TKVR.js +0 -12
  65. package/dist/chunk-YYNIFO2A.js +0 -13
@@ -1,242 +0,0 @@
1
- 'use strict';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
- var __objRest = (source, exclude) => {
23
- var target = {};
24
- for (var prop in source)
25
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
- target[prop] = source[prop];
27
- if (source != null && __getOwnPropSymbols)
28
- for (var prop of __getOwnPropSymbols(source)) {
29
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
- target[prop] = source[prop];
31
- }
32
- return target;
33
- };
34
- var __async = (__this, __arguments, generator) => {
35
- return new Promise((resolve, reject) => {
36
- var fulfilled = (value) => {
37
- try {
38
- step(generator.next(value));
39
- } catch (e) {
40
- reject(e);
41
- }
42
- };
43
- var rejected = (value) => {
44
- try {
45
- step(generator.throw(value));
46
- } catch (e) {
47
- reject(e);
48
- }
49
- };
50
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
51
- step((generator = generator.apply(__this, __arguments)).next());
52
- });
53
- };
54
-
55
- // src/state/apiState.ts
56
- var _ApiState = class _ApiState {
57
- static setClientInitialized() {
58
- _ApiState.resolveInitialization();
59
- }
60
- };
61
- _ApiState.cumulativeAffiliateFeeBPS = "0";
62
- _ApiState.isInitialized = false;
63
- _ApiState.clientInitialized = new Promise((resolve) => {
64
- _ApiState.resolveInitialization = () => {
65
- if (!_ApiState.isInitialized) {
66
- _ApiState.isInitialized = true;
67
- resolve();
68
- }
69
- };
70
- });
71
- var ApiState = _ApiState;
72
-
73
- // src/utils/convert.ts
74
- function toSnake(obj) {
75
- return convertKeys(obj, (key) => key.replace(/([A-Z])/g, "_$1").toLowerCase());
76
- }
77
- function toCamel(obj) {
78
- return convertKeys(obj, (key) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()));
79
- }
80
- function convertKeys(obj, convertKey) {
81
- if (Array.isArray(obj)) {
82
- return obj.map((item) => convertKeys(item, convertKey));
83
- } else if (obj !== null && typeof obj === "object") {
84
- return Object.keys(obj).reduce((acc, key) => {
85
- acc[convertKey(key)] = convertKeys(obj[key], convertKey);
86
- return acc;
87
- }, {});
88
- } else {
89
- return obj;
90
- }
91
- }
92
-
93
- // src/utils/timer.ts
94
- var wait = (ms) => {
95
- return new Promise((resolve) => setTimeout(resolve, ms));
96
- };
97
-
98
- // src/utils/generateApi.ts
99
- var createRequestClient = ({ baseUrl, apiKey }) => {
100
- const defaultHeaders = __spreadValues({
101
- "content-type": "application/json"
102
- }, apiKey ? { authorization: apiKey } : {});
103
- const handleResponse = (response) => __async(void 0, null, function* () {
104
- const contentType = response.headers.get("content-type");
105
- const isJson = contentType == null ? void 0 : contentType.includes("application/json");
106
- const body = isJson ? yield response.json() : yield response.text();
107
- if (!response.ok) {
108
- const message = typeof body === "object" && (body == null ? void 0 : body.message) ? body.message : response.statusText;
109
- throw new Error(message);
110
- }
111
- return body;
112
- });
113
- const get = (path, params, signal) => __async(void 0, null, function* () {
114
- const url = new URL(baseUrl + (path != null ? path : ""));
115
- if (params && typeof params === "object") {
116
- Object.entries(params).forEach(([key, value]) => {
117
- if (value !== void 0 && value !== null) {
118
- url.searchParams.append(key, String(value));
119
- }
120
- });
121
- }
122
- const response = yield fetch(url.toString(), {
123
- method: "GET",
124
- headers: defaultHeaders,
125
- signal
126
- });
127
- return handleResponse(response);
128
- });
129
- const post = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (path, data = {}, signal) {
130
- const response = yield fetch(new URL(baseUrl + path).toString(), {
131
- method: "POST",
132
- headers: defaultHeaders,
133
- body: JSON.stringify(data),
134
- signal
135
- });
136
- return handleResponse(response);
137
- });
138
- return { get, post };
139
- };
140
- function createRequest({
141
- path,
142
- method = "get",
143
- onSuccess,
144
- transformResponse
145
- }) {
146
- let controller = null;
147
- const request = (options) => __async(this, null, function* () {
148
- var _b;
149
- const _a = options != null ? options : {}, { apiKey, apiUrl, abortDuplicateRequests } = _a, requestParams = __objRest(_a, ["apiKey", "apiUrl", "abortDuplicateRequests"]);
150
- let fetchClient = ApiState.client;
151
- if (apiUrl || apiKey) {
152
- fetchClient = createRequestClient({
153
- baseUrl: apiUrl || "https://api.skip.build",
154
- apiKey
155
- });
156
- } else {
157
- yield ApiState.clientInitialized;
158
- }
159
- if (abortDuplicateRequests && controller && !((_b = controller == null ? void 0 : controller.signal) == null ? void 0 : _b.aborted)) {
160
- controller == null ? void 0 : controller.abort();
161
- }
162
- controller = new AbortController();
163
- try {
164
- const response = yield fetchClient[method](
165
- path,
166
- requestParams ? toSnake(requestParams) : void 0,
167
- controller.signal
168
- );
169
- const camelCased = toCamel(response != null ? response : {});
170
- const finalResponse = transformResponse ? transformResponse(camelCased) : camelCased;
171
- onSuccess == null ? void 0 : onSuccess(finalResponse, requestParams);
172
- return finalResponse;
173
- } catch (error) {
174
- if (error.name === "AbortError") {
175
- console.log("Request was cancelled");
176
- } else {
177
- console.error("Error:", error);
178
- throw error;
179
- }
180
- }
181
- });
182
- return request;
183
- }
184
- function api({
185
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
186
- methodName,
187
- path,
188
- onSuccess,
189
- method = "get",
190
- transformResponse
191
- }) {
192
- return createRequest({
193
- path,
194
- method,
195
- onSuccess,
196
- transformResponse
197
- });
198
- }
199
- function pollingApi({
200
- methodName,
201
- path,
202
- method = "get",
203
- onSuccess,
204
- onError,
205
- isSuccess = () => true,
206
- maxRetries = 5,
207
- retryInterval = 1e3,
208
- backoffMultiplier = 2
209
- }) {
210
- const request = (requestParams) => __async(this, null, function* () {
211
- let attempt = 0;
212
- let lastError;
213
- while (attempt < maxRetries) {
214
- try {
215
- const result = yield api({ methodName, path, method })(requestParams);
216
- if (result && isSuccess(result)) {
217
- onSuccess == null ? void 0 : onSuccess(result, attempt);
218
- return result;
219
- }
220
- } catch (err) {
221
- lastError = err;
222
- onError == null ? void 0 : onError(err, attempt);
223
- }
224
- const delay = retryInterval * Math.pow(backoffMultiplier, attempt);
225
- yield wait(delay);
226
- attempt++;
227
- }
228
- throw lastError != null ? lastError : new Error("pollingApi: max retries exceeded");
229
- });
230
- return (params) => request(params);
231
- }
232
-
233
- exports.ApiState = ApiState;
234
- exports.__async = __async;
235
- exports.__objRest = __objRest;
236
- exports.__spreadProps = __spreadProps;
237
- exports.__spreadValues = __spreadValues;
238
- exports.api = api;
239
- exports.createRequestClient = createRequestClient;
240
- exports.pollingApi = pollingApi;
241
- exports.toCamel = toCamel;
242
- exports.wait = wait;