@seedprotocol/arweave 0.7.6-next.949.g73caafc → 0.7.6
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/gateway/transactionStatus.d.ts +21 -0
- package/dist/gateway/transactionStatus.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -480
- package/dist/index.js.map +1 -1
- package/dist/node/ArweaveClient.d.ts.map +1 -1
- package/dist/node.js +25 -43
- package/dist/node.js.map +1 -1
- package/dist/transactionStatus-BpYIaQyY.js +1021 -0
- package/dist/transactionStatus-BpYIaQyY.js.map +1 -0
- package/package.json +1 -1
- package/dist/queries-t-LwBKFl.js +0 -581
- package/dist/queries-t-LwBKFl.js.map +0 -1
|
@@ -0,0 +1,1021 @@
|
|
|
1
|
+
import "graphql-request";
|
|
2
|
+
//#region src/constants.ts
|
|
3
|
+
var e = "ar.seedprotocol.io", t = "", n = "", r = "127.0.0.1", i = 1984, a = `https://${e}/graphql`, o = [
|
|
4
|
+
"ar.seedprotocol.io",
|
|
5
|
+
"arweave.net",
|
|
6
|
+
"arweave.dev",
|
|
7
|
+
"g8way.io",
|
|
8
|
+
"permagate.io",
|
|
9
|
+
"zigza.xyz"
|
|
10
|
+
], s = ["ARWEAVE_READ_GATEWAYS", "NEXT_PUBLIC_ARWEAVE_READ_GATEWAYS"], ee = [
|
|
11
|
+
"NEXT_PUBLIC_ARWEAVE_HOST",
|
|
12
|
+
"ARWEAVE_HOST",
|
|
13
|
+
"VITE_ARWEAVE_HOST"
|
|
14
|
+
];
|
|
15
|
+
function te(e) {
|
|
16
|
+
let t = e.trim();
|
|
17
|
+
return t.startsWith("http://") ? t.slice(7).replace(/\/$/, "") : t.startsWith("https://") ? t.slice(8).replace(/\/$/, "") : t.replace(/\/$/, "");
|
|
18
|
+
}
|
|
19
|
+
function ne() {
|
|
20
|
+
if (typeof process < "u" && process.env) for (let e of ee) {
|
|
21
|
+
let t = process.env[e]?.trim();
|
|
22
|
+
if (t) return te(t);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function re(t, n) {
|
|
26
|
+
let r = t.trim().toLowerCase().replace(/\/$/, ""), i = e.toLowerCase();
|
|
27
|
+
return r === i ? [...n] : n.filter((e) => e.toLowerCase() !== i);
|
|
28
|
+
}
|
|
29
|
+
function c(e) {
|
|
30
|
+
return u(e, re(e, l()));
|
|
31
|
+
}
|
|
32
|
+
function l() {
|
|
33
|
+
if (typeof process > "u" || !process.env) return [...o];
|
|
34
|
+
for (let e of s) {
|
|
35
|
+
let t = process.env[e]?.trim();
|
|
36
|
+
if (t) return t.split(",").map((e) => e.trim()).filter(Boolean);
|
|
37
|
+
}
|
|
38
|
+
return [...o];
|
|
39
|
+
}
|
|
40
|
+
function u(e, t) {
|
|
41
|
+
let n = /* @__PURE__ */ new Set(), r = [], i = (e) => e.trim().toLowerCase().replace(/\/$/, ""), a = (e) => {
|
|
42
|
+
let t = e.trim().replace(/\/$/, "");
|
|
43
|
+
if (!t) return;
|
|
44
|
+
let a = i(t);
|
|
45
|
+
n.has(a) || (n.add(a), r.push(t));
|
|
46
|
+
};
|
|
47
|
+
a(e);
|
|
48
|
+
for (let e of t) a(e);
|
|
49
|
+
return r;
|
|
50
|
+
}
|
|
51
|
+
function ie(e) {
|
|
52
|
+
let t = e.trim().toLowerCase();
|
|
53
|
+
if (!t) return !1;
|
|
54
|
+
if (t.endsWith("arweave.net") || t.endsWith("ar-io.net")) return !0;
|
|
55
|
+
for (let e of o) {
|
|
56
|
+
let n = e.toLowerCase();
|
|
57
|
+
if (t === n || t.endsWith(`.${n}`)) return !0;
|
|
58
|
+
}
|
|
59
|
+
return !1;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/content/arweaveContent.ts
|
|
63
|
+
var d;
|
|
64
|
+
function ae(e) {
|
|
65
|
+
d = e;
|
|
66
|
+
}
|
|
67
|
+
function f() {
|
|
68
|
+
return d !== void 0;
|
|
69
|
+
}
|
|
70
|
+
async function p(e, t) {
|
|
71
|
+
return d ? d(e, t) : e;
|
|
72
|
+
}
|
|
73
|
+
function m(e) {
|
|
74
|
+
return (e.headers?.get("content-type"))?.split(";")[0]?.trim().toLowerCase() || void 0;
|
|
75
|
+
}
|
|
76
|
+
async function oe(e, t) {
|
|
77
|
+
return p({
|
|
78
|
+
bytes: new Uint8Array(await e.arrayBuffer()),
|
|
79
|
+
contentType: m(e)
|
|
80
|
+
}, t);
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/moduleOwner.ts
|
|
84
|
+
var h = Symbol.for("@seedprotocol/arweave:clientOwner"), g = Object.freeze({ package: "@seedprotocol/arweave" });
|
|
85
|
+
function se() {
|
|
86
|
+
globalThis[h] = g;
|
|
87
|
+
}
|
|
88
|
+
var ce = class extends Error {
|
|
89
|
+
constructor() {
|
|
90
|
+
super("Two copies of @seedprotocol/arweave are loaded, and the Arweave client was registered on the other copy (e.g. by SeedClient). Reads through this copy would use a different client and gateway. Make sure every @seedprotocol/* package is the same version and installed once (`npm ls @seedprotocol/arweave`). With Vite, keep @seedprotocol/* packages out of optimizeDeps.exclude so they are pre-bundled together, and dedupe them (seedVitePlugin does) when they are linked into the app."), this.name = "DuplicateArweaveModuleError";
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function le() {
|
|
94
|
+
let e = globalThis[h];
|
|
95
|
+
if (e !== void 0 && e !== g) throw new ce();
|
|
96
|
+
}
|
|
97
|
+
function ue() {
|
|
98
|
+
delete globalThis[h];
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/ArweaveClient/BaseArweaveClient.ts
|
|
102
|
+
function _(e) {
|
|
103
|
+
let t = e.trim();
|
|
104
|
+
return t.startsWith("http://") ? {
|
|
105
|
+
protocol: "http",
|
|
106
|
+
host: t.slice(7).replace(/\/$/, "")
|
|
107
|
+
} : t.startsWith("https://") ? {
|
|
108
|
+
protocol: "https",
|
|
109
|
+
host: t.slice(8).replace(/\/$/, "")
|
|
110
|
+
} : {
|
|
111
|
+
protocol: "https",
|
|
112
|
+
host: t.replace(/\/$/, "")
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
var v = e, y = "https", b = !1, x = !1, S = class e {
|
|
116
|
+
static _impl = null;
|
|
117
|
+
static configure(t) {
|
|
118
|
+
if (!t) throw Error("Cannot configure ArweaveClient with undefined or null. Ensure the platform-specific ArweaveClient is properly created.");
|
|
119
|
+
e._impl = t, se();
|
|
120
|
+
}
|
|
121
|
+
static isConfigured() {
|
|
122
|
+
return e._impl != null;
|
|
123
|
+
}
|
|
124
|
+
static requireImpl() {
|
|
125
|
+
if (!e._impl) throw Error("ArweaveClient not configured. Import from @seedprotocol/arweave/node to register the Node.js implementation, or ensure SDK platform init has run.");
|
|
126
|
+
return e._impl;
|
|
127
|
+
}
|
|
128
|
+
static resolveGateway() {
|
|
129
|
+
let e = ne();
|
|
130
|
+
return e && !b && !x ? _(e) : {
|
|
131
|
+
protocol: y,
|
|
132
|
+
host: v
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
static getHost() {
|
|
136
|
+
return this.resolveGateway().host;
|
|
137
|
+
}
|
|
138
|
+
static getArweaveSdkHost() {
|
|
139
|
+
let e = this.getHost(), t = e.indexOf("/");
|
|
140
|
+
return t === -1 ? e : e.slice(0, t);
|
|
141
|
+
}
|
|
142
|
+
static getArweaveJsApiConfig() {
|
|
143
|
+
let e = this.getProtocol(), t = e === "https" ? 443 : 80;
|
|
144
|
+
try {
|
|
145
|
+
let n = new URL(`${e}://${this.getArweaveSdkHost()}`);
|
|
146
|
+
return {
|
|
147
|
+
host: n.hostname,
|
|
148
|
+
port: n.port ? Number(n.port) : t,
|
|
149
|
+
protocol: e
|
|
150
|
+
};
|
|
151
|
+
} catch {
|
|
152
|
+
return {
|
|
153
|
+
host: this.getArweaveSdkHost(),
|
|
154
|
+
port: t,
|
|
155
|
+
protocol: e
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
static getGatewayPath() {
|
|
160
|
+
let e = this.getHost(), t = e.indexOf("/");
|
|
161
|
+
return t === -1 ? "" : e.slice(t).replace(/\/$/, "") || "";
|
|
162
|
+
}
|
|
163
|
+
static getProtocol() {
|
|
164
|
+
return this.resolveGateway().protocol;
|
|
165
|
+
}
|
|
166
|
+
static getBaseUrl() {
|
|
167
|
+
let { protocol: e, host: t } = this.resolveGateway();
|
|
168
|
+
return `${e}://${t}`;
|
|
169
|
+
}
|
|
170
|
+
static setHost(e) {
|
|
171
|
+
let t = _(e);
|
|
172
|
+
v = t.host, y = t.protocol, b = !0, x = !1;
|
|
173
|
+
}
|
|
174
|
+
static isReadGatewayLocked() {
|
|
175
|
+
return b;
|
|
176
|
+
}
|
|
177
|
+
static resetReadGatewaySelectionStateForTests() {
|
|
178
|
+
x = !1;
|
|
179
|
+
}
|
|
180
|
+
static setPreferredReadGateway(e) {
|
|
181
|
+
let t = _(e);
|
|
182
|
+
v = t.host, y = t.protocol, b = !1;
|
|
183
|
+
}
|
|
184
|
+
static applyProbedReadGateway(e) {
|
|
185
|
+
let t = _(e);
|
|
186
|
+
v = t.host, y = t.protocol, b = !1, x = !0;
|
|
187
|
+
}
|
|
188
|
+
static getEndpoint() {
|
|
189
|
+
return `${this.getBaseUrl()}/graphql`;
|
|
190
|
+
}
|
|
191
|
+
static getRawUrl(e) {
|
|
192
|
+
return `${this.getBaseUrl()}/raw/${e}`;
|
|
193
|
+
}
|
|
194
|
+
static getStatusUrl(e) {
|
|
195
|
+
return `${this.getBaseUrl()}/${e}`;
|
|
196
|
+
}
|
|
197
|
+
static getArweaveClient() {
|
|
198
|
+
return e.requireImpl().getArweaveClient();
|
|
199
|
+
}
|
|
200
|
+
static getTransactionStatus(t) {
|
|
201
|
+
return e.requireImpl().getTransactionStatus(t);
|
|
202
|
+
}
|
|
203
|
+
static async getTransactionData(t, n) {
|
|
204
|
+
let r = await e.requireImpl().getTransactionData(t, n);
|
|
205
|
+
if (n?.decode === !1 || !f()) return r;
|
|
206
|
+
let i = typeof r == "string", { bytes: a } = await p({ bytes: i ? new TextEncoder().encode(r) : r }, { transactionId: t });
|
|
207
|
+
return i ? new TextDecoder().decode(a) : a;
|
|
208
|
+
}
|
|
209
|
+
static getTransactionTags(t) {
|
|
210
|
+
return e.requireImpl().getTransactionTags(t);
|
|
211
|
+
}
|
|
212
|
+
static createTransaction(t, n) {
|
|
213
|
+
return e.requireImpl().createTransaction(t, n);
|
|
214
|
+
}
|
|
215
|
+
static downloadFiles(t) {
|
|
216
|
+
return e.requireImpl().downloadFiles(t);
|
|
217
|
+
}
|
|
218
|
+
}, de = {
|
|
219
|
+
"\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n": {
|
|
220
|
+
kind: "Document",
|
|
221
|
+
definitions: [{
|
|
222
|
+
kind: "OperationDefinition",
|
|
223
|
+
operation: "query",
|
|
224
|
+
name: {
|
|
225
|
+
kind: "Name",
|
|
226
|
+
value: "GetTransactionTags"
|
|
227
|
+
},
|
|
228
|
+
variableDefinitions: [{
|
|
229
|
+
kind: "VariableDefinition",
|
|
230
|
+
variable: {
|
|
231
|
+
kind: "Variable",
|
|
232
|
+
name: {
|
|
233
|
+
kind: "Name",
|
|
234
|
+
value: "transactionId"
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
type: {
|
|
238
|
+
kind: "NonNullType",
|
|
239
|
+
type: {
|
|
240
|
+
kind: "NamedType",
|
|
241
|
+
name: {
|
|
242
|
+
kind: "Name",
|
|
243
|
+
value: "ID"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}],
|
|
248
|
+
selectionSet: {
|
|
249
|
+
kind: "SelectionSet",
|
|
250
|
+
selections: [{
|
|
251
|
+
kind: "Field",
|
|
252
|
+
alias: {
|
|
253
|
+
kind: "Name",
|
|
254
|
+
value: "tags"
|
|
255
|
+
},
|
|
256
|
+
name: {
|
|
257
|
+
kind: "Name",
|
|
258
|
+
value: "transaction"
|
|
259
|
+
},
|
|
260
|
+
arguments: [{
|
|
261
|
+
kind: "Argument",
|
|
262
|
+
name: {
|
|
263
|
+
kind: "Name",
|
|
264
|
+
value: "id"
|
|
265
|
+
},
|
|
266
|
+
value: {
|
|
267
|
+
kind: "Variable",
|
|
268
|
+
name: {
|
|
269
|
+
kind: "Name",
|
|
270
|
+
value: "transactionId"
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}],
|
|
274
|
+
selectionSet: {
|
|
275
|
+
kind: "SelectionSet",
|
|
276
|
+
selections: [{
|
|
277
|
+
kind: "Field",
|
|
278
|
+
name: {
|
|
279
|
+
kind: "Name",
|
|
280
|
+
value: "id"
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
kind: "Field",
|
|
284
|
+
name: {
|
|
285
|
+
kind: "Name",
|
|
286
|
+
value: "tags"
|
|
287
|
+
},
|
|
288
|
+
selectionSet: {
|
|
289
|
+
kind: "SelectionSet",
|
|
290
|
+
selections: [{
|
|
291
|
+
kind: "Field",
|
|
292
|
+
name: {
|
|
293
|
+
kind: "Name",
|
|
294
|
+
value: "name"
|
|
295
|
+
}
|
|
296
|
+
}, {
|
|
297
|
+
kind: "Field",
|
|
298
|
+
name: {
|
|
299
|
+
kind: "Name",
|
|
300
|
+
value: "value"
|
|
301
|
+
}
|
|
302
|
+
}]
|
|
303
|
+
}
|
|
304
|
+
}]
|
|
305
|
+
}
|
|
306
|
+
}]
|
|
307
|
+
}
|
|
308
|
+
}]
|
|
309
|
+
},
|
|
310
|
+
"\n query GetArweaveTransactions(\n $owners: [String!]\n $first: Int\n $after: String\n ) {\n transactions(owners: $owners, first: $first, after: $after) {\n edges {\n cursor\n node {\n id\n anchor\n signature\n block {\n id\n height\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n": {
|
|
311
|
+
kind: "Document",
|
|
312
|
+
definitions: [{
|
|
313
|
+
kind: "OperationDefinition",
|
|
314
|
+
operation: "query",
|
|
315
|
+
name: {
|
|
316
|
+
kind: "Name",
|
|
317
|
+
value: "GetArweaveTransactions"
|
|
318
|
+
},
|
|
319
|
+
variableDefinitions: [
|
|
320
|
+
{
|
|
321
|
+
kind: "VariableDefinition",
|
|
322
|
+
variable: {
|
|
323
|
+
kind: "Variable",
|
|
324
|
+
name: {
|
|
325
|
+
kind: "Name",
|
|
326
|
+
value: "owners"
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
type: {
|
|
330
|
+
kind: "ListType",
|
|
331
|
+
type: {
|
|
332
|
+
kind: "NonNullType",
|
|
333
|
+
type: {
|
|
334
|
+
kind: "NamedType",
|
|
335
|
+
name: {
|
|
336
|
+
kind: "Name",
|
|
337
|
+
value: "String"
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
kind: "VariableDefinition",
|
|
345
|
+
variable: {
|
|
346
|
+
kind: "Variable",
|
|
347
|
+
name: {
|
|
348
|
+
kind: "Name",
|
|
349
|
+
value: "first"
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
type: {
|
|
353
|
+
kind: "NamedType",
|
|
354
|
+
name: {
|
|
355
|
+
kind: "Name",
|
|
356
|
+
value: "Int"
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
kind: "VariableDefinition",
|
|
362
|
+
variable: {
|
|
363
|
+
kind: "Variable",
|
|
364
|
+
name: {
|
|
365
|
+
kind: "Name",
|
|
366
|
+
value: "after"
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
type: {
|
|
370
|
+
kind: "NamedType",
|
|
371
|
+
name: {
|
|
372
|
+
kind: "Name",
|
|
373
|
+
value: "String"
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
],
|
|
378
|
+
selectionSet: {
|
|
379
|
+
kind: "SelectionSet",
|
|
380
|
+
selections: [{
|
|
381
|
+
kind: "Field",
|
|
382
|
+
name: {
|
|
383
|
+
kind: "Name",
|
|
384
|
+
value: "transactions"
|
|
385
|
+
},
|
|
386
|
+
arguments: [
|
|
387
|
+
{
|
|
388
|
+
kind: "Argument",
|
|
389
|
+
name: {
|
|
390
|
+
kind: "Name",
|
|
391
|
+
value: "owners"
|
|
392
|
+
},
|
|
393
|
+
value: {
|
|
394
|
+
kind: "Variable",
|
|
395
|
+
name: {
|
|
396
|
+
kind: "Name",
|
|
397
|
+
value: "owners"
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
kind: "Argument",
|
|
403
|
+
name: {
|
|
404
|
+
kind: "Name",
|
|
405
|
+
value: "first"
|
|
406
|
+
},
|
|
407
|
+
value: {
|
|
408
|
+
kind: "Variable",
|
|
409
|
+
name: {
|
|
410
|
+
kind: "Name",
|
|
411
|
+
value: "first"
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
kind: "Argument",
|
|
417
|
+
name: {
|
|
418
|
+
kind: "Name",
|
|
419
|
+
value: "after"
|
|
420
|
+
},
|
|
421
|
+
value: {
|
|
422
|
+
kind: "Variable",
|
|
423
|
+
name: {
|
|
424
|
+
kind: "Name",
|
|
425
|
+
value: "after"
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
],
|
|
430
|
+
selectionSet: {
|
|
431
|
+
kind: "SelectionSet",
|
|
432
|
+
selections: [{
|
|
433
|
+
kind: "Field",
|
|
434
|
+
name: {
|
|
435
|
+
kind: "Name",
|
|
436
|
+
value: "edges"
|
|
437
|
+
},
|
|
438
|
+
selectionSet: {
|
|
439
|
+
kind: "SelectionSet",
|
|
440
|
+
selections: [{
|
|
441
|
+
kind: "Field",
|
|
442
|
+
name: {
|
|
443
|
+
kind: "Name",
|
|
444
|
+
value: "cursor"
|
|
445
|
+
}
|
|
446
|
+
}, {
|
|
447
|
+
kind: "Field",
|
|
448
|
+
name: {
|
|
449
|
+
kind: "Name",
|
|
450
|
+
value: "node"
|
|
451
|
+
},
|
|
452
|
+
selectionSet: {
|
|
453
|
+
kind: "SelectionSet",
|
|
454
|
+
selections: [
|
|
455
|
+
{
|
|
456
|
+
kind: "Field",
|
|
457
|
+
name: {
|
|
458
|
+
kind: "Name",
|
|
459
|
+
value: "id"
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
kind: "Field",
|
|
464
|
+
name: {
|
|
465
|
+
kind: "Name",
|
|
466
|
+
value: "anchor"
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
kind: "Field",
|
|
471
|
+
name: {
|
|
472
|
+
kind: "Name",
|
|
473
|
+
value: "signature"
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
kind: "Field",
|
|
478
|
+
name: {
|
|
479
|
+
kind: "Name",
|
|
480
|
+
value: "block"
|
|
481
|
+
},
|
|
482
|
+
selectionSet: {
|
|
483
|
+
kind: "SelectionSet",
|
|
484
|
+
selections: [{
|
|
485
|
+
kind: "Field",
|
|
486
|
+
name: {
|
|
487
|
+
kind: "Name",
|
|
488
|
+
value: "id"
|
|
489
|
+
}
|
|
490
|
+
}, {
|
|
491
|
+
kind: "Field",
|
|
492
|
+
name: {
|
|
493
|
+
kind: "Name",
|
|
494
|
+
value: "height"
|
|
495
|
+
}
|
|
496
|
+
}]
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
kind: "Field",
|
|
501
|
+
name: {
|
|
502
|
+
kind: "Name",
|
|
503
|
+
value: "data"
|
|
504
|
+
},
|
|
505
|
+
selectionSet: {
|
|
506
|
+
kind: "SelectionSet",
|
|
507
|
+
selections: [{
|
|
508
|
+
kind: "Field",
|
|
509
|
+
name: {
|
|
510
|
+
kind: "Name",
|
|
511
|
+
value: "size"
|
|
512
|
+
}
|
|
513
|
+
}, {
|
|
514
|
+
kind: "Field",
|
|
515
|
+
name: {
|
|
516
|
+
kind: "Name",
|
|
517
|
+
value: "type"
|
|
518
|
+
}
|
|
519
|
+
}]
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
kind: "Field",
|
|
524
|
+
name: {
|
|
525
|
+
kind: "Name",
|
|
526
|
+
value: "tags"
|
|
527
|
+
},
|
|
528
|
+
selectionSet: {
|
|
529
|
+
kind: "SelectionSet",
|
|
530
|
+
selections: [{
|
|
531
|
+
kind: "Field",
|
|
532
|
+
name: {
|
|
533
|
+
kind: "Name",
|
|
534
|
+
value: "name"
|
|
535
|
+
}
|
|
536
|
+
}, {
|
|
537
|
+
kind: "Field",
|
|
538
|
+
name: {
|
|
539
|
+
kind: "Name",
|
|
540
|
+
value: "value"
|
|
541
|
+
}
|
|
542
|
+
}]
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
]
|
|
546
|
+
}
|
|
547
|
+
}]
|
|
548
|
+
}
|
|
549
|
+
}, {
|
|
550
|
+
kind: "Field",
|
|
551
|
+
name: {
|
|
552
|
+
kind: "Name",
|
|
553
|
+
value: "pageInfo"
|
|
554
|
+
},
|
|
555
|
+
selectionSet: {
|
|
556
|
+
kind: "SelectionSet",
|
|
557
|
+
selections: [{
|
|
558
|
+
kind: "Field",
|
|
559
|
+
name: {
|
|
560
|
+
kind: "Name",
|
|
561
|
+
value: "hasNextPage"
|
|
562
|
+
}
|
|
563
|
+
}]
|
|
564
|
+
}
|
|
565
|
+
}]
|
|
566
|
+
}
|
|
567
|
+
}]
|
|
568
|
+
}
|
|
569
|
+
}]
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
function C(e) {
|
|
573
|
+
return de[e] ?? {};
|
|
574
|
+
}
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region src/ArweaveClient/queries.ts
|
|
577
|
+
var fe = C("\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n"), pe = C("\n query GetArweaveTransactions(\n $owners: [String!]\n $first: Int\n $after: String\n ) {\n transactions(owners: $owners, first: $first, after: $after) {\n edges {\n cursor\n node {\n id\n anchor\n signature\n block {\n id\n height\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n"), w = 1, T = 6e4, E = w, D = T, O = /* @__PURE__ */ new Map();
|
|
578
|
+
function k(e) {
|
|
579
|
+
let t = e.trim();
|
|
580
|
+
return t ? (t.startsWith("http://") ? t = t.slice(7) : t.startsWith("https://") && (t = t.slice(8)), t.replace(/\/$/, "").toLowerCase()) : "";
|
|
581
|
+
}
|
|
582
|
+
function me(e) {
|
|
583
|
+
let t = O.get(e);
|
|
584
|
+
return t || (t = {
|
|
585
|
+
failures: 0,
|
|
586
|
+
openedAt: null,
|
|
587
|
+
halfOpenProbeInFlight: !1
|
|
588
|
+
}, O.set(e, t)), t;
|
|
589
|
+
}
|
|
590
|
+
function A(e, t) {
|
|
591
|
+
return e.openedAt == null ? "closed" : t - e.openedAt >= D ? "half-open" : "open";
|
|
592
|
+
}
|
|
593
|
+
function he(e) {
|
|
594
|
+
e.failureThreshold != null && e.failureThreshold >= 1 && (E = e.failureThreshold), e.openDurationMs != null && e.openDurationMs >= 0 && (D = e.openDurationMs);
|
|
595
|
+
}
|
|
596
|
+
function ge() {
|
|
597
|
+
O.clear(), E = w, D = T;
|
|
598
|
+
}
|
|
599
|
+
function j(e, t = Date.now()) {
|
|
600
|
+
let n = k(e);
|
|
601
|
+
if (!n) return !1;
|
|
602
|
+
let r = O.get(n);
|
|
603
|
+
if (!r) return !1;
|
|
604
|
+
let i = A(r, t);
|
|
605
|
+
return !!(i === "open" || i === "half-open" && r.halfOpenProbeInFlight);
|
|
606
|
+
}
|
|
607
|
+
function _e(e, t = Date.now()) {
|
|
608
|
+
let n = k(e);
|
|
609
|
+
if (!n) return "closed";
|
|
610
|
+
let r = O.get(n);
|
|
611
|
+
return r ? A(r, t) : "closed";
|
|
612
|
+
}
|
|
613
|
+
function ve(e, t = Date.now()) {
|
|
614
|
+
let n = k(e);
|
|
615
|
+
if (!n) return;
|
|
616
|
+
let r = me(n);
|
|
617
|
+
A(r, t) === "half-open" && (r.halfOpenProbeInFlight = !0);
|
|
618
|
+
}
|
|
619
|
+
function M(e) {
|
|
620
|
+
let t = k(e);
|
|
621
|
+
t && O.set(t, {
|
|
622
|
+
failures: 0,
|
|
623
|
+
openedAt: null,
|
|
624
|
+
halfOpenProbeInFlight: !1
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
function N(e, t = Date.now()) {
|
|
628
|
+
let n = k(e);
|
|
629
|
+
if (!n) return;
|
|
630
|
+
let r = me(n);
|
|
631
|
+
r.failures += 1, r.halfOpenProbeInFlight = !1, r.failures >= E && (r.openedAt = t);
|
|
632
|
+
}
|
|
633
|
+
function ye(e = Date.now()) {
|
|
634
|
+
let t = [];
|
|
635
|
+
for (let n of O.keys()) j(n, e) && t.push(n);
|
|
636
|
+
return t;
|
|
637
|
+
}
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/ArweaveClient/selectReadGateway.ts
|
|
640
|
+
var P = 18e4, be = 6e4, xe = 5e3, F = null, I = null, L = null;
|
|
641
|
+
function R() {
|
|
642
|
+
F = null, I = null;
|
|
643
|
+
}
|
|
644
|
+
function Se() {
|
|
645
|
+
R(), L = null, ge(), S.resetReadGatewaySelectionStateForTests(), S.isReadGatewayLocked() || S.setPreferredReadGateway(e);
|
|
646
|
+
}
|
|
647
|
+
function Ce() {
|
|
648
|
+
return S.isReadGatewayLocked() ? !0 : F && Date.now() < F.expiresAt ? F.healthy : L != null;
|
|
649
|
+
}
|
|
650
|
+
function we() {
|
|
651
|
+
return L;
|
|
652
|
+
}
|
|
653
|
+
async function z(e, t) {
|
|
654
|
+
let n = `${e.replace(/\/$/, "")}/info`, r = e;
|
|
655
|
+
try {
|
|
656
|
+
r = new URL(e.includes("://") ? e : `https://${e}`).host;
|
|
657
|
+
} catch {
|
|
658
|
+
r = e.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
659
|
+
}
|
|
660
|
+
if (j(r)) return !1;
|
|
661
|
+
ve(r);
|
|
662
|
+
let i, a = new AbortController(), o = t ?? a.signal;
|
|
663
|
+
t || (i = setTimeout(() => a.abort(), xe));
|
|
664
|
+
try {
|
|
665
|
+
let e = await fetch(n, {
|
|
666
|
+
method: "GET",
|
|
667
|
+
signal: o,
|
|
668
|
+
headers: { Accept: "application/json" }
|
|
669
|
+
});
|
|
670
|
+
if (!e.ok) return N(r), !1;
|
|
671
|
+
let t = await e.text();
|
|
672
|
+
if (!t.trim()) return N(r), !1;
|
|
673
|
+
try {
|
|
674
|
+
let e = JSON.parse(t), n = typeof e == "object" && !!e;
|
|
675
|
+
return n ? M(r) : N(r), n;
|
|
676
|
+
} catch {
|
|
677
|
+
return N(r), !1;
|
|
678
|
+
}
|
|
679
|
+
} catch {
|
|
680
|
+
return N(r), !1;
|
|
681
|
+
} finally {
|
|
682
|
+
i && clearTimeout(i);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
async function B(e, t = "https", n) {
|
|
686
|
+
for (let r of e) {
|
|
687
|
+
let e = r.trim().replace(/\/$/, "");
|
|
688
|
+
if (e && !j(e) && await z(`${t}://${e}`, n)) return e;
|
|
689
|
+
}
|
|
690
|
+
return null;
|
|
691
|
+
}
|
|
692
|
+
function Te() {
|
|
693
|
+
return c(S.getHost());
|
|
694
|
+
}
|
|
695
|
+
async function V(e) {
|
|
696
|
+
if (S.isReadGatewayLocked()) return S.getHost();
|
|
697
|
+
if (F && Date.now() < F.expiresAt) return F.host;
|
|
698
|
+
if (I) return I;
|
|
699
|
+
I = (async () => {
|
|
700
|
+
let t = await B(Te(), S.getProtocol(), e);
|
|
701
|
+
if (S.isReadGatewayLocked()) F = {
|
|
702
|
+
host: S.getHost(),
|
|
703
|
+
healthy: !0,
|
|
704
|
+
expiresAt: Date.now() + P
|
|
705
|
+
};
|
|
706
|
+
else if (t) S.applyProbedReadGateway(t), L = t, F = {
|
|
707
|
+
host: t,
|
|
708
|
+
healthy: !0,
|
|
709
|
+
expiresAt: Date.now() + P
|
|
710
|
+
};
|
|
711
|
+
else {
|
|
712
|
+
let e = L ?? S.getHost();
|
|
713
|
+
L && S.getHost() !== L && S.applyProbedReadGateway(L), F = {
|
|
714
|
+
host: e,
|
|
715
|
+
healthy: !1,
|
|
716
|
+
expiresAt: Date.now() + be
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
return F.host;
|
|
720
|
+
})();
|
|
721
|
+
try {
|
|
722
|
+
return await I;
|
|
723
|
+
} finally {
|
|
724
|
+
I = null;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/gateway/resolveSeedGatewayEndpoints.ts
|
|
729
|
+
var H = 18e4, U = null, W = /* @__PURE__ */ new Map();
|
|
730
|
+
function G() {
|
|
731
|
+
U = null, W.clear();
|
|
732
|
+
}
|
|
733
|
+
function Ee(e) {
|
|
734
|
+
let t = (e ?? "ar.seedprotocol.io").trim();
|
|
735
|
+
return t.startsWith("http://") ? {
|
|
736
|
+
protocol: "http",
|
|
737
|
+
host: t.slice(7).replace(/\/$/, "")
|
|
738
|
+
} : t.startsWith("https://") ? {
|
|
739
|
+
protocol: "https",
|
|
740
|
+
host: t.slice(8).replace(/\/$/, "")
|
|
741
|
+
} : {
|
|
742
|
+
protocol: "https",
|
|
743
|
+
host: t.replace(/\/$/, "")
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
function K(e) {
|
|
747
|
+
let t = e.hyper?.localSidecarHost?.trim() || "127.0.0.1", n = e.hyper?.localSidecarPort ?? 1984;
|
|
748
|
+
return {
|
|
749
|
+
host: n === 80 || n === 443 ? t : `${t}:${n}`,
|
|
750
|
+
port: n,
|
|
751
|
+
baseUrl: `http://${t}:${n}`
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
function De() {
|
|
755
|
+
try {
|
|
756
|
+
let e = globalThis.window?.location?.origin;
|
|
757
|
+
return typeof e == "string" && e.length > 0 ? e.replace(/\/$/, "") : void 0;
|
|
758
|
+
} catch {
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
function q(e, t) {
|
|
763
|
+
let n = e.trim();
|
|
764
|
+
if (!n) throw Error("proxyBaseUrl is empty");
|
|
765
|
+
if (n.startsWith("http://") || n.startsWith("https://")) return n.replace(/\/$/, "");
|
|
766
|
+
if (n.startsWith("/")) {
|
|
767
|
+
let r = (t?.origin?.trim() || De() || "").replace(/\/$/, "");
|
|
768
|
+
if (!r) throw Error(`Relative proxyBaseUrl "${e}" requires a browser origin or resolve options.origin`);
|
|
769
|
+
return `${r}${n.replace(/\/$/, "")}`;
|
|
770
|
+
}
|
|
771
|
+
return `https://${n.replace(/\/$/, "")}`;
|
|
772
|
+
}
|
|
773
|
+
async function J(e, t, n) {
|
|
774
|
+
let r = Date.now();
|
|
775
|
+
if (t === "sidecar") {
|
|
776
|
+
if (U && r < U.expiresAt) return U.healthy;
|
|
777
|
+
let t = await z(e, n);
|
|
778
|
+
return U = {
|
|
779
|
+
healthy: t,
|
|
780
|
+
expiresAt: r + H
|
|
781
|
+
}, t;
|
|
782
|
+
}
|
|
783
|
+
let i = W.get(t);
|
|
784
|
+
if (i && r < i.expiresAt) return i.healthy;
|
|
785
|
+
let a = await z(e, n);
|
|
786
|
+
return W.set(t, {
|
|
787
|
+
healthy: a,
|
|
788
|
+
expiresAt: r + H
|
|
789
|
+
}), a;
|
|
790
|
+
}
|
|
791
|
+
function Oe(e) {
|
|
792
|
+
let { host: t, protocol: n } = Ee(e.arweaveDomain), r = `${n}://${t}`, i = e.uploadApiBaseUrl?.trim() || r;
|
|
793
|
+
return {
|
|
794
|
+
mode: e.transport ?? "http-gateway",
|
|
795
|
+
arweaveHost: t,
|
|
796
|
+
arweaveProtocol: n,
|
|
797
|
+
arweaveBaseUrl: r,
|
|
798
|
+
arweaveGraphqlUrl: `${n}://${t}/graphql`,
|
|
799
|
+
uploadApiBaseUrl: i,
|
|
800
|
+
activePath: "http",
|
|
801
|
+
gatewayHyperKey: e.hyper?.gatewayHyperKey?.trim() || void 0
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
function Y(e) {
|
|
805
|
+
let t = K(e), n = e.hyper?.gatewayHyperKey?.trim();
|
|
806
|
+
return {
|
|
807
|
+
mode: "hyper",
|
|
808
|
+
arweaveHost: t.host,
|
|
809
|
+
arweaveProtocol: "http",
|
|
810
|
+
arweaveBaseUrl: t.baseUrl,
|
|
811
|
+
arweaveGraphqlUrl: `${t.baseUrl}/graphql`,
|
|
812
|
+
uploadApiBaseUrl: t.baseUrl,
|
|
813
|
+
activePath: "hyper-sidecar",
|
|
814
|
+
gatewayHyperKey: n || void 0
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
function ke(e, t) {
|
|
818
|
+
let n = new URL(t), r = n.protocol === "http:" ? "http" : "https", i = n.pathname.replace(/\/$/, ""), a = i ? `${n.host}${i}` : n.host, o = `${r}://${a}`;
|
|
819
|
+
return {
|
|
820
|
+
mode: e.transport ?? "http-gateway",
|
|
821
|
+
arweaveHost: a,
|
|
822
|
+
arweaveProtocol: r,
|
|
823
|
+
arweaveBaseUrl: o,
|
|
824
|
+
arweaveGraphqlUrl: `${o}/graphql`,
|
|
825
|
+
uploadApiBaseUrl: o,
|
|
826
|
+
activePath: "http-proxy",
|
|
827
|
+
gatewayHyperKey: e.hyper?.gatewayHyperKey?.trim() || void 0,
|
|
828
|
+
proxyBaseUrl: t
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
async function Ae(e, t) {
|
|
832
|
+
let n = e.proxyBaseUrl?.trim();
|
|
833
|
+
if (!n) return null;
|
|
834
|
+
let r = q(n, { origin: t?.origin });
|
|
835
|
+
return e.hyper?.probeSidecar !== !1 && !await J(r, `proxy:${r}`, t?.signal) ? null : ke(e, r);
|
|
836
|
+
}
|
|
837
|
+
async function je(e, t) {
|
|
838
|
+
t?.forceSidecarProbe && G();
|
|
839
|
+
let n = e.transport ?? "http-gateway", r = e.hyper?.probeSidecar !== !1;
|
|
840
|
+
if (n === "http-gateway") {
|
|
841
|
+
if (e.proxyBaseUrl?.trim()) {
|
|
842
|
+
let i = q(e.proxyBaseUrl, { origin: t?.origin });
|
|
843
|
+
if (r && !await J(i, `proxy:${i}`, t?.signal)) throw Error(`Gateway HTTP proxy not reachable at ${i}. Ensure your Node route runs createGatewayProxy (or equivalent) and mounts at proxyBaseUrl.`);
|
|
844
|
+
return ke({
|
|
845
|
+
...e,
|
|
846
|
+
transport: n
|
|
847
|
+
}, i);
|
|
848
|
+
}
|
|
849
|
+
return Oe({
|
|
850
|
+
...e,
|
|
851
|
+
transport: n
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
if (n === "hyper") {
|
|
855
|
+
let i = await Ae({
|
|
856
|
+
...e,
|
|
857
|
+
transport: n
|
|
858
|
+
}, t);
|
|
859
|
+
if (i) return i;
|
|
860
|
+
let a = Y({
|
|
861
|
+
...e,
|
|
862
|
+
transport: n
|
|
863
|
+
});
|
|
864
|
+
if (r && !await J(a.arweaveBaseUrl, "sidecar", t?.signal)) throw Error(`Gateway Hyper sidecar not reachable at ${a.arweaveBaseUrl}. Run: seed-gateway connect <operator-z32-key> — or configure gateway.proxyBaseUrl for an app-server proxy.`);
|
|
865
|
+
return a;
|
|
866
|
+
}
|
|
867
|
+
let i = await Ae({
|
|
868
|
+
...e,
|
|
869
|
+
transport: n
|
|
870
|
+
}, t);
|
|
871
|
+
if (i) return i;
|
|
872
|
+
let a = K(e);
|
|
873
|
+
return r && await J(a.baseUrl, "sidecar", t?.signal) ? Y({
|
|
874
|
+
...e,
|
|
875
|
+
transport: "hyper"
|
|
876
|
+
}) : {
|
|
877
|
+
...Oe({
|
|
878
|
+
...e,
|
|
879
|
+
transport: "http-gateway"
|
|
880
|
+
}),
|
|
881
|
+
mode: "hybrid",
|
|
882
|
+
activePath: "hybrid-fallback-http"
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
function Me(e, t) {
|
|
886
|
+
return e.activePath === "hyper-sidecar" || e.activePath === "http-proxy" ? [e.arweaveHost] : c(e.arweaveHost);
|
|
887
|
+
}
|
|
888
|
+
//#endregion
|
|
889
|
+
//#region src/gateway/gatewayState.ts
|
|
890
|
+
var Ne = null;
|
|
891
|
+
function X() {
|
|
892
|
+
return Ne;
|
|
893
|
+
}
|
|
894
|
+
function Pe(e) {
|
|
895
|
+
Ne = e;
|
|
896
|
+
}
|
|
897
|
+
var Fe = [];
|
|
898
|
+
function Z() {
|
|
899
|
+
return Fe;
|
|
900
|
+
}
|
|
901
|
+
function Ie(e) {
|
|
902
|
+
let t = [], n = /* @__PURE__ */ new Set();
|
|
903
|
+
for (let r of e) {
|
|
904
|
+
let e = r?.trim();
|
|
905
|
+
if (!e) continue;
|
|
906
|
+
let i;
|
|
907
|
+
try {
|
|
908
|
+
let t = new URL(/^https?:\/\//i.test(e) ? e : q(e));
|
|
909
|
+
i = `${t.origin}${t.pathname.replace(/\/+$/, "")}`;
|
|
910
|
+
} catch {
|
|
911
|
+
continue;
|
|
912
|
+
}
|
|
913
|
+
n.has(i) || (n.add(i), t.push(i));
|
|
914
|
+
}
|
|
915
|
+
Fe = t;
|
|
916
|
+
}
|
|
917
|
+
//#endregion
|
|
918
|
+
//#region src/gateway/readBaseUrls.ts
|
|
919
|
+
var Le = 1e4;
|
|
920
|
+
function Q(e, t, n) {
|
|
921
|
+
let r = n.trim().replace(/\/$/, "");
|
|
922
|
+
r && !t.has(r) && (t.add(r), e.push(r));
|
|
923
|
+
}
|
|
924
|
+
function $(e) {
|
|
925
|
+
let t = X(), n = S.getProtocol(), r = t ? Me(t) : e?.fallbackHosts?.length ? [...e.fallbackHosts] : c(S.getHost()), i = [], a = /* @__PURE__ */ new Set();
|
|
926
|
+
for (let e of r) {
|
|
927
|
+
let t = e.trim();
|
|
928
|
+
t && Q(i, a, /^https?:\/\//i.test(t) ? t : `${n}://${t}`);
|
|
929
|
+
}
|
|
930
|
+
return i;
|
|
931
|
+
}
|
|
932
|
+
function Re(e) {
|
|
933
|
+
let t = [], n = /* @__PURE__ */ new Set();
|
|
934
|
+
for (let e of Z()) Q(t, n, e);
|
|
935
|
+
for (let r of $(e)) Q(t, n, r);
|
|
936
|
+
return t;
|
|
937
|
+
}
|
|
938
|
+
async function ze() {
|
|
939
|
+
try {
|
|
940
|
+
let e = X();
|
|
941
|
+
if (e && (e.activePath === "hyper-sidecar" || e.activePath === "http-proxy")) return;
|
|
942
|
+
await V();
|
|
943
|
+
} catch {}
|
|
944
|
+
}
|
|
945
|
+
async function Be(e, t, n) {
|
|
946
|
+
let r = new AbortController(), i = setTimeout(() => r.abort(), n?.timeoutMs ?? 1e4);
|
|
947
|
+
try {
|
|
948
|
+
let n = await fetch(`${e.replace(/\/$/, "")}/raw/${encodeURIComponent(t)}`, {
|
|
949
|
+
method: "GET",
|
|
950
|
+
credentials: "omit",
|
|
951
|
+
signal: r.signal
|
|
952
|
+
});
|
|
953
|
+
return n.ok ? n : void 0;
|
|
954
|
+
} catch {
|
|
955
|
+
return;
|
|
956
|
+
} finally {
|
|
957
|
+
clearTimeout(i);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
async function Ve(e, t) {
|
|
961
|
+
let n = /* @__PURE__ */ new Set(), r = async (r) => {
|
|
962
|
+
for (let i of r) {
|
|
963
|
+
if (n.has(i)) continue;
|
|
964
|
+
n.add(i);
|
|
965
|
+
let r = await Be(i, e, t);
|
|
966
|
+
if (r) try {
|
|
967
|
+
let { bytes: t } = await oe(r, { transactionId: e }), n = new TextDecoder().decode(t);
|
|
968
|
+
if (n.length > 0) return n;
|
|
969
|
+
} catch {}
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
return await r(Z()) || (await ze(), r($(t)));
|
|
973
|
+
}
|
|
974
|
+
//#endregion
|
|
975
|
+
//#region src/gateway/transactionStatus.ts
|
|
976
|
+
var He = 1e4, Ue = 2e4, We = (e) => e >= 500 || e === 429;
|
|
977
|
+
async function Ge(e, t, n) {
|
|
978
|
+
let r = new AbortController(), i = setTimeout(() => r.abort(), n);
|
|
979
|
+
try {
|
|
980
|
+
let n = await fetch(`${e.replace(/\/$/, "")}/${encodeURIComponent(t)}`, {
|
|
981
|
+
method: "GET",
|
|
982
|
+
credentials: "omit",
|
|
983
|
+
signal: r.signal
|
|
984
|
+
});
|
|
985
|
+
return await n.body?.cancel().catch(() => {}), We(n.status) ? {
|
|
986
|
+
kind: "retry",
|
|
987
|
+
status: n.status
|
|
988
|
+
} : {
|
|
989
|
+
kind: "answer",
|
|
990
|
+
status: n.status
|
|
991
|
+
};
|
|
992
|
+
} catch {
|
|
993
|
+
return {
|
|
994
|
+
kind: "retry",
|
|
995
|
+
status: r.signal.aborted ? 504 : 500
|
|
996
|
+
};
|
|
997
|
+
} finally {
|
|
998
|
+
clearTimeout(i);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
async function Ke(e, t = {}) {
|
|
1002
|
+
let n = t.timeoutMs ?? 1e4, r = Date.now() + (t.totalTimeoutMs ?? 2e4), i = t.baseUrls ?? Re(), a = i.filter((e) => !j(e)), o = a.length > 0 ? a : i, s = 500;
|
|
1003
|
+
for (let t of o) {
|
|
1004
|
+
let i = r - Date.now();
|
|
1005
|
+
if (i <= 0) break;
|
|
1006
|
+
let a = await Ge(t, e, Math.min(n, i));
|
|
1007
|
+
if (a.kind === "answer") return M(t), {
|
|
1008
|
+
status: a.status >= 200 && a.status < 300 ? 200 : a.status,
|
|
1009
|
+
confirmed: null
|
|
1010
|
+
};
|
|
1011
|
+
N(t), s = a.status;
|
|
1012
|
+
}
|
|
1013
|
+
return {
|
|
1014
|
+
status: s,
|
|
1015
|
+
confirmed: null
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
//#endregion
|
|
1019
|
+
export { c as $, k as A, m as B, Se as C, _e as D, he as E, fe as F, ee as G, oe as H, S as I, e as J, o as K, ce as L, M, ge as N, j as O, pe as P, n as Q, le as R, z as S, ve as T, ae as U, f as V, p as W, i as X, r as Y, t as Z, je as _, ze as a, R as b, Re as c, X as d, l as et, Ie as f, q as g, G as h, Le as i, N as j, ye as k, $ as l, Me as m, Ue as n, u as nt, Be as o, Pe as p, a as q, Ke as r, ne as rt, Ve as s, He as t, ie as tt, Z as u, V as v, B as w, Ce as x, we as y, ue as z };
|
|
1020
|
+
|
|
1021
|
+
//# sourceMappingURL=transactionStatus-BpYIaQyY.js.map
|