@skip-go/client 1.0.1-alpha-0 → 1.0.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.
- package/dist/api/getAssets.js +15 -2
- package/dist/api/getAssetsBetweenChains.js +11 -2
- package/dist/api/getBridges.js +11 -2
- package/dist/api/getChains.js +11 -2
- package/dist/api/getVenues.js +11 -2
- package/dist/api/postAssetsFromSource.js +12 -3
- package/dist/api/postBalances.js +11 -2
- package/dist/api/postIbcOriginAssets.js +11 -2
- package/dist/api/postMessages.js +11 -2
- package/dist/api/postMessagesDirect.js +11 -2
- package/dist/api/postRecommendAssets.js +11 -2
- package/dist/api/postRoute.js +11 -2
- package/dist/api/postSubmitTransaction.js +11 -2
- package/dist/api/postTrackTransaction.js +11 -2
- package/dist/api/postTransactionStatus.js +11 -2
- package/dist/{chunk-DAMZSSOH.cjs → chunk-2WHYWV4Y.js} +2 -2
- package/dist/{chunk-J4LI33TK.cjs → chunk-4XWIXR2P.js} +24 -18
- package/dist/chunk-5KVRQLI5.js +17 -0
- package/dist/{chunk-VI7UMBQ7.cjs → chunk-5ZJBR5AQ.js} +2 -2
- package/dist/{chunk-ISHM4QWP.cjs → chunk-6BTWKTNM.js} +4 -4
- package/dist/chunk-6GJEXV5J.js +130 -0
- package/dist/chunk-ASPVKNJ7.js +242 -0
- package/dist/{chunk-7SK3IFXJ.cjs → chunk-CG5CQQBW.js} +36 -32
- package/dist/chunk-EQLA2SEZ.js +2361 -0
- package/dist/{chunk-32MRDO7V.cjs → chunk-FVSSCQ6C.js} +2 -2
- package/dist/{chunk-5IAEEEOQ.cjs → chunk-GFRPLEJR.js} +227 -217
- package/dist/{chunk-L5V5PASH.cjs → chunk-KYFTM3PI.js} +2 -2
- package/dist/chunk-L2Q5RP6O.js +25 -0
- package/dist/{chunk-URLFWBSC.cjs → chunk-LRIPQQ4M.js} +2 -2
- package/dist/{chunk-ZNXE6PUV.cjs → chunk-PKPZTO4H.js} +10 -9
- package/dist/{chunk-RDOSNDAQ.cjs → chunk-RE2QZJWE.js} +2 -2
- package/dist/{chunk-7OIZPQJB.cjs → chunk-RT5TZAMU.js} +138 -101
- package/dist/chunk-SWYON2RG.js +4 -1
- package/dist/chunk-VQ5SIQWU.js +3 -1
- package/dist/{chunk-LXYLWTNZ.cjs → chunk-X2E2TKVR.js} +2 -2
- package/dist/{chunk-SW3SEQMJ.cjs → chunk-X2YPYBVN.js} +30 -25
- package/dist/{chunk-KDN7RCGP.cjs → chunk-YYNIFO2A.js} +2 -2
- package/dist/{chunk-77ITCT75.cjs → chunk-Z4ZKOUGH.js} +2 -2
- package/dist/{chunk-PNWIJSMA.cjs → chunk-ZG23Z3WY.js} +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +209 -24
- package/dist/public-functions/executeRoute.js +21 -12
- package/dist/public-functions/getFeeInfoForChain.js +14 -5
- package/dist/public-functions/getRecommendedGasPrice.d.ts +1 -1
- package/dist/public-functions/getRecommendedGasPrice.js +16 -7
- package/dist/public-functions/getSigningStargateClient.d.ts +1 -1
- package/dist/public-functions/getSigningStargateClient.js +13 -4
- package/dist/public-functions/setApiOptions.js +11 -2
- package/dist/public-functions/setClientOptions.js +13 -4
- package/package.json +1 -10
- package/dist/api/getAssets.cjs +0 -15
- package/dist/api/getAssets.d.cts +0 -19
- package/dist/api/getAssetsBetweenChains.cjs +0 -11
- package/dist/api/getAssetsBetweenChains.d.cts +0 -56
- package/dist/api/getBridges.cjs +0 -11
- package/dist/api/getBridges.d.cts +0 -54
- package/dist/api/getChains.cjs +0 -11
- package/dist/api/getChains.d.cts +0 -41
- package/dist/api/getVenues.cjs +0 -11
- package/dist/api/getVenues.d.cts +0 -13
- package/dist/api/postAssetsFromSource.cjs +0 -12
- package/dist/api/postAssetsFromSource.d.cts +0 -13
- package/dist/api/postBalances.cjs +0 -11
- package/dist/api/postBalances.d.cts +0 -35
- package/dist/api/postIbcOriginAssets.cjs +0 -11
- package/dist/api/postIbcOriginAssets.d.cts +0 -32
- package/dist/api/postMessages.cjs +0 -11
- package/dist/api/postMessages.d.cts +0 -528
- package/dist/api/postMessagesDirect.cjs +0 -11
- package/dist/api/postMessagesDirect.d.cts +0 -568
- package/dist/api/postRecommendAssets.cjs +0 -11
- package/dist/api/postRecommendAssets.d.cts +0 -40
- package/dist/api/postRoute.cjs +0 -11
- package/dist/api/postRoute.d.cts +0 -460
- package/dist/api/postSubmitTransaction.cjs +0 -11
- package/dist/api/postSubmitTransaction.d.cts +0 -13
- package/dist/api/postTrackTransaction.cjs +0 -11
- package/dist/api/postTrackTransaction.d.cts +0 -13
- package/dist/api/postTransactionStatus.cjs +0 -11
- package/dist/api/postTransactionStatus.d.cts +0 -559
- package/dist/apiState-CdzxTxYd.d.cts +0 -6
- package/dist/chunk-33K6EESX.js +0 -10
- package/dist/chunk-3N7XVGLX.js +0 -269
- package/dist/chunk-3OZQ35X3.js +0 -3597
- package/dist/chunk-44PBLFB5.cjs +0 -24
- package/dist/chunk-4JJWOILI.js +0 -13
- package/dist/chunk-4R6OCWRR.cjs +0 -1346
- package/dist/chunk-BQTQJQ5E.js +0 -10
- package/dist/chunk-BRJDNGYH.js +0 -22
- package/dist/chunk-BRMONS6A.js +0 -130
- package/dist/chunk-C2EDPY6J.js +0 -10
- package/dist/chunk-DW4U6YI6.js +0 -10
- package/dist/chunk-ED2OY55G.cjs +0 -136
- package/dist/chunk-GARVPN2H.js +0 -16
- package/dist/chunk-HAR3IXDE.cjs +0 -705
- package/dist/chunk-JTIHU43D.js +0 -183
- package/dist/chunk-KNV72XRZ.js +0 -10
- package/dist/chunk-KZOSEIWH.cjs +0 -10
- package/dist/chunk-MGVXJ2U4.js +0 -11
- package/dist/chunk-MTMPHY3Y.js +0 -9
- package/dist/chunk-PRQ2NHRZ.js +0 -11
- package/dist/chunk-RDRDFJQE.js +0 -10
- package/dist/chunk-RMP3HM5N.js +0 -14
- package/dist/chunk-SFMBRLUS.cjs +0 -18
- package/dist/chunk-SQGWZAUC.js +0 -2229
- package/dist/chunk-TW77BXMT.js +0 -44
- package/dist/chunk-VMPFHQ7U.js +0 -93
- package/dist/chunk-W2U2UOFA.js +0 -1790
- package/dist/chunk-W6TBGBV3.js +0 -675
- package/dist/chunk-WWNTHZ6I.cjs +0 -1812
- package/dist/client-types-qvyKvyFh.d.cts +0 -60
- package/dist/executeRoute-BKRpODCc.d.cts +0 -69
- package/dist/generateApi-C0amiydg.d.cts +0 -22
- package/dist/index.cjs +0 -209
- package/dist/index.d.cts +0 -35
- package/dist/public-functions/executeRoute.cjs +0 -21
- package/dist/public-functions/executeRoute.d.cts +0 -9
- package/dist/public-functions/getFeeInfoForChain.cjs +0 -14
- package/dist/public-functions/getFeeInfoForChain.d.cts +0 -9
- package/dist/public-functions/getRecommendedGasPrice.cjs +0 -16
- package/dist/public-functions/getRecommendedGasPrice.d.cts +0 -9
- package/dist/public-functions/getSigningStargateClient.cjs +0 -13
- package/dist/public-functions/getSigningStargateClient.d.cts +0 -13
- package/dist/public-functions/setApiOptions.cjs +0 -11
- package/dist/public-functions/setApiOptions.d.cts +0 -9
- package/dist/public-functions/setClientOptions.cjs +0 -13
- package/dist/public-functions/setClientOptions.d.cts +0 -9
- package/dist/setClientOptions-CT6CHI9I.d.cts +0 -19
- package/dist/swaggerTypes-O9-gvCT1.d.cts +0 -1890
|
@@ -0,0 +1,242 @@
|
|
|
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;
|