@skip-go/client 1.6.0-alpha.1 → 1.6.0-alpha.3
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/package.json +1 -1
- package/dist/cjs/api/getAssets.cjs +0 -16
- package/dist/cjs/api/getAssetsBetweenChains.cjs +0 -12
- package/dist/cjs/api/getBridges.cjs +0 -12
- package/dist/cjs/api/getChains.cjs +0 -12
- package/dist/cjs/api/getVenues.cjs +0 -12
- package/dist/cjs/api/postAssetsFromSource.cjs +0 -13
- package/dist/cjs/api/postBalances.cjs +0 -12
- package/dist/cjs/api/postIbcOriginAssets.cjs +0 -12
- package/dist/cjs/api/postMessages.cjs +0 -12
- package/dist/cjs/api/postMessagesDirect.cjs +0 -12
- package/dist/cjs/api/postRecommendAssets.cjs +0 -12
- package/dist/cjs/api/postRoute.cjs +0 -12
- package/dist/cjs/api/postSubmitTransaction.cjs +0 -12
- package/dist/cjs/api/postTrackTransaction.cjs +0 -12
- package/dist/cjs/api/postTransactionStatus.cjs +0 -12
- package/dist/cjs/chunk-2QPPD3BB.cjs +0 -210
- package/dist/cjs/chunk-2SA3OAIJ.cjs +0 -18
- package/dist/cjs/chunk-4BWE7SOV.cjs +0 -68
- package/dist/cjs/chunk-4GHUZDDP.cjs +0 -16
- package/dist/cjs/chunk-4ZIVDKQN.cjs +0 -387
- package/dist/cjs/chunk-A3UNNRKD.cjs +0 -574
- package/dist/cjs/chunk-A5S6SIYN.cjs +0 -12
- package/dist/cjs/chunk-AQTXZWLA.cjs +0 -55
- package/dist/cjs/chunk-ASDMDYTC.cjs +0 -11
- package/dist/cjs/chunk-ATW6UNT5.cjs +0 -136
- package/dist/cjs/chunk-AUTOIM57.cjs +0 -22
- package/dist/cjs/chunk-AVWWCQ5P.cjs +0 -2264
- package/dist/cjs/chunk-CIZTNJ3K.cjs +0 -24
- package/dist/cjs/chunk-CK6CQWQU.cjs +0 -49
- package/dist/cjs/chunk-EAZQ2ECA.cjs +0 -185
- package/dist/cjs/chunk-F3EB2AQG.cjs +0 -28
- package/dist/cjs/chunk-FCTBCHOT.cjs +0 -12
- package/dist/cjs/chunk-GDDD6R2X.cjs +0 -459
- package/dist/cjs/chunk-IJIBMN2F.cjs +0 -12
- package/dist/cjs/chunk-JRXPJ45U.cjs +0 -12
- package/dist/cjs/chunk-LJF74VNZ.cjs +0 -214
- package/dist/cjs/chunk-LJV45UGL.cjs +0 -582
- package/dist/cjs/chunk-MUJBB64F.cjs +0 -291
- package/dist/cjs/chunk-NCFH5MGF.cjs +0 -39
- package/dist/cjs/chunk-NM4PISTQ.cjs +0 -3359
- package/dist/cjs/chunk-OJISEAMX.cjs +0 -13
- package/dist/cjs/chunk-OVKHTOBP.cjs +0 -99
- package/dist/cjs/chunk-PDNKS5R2.cjs +0 -13
- package/dist/cjs/chunk-TEH6UMUR.cjs +0 -280
- package/dist/cjs/chunk-UXW4XVHF.cjs +0 -15
- package/dist/cjs/chunk-WVMDZODS.cjs +0 -1495
- package/dist/cjs/chunk-YX56UXDX.cjs +0 -189
- package/dist/cjs/index.cjs +0 -349
- package/dist/cjs/public-functions/executeMultipleRoutes.cjs +0 -27
- package/dist/cjs/public-functions/executeRoute.cjs +0 -27
- package/dist/cjs/public-functions/getCosmosGasAmountForMessage.cjs +0 -16
- package/dist/cjs/public-functions/getEvmGasAmountForMessage.cjs +0 -11
- package/dist/cjs/public-functions/getFeeInfoForChain.cjs +0 -14
- package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +0 -15
- package/dist/cjs/public-functions/getRouteWithGasOnReceive.cjs +0 -41
- package/dist/cjs/public-functions/getSigningStargateClient.cjs +0 -15
- package/dist/cjs/public-functions/setApiOptions.cjs +0 -12
- package/dist/cjs/public-functions/setClientOptions.cjs +0 -16
- package/dist/cjs/public-functions/subscribeToRouteStatus.cjs +0 -26
- package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +0 -18
- package/dist/cjs/public-functions/waitForTransaction.cjs +0 -18
- package/dist/esm/api/getAssets.d.ts +0 -19
- package/dist/esm/api/getAssets.js +0 -3
- package/dist/esm/api/getAssetsBetweenChains.d.ts +0 -56
- package/dist/esm/api/getAssetsBetweenChains.js +0 -3
- package/dist/esm/api/getBridges.d.ts +0 -55
- package/dist/esm/api/getBridges.js +0 -3
- package/dist/esm/api/getChains.d.ts +0 -41
- package/dist/esm/api/getChains.js +0 -3
- package/dist/esm/api/getVenues.d.ts +0 -13
- package/dist/esm/api/getVenues.js +0 -3
- package/dist/esm/api/postAssetsFromSource.d.ts +0 -22
- package/dist/esm/api/postAssetsFromSource.js +0 -4
- package/dist/esm/api/postBalances.d.ts +0 -35
- package/dist/esm/api/postBalances.js +0 -3
- package/dist/esm/api/postIbcOriginAssets.d.ts +0 -32
- package/dist/esm/api/postIbcOriginAssets.js +0 -3
- package/dist/esm/api/postMessages.d.ts +0 -101
- package/dist/esm/api/postMessages.js +0 -3
- package/dist/esm/api/postMessagesDirect.d.ts +0 -617
- package/dist/esm/api/postMessagesDirect.js +0 -3
- package/dist/esm/api/postRecommendAssets.d.ts +0 -40
- package/dist/esm/api/postRecommendAssets.js +0 -3
- package/dist/esm/api/postRoute.d.ts +0 -507
- package/dist/esm/api/postRoute.js +0 -3
- package/dist/esm/api/postSubmitTransaction.d.ts +0 -17
- package/dist/esm/api/postSubmitTransaction.js +0 -3
- package/dist/esm/api/postTrackTransaction.d.ts +0 -12
- package/dist/esm/api/postTrackTransaction.js +0 -3
- package/dist/esm/api/postTransactionStatus.d.ts +0 -639
- package/dist/esm/api/postTransactionStatus.js +0 -3
- package/dist/esm/apiState-1VvikVK-.d.ts +0 -8
- package/dist/esm/callbacks-1e6BnDot.d.ts +0 -158
- package/dist/esm/chunk-3DIX6KRJ.js +0 -566
- package/dist/esm/chunk-3JHLVPRG.js +0 -10
- package/dist/esm/chunk-5WYMRZIO.js +0 -97
- package/dist/esm/chunk-6QW6MRVQ.js +0 -53
- package/dist/esm/chunk-A4HQEGYV.js +0 -432
- package/dist/esm/chunk-A5NZMSTI.js +0 -10
- package/dist/esm/chunk-CGJRRAFS.js +0 -22
- package/dist/esm/chunk-DMJMN4J3.js +0 -379
- package/dist/esm/chunk-E4NRDAVO.js +0 -65
- package/dist/esm/chunk-ETBJVFQP.js +0 -10
- package/dist/esm/chunk-F2LQB2DP.js +0 -3323
- package/dist/esm/chunk-F66EKL3W.js +0 -203
- package/dist/esm/chunk-GV2QOWB4.js +0 -26
- package/dist/esm/chunk-GZJLX2CP.js +0 -2258
- package/dist/esm/chunk-HNU2Y3JI.js +0 -13
- package/dist/esm/chunk-J24LYWJE.js +0 -130
- package/dist/esm/chunk-KZKAL5ZN.js +0 -16
- package/dist/esm/chunk-N4PTRCNT.js +0 -11
- package/dist/esm/chunk-NUHMTWHP.js +0 -180
- package/dist/esm/chunk-OMOVHXSC.js +0 -212
- package/dist/esm/chunk-P36PE4CR.js +0 -37
- package/dist/esm/chunk-PZ2624FK.js +0 -187
- package/dist/esm/chunk-QYXGDTUU.js +0 -47
- package/dist/esm/chunk-R2GHDOWX.js +0 -272
- package/dist/esm/chunk-RTDD7HZ3.js +0 -275
- package/dist/esm/chunk-SXBG57J3.js +0 -20
- package/dist/esm/chunk-TGTOO2ZQ.js +0 -14
- package/dist/esm/chunk-UHCKOKBM.js +0 -9
- package/dist/esm/chunk-ULUX2CVU.js +0 -557
- package/dist/esm/chunk-UN46DUOV.js +0 -11
- package/dist/esm/chunk-XNU3TKKM.js +0 -10
- package/dist/esm/chunk-ZVFYCNA5.js +0 -1492
- package/dist/esm/client-types-Bz-WqtM3.d.ts +0 -114
- package/dist/esm/generateApi-Bi3W_Sti.d.ts +0 -56
- package/dist/esm/index.d.ts +0 -1859
- package/dist/esm/index.js +0 -32
- package/dist/esm/public-functions/executeMultipleRoutes.d.ts +0 -80
- package/dist/esm/public-functions/executeMultipleRoutes.js +0 -18
- package/dist/esm/public-functions/executeRoute.d.ts +0 -12
- package/dist/esm/public-functions/executeRoute.js +0 -18
- package/dist/esm/public-functions/getCosmosGasAmountForMessage.d.ts +0 -8
- package/dist/esm/public-functions/getCosmosGasAmountForMessage.js +0 -3
- package/dist/esm/public-functions/getEvmGasAmountForMessage.d.ts +0 -14
- package/dist/esm/public-functions/getEvmGasAmountForMessage.js +0 -2
- package/dist/esm/public-functions/getFeeInfoForChain.d.ts +0 -9
- package/dist/esm/public-functions/getFeeInfoForChain.js +0 -5
- package/dist/esm/public-functions/getRecommendedGasPrice.d.ts +0 -9
- package/dist/esm/public-functions/getRecommendedGasPrice.js +0 -6
- package/dist/esm/public-functions/getRouteWithGasOnReceive.d.ts +0 -20
- package/dist/esm/public-functions/getRouteWithGasOnReceive.js +0 -32
- package/dist/esm/public-functions/getSigningStargateClient.d.ts +0 -13
- package/dist/esm/public-functions/getSigningStargateClient.js +0 -6
- package/dist/esm/public-functions/setApiOptions.d.ts +0 -9
- package/dist/esm/public-functions/setApiOptions.js +0 -3
- package/dist/esm/public-functions/setClientOptions.d.ts +0 -11
- package/dist/esm/public-functions/setClientOptions.js +0 -7
- package/dist/esm/public-functions/subscribeToRouteStatus.d.ts +0 -12
- package/dist/esm/public-functions/subscribeToRouteStatus.js +0 -5
- package/dist/esm/public-functions/validateCosmosGasBalance.d.ts +0 -44
- package/dist/esm/public-functions/validateCosmosGasBalance.js +0 -9
- package/dist/esm/public-functions/waitForTransaction.d.ts +0 -1279
- package/dist/esm/public-functions/waitForTransaction.js +0 -5
- package/dist/esm/setClientOptions-QO8p3yRr.d.ts +0 -76
- package/dist/esm/swaggerTypes-Cvh0GDv-.d.ts +0 -2050
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
// src/utils/timer.ts
|
|
2
|
-
var wait = (ms) => {
|
|
3
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
// src/utils/convert.ts
|
|
7
|
-
function toSnake(obj) {
|
|
8
|
-
return convertKeys(obj, (key) => key.replace(/([A-Z])/g, "_$1").toLowerCase());
|
|
9
|
-
}
|
|
10
|
-
function toCamel(obj) {
|
|
11
|
-
return convertKeys(obj, (key) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()));
|
|
12
|
-
}
|
|
13
|
-
function convertKeys(obj, convertKey) {
|
|
14
|
-
if (Array.isArray(obj)) {
|
|
15
|
-
return obj.map((item) => convertKeys(item, convertKey));
|
|
16
|
-
} else if (obj !== null && typeof obj === "object") {
|
|
17
|
-
return Object.keys(obj).reduce((acc, key) => {
|
|
18
|
-
acc[convertKey(key)] = convertKeys(obj[key], convertKey);
|
|
19
|
-
return acc;
|
|
20
|
-
}, {});
|
|
21
|
-
} else {
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// src/utils/generateApi.ts
|
|
27
|
-
var createRequestClient = ({ apiUrl, apiKey, apiHeaders }) => {
|
|
28
|
-
if (!apiUrl?.endsWith("/")) {
|
|
29
|
-
apiUrl += "/";
|
|
30
|
-
}
|
|
31
|
-
const headers = new Headers({
|
|
32
|
-
"content-type": "application/json"
|
|
33
|
-
});
|
|
34
|
-
if (apiKey) {
|
|
35
|
-
headers.set("authorization", apiKey);
|
|
36
|
-
}
|
|
37
|
-
if (apiHeaders) {
|
|
38
|
-
new Headers(apiHeaders).forEach((value, key) => {
|
|
39
|
-
headers.set(key, value);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
const handleResponse = async (response) => {
|
|
43
|
-
const contentType = response.headers.get("content-type");
|
|
44
|
-
const isJson = contentType?.includes("application/json");
|
|
45
|
-
const body = isJson ? await response.json() : await response.text();
|
|
46
|
-
if (!response.ok) {
|
|
47
|
-
const message = typeof body === "object" && body?.message ? body.message : response.statusText;
|
|
48
|
-
const error = new Error(message);
|
|
49
|
-
if (body?.code) {
|
|
50
|
-
error.code = body.code;
|
|
51
|
-
}
|
|
52
|
-
if (body?.details) {
|
|
53
|
-
error.details = body.details;
|
|
54
|
-
}
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
return body;
|
|
58
|
-
};
|
|
59
|
-
const get = async (path, params, signal) => {
|
|
60
|
-
if (path?.startsWith("/")) {
|
|
61
|
-
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");
|
|
62
|
-
}
|
|
63
|
-
const url = new URL(path ?? "", apiUrl);
|
|
64
|
-
if (params && typeof params === "object") {
|
|
65
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
66
|
-
if (value !== void 0 && value !== null) {
|
|
67
|
-
if (Array.isArray(value)) {
|
|
68
|
-
value.forEach((item) => {
|
|
69
|
-
url.searchParams.append(key, String(item));
|
|
70
|
-
});
|
|
71
|
-
} else {
|
|
72
|
-
url.searchParams.append(key, String(value));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
const response = await fetch(url.toString(), {
|
|
78
|
-
method: "GET",
|
|
79
|
-
headers,
|
|
80
|
-
signal
|
|
81
|
-
});
|
|
82
|
-
return handleResponse(response);
|
|
83
|
-
};
|
|
84
|
-
const post = async (path, data = {}, signal) => {
|
|
85
|
-
if (path?.startsWith("/")) {
|
|
86
|
-
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");
|
|
87
|
-
}
|
|
88
|
-
const response = await fetch(new URL(path, apiUrl).toString(), {
|
|
89
|
-
method: "POST",
|
|
90
|
-
headers,
|
|
91
|
-
body: JSON.stringify(data),
|
|
92
|
-
signal
|
|
93
|
-
});
|
|
94
|
-
return handleResponse(response);
|
|
95
|
-
};
|
|
96
|
-
return { get, post };
|
|
97
|
-
};
|
|
98
|
-
function createRequest({
|
|
99
|
-
path,
|
|
100
|
-
method = "get",
|
|
101
|
-
onSuccess,
|
|
102
|
-
transformResponse
|
|
103
|
-
}) {
|
|
104
|
-
let controller = null;
|
|
105
|
-
const request = async (options) => {
|
|
106
|
-
const { apiKey, apiUrl, apiHeaders, abortDuplicateRequests, ...requestParams } = options ?? {};
|
|
107
|
-
let fetchClient = ApiState.client;
|
|
108
|
-
if (apiKey || apiUrl || apiHeaders || fetchClient === void 0) {
|
|
109
|
-
fetchClient = createRequestClient({
|
|
110
|
-
apiUrl: apiUrl || "https://api.skip.build",
|
|
111
|
-
apiKey,
|
|
112
|
-
apiHeaders
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
ApiState.apiCalled = true;
|
|
116
|
-
if (abortDuplicateRequests && controller && !controller?.signal?.aborted) {
|
|
117
|
-
controller?.abort();
|
|
118
|
-
}
|
|
119
|
-
controller = new AbortController();
|
|
120
|
-
try {
|
|
121
|
-
const response = await fetchClient[method](
|
|
122
|
-
path,
|
|
123
|
-
requestParams ? toSnake(requestParams) : void 0,
|
|
124
|
-
controller.signal
|
|
125
|
-
);
|
|
126
|
-
const camelCased = toCamel(response ?? {});
|
|
127
|
-
const finalResponse = transformResponse ? transformResponse(camelCased) : camelCased;
|
|
128
|
-
onSuccess?.(finalResponse, requestParams);
|
|
129
|
-
return finalResponse;
|
|
130
|
-
} catch (error) {
|
|
131
|
-
if (error.name === "AbortError") {
|
|
132
|
-
console.log("Request was cancelled");
|
|
133
|
-
} else {
|
|
134
|
-
console.error("Error:", error);
|
|
135
|
-
throw error;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
return request;
|
|
140
|
-
}
|
|
141
|
-
function api({
|
|
142
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
143
|
-
methodName,
|
|
144
|
-
path,
|
|
145
|
-
onSuccess,
|
|
146
|
-
method = "get",
|
|
147
|
-
transformResponse
|
|
148
|
-
}) {
|
|
149
|
-
return createRequest({
|
|
150
|
-
path,
|
|
151
|
-
method,
|
|
152
|
-
onSuccess,
|
|
153
|
-
transformResponse
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
function pollingApi({
|
|
157
|
-
methodName,
|
|
158
|
-
path,
|
|
159
|
-
method = "get",
|
|
160
|
-
onSuccess,
|
|
161
|
-
onError,
|
|
162
|
-
isSuccess = () => true,
|
|
163
|
-
maxRetries = 10,
|
|
164
|
-
retryInterval = 1e3,
|
|
165
|
-
backoffMultiplier = 2,
|
|
166
|
-
throwOnError = false
|
|
167
|
-
}) {
|
|
168
|
-
const request = async (requestParams) => {
|
|
169
|
-
let attempt = 0;
|
|
170
|
-
let lastError;
|
|
171
|
-
while (attempt < maxRetries) {
|
|
172
|
-
try {
|
|
173
|
-
const result = await api({ methodName, path, method })(requestParams);
|
|
174
|
-
if (result && isSuccess(result)) {
|
|
175
|
-
onSuccess?.(result, attempt);
|
|
176
|
-
return result;
|
|
177
|
-
}
|
|
178
|
-
} catch (err) {
|
|
179
|
-
lastError = err;
|
|
180
|
-
onError?.(err, attempt);
|
|
181
|
-
if (throwOnError) {
|
|
182
|
-
throw err;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
const delay = retryInterval * Math.pow(backoffMultiplier, attempt);
|
|
186
|
-
await wait(delay);
|
|
187
|
-
attempt++;
|
|
188
|
-
}
|
|
189
|
-
throw lastError ?? new Error("pollingApi: max retries exceeded");
|
|
190
|
-
};
|
|
191
|
-
return (params) => request(params);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// src/state/apiState.ts
|
|
195
|
-
var ApiState = class {
|
|
196
|
-
static client;
|
|
197
|
-
static chainIdsToAffiliates;
|
|
198
|
-
static cumulativeAffiliateFeeBPS = "0";
|
|
199
|
-
static initialized = false;
|
|
200
|
-
static apiCalled = false;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export { ApiState, api, createRequestClient, pollingApi, toCamel, wait };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { publicActions } from 'viem';
|
|
2
|
-
|
|
3
|
-
// src/public-functions/getEvmGasAmountForMessage.ts
|
|
4
|
-
async function getEVMGasAmountForMessage(signer, tx, getFallbackGasAmount) {
|
|
5
|
-
const { to, data, value } = tx;
|
|
6
|
-
if (!signer.account) throw new Error("estimateGasForEvmTx: No account found");
|
|
7
|
-
const extendedSigner = signer.extend(publicActions);
|
|
8
|
-
const fee = await extendedSigner.estimateFeesPerGas();
|
|
9
|
-
try {
|
|
10
|
-
const gasAmount = await extendedSigner.estimateGas({
|
|
11
|
-
account: signer.account,
|
|
12
|
-
to,
|
|
13
|
-
data: `0x${data}`,
|
|
14
|
-
value: value === "" ? void 0 : BigInt(value ?? "")
|
|
15
|
-
});
|
|
16
|
-
return gasAmount * fee.maxFeePerGas;
|
|
17
|
-
} catch (error) {
|
|
18
|
-
const fallbackGasAmount = await getFallbackGasAmount?.(tx.chainId ?? "", "evm" /* Evm */);
|
|
19
|
-
if (fallbackGasAmount) {
|
|
20
|
-
return BigInt(fallbackGasAmount) * fee.maxFeePerGas;
|
|
21
|
-
}
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { getEVMGasAmountForMessage };
|