@solana/web3.js 2.0.0-experimental.34c3228 → 2.0.0-experimental.356279e
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/index.browser.cjs +15 -472
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +4 -465
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +3085 -3032
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +4 -454
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +15 -461
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +4 -454
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +261 -253
- package/dist/types/airdrop-internal.d.ts +4 -4
- package/dist/types/airdrop-internal.d.ts.map +1 -1
- package/dist/types/airdrop.d.ts +3 -3
- package/dist/types/airdrop.d.ts.map +1 -1
- package/dist/types/decode-transaction.d.ts +1 -2
- package/dist/types/decode-transaction.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/send-transaction-internal.d.ts +3 -3
- package/dist/types/send-transaction-internal.d.ts.map +1 -1
- package/dist/types/send-transaction.d.ts +2 -2
- package/dist/types/send-transaction.d.ts.map +1 -1
- package/package.json +16 -17
- package/dist/types/cached-abortable-iterable.d.ts +0 -11
- package/dist/types/cached-abortable-iterable.d.ts.map +0 -1
- package/dist/types/rpc-default-config.d.ts +0 -3
- package/dist/types/rpc-default-config.d.ts.map +0 -1
- package/dist/types/rpc-integer-overflow-error.d.ts +0 -4
- package/dist/types/rpc-integer-overflow-error.d.ts.map +0 -1
- package/dist/types/rpc-request-coalescer.d.ts +0 -5
- package/dist/types/rpc-request-coalescer.d.ts.map +0 -1
- package/dist/types/rpc-request-deduplication.d.ts +0 -2
- package/dist/types/rpc-request-deduplication.d.ts.map +0 -1
- package/dist/types/rpc-subscription-coalescer.d.ts +0 -10
- package/dist/types/rpc-subscription-coalescer.d.ts.map +0 -1
- package/dist/types/rpc-transport.d.ts +0 -9
- package/dist/types/rpc-transport.d.ts.map +0 -1
- package/dist/types/rpc-websocket-autopinger.d.ts +0 -8
- package/dist/types/rpc-websocket-autopinger.d.ts.map +0 -1
- package/dist/types/rpc-websocket-connection-sharding.d.ts +0 -13
- package/dist/types/rpc-websocket-connection-sharding.d.ts.map +0 -1
- package/dist/types/rpc-websocket-transport.d.ts +0 -16
- package/dist/types/rpc-websocket-transport.d.ts.map +0 -1
- package/dist/types/rpc.d.ts +0 -13
- package/dist/types/rpc.d.ts.map +0 -1
package/dist/index.browser.cjs
CHANGED
|
@@ -7,22 +7,15 @@ var functional = require('@solana/functional');
|
|
|
7
7
|
var instructions = require('@solana/instructions');
|
|
8
8
|
var keys = require('@solana/keys');
|
|
9
9
|
var programs = require('@solana/programs');
|
|
10
|
+
var rpc = require('@solana/rpc');
|
|
10
11
|
var rpcParsedTypes = require('@solana/rpc-parsed-types');
|
|
12
|
+
var rpcSubscriptions = require('@solana/rpc-subscriptions');
|
|
11
13
|
var rpcTypes = require('@solana/rpc-types');
|
|
12
14
|
var signers = require('@solana/signers');
|
|
13
15
|
var transactions = require('@solana/transactions');
|
|
14
16
|
var transactionConfirmation = require('@solana/transaction-confirmation');
|
|
15
|
-
var rpcCore = require('@solana/rpc-core');
|
|
16
|
-
var rpcTransport = require('@solana/rpc-transport');
|
|
17
|
-
var fastStableStringify = require('fast-stable-stringify');
|
|
18
|
-
var errors = require('@solana/errors');
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var fastStableStringify__default = /*#__PURE__*/_interopDefault(fastStableStringify);
|
|
23
|
-
|
|
24
|
-
// ../build-scripts/env-shim.ts
|
|
25
|
-
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
18
|
+
// src/index.ts
|
|
26
19
|
|
|
27
20
|
// src/airdrop-internal.ts
|
|
28
21
|
async function requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
@@ -93,463 +86,6 @@ async function decodeTransaction(encodedTransaction, rpc, config) {
|
|
|
93
86
|
lastValidBlockHeight
|
|
94
87
|
});
|
|
95
88
|
}
|
|
96
|
-
function createSolanaJsonRpcIntegerOverflowError(methodName, keyPath, value) {
|
|
97
|
-
let argumentLabel = "";
|
|
98
|
-
if (typeof keyPath[0] === "number") {
|
|
99
|
-
const argPosition = keyPath[0] + 1;
|
|
100
|
-
const lastDigit = argPosition % 10;
|
|
101
|
-
const lastTwoDigits = argPosition % 100;
|
|
102
|
-
if (lastDigit == 1 && lastTwoDigits != 11) {
|
|
103
|
-
argumentLabel = argPosition + "st";
|
|
104
|
-
} else if (lastDigit == 2 && lastTwoDigits != 12) {
|
|
105
|
-
argumentLabel = argPosition + "nd";
|
|
106
|
-
} else if (lastDigit == 3 && lastTwoDigits != 13) {
|
|
107
|
-
argumentLabel = argPosition + "rd";
|
|
108
|
-
} else {
|
|
109
|
-
argumentLabel = argPosition + "th";
|
|
110
|
-
}
|
|
111
|
-
} else {
|
|
112
|
-
argumentLabel = `\`${keyPath[0].toString()}\``;
|
|
113
|
-
}
|
|
114
|
-
const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : void 0;
|
|
115
|
-
const error = new errors.SolanaError(errors.SOLANA_ERROR__RPC_INTEGER_OVERFLOW, {
|
|
116
|
-
argumentLabel,
|
|
117
|
-
keyPath,
|
|
118
|
-
methodName,
|
|
119
|
-
optionalPathLabel: path ? ` at path \`${path}\`` : "",
|
|
120
|
-
value,
|
|
121
|
-
...path !== void 0 ? { path } : void 0
|
|
122
|
-
});
|
|
123
|
-
if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") {
|
|
124
|
-
Error.captureStackTrace(error, createSolanaJsonRpcIntegerOverflowError);
|
|
125
|
-
}
|
|
126
|
-
return error;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// src/rpc-default-config.ts
|
|
130
|
-
var DEFAULT_RPC_CONFIG = {
|
|
131
|
-
defaultCommitment: "confirmed",
|
|
132
|
-
onIntegerOverflow(methodName, keyPath, value) {
|
|
133
|
-
throw createSolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// src/cached-abortable-iterable.ts
|
|
138
|
-
function registerIterableCleanup(iterable, cleanupFn) {
|
|
139
|
-
(async () => {
|
|
140
|
-
try {
|
|
141
|
-
for await (const _ of iterable)
|
|
142
|
-
;
|
|
143
|
-
} catch {
|
|
144
|
-
} finally {
|
|
145
|
-
cleanupFn();
|
|
146
|
-
}
|
|
147
|
-
})();
|
|
148
|
-
}
|
|
149
|
-
function getCachedAbortableIterableFactory({
|
|
150
|
-
getAbortSignalFromInputArgs,
|
|
151
|
-
getCacheEntryMissingError,
|
|
152
|
-
getCacheKeyFromInputArgs,
|
|
153
|
-
onCacheHit,
|
|
154
|
-
onCreateIterable
|
|
155
|
-
}) {
|
|
156
|
-
const cache = /* @__PURE__ */ new Map();
|
|
157
|
-
function getCacheEntryOrThrow(cacheKey) {
|
|
158
|
-
const currentCacheEntry = cache.get(cacheKey);
|
|
159
|
-
if (!currentCacheEntry) {
|
|
160
|
-
throw getCacheEntryMissingError(cacheKey);
|
|
161
|
-
}
|
|
162
|
-
return currentCacheEntry;
|
|
163
|
-
}
|
|
164
|
-
return async (...args) => {
|
|
165
|
-
const cacheKey = getCacheKeyFromInputArgs(...args);
|
|
166
|
-
const signal = getAbortSignalFromInputArgs(...args);
|
|
167
|
-
if (cacheKey === void 0) {
|
|
168
|
-
return await onCreateIterable(signal, ...args);
|
|
169
|
-
}
|
|
170
|
-
const cleanup = () => {
|
|
171
|
-
cache.delete(cacheKey);
|
|
172
|
-
signal.removeEventListener("abort", handleAbort);
|
|
173
|
-
};
|
|
174
|
-
const handleAbort = () => {
|
|
175
|
-
const cacheEntry = getCacheEntryOrThrow(cacheKey);
|
|
176
|
-
if (cacheEntry.purgeScheduled !== true) {
|
|
177
|
-
cacheEntry.purgeScheduled = true;
|
|
178
|
-
globalThis.queueMicrotask(() => {
|
|
179
|
-
cacheEntry.purgeScheduled = false;
|
|
180
|
-
if (cacheEntry.referenceCount === 0) {
|
|
181
|
-
cacheEntry.abortController.abort();
|
|
182
|
-
cleanup();
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
cacheEntry.referenceCount--;
|
|
187
|
-
};
|
|
188
|
-
signal.addEventListener("abort", handleAbort);
|
|
189
|
-
try {
|
|
190
|
-
const cacheEntry = cache.get(cacheKey);
|
|
191
|
-
if (!cacheEntry) {
|
|
192
|
-
const singletonAbortController = new AbortController();
|
|
193
|
-
const newIterablePromise = onCreateIterable(singletonAbortController.signal, ...args);
|
|
194
|
-
const newCacheEntry = {
|
|
195
|
-
abortController: singletonAbortController,
|
|
196
|
-
iterable: newIterablePromise,
|
|
197
|
-
purgeScheduled: false,
|
|
198
|
-
referenceCount: 1
|
|
199
|
-
};
|
|
200
|
-
cache.set(cacheKey, newCacheEntry);
|
|
201
|
-
const newIterable = await newIterablePromise;
|
|
202
|
-
registerIterableCleanup(newIterable, cleanup);
|
|
203
|
-
newCacheEntry.iterable = newIterable;
|
|
204
|
-
return newIterable;
|
|
205
|
-
} else {
|
|
206
|
-
cacheEntry.referenceCount++;
|
|
207
|
-
const iterableOrIterablePromise = cacheEntry.iterable;
|
|
208
|
-
const cachedIterable = "then" in iterableOrIterablePromise ? await iterableOrIterablePromise : iterableOrIterablePromise;
|
|
209
|
-
await onCacheHit(cachedIterable, ...args);
|
|
210
|
-
return cachedIterable;
|
|
211
|
-
}
|
|
212
|
-
} catch (e) {
|
|
213
|
-
cleanup();
|
|
214
|
-
throw e;
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// src/rpc-subscription-coalescer.ts
|
|
220
|
-
var EXPLICIT_ABORT_TOKEN = Symbol(
|
|
221
|
-
__DEV__ ? "This symbol is thrown from a subscription's iterator when the subscription is explicitly aborted by the user" : void 0
|
|
222
|
-
);
|
|
223
|
-
function registerIterableCleanup2(iterable, cleanupFn) {
|
|
224
|
-
(async () => {
|
|
225
|
-
try {
|
|
226
|
-
for await (const _ of iterable)
|
|
227
|
-
;
|
|
228
|
-
} catch {
|
|
229
|
-
} finally {
|
|
230
|
-
cleanupFn();
|
|
231
|
-
}
|
|
232
|
-
})();
|
|
233
|
-
}
|
|
234
|
-
function getRpcSubscriptionsWithSubscriptionCoalescing({
|
|
235
|
-
getDeduplicationKey,
|
|
236
|
-
rpcSubscriptions
|
|
237
|
-
}) {
|
|
238
|
-
const cache = /* @__PURE__ */ new Map();
|
|
239
|
-
return new Proxy(rpcSubscriptions, {
|
|
240
|
-
defineProperty() {
|
|
241
|
-
return false;
|
|
242
|
-
},
|
|
243
|
-
deleteProperty() {
|
|
244
|
-
return false;
|
|
245
|
-
},
|
|
246
|
-
get(target, p, receiver) {
|
|
247
|
-
const subscriptionMethod = Reflect.get(target, p, receiver);
|
|
248
|
-
if (typeof subscriptionMethod !== "function") {
|
|
249
|
-
return subscriptionMethod;
|
|
250
|
-
}
|
|
251
|
-
return function(...rawParams) {
|
|
252
|
-
const deduplicationKey = getDeduplicationKey(p, rawParams);
|
|
253
|
-
if (deduplicationKey === void 0) {
|
|
254
|
-
return subscriptionMethod(...rawParams);
|
|
255
|
-
}
|
|
256
|
-
if (cache.has(deduplicationKey)) {
|
|
257
|
-
return cache.get(deduplicationKey);
|
|
258
|
-
}
|
|
259
|
-
const iterableFactory = getCachedAbortableIterableFactory({
|
|
260
|
-
getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
|
|
261
|
-
getCacheEntryMissingError(deduplicationKey2) {
|
|
262
|
-
return new Error(
|
|
263
|
-
`Found no cache entry for subscription with deduplication key \`${deduplicationKey2?.toString()}\``
|
|
264
|
-
);
|
|
265
|
-
},
|
|
266
|
-
getCacheKeyFromInputArgs: () => deduplicationKey,
|
|
267
|
-
async onCacheHit(_iterable, _config) {
|
|
268
|
-
},
|
|
269
|
-
async onCreateIterable(abortSignal, config) {
|
|
270
|
-
const pendingSubscription2 = subscriptionMethod(
|
|
271
|
-
...rawParams
|
|
272
|
-
);
|
|
273
|
-
const iterable = await pendingSubscription2.subscribe({
|
|
274
|
-
...config,
|
|
275
|
-
abortSignal
|
|
276
|
-
});
|
|
277
|
-
registerIterableCleanup2(iterable, () => {
|
|
278
|
-
cache.delete(deduplicationKey);
|
|
279
|
-
});
|
|
280
|
-
return iterable;
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
const pendingSubscription = {
|
|
284
|
-
async subscribe(...args) {
|
|
285
|
-
const iterable = await iterableFactory(...args);
|
|
286
|
-
const { abortSignal } = args[0];
|
|
287
|
-
let abortPromise;
|
|
288
|
-
return {
|
|
289
|
-
...iterable,
|
|
290
|
-
async *[Symbol.asyncIterator]() {
|
|
291
|
-
abortPromise ||= abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN) : new Promise((_, reject) => {
|
|
292
|
-
abortSignal.addEventListener("abort", () => {
|
|
293
|
-
reject(EXPLICIT_ABORT_TOKEN);
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
try {
|
|
297
|
-
const iterator = iterable[Symbol.asyncIterator]();
|
|
298
|
-
while (true) {
|
|
299
|
-
const iteratorResult = await Promise.race([iterator.next(), abortPromise]);
|
|
300
|
-
if (iteratorResult.done) {
|
|
301
|
-
return;
|
|
302
|
-
} else {
|
|
303
|
-
yield iteratorResult.value;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
} catch (e) {
|
|
307
|
-
if (e === EXPLICIT_ABORT_TOKEN) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
cache.delete(deduplicationKey);
|
|
311
|
-
throw e;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
cache.set(deduplicationKey, pendingSubscription);
|
|
318
|
-
return pendingSubscription;
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// src/rpc.ts
|
|
325
|
-
function createSolanaRpc(config) {
|
|
326
|
-
const api = rpcCore.createSolanaRpcApi(DEFAULT_RPC_CONFIG);
|
|
327
|
-
return rpcTransport.createJsonRpc({
|
|
328
|
-
...config,
|
|
329
|
-
api
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
function createSolanaRpcSubscriptions(config) {
|
|
333
|
-
return functional.pipe(
|
|
334
|
-
rpcTransport.createJsonSubscriptionRpc({
|
|
335
|
-
...config,
|
|
336
|
-
api: rpcCore.createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
|
|
337
|
-
}),
|
|
338
|
-
(rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
|
|
339
|
-
getDeduplicationKey: (...args) => fastStableStringify__default.default(args),
|
|
340
|
-
rpcSubscriptions
|
|
341
|
-
})
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
function createSolanaRpcSubscriptions_UNSTABLE(config) {
|
|
345
|
-
return rpcTransport.createJsonSubscriptionRpc({
|
|
346
|
-
...config,
|
|
347
|
-
api: rpcCore.createSolanaRpcSubscriptionsApi_UNSTABLE(DEFAULT_RPC_CONFIG)
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// src/rpc-request-coalescer.ts
|
|
352
|
-
function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
|
|
353
|
-
let coalescedRequestsByDeduplicationKey;
|
|
354
|
-
return async function makeCoalescedHttpRequest(config) {
|
|
355
|
-
const { payload, signal } = config;
|
|
356
|
-
const deduplicationKey = getDeduplicationKey(payload);
|
|
357
|
-
if (deduplicationKey === void 0) {
|
|
358
|
-
return await transport(config);
|
|
359
|
-
}
|
|
360
|
-
if (!coalescedRequestsByDeduplicationKey) {
|
|
361
|
-
Promise.resolve().then(() => {
|
|
362
|
-
coalescedRequestsByDeduplicationKey = void 0;
|
|
363
|
-
});
|
|
364
|
-
coalescedRequestsByDeduplicationKey = {};
|
|
365
|
-
}
|
|
366
|
-
if (coalescedRequestsByDeduplicationKey[deduplicationKey] == null) {
|
|
367
|
-
const abortController = new AbortController();
|
|
368
|
-
const responsePromise = (async () => {
|
|
369
|
-
try {
|
|
370
|
-
return await transport({
|
|
371
|
-
...config,
|
|
372
|
-
signal: abortController.signal
|
|
373
|
-
});
|
|
374
|
-
} catch (e) {
|
|
375
|
-
if (e && typeof e === "object" && "name" in e && e.name === "AbortError") {
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
throw e;
|
|
379
|
-
}
|
|
380
|
-
})();
|
|
381
|
-
coalescedRequestsByDeduplicationKey[deduplicationKey] = {
|
|
382
|
-
abortController,
|
|
383
|
-
numConsumers: 0,
|
|
384
|
-
responsePromise
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
const coalescedRequest = coalescedRequestsByDeduplicationKey[deduplicationKey];
|
|
388
|
-
coalescedRequest.numConsumers++;
|
|
389
|
-
if (signal) {
|
|
390
|
-
const responsePromise = coalescedRequest.responsePromise;
|
|
391
|
-
return await new Promise((resolve, reject) => {
|
|
392
|
-
const handleAbort = (e) => {
|
|
393
|
-
signal.removeEventListener("abort", handleAbort);
|
|
394
|
-
coalescedRequest.numConsumers -= 1;
|
|
395
|
-
if (coalescedRequest.numConsumers === 0) {
|
|
396
|
-
const abortController = coalescedRequest.abortController;
|
|
397
|
-
abortController.abort();
|
|
398
|
-
}
|
|
399
|
-
const abortError = new DOMException(e.target.reason, "AbortError");
|
|
400
|
-
reject(abortError);
|
|
401
|
-
};
|
|
402
|
-
signal.addEventListener("abort", handleAbort);
|
|
403
|
-
responsePromise.then(resolve).finally(() => {
|
|
404
|
-
signal.removeEventListener("abort", handleAbort);
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
} else {
|
|
408
|
-
return await coalescedRequest.responsePromise;
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
function isJsonRpcPayload(payload) {
|
|
413
|
-
if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
414
|
-
return false;
|
|
415
|
-
}
|
|
416
|
-
return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
|
|
417
|
-
}
|
|
418
|
-
function getSolanaRpcPayloadDeduplicationKey(payload) {
|
|
419
|
-
return isJsonRpcPayload(payload) ? fastStableStringify__default.default([payload.method, payload.params]) : void 0;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// src/rpc-transport.ts
|
|
423
|
-
function normalizeHeaders(headers) {
|
|
424
|
-
const out = {};
|
|
425
|
-
for (const headerName in headers) {
|
|
426
|
-
out[headerName.toLowerCase()] = headers[headerName];
|
|
427
|
-
}
|
|
428
|
-
return out;
|
|
429
|
-
}
|
|
430
|
-
function createDefaultRpcTransport(config) {
|
|
431
|
-
return functional.pipe(
|
|
432
|
-
rpcTransport.createHttpTransport({
|
|
433
|
-
...config,
|
|
434
|
-
headers: {
|
|
435
|
-
...config.headers ? normalizeHeaders(config.headers) : void 0,
|
|
436
|
-
...{
|
|
437
|
-
// Keep these headers lowercase so they will override any user-supplied headers above.
|
|
438
|
-
"solana-client": `js/${"2.0.0-development"}` ?? "UNKNOWN"
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}),
|
|
442
|
-
(transport) => getRpcTransportWithRequestCoalescing(transport, getSolanaRpcPayloadDeduplicationKey)
|
|
443
|
-
);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// src/rpc-websocket-autopinger.ts
|
|
447
|
-
var PING_PAYLOAD = {
|
|
448
|
-
jsonrpc: "2.0",
|
|
449
|
-
method: "ping"
|
|
450
|
-
};
|
|
451
|
-
function getWebSocketTransportWithAutoping({
|
|
452
|
-
intervalMs,
|
|
453
|
-
transport
|
|
454
|
-
}) {
|
|
455
|
-
const pingableConnections = /* @__PURE__ */ new Map();
|
|
456
|
-
return async (...args) => {
|
|
457
|
-
const connection = await transport(...args);
|
|
458
|
-
let intervalId;
|
|
459
|
-
function sendPing() {
|
|
460
|
-
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(PING_PAYLOAD);
|
|
461
|
-
}
|
|
462
|
-
function restartPingTimer() {
|
|
463
|
-
clearInterval(intervalId);
|
|
464
|
-
intervalId = setInterval(sendPing, intervalMs);
|
|
465
|
-
}
|
|
466
|
-
if (pingableConnections.has(connection) === false) {
|
|
467
|
-
pingableConnections.set(connection, {
|
|
468
|
-
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
469
|
-
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...args2) => {
|
|
470
|
-
restartPingTimer();
|
|
471
|
-
return connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...args2);
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
(async () => {
|
|
475
|
-
try {
|
|
476
|
-
for await (const _ of connection) {
|
|
477
|
-
restartPingTimer();
|
|
478
|
-
}
|
|
479
|
-
} catch {
|
|
480
|
-
} finally {
|
|
481
|
-
pingableConnections.delete(connection);
|
|
482
|
-
clearInterval(intervalId);
|
|
483
|
-
if (handleOffline) {
|
|
484
|
-
globalThis.window.removeEventListener("offline", handleOffline);
|
|
485
|
-
}
|
|
486
|
-
if (handleOnline) {
|
|
487
|
-
globalThis.window.removeEventListener("online", handleOnline);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
})();
|
|
491
|
-
if (globalThis.navigator.onLine) {
|
|
492
|
-
restartPingTimer();
|
|
493
|
-
}
|
|
494
|
-
let handleOffline;
|
|
495
|
-
let handleOnline;
|
|
496
|
-
{
|
|
497
|
-
handleOffline = () => {
|
|
498
|
-
clearInterval(intervalId);
|
|
499
|
-
};
|
|
500
|
-
handleOnline = () => {
|
|
501
|
-
sendPing();
|
|
502
|
-
restartPingTimer();
|
|
503
|
-
};
|
|
504
|
-
globalThis.window.addEventListener("offline", handleOffline);
|
|
505
|
-
globalThis.window.addEventListener("online", handleOnline);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
return pingableConnections.get(connection);
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// src/rpc-websocket-connection-sharding.ts
|
|
513
|
-
var NULL_SHARD_CACHE_KEY = Symbol(
|
|
514
|
-
__DEV__ ? "Cache key to use when there is no connection sharding strategy" : void 0
|
|
515
|
-
);
|
|
516
|
-
function getWebSocketTransportWithConnectionSharding({
|
|
517
|
-
getShard,
|
|
518
|
-
transport
|
|
519
|
-
}) {
|
|
520
|
-
return getCachedAbortableIterableFactory({
|
|
521
|
-
getAbortSignalFromInputArgs: ({ signal }) => signal,
|
|
522
|
-
getCacheEntryMissingError(shardKey) {
|
|
523
|
-
return new Error(`Found no cache entry for connection with shard key \`${shardKey?.toString()}\``);
|
|
524
|
-
},
|
|
525
|
-
getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
|
|
526
|
-
onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
|
|
527
|
-
onCreateIterable: (abortSignal, config) => transport({
|
|
528
|
-
...config,
|
|
529
|
-
signal: abortSignal
|
|
530
|
-
})
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
// src/rpc-websocket-transport.ts
|
|
535
|
-
function createDefaultRpcSubscriptionsTransport(config) {
|
|
536
|
-
const { getShard, intervalMs, ...rest } = config;
|
|
537
|
-
return functional.pipe(
|
|
538
|
-
rpcTransport.createWebSocketTransport({
|
|
539
|
-
...rest,
|
|
540
|
-
sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
|
|
541
|
-
131072
|
|
542
|
-
}),
|
|
543
|
-
(transport) => getWebSocketTransportWithAutoping({
|
|
544
|
-
intervalMs: intervalMs ?? 5e3,
|
|
545
|
-
transport
|
|
546
|
-
}),
|
|
547
|
-
(transport) => getWebSocketTransportWithConnectionSharding({
|
|
548
|
-
getShard,
|
|
549
|
-
transport
|
|
550
|
-
})
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
89
|
function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
|
|
554
90
|
if (
|
|
555
91
|
// The developer has supplied no value for `preflightCommitment`.
|
|
@@ -696,11 +232,6 @@ function sendAndConfirmTransactionFactory({
|
|
|
696
232
|
}
|
|
697
233
|
|
|
698
234
|
exports.airdropFactory = airdropFactory;
|
|
699
|
-
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
|
700
|
-
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
701
|
-
exports.createSolanaRpc = createSolanaRpc;
|
|
702
|
-
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
703
|
-
exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
|
|
704
235
|
exports.decodeTransaction = decodeTransaction;
|
|
705
236
|
exports.sendAndConfirmDurableNonceTransactionFactory = sendAndConfirmDurableNonceTransactionFactory;
|
|
706
237
|
exports.sendAndConfirmTransactionFactory = sendAndConfirmTransactionFactory;
|
|
@@ -747,12 +278,24 @@ Object.keys(programs).forEach(function (k) {
|
|
|
747
278
|
get: function () { return programs[k]; }
|
|
748
279
|
});
|
|
749
280
|
});
|
|
281
|
+
Object.keys(rpc).forEach(function (k) {
|
|
282
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
283
|
+
enumerable: true,
|
|
284
|
+
get: function () { return rpc[k]; }
|
|
285
|
+
});
|
|
286
|
+
});
|
|
750
287
|
Object.keys(rpcParsedTypes).forEach(function (k) {
|
|
751
288
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
752
289
|
enumerable: true,
|
|
753
290
|
get: function () { return rpcParsedTypes[k]; }
|
|
754
291
|
});
|
|
755
292
|
});
|
|
293
|
+
Object.keys(rpcSubscriptions).forEach(function (k) {
|
|
294
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
295
|
+
enumerable: true,
|
|
296
|
+
get: function () { return rpcSubscriptions[k]; }
|
|
297
|
+
});
|
|
298
|
+
});
|
|
756
299
|
Object.keys(rpcTypes).forEach(function (k) {
|
|
757
300
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
758
301
|
enumerable: true,
|