@chainrails/react 0.0.10 → 0.0.12
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/PaymentModal/index.d.ts.map +1 -1
- package/dist/chainrails-sdk.es.js +226 -188
- package/dist/chainrails-sdk.es.mjs +226 -188
- package/dist/chainrails-sdk.umd.js +2 -2
- package/package.json +2 -2
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { jsxs as k, jsx as
|
|
3
|
-
import './index.css';function
|
|
1
|
+
import { useState as O, useEffect as J } from "react";
|
|
2
|
+
import { jsxs as k, jsx as b } from "react/jsx-runtime";
|
|
3
|
+
import './index.css';function I(t) {
|
|
4
4
|
var e, s, r = "";
|
|
5
5
|
if (typeof t == "string" || typeof t == "number") r += t;
|
|
6
6
|
else if (typeof t == "object") if (Array.isArray(t)) {
|
|
7
7
|
var n = t.length;
|
|
8
|
-
for (e = 0; e < n; e++) t[e] && (s =
|
|
8
|
+
for (e = 0; e < n; e++) t[e] && (s = I(t[e])) && (r && (r += " "), r += s);
|
|
9
9
|
} else for (s in t) t[s] && (r && (r += " "), r += s);
|
|
10
10
|
return r;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
for (var t, e, s = 0, r = "", n = arguments.length; s < n; s++) (t = arguments[s]) && (e =
|
|
12
|
+
function K() {
|
|
13
|
+
for (var t, e, s = 0, r = "", n = arguments.length; s < n; s++) (t = arguments[s]) && (e = I(t)) && (r && (r += " "), r += e);
|
|
14
14
|
return r;
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class P extends Error {
|
|
17
17
|
response;
|
|
18
18
|
request;
|
|
19
19
|
options;
|
|
@@ -34,7 +34,7 @@ class L extends Error {
|
|
|
34
34
|
super(s), this.value = e;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
class
|
|
37
|
+
class A extends Error {
|
|
38
38
|
name = "ForceRetryError";
|
|
39
39
|
customDelay;
|
|
40
40
|
code;
|
|
@@ -44,7 +44,7 @@ class E extends Error {
|
|
|
44
44
|
super(e?.code ? `Forced retry: ${e.code}` : "Forced retry", s ? { cause: s } : void 0), this.customDelay = e?.delay, this.code = e?.code, this.customRequest = e?.request;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
const
|
|
47
|
+
const v = (() => {
|
|
48
48
|
let t = !1, e = !1;
|
|
49
49
|
const s = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
|
|
50
50
|
if (s && r)
|
|
@@ -63,7 +63,7 @@ const N = (() => {
|
|
|
63
63
|
throw n;
|
|
64
64
|
}
|
|
65
65
|
return t && !e;
|
|
66
|
-
})(),
|
|
66
|
+
})(), V = typeof globalThis.AbortController == "function", M = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", W = typeof globalThis.ReadableStream == "function", G = typeof globalThis.FormData == "function", B = ["get", "post", "put", "patch", "head", "delete"], X = {
|
|
67
67
|
json: "application/json",
|
|
68
68
|
text: "text/*",
|
|
69
69
|
formData: "multipart/form-data",
|
|
@@ -72,14 +72,14 @@ const N = (() => {
|
|
|
72
72
|
// Supported in modern Fetch implementations (for example, browsers and recent Node.js/undici).
|
|
73
73
|
// We still feature-check at runtime before exposing the shortcut.
|
|
74
74
|
bytes: "*/*"
|
|
75
|
-
},
|
|
76
|
-
class
|
|
75
|
+
}, C = 2147483647, Z = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, D = Symbol("stop");
|
|
76
|
+
class H {
|
|
77
77
|
options;
|
|
78
78
|
constructor(e) {
|
|
79
79
|
this.options = e;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
const
|
|
82
|
+
const Y = (t) => new H(t), Q = {
|
|
83
83
|
json: !0,
|
|
84
84
|
parseJson: !0,
|
|
85
85
|
stringifyJson: !0,
|
|
@@ -93,10 +93,10 @@ const Z = (t) => new _(t), Y = {
|
|
|
93
93
|
onUploadProgress: !0,
|
|
94
94
|
fetch: !0,
|
|
95
95
|
context: !0
|
|
96
|
-
},
|
|
96
|
+
}, ee = {
|
|
97
97
|
next: !0
|
|
98
98
|
// Next.js cache revalidation (revalidate, tags)
|
|
99
|
-
},
|
|
99
|
+
}, te = {
|
|
100
100
|
method: !0,
|
|
101
101
|
headers: !0,
|
|
102
102
|
body: !0,
|
|
@@ -111,13 +111,13 @@ const Z = (t) => new _(t), Y = {
|
|
|
111
111
|
signal: !0,
|
|
112
112
|
window: !0,
|
|
113
113
|
duplex: !0
|
|
114
|
-
},
|
|
114
|
+
}, se = (t) => {
|
|
115
115
|
if (!t)
|
|
116
116
|
return 0;
|
|
117
117
|
if (t instanceof FormData) {
|
|
118
118
|
let e = 0;
|
|
119
119
|
for (const [s, r] of t)
|
|
120
|
-
e +=
|
|
120
|
+
e += Z, e += new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length, e += typeof r == "string" ? new TextEncoder().encode(r).length : r.size;
|
|
121
121
|
return e;
|
|
122
122
|
}
|
|
123
123
|
if (t instanceof Blob)
|
|
@@ -138,7 +138,7 @@ const Z = (t) => new _(t), Y = {
|
|
|
138
138
|
return 0;
|
|
139
139
|
}
|
|
140
140
|
return 0;
|
|
141
|
-
},
|
|
141
|
+
}, $ = (t, e, s) => {
|
|
142
142
|
let r, n = 0;
|
|
143
143
|
return t.pipeThrough(new TransformStream({
|
|
144
144
|
transform(o, i) {
|
|
@@ -153,7 +153,7 @@ const Z = (t) => new _(t), Y = {
|
|
|
153
153
|
r && (n += r.byteLength, s?.({ percent: 1, totalBytes: Math.max(e, n), transferredBytes: n }, r));
|
|
154
154
|
}
|
|
155
155
|
}));
|
|
156
|
-
},
|
|
156
|
+
}, re = (t, e) => {
|
|
157
157
|
if (!t.body)
|
|
158
158
|
return t;
|
|
159
159
|
if (t.status === 204)
|
|
@@ -163,40 +163,40 @@ const Z = (t) => new _(t), Y = {
|
|
|
163
163
|
headers: t.headers
|
|
164
164
|
});
|
|
165
165
|
const s = Math.max(0, Number(t.headers.get("content-length")) || 0);
|
|
166
|
-
return new Response(
|
|
166
|
+
return new Response($(t.body, s, e), {
|
|
167
167
|
status: t.status,
|
|
168
168
|
statusText: t.statusText,
|
|
169
169
|
headers: t.headers
|
|
170
170
|
});
|
|
171
|
-
},
|
|
171
|
+
}, ne = (t, e, s) => {
|
|
172
172
|
if (!t.body)
|
|
173
173
|
return t;
|
|
174
|
-
const r =
|
|
174
|
+
const r = se(s ?? t.body);
|
|
175
175
|
return new Request(t, {
|
|
176
176
|
// @ts-expect-error - Types are outdated.
|
|
177
177
|
duplex: "half",
|
|
178
|
-
body:
|
|
178
|
+
body: $(t.body, r, e)
|
|
179
179
|
});
|
|
180
|
-
},
|
|
180
|
+
}, d = (t) => t !== null && typeof t == "object", T = (...t) => {
|
|
181
181
|
for (const e of t)
|
|
182
|
-
if ((!
|
|
182
|
+
if ((!d(e) || Array.isArray(e)) && e !== void 0)
|
|
183
183
|
throw new TypeError("The `options` argument must be an object");
|
|
184
|
-
return
|
|
185
|
-
},
|
|
184
|
+
return N({}, ...t);
|
|
185
|
+
}, _ = (t = {}, e = {}) => {
|
|
186
186
|
const s = new globalThis.Headers(t), r = e instanceof globalThis.Headers, n = new globalThis.Headers(e);
|
|
187
187
|
for (const [o, i] of n.entries())
|
|
188
188
|
r && i === "undefined" || i === void 0 ? s.delete(o) : s.set(o, i);
|
|
189
189
|
return s;
|
|
190
190
|
};
|
|
191
|
-
function
|
|
192
|
-
return Object.hasOwn(e, s) && e[s] === void 0 ? [] :
|
|
191
|
+
function R(t, e, s) {
|
|
192
|
+
return Object.hasOwn(e, s) && e[s] === void 0 ? [] : N(t[s] ?? [], e[s] ?? []);
|
|
193
193
|
}
|
|
194
|
-
const
|
|
195
|
-
beforeRequest:
|
|
196
|
-
beforeRetry:
|
|
197
|
-
afterResponse:
|
|
198
|
-
beforeError:
|
|
199
|
-
}),
|
|
194
|
+
const F = (t = {}, e = {}) => ({
|
|
195
|
+
beforeRequest: R(t, e, "beforeRequest"),
|
|
196
|
+
beforeRetry: R(t, e, "beforeRetry"),
|
|
197
|
+
afterResponse: R(t, e, "afterResponse"),
|
|
198
|
+
beforeError: R(t, e, "beforeError")
|
|
199
|
+
}), oe = (t, e) => {
|
|
200
200
|
const s = new URLSearchParams();
|
|
201
201
|
for (const r of [t, e])
|
|
202
202
|
if (r !== void 0)
|
|
@@ -209,7 +209,7 @@ const $ = (t = {}, e = {}) => ({
|
|
|
209
209
|
throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
|
|
210
210
|
s.append(String(n[0]), String(n[1]));
|
|
211
211
|
}
|
|
212
|
-
else if (
|
|
212
|
+
else if (d(r))
|
|
213
213
|
for (const [n, o] of Object.entries(r))
|
|
214
214
|
o !== void 0 && s.append(n, String(o));
|
|
215
215
|
else {
|
|
@@ -218,20 +218,20 @@ const $ = (t = {}, e = {}) => ({
|
|
|
218
218
|
s.append(o, i);
|
|
219
219
|
}
|
|
220
220
|
return s;
|
|
221
|
-
},
|
|
221
|
+
}, N = (...t) => {
|
|
222
222
|
let e = {}, s = {}, r = {}, n;
|
|
223
223
|
const o = [];
|
|
224
224
|
for (const i of t)
|
|
225
225
|
if (Array.isArray(i))
|
|
226
226
|
Array.isArray(e) || (e = []), e = [...e, ...i];
|
|
227
|
-
else if (
|
|
227
|
+
else if (d(i)) {
|
|
228
228
|
for (let [u, a] of Object.entries(i)) {
|
|
229
229
|
if (u === "signal" && a instanceof globalThis.AbortSignal) {
|
|
230
230
|
o.push(a);
|
|
231
231
|
continue;
|
|
232
232
|
}
|
|
233
233
|
if (u === "context") {
|
|
234
|
-
if (a != null && (!
|
|
234
|
+
if (a != null && (!d(a) || Array.isArray(a)))
|
|
235
235
|
throw new TypeError("The `context` option must be an object");
|
|
236
236
|
e = {
|
|
237
237
|
...e,
|
|
@@ -240,25 +240,25 @@ const $ = (t = {}, e = {}) => ({
|
|
|
240
240
|
continue;
|
|
241
241
|
}
|
|
242
242
|
if (u === "searchParams") {
|
|
243
|
-
a == null ? n = void 0 : n = n === void 0 ? a :
|
|
243
|
+
a == null ? n = void 0 : n = n === void 0 ? a : oe(n, a);
|
|
244
244
|
continue;
|
|
245
245
|
}
|
|
246
|
-
|
|
246
|
+
d(a) && u in e && (a = N(e[u], a)), e = { ...e, [u]: a };
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
d(i.hooks) && (r = F(r, i.hooks), e.hooks = r), d(i.headers) && (s = _(s, i.headers), e.headers = s);
|
|
249
249
|
}
|
|
250
250
|
return n !== void 0 && (e.searchParams = n), o.length > 0 && (o.length === 1 ? e.signal = o[0] : M ? e.signal = AbortSignal.any(o) : e.signal = o.at(-1)), e.context === void 0 && (e.context = {}), e;
|
|
251
|
-
},
|
|
251
|
+
}, ie = (t) => B.includes(t) ? t.toUpperCase() : t, ae = ["get", "put", "head", "delete", "options", "trace"], ue = [408, 413, 429, 500, 502, 503, 504], ce = [413, 429, 503], U = {
|
|
252
252
|
limit: 2,
|
|
253
|
-
methods:
|
|
254
|
-
statusCodes:
|
|
255
|
-
afterStatusCodes:
|
|
253
|
+
methods: ae,
|
|
254
|
+
statusCodes: ue,
|
|
255
|
+
afterStatusCodes: ce,
|
|
256
256
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
257
257
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
258
258
|
delay: (t) => 0.3 * 2 ** (t - 1) * 1e3,
|
|
259
259
|
jitter: void 0,
|
|
260
260
|
retryOnTimeout: !1
|
|
261
|
-
},
|
|
261
|
+
}, le = (t = {}) => {
|
|
262
262
|
if (typeof t == "number")
|
|
263
263
|
return {
|
|
264
264
|
...U,
|
|
@@ -273,23 +273,23 @@ const $ = (t = {}, e = {}) => ({
|
|
|
273
273
|
...t
|
|
274
274
|
};
|
|
275
275
|
};
|
|
276
|
-
class
|
|
276
|
+
class x extends Error {
|
|
277
277
|
request;
|
|
278
278
|
constructor(e) {
|
|
279
279
|
super(`Request timed out: ${e.method} ${e.url}`), this.name = "TimeoutError", this.request = e;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
async function
|
|
282
|
+
async function he(t, e, s, r) {
|
|
283
283
|
return new Promise((n, o) => {
|
|
284
284
|
const i = setTimeout(() => {
|
|
285
|
-
s && s.abort(), o(new
|
|
285
|
+
s && s.abort(), o(new x(t));
|
|
286
286
|
}, r.timeout);
|
|
287
287
|
r.fetch(t, e).then(n).catch(o).then(() => {
|
|
288
288
|
clearTimeout(i);
|
|
289
289
|
});
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
-
async function
|
|
292
|
+
async function fe(t, { signal: e }) {
|
|
293
293
|
return new Promise((s, r) => {
|
|
294
294
|
e && (e.throwIfAborted(), e.addEventListener("abort", n, { once: !0 }));
|
|
295
295
|
function n() {
|
|
@@ -300,35 +300,35 @@ async function he(t, { signal: e }) {
|
|
|
300
300
|
}, t);
|
|
301
301
|
});
|
|
302
302
|
}
|
|
303
|
-
const
|
|
303
|
+
const de = (t, e) => {
|
|
304
304
|
const s = {};
|
|
305
305
|
for (const r in e)
|
|
306
|
-
Object.hasOwn(e, r) && !(r in
|
|
306
|
+
Object.hasOwn(e, r) && !(r in te) && !(r in Q) && (!(r in t) || r in ee) && (s[r] = e[r]);
|
|
307
307
|
return s;
|
|
308
|
-
},
|
|
309
|
-
function
|
|
310
|
-
return t instanceof
|
|
308
|
+
}, pe = (t) => t === void 0 ? !1 : Array.isArray(t) ? t.length > 0 : t instanceof URLSearchParams ? t.size > 0 : typeof t == "object" ? Object.keys(t).length > 0 : typeof t == "string" ? t.trim().length > 0 : !!t;
|
|
309
|
+
function ye(t) {
|
|
310
|
+
return t instanceof P || t?.name === P.name;
|
|
311
311
|
}
|
|
312
|
-
function
|
|
313
|
-
return t instanceof
|
|
312
|
+
function me(t) {
|
|
313
|
+
return t instanceof x || t?.name === x.name;
|
|
314
314
|
}
|
|
315
|
-
class
|
|
315
|
+
class m {
|
|
316
316
|
static create(e, s) {
|
|
317
|
-
const r = new
|
|
318
|
-
if (typeof r.#e.timeout == "number" && r.#e.timeout >
|
|
319
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${
|
|
317
|
+
const r = new m(e, s), n = async () => {
|
|
318
|
+
if (typeof r.#e.timeout == "number" && r.#e.timeout > C)
|
|
319
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${C}`);
|
|
320
320
|
await Promise.resolve();
|
|
321
321
|
let i = await r.#y();
|
|
322
322
|
for (const u of r.#e.hooks.afterResponse) {
|
|
323
|
-
const a = r.#
|
|
324
|
-
if (h instanceof globalThis.Response && (i = h), h instanceof
|
|
323
|
+
const a = r.#l(i.clone()), h = await u(r.request, r.#a(), a, { retryCount: r.#s });
|
|
324
|
+
if (h instanceof globalThis.Response && (i = h), h instanceof H)
|
|
325
325
|
throw await Promise.all([
|
|
326
326
|
a.body?.cancel(),
|
|
327
327
|
i.body?.cancel()
|
|
328
|
-
]), new
|
|
328
|
+
]), new A(h.options);
|
|
329
329
|
}
|
|
330
|
-
if (r.#
|
|
331
|
-
let u = new
|
|
330
|
+
if (r.#l(i), !i.ok && (typeof r.#e.throwHttpErrors == "function" ? r.#e.throwHttpErrors(i.status) : r.#e.throwHttpErrors)) {
|
|
331
|
+
let u = new P(i, r.request, r.#a());
|
|
332
332
|
for (const a of r.#e.hooks.beforeError)
|
|
333
333
|
u = await a(u, { retryCount: r.#s });
|
|
334
334
|
throw u;
|
|
@@ -336,16 +336,16 @@ class p {
|
|
|
336
336
|
if (r.#e.onDownloadProgress) {
|
|
337
337
|
if (typeof r.#e.onDownloadProgress != "function")
|
|
338
338
|
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
339
|
-
if (!
|
|
339
|
+
if (!W)
|
|
340
340
|
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
341
|
-
return
|
|
341
|
+
return re(i.clone(), r.#e.onDownloadProgress);
|
|
342
342
|
}
|
|
343
343
|
return i;
|
|
344
|
-
}, o = r.#
|
|
344
|
+
}, o = r.#h(n).finally(async () => {
|
|
345
345
|
const i = r.#o, u = [];
|
|
346
346
|
i && !i.bodyUsed && u.push(i.body?.cancel()), r.request.bodyUsed || u.push(r.request.body?.cancel()), await Promise.all(u);
|
|
347
347
|
});
|
|
348
|
-
for (const [i, u] of Object.entries(
|
|
348
|
+
for (const [i, u] of Object.entries(X))
|
|
349
349
|
i === "bytes" && typeof globalThis.Response?.prototype?.bytes != "function" || (o[i] = async () => {
|
|
350
350
|
r.request.headers.set("accept", r.request.headers.get("accept") || u);
|
|
351
351
|
const a = await o;
|
|
@@ -376,17 +376,17 @@ class p {
|
|
|
376
376
|
constructor(e, s = {}) {
|
|
377
377
|
if (this.#t = e, this.#e = {
|
|
378
378
|
...s,
|
|
379
|
-
headers:
|
|
380
|
-
hooks:
|
|
379
|
+
headers: _(this.#t.headers, s.headers),
|
|
380
|
+
hooks: F({
|
|
381
381
|
beforeRequest: [],
|
|
382
382
|
beforeRetry: [],
|
|
383
383
|
beforeError: [],
|
|
384
384
|
afterResponse: []
|
|
385
385
|
}, s.hooks),
|
|
386
|
-
method:
|
|
386
|
+
method: ie(s.method ?? this.#t.method ?? "GET"),
|
|
387
387
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
388
388
|
prefixUrl: String(s.prefixUrl || ""),
|
|
389
|
-
retry:
|
|
389
|
+
retry: le(s.retry),
|
|
390
390
|
throwHttpErrors: s.throwHttpErrors ?? !0,
|
|
391
391
|
timeout: s.timeout ?? 1e4,
|
|
392
392
|
fetch: s.fetch ?? globalThis.fetch.bind(globalThis),
|
|
@@ -398,16 +398,16 @@ class p {
|
|
|
398
398
|
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
399
399
|
this.#e.prefixUrl.endsWith("/") || (this.#e.prefixUrl += "/"), this.#t = this.#e.prefixUrl + this.#t;
|
|
400
400
|
}
|
|
401
|
-
|
|
401
|
+
V && M && (this.#n = this.#e.signal ?? this.#t.signal, this.#r = new globalThis.AbortController(), this.#e.signal = this.#n ? AbortSignal.any([this.#n, this.#r.signal]) : this.#r.signal), v && (this.#e.duplex = "half"), this.#e.json !== void 0 && (this.#e.body = this.#e.stringifyJson?.(this.#e.json) ?? JSON.stringify(this.#e.json), this.#e.headers.set("content-type", this.#e.headers.get("content-type") ?? "application/json"));
|
|
402
402
|
const r = s.headers && new globalThis.Headers(s.headers).has("content-type");
|
|
403
|
-
if (this.#t instanceof globalThis.Request && (
|
|
404
|
-
const o = "?" + (typeof this.#e.searchParams == "string" ? this.#e.searchParams.replace(/^\?/, "") : new URLSearchParams(
|
|
403
|
+
if (this.#t instanceof globalThis.Request && (G && this.#e.body instanceof globalThis.FormData || this.#e.body instanceof URLSearchParams) && !r && this.#e.headers.delete("content-type"), this.request = new globalThis.Request(this.#t, this.#e), pe(this.#e.searchParams)) {
|
|
404
|
+
const o = "?" + (typeof this.#e.searchParams == "string" ? this.#e.searchParams.replace(/^\?/, "") : new URLSearchParams(m.#d(this.#e.searchParams)).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, o);
|
|
405
405
|
this.request = new globalThis.Request(i, this.#e);
|
|
406
406
|
}
|
|
407
407
|
if (this.#e.onUploadProgress) {
|
|
408
408
|
if (typeof this.#e.onUploadProgress != "function")
|
|
409
409
|
throw new TypeError("The `onUploadProgress` option must be a function");
|
|
410
|
-
if (!
|
|
410
|
+
if (!v)
|
|
411
411
|
throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
|
|
412
412
|
this.request = this.#f(this.request, this.#e.body ?? void 0);
|
|
413
413
|
}
|
|
@@ -421,7 +421,7 @@ class p {
|
|
|
421
421
|
if (this.#s++, this.#s > this.#e.retry.limit)
|
|
422
422
|
throw e;
|
|
423
423
|
const s = e instanceof Error ? e : new L(e);
|
|
424
|
-
if (s instanceof
|
|
424
|
+
if (s instanceof A)
|
|
425
425
|
return s.customDelay ?? this.#u();
|
|
426
426
|
if (!this.#e.retry.methods.includes(this.request.method.toLowerCase()))
|
|
427
427
|
throw e;
|
|
@@ -432,9 +432,9 @@ class p {
|
|
|
432
432
|
if (r === !0)
|
|
433
433
|
return this.#u();
|
|
434
434
|
}
|
|
435
|
-
if (
|
|
435
|
+
if (me(e) && !this.#e.retry.retryOnTimeout)
|
|
436
436
|
throw e;
|
|
437
|
-
if (
|
|
437
|
+
if (ye(e)) {
|
|
438
438
|
if (!this.#e.retry.statusCodes.includes(e.response.status))
|
|
439
439
|
throw e;
|
|
440
440
|
const r = e.response.headers.get("Retry-After") ?? e.response.headers.get("RateLimit-Reset") ?? e.response.headers.get("X-RateLimit-Retry-After") ?? e.response.headers.get("X-RateLimit-Reset") ?? e.response.headers.get("X-Rate-Limit-Reset");
|
|
@@ -449,17 +449,17 @@ class p {
|
|
|
449
449
|
}
|
|
450
450
|
return this.#u();
|
|
451
451
|
}
|
|
452
|
-
#
|
|
452
|
+
#l(e) {
|
|
453
453
|
return this.#e.parseJson && (e.json = async () => this.#e.parseJson(await e.text())), e;
|
|
454
454
|
}
|
|
455
|
-
async #
|
|
455
|
+
async #h(e) {
|
|
456
456
|
try {
|
|
457
457
|
return await e();
|
|
458
458
|
} catch (s) {
|
|
459
|
-
const r = Math.min(await this.#p(s),
|
|
459
|
+
const r = Math.min(await this.#p(s), C);
|
|
460
460
|
if (this.#s < 1)
|
|
461
461
|
throw s;
|
|
462
|
-
if (await
|
|
462
|
+
if (await fe(r, this.#n ? { signal: this.#n } : {}), s instanceof A && s.customRequest) {
|
|
463
463
|
const n = this.#e.signal ? new globalThis.Request(s.customRequest, { signal: this.#e.signal }) : new globalThis.Request(s.customRequest);
|
|
464
464
|
this.#c(n);
|
|
465
465
|
}
|
|
@@ -476,10 +476,10 @@ class p {
|
|
|
476
476
|
}
|
|
477
477
|
if (o instanceof globalThis.Response)
|
|
478
478
|
return o;
|
|
479
|
-
if (o ===
|
|
479
|
+
if (o === D)
|
|
480
480
|
return;
|
|
481
481
|
}
|
|
482
|
-
return this.#
|
|
482
|
+
return this.#h(e);
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
485
|
async #y() {
|
|
@@ -493,8 +493,8 @@ class p {
|
|
|
493
493
|
break;
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
const e =
|
|
497
|
-
return this.#o = this.request, this.request = this.#o.clone(), this.#e.timeout === !1 ? this.#e.fetch(this.#o, e) :
|
|
496
|
+
const e = de(this.request, this.#e);
|
|
497
|
+
return this.#o = this.request, this.request = this.#o.clone(), this.#e.timeout === !1 ? this.#e.fetch(this.#o, e) : he(this.#o, e, this.#r, this.#e);
|
|
498
498
|
}
|
|
499
499
|
#a() {
|
|
500
500
|
if (!this.#i) {
|
|
@@ -507,118 +507,151 @@ class p {
|
|
|
507
507
|
this.#i = void 0, this.request = this.#f(e);
|
|
508
508
|
}
|
|
509
509
|
#f(e, s) {
|
|
510
|
-
return !this.#e.onUploadProgress || !e.body ? e :
|
|
510
|
+
return !this.#e.onUploadProgress || !e.body ? e : ne(e, this.#e.onUploadProgress, s ?? this.#e.body ?? void 0);
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
/*! MIT License © Sindre Sorhus */
|
|
514
|
-
const
|
|
515
|
-
const e = (s, r) =>
|
|
516
|
-
for (const s of
|
|
517
|
-
e[s] = (r, n) =>
|
|
518
|
-
return e.create = (s) =>
|
|
519
|
-
},
|
|
520
|
-
var
|
|
521
|
-
class
|
|
522
|
-
constructor({ api_key: e }) {
|
|
523
|
-
this.api_key = e;
|
|
514
|
+
const q = (t) => {
|
|
515
|
+
const e = (s, r) => m.create(s, T(t, r));
|
|
516
|
+
for (const s of B)
|
|
517
|
+
e[s] = (r, n) => m.create(r, T(t, n, { method: s }));
|
|
518
|
+
return e.create = (s) => q(T(s)), e.extend = (s) => (typeof s == "function" && (s = s(t ?? {})), q(T(t, s))), e.stop = D, e.retry = Y, e;
|
|
519
|
+
}, ge = q();
|
|
520
|
+
var we = /* @__PURE__ */ ((t) => (t.ARBITRUM = "ARBITRUM_MAINNET", t.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", t.AVALANCHE = "AVALANCHE_MAINNET", t.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", t.BASE = "BASE_MAINNET", t.BASE_TESTNET = "BASE_TESTNET", t.BSC = "BSC_MAINNET", t.ETHEREUM = "ETHEREUM_MAINNET", t.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", t.STARKNET = "STARKNET_MAINNET", t))(we || {}), be = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(be || {}), z = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(z || {});
|
|
521
|
+
class c {
|
|
522
|
+
constructor({ api_key: e, env: s }) {
|
|
523
|
+
this.api_key = e, this.env = s ?? z.PRODUCTION;
|
|
524
524
|
}
|
|
525
525
|
static config(e) {
|
|
526
|
-
if (!
|
|
526
|
+
if (!c.app) {
|
|
527
527
|
if (!e)
|
|
528
528
|
throw new Error("Please provide an api_key");
|
|
529
|
-
|
|
529
|
+
c.app = new c(e);
|
|
530
530
|
}
|
|
531
|
-
return e && (
|
|
531
|
+
return e && (c.app.api_key = e.api_key, e.env !== void 0 && (c.app.env = e.env)), c.app;
|
|
532
532
|
}
|
|
533
533
|
static getApiKey() {
|
|
534
|
-
|
|
534
|
+
if (!c.app)
|
|
535
|
+
throw new Error(
|
|
536
|
+
"Chainrails SDK not configured. Please call Chainrails.config() first."
|
|
537
|
+
);
|
|
538
|
+
return c.app.api_key;
|
|
539
|
+
}
|
|
540
|
+
static getEnv() {
|
|
541
|
+
if (!c.app)
|
|
542
|
+
throw new Error(
|
|
543
|
+
"Chainrails SDK not configured. Please call Chainrails.config() first."
|
|
544
|
+
);
|
|
545
|
+
return c.app.env;
|
|
546
|
+
}
|
|
547
|
+
static getBaseUrl() {
|
|
548
|
+
if (!c.app)
|
|
549
|
+
throw new Error(
|
|
550
|
+
"Chainrails SDK not configured. Please call Chainrails.config() first."
|
|
551
|
+
);
|
|
552
|
+
switch (c.app.env) {
|
|
553
|
+
case "production":
|
|
554
|
+
return "https://api.chainrails.io/api/v1";
|
|
555
|
+
case "staging":
|
|
556
|
+
return "https://dev.chainrails.io/api/v1";
|
|
557
|
+
default:
|
|
558
|
+
return "https://api.chainrails.io/api/v1";
|
|
559
|
+
}
|
|
535
560
|
}
|
|
536
561
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
t
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
562
|
+
let j = null;
|
|
563
|
+
function Te() {
|
|
564
|
+
j = ge.create({
|
|
565
|
+
prefixUrl: c.getBaseUrl(),
|
|
566
|
+
headers: {
|
|
567
|
+
"Content-Type": "application/json"
|
|
568
|
+
},
|
|
569
|
+
hooks: {
|
|
570
|
+
beforeRequest: [
|
|
571
|
+
(t) => {
|
|
572
|
+
const e = c.getApiKey();
|
|
573
|
+
t.headers.set("Authorization", `Bearer ${e}`);
|
|
574
|
+
}
|
|
575
|
+
],
|
|
576
|
+
afterResponse: [(t, e, s) => s]
|
|
577
|
+
},
|
|
578
|
+
retry: {
|
|
579
|
+
limit: 2
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
function l() {
|
|
584
|
+
return j || Te(), j;
|
|
585
|
+
}
|
|
586
|
+
class Re {
|
|
556
587
|
async getById(e) {
|
|
557
|
-
return await
|
|
588
|
+
return await l().get("intents/" + e).json();
|
|
558
589
|
}
|
|
559
590
|
async getForSender(e) {
|
|
560
|
-
return await
|
|
591
|
+
return await l().get("intents/user/" + e).json();
|
|
561
592
|
}
|
|
562
593
|
async getForAddress(e) {
|
|
563
|
-
return await
|
|
594
|
+
return await l().get("intents/address/" + e).json();
|
|
564
595
|
}
|
|
565
596
|
async getAll(e) {
|
|
566
|
-
return await
|
|
597
|
+
return await l().get("intents", { searchParams: e }).json();
|
|
567
598
|
}
|
|
568
599
|
async create(e) {
|
|
569
|
-
return await
|
|
600
|
+
return await l().post("intents", { json: e }).json();
|
|
570
601
|
}
|
|
571
602
|
async update(e, s) {
|
|
572
|
-
return await
|
|
603
|
+
return await l().post("intents", { json: s }).json();
|
|
604
|
+
}
|
|
605
|
+
async triggerProcessing(e) {
|
|
606
|
+
return await l().post(`intents/${e}/trigger-processing`).json();
|
|
573
607
|
}
|
|
574
|
-
//Calculate Destination
|
|
575
608
|
}
|
|
576
|
-
class
|
|
609
|
+
class Ee {
|
|
577
610
|
async getFromSpecificBridge(e) {
|
|
578
|
-
return await
|
|
611
|
+
return await l().get("quotes/single", { searchParams: e }).json();
|
|
579
612
|
}
|
|
580
613
|
async getFromAllBridges(e) {
|
|
581
|
-
return await
|
|
614
|
+
return await l().get("quotes/multiple", { searchParams: e }).json();
|
|
582
615
|
}
|
|
583
616
|
async getBestAcrossBridges(e) {
|
|
584
|
-
return await
|
|
617
|
+
return await l().get("quotes/best", { searchParams: e }).json();
|
|
585
618
|
}
|
|
586
619
|
async getAll(e) {
|
|
587
|
-
return await
|
|
620
|
+
return await l().get("quotes/multi-source", { searchParams: e }).json();
|
|
588
621
|
}
|
|
589
622
|
}
|
|
590
|
-
class
|
|
623
|
+
class Se {
|
|
591
624
|
async getOptimalRoutes(e) {
|
|
592
|
-
return await
|
|
625
|
+
return await l().get("router/optimal-route", { searchParams: e }).json();
|
|
593
626
|
}
|
|
594
627
|
async getAllSupportedBridges() {
|
|
595
|
-
return await
|
|
628
|
+
return await l().get("router/supported-bridges/all").json();
|
|
596
629
|
}
|
|
597
630
|
async getSupportedBridges(e) {
|
|
598
|
-
return await
|
|
631
|
+
return await l().get("router/supported-bridges/route", { searchParams: e }).json();
|
|
599
632
|
}
|
|
600
633
|
async getSupportedRoutes(e, s) {
|
|
601
|
-
return await
|
|
634
|
+
return await l().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
|
|
602
635
|
}
|
|
603
636
|
}
|
|
604
|
-
class
|
|
637
|
+
class Ae {
|
|
605
638
|
async getSupported(e) {
|
|
606
|
-
return await
|
|
639
|
+
return await l().get("chains", { searchParams: e }).json();
|
|
607
640
|
}
|
|
608
641
|
}
|
|
609
|
-
class
|
|
642
|
+
class Ce {
|
|
610
643
|
async getClientInfo() {
|
|
611
|
-
return await
|
|
644
|
+
return await l().get("client/auth/client-info").json();
|
|
612
645
|
}
|
|
613
646
|
}
|
|
614
|
-
const
|
|
615
|
-
router: new
|
|
616
|
-
quotes: new
|
|
617
|
-
intents: new
|
|
618
|
-
chains: new
|
|
619
|
-
client: new
|
|
647
|
+
const qe = {
|
|
648
|
+
router: new Se(),
|
|
649
|
+
quotes: new Ee(),
|
|
650
|
+
intents: new Re(),
|
|
651
|
+
chains: new Ae(),
|
|
652
|
+
client: new Ce()
|
|
620
653
|
};
|
|
621
|
-
function
|
|
654
|
+
function je(t) {
|
|
622
655
|
const {
|
|
623
656
|
to: e,
|
|
624
657
|
token: s,
|
|
@@ -629,22 +662,22 @@ function xe(t) {
|
|
|
629
662
|
complete: u,
|
|
630
663
|
cancel: a,
|
|
631
664
|
chainSelected: h,
|
|
632
|
-
intentCreated:
|
|
633
|
-
...
|
|
634
|
-
} = t, [
|
|
635
|
-
return
|
|
636
|
-
const
|
|
637
|
-
o ? document.body.style.overflow = "hidden" : document.body.style.overflow =
|
|
638
|
-
const
|
|
639
|
-
|
|
665
|
+
intentCreated: g,
|
|
666
|
+
...E
|
|
667
|
+
} = t, [y, S] = O(!0);
|
|
668
|
+
return J(() => {
|
|
669
|
+
const w = document.body.style.overflow;
|
|
670
|
+
o ? document.body.style.overflow = "hidden" : document.body.style.overflow = w || "";
|
|
671
|
+
const p = (f) => {
|
|
672
|
+
f.data === "closed" && a(), f.data === "completed" && u(), f.data === "chainSelected" && h(), f.data === "intentCreated" && g();
|
|
640
673
|
};
|
|
641
|
-
return window.addEventListener("message",
|
|
642
|
-
document.body.style.overflow =
|
|
674
|
+
return window.addEventListener("message", p), () => {
|
|
675
|
+
document.body.style.overflow = w || "", window.removeEventListener("message", p);
|
|
643
676
|
};
|
|
644
|
-
}, [o, a, u, h,
|
|
645
|
-
...
|
|
646
|
-
className:
|
|
647
|
-
children: [
|
|
677
|
+
}, [o, a, u, h, g]), /* @__PURE__ */ k("div", {
|
|
678
|
+
...E,
|
|
679
|
+
className: K("payment-modal-wrapper", y ? "loading" : "not-loading", o ? "open" : "closed"),
|
|
680
|
+
children: [y && /* @__PURE__ */ b("div", {
|
|
648
681
|
role: "status",
|
|
649
682
|
className: "payment-modal-loader",
|
|
650
683
|
children: /* @__PURE__ */ k("svg", {
|
|
@@ -653,66 +686,71 @@ function xe(t) {
|
|
|
653
686
|
viewBox: "0 0 100 101",
|
|
654
687
|
fill: "none",
|
|
655
688
|
xmlns: "http://www.w3.org/2000/svg",
|
|
656
|
-
children: [/* @__PURE__ */
|
|
689
|
+
children: [/* @__PURE__ */ b("path", {
|
|
657
690
|
d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",
|
|
658
691
|
fill: "currentColor"
|
|
659
|
-
}), /* @__PURE__ */
|
|
692
|
+
}), /* @__PURE__ */ b("path", {
|
|
660
693
|
d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",
|
|
661
694
|
fill: "currentFill"
|
|
662
695
|
})]
|
|
663
696
|
})
|
|
664
|
-
}), /* @__PURE__ */
|
|
697
|
+
}), /* @__PURE__ */ b("iframe", {
|
|
665
698
|
allow: "clipboard-read *; clipboard-write *",
|
|
666
|
-
src:
|
|
699
|
+
src: (() => {
|
|
700
|
+
const w = `https://app.chainrails.io/pay/_chain_/${encodeURIComponent(r)}/_token_/${encodeURIComponent(s)}/_to_/${encodeURIComponent(e)}/_amount_/${n * 100}`, p = new URLSearchParams();
|
|
701
|
+
p.append("id", c.getApiKey());
|
|
702
|
+
const f = c.getEnv();
|
|
703
|
+
return f !== "production" && p.append("env", f), `${w}?${p.toString()}`;
|
|
704
|
+
})(),
|
|
667
705
|
onLoad: () => {
|
|
668
|
-
|
|
706
|
+
S(!1);
|
|
669
707
|
},
|
|
670
|
-
className: `payment-modal ${
|
|
708
|
+
className: `payment-modal ${y ? "invisible" : "visible"}`
|
|
671
709
|
})]
|
|
672
710
|
});
|
|
673
711
|
}
|
|
674
|
-
function
|
|
712
|
+
function Ne(t) {
|
|
675
713
|
const {
|
|
676
714
|
onCancel: e,
|
|
677
715
|
onSuccess: s,
|
|
678
716
|
onChainSelect: r,
|
|
679
717
|
onIntentCreate: n,
|
|
680
718
|
...o
|
|
681
|
-
} = t, [i, u] =
|
|
719
|
+
} = t, [i, u] = O(!1);
|
|
682
720
|
function a() {
|
|
683
721
|
u(!0);
|
|
684
722
|
}
|
|
685
723
|
function h() {
|
|
686
724
|
u(!1);
|
|
687
725
|
}
|
|
688
|
-
function
|
|
726
|
+
function g() {
|
|
689
727
|
h(), e?.();
|
|
690
728
|
}
|
|
691
|
-
function
|
|
729
|
+
function E() {
|
|
692
730
|
window.setTimeout(h, 2e3), s?.();
|
|
693
731
|
}
|
|
694
|
-
function
|
|
732
|
+
function y() {
|
|
695
733
|
r?.();
|
|
696
734
|
}
|
|
697
|
-
function
|
|
735
|
+
function S() {
|
|
698
736
|
n?.();
|
|
699
737
|
}
|
|
700
738
|
return {
|
|
701
739
|
open: a,
|
|
702
740
|
close: h,
|
|
703
|
-
complete:
|
|
704
|
-
cancel:
|
|
705
|
-
chainSelected:
|
|
706
|
-
intentCreated:
|
|
741
|
+
complete: E,
|
|
742
|
+
cancel: g,
|
|
743
|
+
chainSelected: y,
|
|
744
|
+
intentCreated: S,
|
|
707
745
|
isOpen: i,
|
|
708
746
|
...o
|
|
709
747
|
};
|
|
710
748
|
}
|
|
711
749
|
export {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
750
|
+
c as Chainrails,
|
|
751
|
+
je as PaymentModal,
|
|
752
|
+
we as chains,
|
|
753
|
+
qe as crapi,
|
|
754
|
+
be as tokens,
|
|
755
|
+
Ne as usePaymentModal
|
|
718
756
|
};
|