@solana/web3.js 2.0.0-experimental.606040b → 2.0.0-experimental.61e27a2
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 +114 -855
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +97 -834
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +3524 -3063
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +97 -823
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +114 -844
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +97 -823
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +275 -270
- package/dist/types/airdrop-internal.d.ts +16 -0
- package/dist/types/airdrop-internal.d.ts.map +1 -0
- package/dist/types/airdrop.d.ts +7 -16
- 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 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/send-transaction-internal.d.ts +27 -0
- package/dist/types/send-transaction-internal.d.ts.map +1 -0
- package/dist/types/send-transaction.d.ts +16 -30
- package/dist/types/send-transaction.d.ts.map +1 -1
- package/package.json +24 -45
- package/dist/types/airdrop-confirmer.d.ts +0 -19
- package/dist/types/airdrop-confirmer.d.ts.map +0 -1
- 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/types/transaction-confirmation-strategy-blockheight.d.ts +0 -14
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts.map +0 -1
- package/dist/types/transaction-confirmation-strategy-nonce.d.ts +0 -13
- package/dist/types/transaction-confirmation-strategy-nonce.d.ts.map +0 -1
- package/dist/types/transaction-confirmation-strategy-racer.d.ts +0 -14
- package/dist/types/transaction-confirmation-strategy-racer.d.ts.map +0 -1
- package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts +0 -11
- package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts.map +0 -1
- package/dist/types/transaction-confirmation-strategy-timeout.d.ts +0 -8
- package/dist/types/transaction-confirmation-strategy-timeout.d.ts.map +0 -1
- package/dist/types/transaction-confirmation.d.ts +0 -32
- package/dist/types/transaction-confirmation.d.ts.map +0 -1
package/dist/index.browser.cjs
CHANGED
|
@@ -7,176 +7,55 @@ 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
|
-
var
|
|
15
|
-
var rpcTransport = require('@solana/rpc-transport');
|
|
16
|
-
var fastStableStringify = require('fast-stable-stringify');
|
|
17
|
-
var errors = require('@solana/errors');
|
|
16
|
+
var transactionConfirmation = require('@solana/transaction-confirmation');
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
// src/index.ts
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
abortController.abort();
|
|
34
|
-
};
|
|
35
|
-
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
36
|
-
}
|
|
37
|
-
try {
|
|
38
|
-
const specificStrategies = getSpecificStrategiesForRace({
|
|
39
|
-
...config,
|
|
40
|
-
abortSignal: abortController.signal
|
|
41
|
-
});
|
|
42
|
-
return await Promise.race([
|
|
43
|
-
getRecentSignatureConfirmationPromise({
|
|
44
|
-
abortSignal: abortController.signal,
|
|
45
|
-
commitment,
|
|
46
|
-
signature
|
|
47
|
-
}),
|
|
48
|
-
...specificStrategies
|
|
49
|
-
]);
|
|
50
|
-
} finally {
|
|
51
|
-
abortController.abort();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function createRecentSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
|
|
55
|
-
return async function getRecentSignatureConfirmationPromise({
|
|
56
|
-
abortSignal: callerAbortSignal,
|
|
20
|
+
// src/airdrop-internal.ts
|
|
21
|
+
async function requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
22
|
+
abortSignal,
|
|
23
|
+
commitment,
|
|
24
|
+
confirmSignatureOnlyTransaction,
|
|
25
|
+
lamports,
|
|
26
|
+
recipientAddress,
|
|
27
|
+
rpc
|
|
28
|
+
}) {
|
|
29
|
+
const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports, { commitment }).send({ abortSignal });
|
|
30
|
+
await confirmSignatureOnlyTransaction({
|
|
31
|
+
abortSignal,
|
|
57
32
|
commitment,
|
|
58
|
-
signature
|
|
59
|
-
}) {
|
|
60
|
-
const abortController = new AbortController();
|
|
61
|
-
function handleAbort() {
|
|
62
|
-
abortController.abort();
|
|
63
|
-
}
|
|
64
|
-
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
65
|
-
const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature, { commitment }).subscribe({ abortSignal: abortController.signal });
|
|
66
|
-
const signatureDidCommitPromise = (async () => {
|
|
67
|
-
for await (const signatureStatusNotification of signatureStatusNotifications) {
|
|
68
|
-
if (signatureStatusNotification.value.err) {
|
|
69
|
-
throw new Error(`The transaction with signature \`${signature}\` failed.`, {
|
|
70
|
-
cause: signatureStatusNotification.value.err
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
})();
|
|
77
|
-
const signatureStatusLookupPromise = (async () => {
|
|
78
|
-
const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature]).send({ abortSignal: abortController.signal });
|
|
79
|
-
const signatureStatus = signatureStatusResults[0];
|
|
80
|
-
if (signatureStatus && signatureStatus.confirmationStatus && rpcTypes.commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
|
|
81
|
-
return;
|
|
82
|
-
} else {
|
|
83
|
-
await new Promise(() => {
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
})();
|
|
87
|
-
try {
|
|
88
|
-
return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
|
|
89
|
-
} finally {
|
|
90
|
-
abortController.abort();
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// src/transaction-confirmation-strategy-timeout.ts
|
|
96
|
-
async function getTimeoutPromise({ abortSignal: callerAbortSignal, commitment }) {
|
|
97
|
-
return await new Promise((_, reject) => {
|
|
98
|
-
const handleAbort = (e) => {
|
|
99
|
-
clearTimeout(timeoutId);
|
|
100
|
-
const abortError = new DOMException(e.target.reason, "AbortError");
|
|
101
|
-
reject(abortError);
|
|
102
|
-
};
|
|
103
|
-
callerAbortSignal.addEventListener("abort", handleAbort);
|
|
104
|
-
const timeoutMs = commitment === "processed" ? 3e4 : 6e4;
|
|
105
|
-
const startMs = performance.now();
|
|
106
|
-
const timeoutId = (
|
|
107
|
-
// We use `setTimeout` instead of `AbortSignal.timeout()` because we want to measure
|
|
108
|
-
// elapsed time instead of active time.
|
|
109
|
-
// See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
|
|
110
|
-
setTimeout(() => {
|
|
111
|
-
const elapsedMs = performance.now() - startMs;
|
|
112
|
-
reject(new DOMException(`Timeout elapsed after ${elapsedMs} ms`, "TimeoutError"));
|
|
113
|
-
}, timeoutMs)
|
|
114
|
-
);
|
|
33
|
+
signature: airdropTransactionSignature
|
|
115
34
|
});
|
|
35
|
+
return airdropTransactionSignature;
|
|
116
36
|
}
|
|
117
37
|
|
|
118
|
-
// src/airdrop
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
rpcSubscriptions
|
|
122
|
-
}) {
|
|
123
|
-
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
38
|
+
// src/airdrop.ts
|
|
39
|
+
function airdropFactory({ rpc, rpcSubscriptions }) {
|
|
40
|
+
const getRecentSignatureConfirmationPromise = transactionConfirmation.createRecentSignatureConfirmationPromiseFactory(
|
|
124
41
|
rpc,
|
|
125
42
|
rpcSubscriptions
|
|
126
43
|
);
|
|
127
|
-
|
|
128
|
-
await waitForRecentTransactionConfirmationUntilTimeout({
|
|
44
|
+
async function confirmSignatureOnlyTransaction(config) {
|
|
45
|
+
await transactionConfirmation.waitForRecentTransactionConfirmationUntilTimeout({
|
|
129
46
|
...config,
|
|
130
47
|
getRecentSignatureConfirmationPromise,
|
|
131
|
-
getTimeoutPromise
|
|
48
|
+
getTimeoutPromise: transactionConfirmation.getTimeoutPromise
|
|
132
49
|
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
await raceStrategies(
|
|
137
|
-
config.signature,
|
|
138
|
-
config,
|
|
139
|
-
function getSpecificStrategiesForRace({ abortSignal, commitment, getTimeoutPromise: getTimeoutPromise2 }) {
|
|
140
|
-
return [
|
|
141
|
-
getTimeoutPromise2({
|
|
142
|
-
abortSignal,
|
|
143
|
-
commitment
|
|
144
|
-
})
|
|
145
|
-
];
|
|
146
|
-
}
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// src/airdrop.ts
|
|
151
|
-
function createDefaultAirdropRequester({ rpc, rpcSubscriptions }) {
|
|
152
|
-
const confirmSignatureOnlyTransaction = createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
153
|
-
rpc,
|
|
154
|
-
rpcSubscriptions
|
|
155
|
-
});
|
|
156
|
-
return async function requestAirdrop(config) {
|
|
157
|
-
return await requestAndConfirmAirdrop({
|
|
50
|
+
}
|
|
51
|
+
return async function airdrop(config) {
|
|
52
|
+
return await requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
158
53
|
...config,
|
|
159
54
|
confirmSignatureOnlyTransaction,
|
|
160
55
|
rpc
|
|
161
56
|
});
|
|
162
57
|
};
|
|
163
58
|
}
|
|
164
|
-
async function requestAndConfirmAirdrop({
|
|
165
|
-
abortSignal,
|
|
166
|
-
commitment,
|
|
167
|
-
confirmSignatureOnlyTransaction,
|
|
168
|
-
lamports,
|
|
169
|
-
recipientAddress,
|
|
170
|
-
rpc
|
|
171
|
-
}) {
|
|
172
|
-
const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports, { commitment }).send({ abortSignal });
|
|
173
|
-
await confirmSignatureOnlyTransaction({
|
|
174
|
-
abortSignal,
|
|
175
|
-
commitment,
|
|
176
|
-
signature: airdropTransactionSignature
|
|
177
|
-
});
|
|
178
|
-
return airdropTransactionSignature;
|
|
179
|
-
}
|
|
180
59
|
var compiledTransactionDecoder = void 0;
|
|
181
60
|
async function fetchLookupTables(lookupTableAddresses, rpc, config) {
|
|
182
61
|
const fetchedLookupTables = await accounts.fetchJsonParsedAccounts(
|
|
@@ -207,656 +86,6 @@ async function decodeTransaction(encodedTransaction, rpc, config) {
|
|
|
207
86
|
lastValidBlockHeight
|
|
208
87
|
});
|
|
209
88
|
}
|
|
210
|
-
function createSolanaJsonRpcIntegerOverflowError(methodName, keyPath, value) {
|
|
211
|
-
let argumentLabel = "";
|
|
212
|
-
if (typeof keyPath[0] === "number") {
|
|
213
|
-
const argPosition = keyPath[0] + 1;
|
|
214
|
-
const lastDigit = argPosition % 10;
|
|
215
|
-
const lastTwoDigits = argPosition % 100;
|
|
216
|
-
if (lastDigit == 1 && lastTwoDigits != 11) {
|
|
217
|
-
argumentLabel = argPosition + "st";
|
|
218
|
-
} else if (lastDigit == 2 && lastTwoDigits != 12) {
|
|
219
|
-
argumentLabel = argPosition + "nd";
|
|
220
|
-
} else if (lastDigit == 3 && lastTwoDigits != 13) {
|
|
221
|
-
argumentLabel = argPosition + "rd";
|
|
222
|
-
} else {
|
|
223
|
-
argumentLabel = argPosition + "th";
|
|
224
|
-
}
|
|
225
|
-
} else {
|
|
226
|
-
argumentLabel = `\`${keyPath[0].toString()}\``;
|
|
227
|
-
}
|
|
228
|
-
const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : void 0;
|
|
229
|
-
const error = new errors.SolanaError(errors.SOLANA_ERROR__RPC_INTEGER_OVERFLOW, {
|
|
230
|
-
argumentLabel,
|
|
231
|
-
keyPath,
|
|
232
|
-
methodName,
|
|
233
|
-
optionalPathLabel: path ? ` at path \`${path}\`` : "",
|
|
234
|
-
value,
|
|
235
|
-
...path !== void 0 ? { path } : void 0
|
|
236
|
-
});
|
|
237
|
-
if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") {
|
|
238
|
-
Error.captureStackTrace(error, createSolanaJsonRpcIntegerOverflowError);
|
|
239
|
-
}
|
|
240
|
-
return error;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// src/rpc-default-config.ts
|
|
244
|
-
var DEFAULT_RPC_CONFIG = {
|
|
245
|
-
defaultCommitment: "confirmed",
|
|
246
|
-
onIntegerOverflow(methodName, keyPath, value) {
|
|
247
|
-
throw createSolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
// src/cached-abortable-iterable.ts
|
|
252
|
-
function registerIterableCleanup(iterable, cleanupFn) {
|
|
253
|
-
(async () => {
|
|
254
|
-
try {
|
|
255
|
-
for await (const _ of iterable)
|
|
256
|
-
;
|
|
257
|
-
} catch {
|
|
258
|
-
} finally {
|
|
259
|
-
cleanupFn();
|
|
260
|
-
}
|
|
261
|
-
})();
|
|
262
|
-
}
|
|
263
|
-
function getCachedAbortableIterableFactory({
|
|
264
|
-
getAbortSignalFromInputArgs,
|
|
265
|
-
getCacheEntryMissingError,
|
|
266
|
-
getCacheKeyFromInputArgs,
|
|
267
|
-
onCacheHit,
|
|
268
|
-
onCreateIterable
|
|
269
|
-
}) {
|
|
270
|
-
const cache = /* @__PURE__ */ new Map();
|
|
271
|
-
function getCacheEntryOrThrow(cacheKey) {
|
|
272
|
-
const currentCacheEntry = cache.get(cacheKey);
|
|
273
|
-
if (!currentCacheEntry) {
|
|
274
|
-
throw getCacheEntryMissingError(cacheKey);
|
|
275
|
-
}
|
|
276
|
-
return currentCacheEntry;
|
|
277
|
-
}
|
|
278
|
-
return async (...args) => {
|
|
279
|
-
const cacheKey = getCacheKeyFromInputArgs(...args);
|
|
280
|
-
const signal = getAbortSignalFromInputArgs(...args);
|
|
281
|
-
if (cacheKey === void 0) {
|
|
282
|
-
return await onCreateIterable(signal, ...args);
|
|
283
|
-
}
|
|
284
|
-
const cleanup = () => {
|
|
285
|
-
cache.delete(cacheKey);
|
|
286
|
-
signal.removeEventListener("abort", handleAbort);
|
|
287
|
-
};
|
|
288
|
-
const handleAbort = () => {
|
|
289
|
-
const cacheEntry = getCacheEntryOrThrow(cacheKey);
|
|
290
|
-
if (cacheEntry.purgeScheduled !== true) {
|
|
291
|
-
cacheEntry.purgeScheduled = true;
|
|
292
|
-
globalThis.queueMicrotask(() => {
|
|
293
|
-
cacheEntry.purgeScheduled = false;
|
|
294
|
-
if (cacheEntry.referenceCount === 0) {
|
|
295
|
-
cacheEntry.abortController.abort();
|
|
296
|
-
cleanup();
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
cacheEntry.referenceCount--;
|
|
301
|
-
};
|
|
302
|
-
signal.addEventListener("abort", handleAbort);
|
|
303
|
-
try {
|
|
304
|
-
const cacheEntry = cache.get(cacheKey);
|
|
305
|
-
if (!cacheEntry) {
|
|
306
|
-
const singletonAbortController = new AbortController();
|
|
307
|
-
const newIterablePromise = onCreateIterable(singletonAbortController.signal, ...args);
|
|
308
|
-
const newCacheEntry = {
|
|
309
|
-
abortController: singletonAbortController,
|
|
310
|
-
iterable: newIterablePromise,
|
|
311
|
-
purgeScheduled: false,
|
|
312
|
-
referenceCount: 1
|
|
313
|
-
};
|
|
314
|
-
cache.set(cacheKey, newCacheEntry);
|
|
315
|
-
const newIterable = await newIterablePromise;
|
|
316
|
-
registerIterableCleanup(newIterable, cleanup);
|
|
317
|
-
newCacheEntry.iterable = newIterable;
|
|
318
|
-
return newIterable;
|
|
319
|
-
} else {
|
|
320
|
-
cacheEntry.referenceCount++;
|
|
321
|
-
const iterableOrIterablePromise = cacheEntry.iterable;
|
|
322
|
-
const cachedIterable = "then" in iterableOrIterablePromise ? await iterableOrIterablePromise : iterableOrIterablePromise;
|
|
323
|
-
await onCacheHit(cachedIterable, ...args);
|
|
324
|
-
return cachedIterable;
|
|
325
|
-
}
|
|
326
|
-
} catch (e) {
|
|
327
|
-
cleanup();
|
|
328
|
-
throw e;
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// src/rpc-subscription-coalescer.ts
|
|
334
|
-
var EXPLICIT_ABORT_TOKEN = Symbol(
|
|
335
|
-
__DEV__ ? "This symbol is thrown from a subscription's iterator when the subscription is explicitly aborted by the user" : void 0
|
|
336
|
-
);
|
|
337
|
-
function registerIterableCleanup2(iterable, cleanupFn) {
|
|
338
|
-
(async () => {
|
|
339
|
-
try {
|
|
340
|
-
for await (const _ of iterable)
|
|
341
|
-
;
|
|
342
|
-
} catch {
|
|
343
|
-
} finally {
|
|
344
|
-
cleanupFn();
|
|
345
|
-
}
|
|
346
|
-
})();
|
|
347
|
-
}
|
|
348
|
-
function getRpcSubscriptionsWithSubscriptionCoalescing({
|
|
349
|
-
getDeduplicationKey,
|
|
350
|
-
rpcSubscriptions
|
|
351
|
-
}) {
|
|
352
|
-
const cache = /* @__PURE__ */ new Map();
|
|
353
|
-
return new Proxy(rpcSubscriptions, {
|
|
354
|
-
defineProperty() {
|
|
355
|
-
return false;
|
|
356
|
-
},
|
|
357
|
-
deleteProperty() {
|
|
358
|
-
return false;
|
|
359
|
-
},
|
|
360
|
-
get(target, p, receiver) {
|
|
361
|
-
const subscriptionMethod = Reflect.get(target, p, receiver);
|
|
362
|
-
if (typeof subscriptionMethod !== "function") {
|
|
363
|
-
return subscriptionMethod;
|
|
364
|
-
}
|
|
365
|
-
return function(...rawParams) {
|
|
366
|
-
const deduplicationKey = getDeduplicationKey(p, rawParams);
|
|
367
|
-
if (deduplicationKey === void 0) {
|
|
368
|
-
return subscriptionMethod(...rawParams);
|
|
369
|
-
}
|
|
370
|
-
if (cache.has(deduplicationKey)) {
|
|
371
|
-
return cache.get(deduplicationKey);
|
|
372
|
-
}
|
|
373
|
-
const iterableFactory = getCachedAbortableIterableFactory({
|
|
374
|
-
getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
|
|
375
|
-
getCacheEntryMissingError(deduplicationKey2) {
|
|
376
|
-
return new Error(
|
|
377
|
-
`Found no cache entry for subscription with deduplication key \`${deduplicationKey2?.toString()}\``
|
|
378
|
-
);
|
|
379
|
-
},
|
|
380
|
-
getCacheKeyFromInputArgs: () => deduplicationKey,
|
|
381
|
-
async onCacheHit(_iterable, _config) {
|
|
382
|
-
},
|
|
383
|
-
async onCreateIterable(abortSignal, config) {
|
|
384
|
-
const pendingSubscription2 = subscriptionMethod(
|
|
385
|
-
...rawParams
|
|
386
|
-
);
|
|
387
|
-
const iterable = await pendingSubscription2.subscribe({
|
|
388
|
-
...config,
|
|
389
|
-
abortSignal
|
|
390
|
-
});
|
|
391
|
-
registerIterableCleanup2(iterable, () => {
|
|
392
|
-
cache.delete(deduplicationKey);
|
|
393
|
-
});
|
|
394
|
-
return iterable;
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
const pendingSubscription = {
|
|
398
|
-
async subscribe(...args) {
|
|
399
|
-
const iterable = await iterableFactory(...args);
|
|
400
|
-
const { abortSignal } = args[0];
|
|
401
|
-
let abortPromise;
|
|
402
|
-
return {
|
|
403
|
-
...iterable,
|
|
404
|
-
async *[Symbol.asyncIterator]() {
|
|
405
|
-
abortPromise ||= abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN) : new Promise((_, reject) => {
|
|
406
|
-
abortSignal.addEventListener("abort", () => {
|
|
407
|
-
reject(EXPLICIT_ABORT_TOKEN);
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
try {
|
|
411
|
-
const iterator = iterable[Symbol.asyncIterator]();
|
|
412
|
-
while (true) {
|
|
413
|
-
const iteratorResult = await Promise.race([iterator.next(), abortPromise]);
|
|
414
|
-
if (iteratorResult.done) {
|
|
415
|
-
return;
|
|
416
|
-
} else {
|
|
417
|
-
yield iteratorResult.value;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
} catch (e) {
|
|
421
|
-
if (e === EXPLICIT_ABORT_TOKEN) {
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
cache.delete(deduplicationKey);
|
|
425
|
-
throw e;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
cache.set(deduplicationKey, pendingSubscription);
|
|
432
|
-
return pendingSubscription;
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// src/rpc.ts
|
|
439
|
-
function createSolanaRpc(config) {
|
|
440
|
-
const api = rpcCore.createSolanaRpcApi(DEFAULT_RPC_CONFIG);
|
|
441
|
-
return rpcTransport.createJsonRpc({
|
|
442
|
-
...config,
|
|
443
|
-
api
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
function createSolanaRpcSubscriptions(config) {
|
|
447
|
-
return functional.pipe(
|
|
448
|
-
rpcTransport.createJsonSubscriptionRpc({
|
|
449
|
-
...config,
|
|
450
|
-
api: rpcCore.createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
|
|
451
|
-
}),
|
|
452
|
-
(rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
|
|
453
|
-
getDeduplicationKey: (...args) => fastStableStringify__default.default(args),
|
|
454
|
-
rpcSubscriptions
|
|
455
|
-
})
|
|
456
|
-
);
|
|
457
|
-
}
|
|
458
|
-
function createSolanaRpcSubscriptions_UNSTABLE(config) {
|
|
459
|
-
return rpcTransport.createJsonSubscriptionRpc({
|
|
460
|
-
...config,
|
|
461
|
-
api: rpcCore.createSolanaRpcSubscriptionsApi_UNSTABLE(DEFAULT_RPC_CONFIG)
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// src/rpc-request-coalescer.ts
|
|
466
|
-
function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
|
|
467
|
-
let coalescedRequestsByDeduplicationKey;
|
|
468
|
-
return async function makeCoalescedHttpRequest(config) {
|
|
469
|
-
const { payload, signal } = config;
|
|
470
|
-
const deduplicationKey = getDeduplicationKey(payload);
|
|
471
|
-
if (deduplicationKey === void 0) {
|
|
472
|
-
return await transport(config);
|
|
473
|
-
}
|
|
474
|
-
if (!coalescedRequestsByDeduplicationKey) {
|
|
475
|
-
Promise.resolve().then(() => {
|
|
476
|
-
coalescedRequestsByDeduplicationKey = void 0;
|
|
477
|
-
});
|
|
478
|
-
coalescedRequestsByDeduplicationKey = {};
|
|
479
|
-
}
|
|
480
|
-
if (coalescedRequestsByDeduplicationKey[deduplicationKey] == null) {
|
|
481
|
-
const abortController = new AbortController();
|
|
482
|
-
const responsePromise = (async () => {
|
|
483
|
-
try {
|
|
484
|
-
return await transport({
|
|
485
|
-
...config,
|
|
486
|
-
signal: abortController.signal
|
|
487
|
-
});
|
|
488
|
-
} catch (e) {
|
|
489
|
-
if (e && typeof e === "object" && "name" in e && e.name === "AbortError") {
|
|
490
|
-
return;
|
|
491
|
-
}
|
|
492
|
-
throw e;
|
|
493
|
-
}
|
|
494
|
-
})();
|
|
495
|
-
coalescedRequestsByDeduplicationKey[deduplicationKey] = {
|
|
496
|
-
abortController,
|
|
497
|
-
numConsumers: 0,
|
|
498
|
-
responsePromise
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
const coalescedRequest = coalescedRequestsByDeduplicationKey[deduplicationKey];
|
|
502
|
-
coalescedRequest.numConsumers++;
|
|
503
|
-
if (signal) {
|
|
504
|
-
const responsePromise = coalescedRequest.responsePromise;
|
|
505
|
-
return await new Promise((resolve, reject) => {
|
|
506
|
-
const handleAbort = (e) => {
|
|
507
|
-
signal.removeEventListener("abort", handleAbort);
|
|
508
|
-
coalescedRequest.numConsumers -= 1;
|
|
509
|
-
if (coalescedRequest.numConsumers === 0) {
|
|
510
|
-
const abortController = coalescedRequest.abortController;
|
|
511
|
-
abortController.abort();
|
|
512
|
-
}
|
|
513
|
-
const abortError = new DOMException(e.target.reason, "AbortError");
|
|
514
|
-
reject(abortError);
|
|
515
|
-
};
|
|
516
|
-
signal.addEventListener("abort", handleAbort);
|
|
517
|
-
responsePromise.then(resolve).finally(() => {
|
|
518
|
-
signal.removeEventListener("abort", handleAbort);
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
} else {
|
|
522
|
-
return await coalescedRequest.responsePromise;
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
function isJsonRpcPayload(payload) {
|
|
527
|
-
if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
528
|
-
return false;
|
|
529
|
-
}
|
|
530
|
-
return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
|
|
531
|
-
}
|
|
532
|
-
function getSolanaRpcPayloadDeduplicationKey(payload) {
|
|
533
|
-
return isJsonRpcPayload(payload) ? fastStableStringify__default.default([payload.method, payload.params]) : void 0;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// src/rpc-transport.ts
|
|
537
|
-
function normalizeHeaders(headers) {
|
|
538
|
-
const out = {};
|
|
539
|
-
for (const headerName in headers) {
|
|
540
|
-
out[headerName.toLowerCase()] = headers[headerName];
|
|
541
|
-
}
|
|
542
|
-
return out;
|
|
543
|
-
}
|
|
544
|
-
function createDefaultRpcTransport(config) {
|
|
545
|
-
return functional.pipe(
|
|
546
|
-
rpcTransport.createHttpTransport({
|
|
547
|
-
...config,
|
|
548
|
-
headers: {
|
|
549
|
-
...config.headers ? normalizeHeaders(config.headers) : void 0,
|
|
550
|
-
...{
|
|
551
|
-
// Keep these headers lowercase so they will override any user-supplied headers above.
|
|
552
|
-
"solana-client": `js/${"2.0.0-development"}` ?? "UNKNOWN"
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}),
|
|
556
|
-
(transport) => getRpcTransportWithRequestCoalescing(transport, getSolanaRpcPayloadDeduplicationKey)
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
// src/rpc-websocket-autopinger.ts
|
|
561
|
-
var PING_PAYLOAD = {
|
|
562
|
-
jsonrpc: "2.0",
|
|
563
|
-
method: "ping"
|
|
564
|
-
};
|
|
565
|
-
function getWebSocketTransportWithAutoping({
|
|
566
|
-
intervalMs,
|
|
567
|
-
transport
|
|
568
|
-
}) {
|
|
569
|
-
const pingableConnections = /* @__PURE__ */ new Map();
|
|
570
|
-
return async (...args) => {
|
|
571
|
-
const connection = await transport(...args);
|
|
572
|
-
let intervalId;
|
|
573
|
-
function sendPing() {
|
|
574
|
-
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(PING_PAYLOAD);
|
|
575
|
-
}
|
|
576
|
-
function restartPingTimer() {
|
|
577
|
-
clearInterval(intervalId);
|
|
578
|
-
intervalId = setInterval(sendPing, intervalMs);
|
|
579
|
-
}
|
|
580
|
-
if (pingableConnections.has(connection) === false) {
|
|
581
|
-
pingableConnections.set(connection, {
|
|
582
|
-
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
583
|
-
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...args2) => {
|
|
584
|
-
restartPingTimer();
|
|
585
|
-
return connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...args2);
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
(async () => {
|
|
589
|
-
try {
|
|
590
|
-
for await (const _ of connection) {
|
|
591
|
-
restartPingTimer();
|
|
592
|
-
}
|
|
593
|
-
} catch {
|
|
594
|
-
} finally {
|
|
595
|
-
pingableConnections.delete(connection);
|
|
596
|
-
clearInterval(intervalId);
|
|
597
|
-
if (handleOffline) {
|
|
598
|
-
globalThis.window.removeEventListener("offline", handleOffline);
|
|
599
|
-
}
|
|
600
|
-
if (handleOnline) {
|
|
601
|
-
globalThis.window.removeEventListener("online", handleOnline);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
})();
|
|
605
|
-
if (globalThis.navigator.onLine) {
|
|
606
|
-
restartPingTimer();
|
|
607
|
-
}
|
|
608
|
-
let handleOffline;
|
|
609
|
-
let handleOnline;
|
|
610
|
-
{
|
|
611
|
-
handleOffline = () => {
|
|
612
|
-
clearInterval(intervalId);
|
|
613
|
-
};
|
|
614
|
-
handleOnline = () => {
|
|
615
|
-
sendPing();
|
|
616
|
-
restartPingTimer();
|
|
617
|
-
};
|
|
618
|
-
globalThis.window.addEventListener("offline", handleOffline);
|
|
619
|
-
globalThis.window.addEventListener("online", handleOnline);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
return pingableConnections.get(connection);
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// src/rpc-websocket-connection-sharding.ts
|
|
627
|
-
var NULL_SHARD_CACHE_KEY = Symbol(
|
|
628
|
-
__DEV__ ? "Cache key to use when there is no connection sharding strategy" : void 0
|
|
629
|
-
);
|
|
630
|
-
function getWebSocketTransportWithConnectionSharding({
|
|
631
|
-
getShard,
|
|
632
|
-
transport
|
|
633
|
-
}) {
|
|
634
|
-
return getCachedAbortableIterableFactory({
|
|
635
|
-
getAbortSignalFromInputArgs: ({ signal }) => signal,
|
|
636
|
-
getCacheEntryMissingError(shardKey) {
|
|
637
|
-
return new Error(`Found no cache entry for connection with shard key \`${shardKey?.toString()}\``);
|
|
638
|
-
},
|
|
639
|
-
getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
|
|
640
|
-
onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
|
|
641
|
-
onCreateIterable: (abortSignal, config) => transport({
|
|
642
|
-
...config,
|
|
643
|
-
signal: abortSignal
|
|
644
|
-
})
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
// src/rpc-websocket-transport.ts
|
|
649
|
-
function createDefaultRpcSubscriptionsTransport(config) {
|
|
650
|
-
const { getShard, intervalMs, ...rest } = config;
|
|
651
|
-
return functional.pipe(
|
|
652
|
-
rpcTransport.createWebSocketTransport({
|
|
653
|
-
...rest,
|
|
654
|
-
sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
|
|
655
|
-
131072
|
|
656
|
-
}),
|
|
657
|
-
(transport) => getWebSocketTransportWithAutoping({
|
|
658
|
-
intervalMs: intervalMs ?? 5e3,
|
|
659
|
-
transport
|
|
660
|
-
}),
|
|
661
|
-
(transport) => getWebSocketTransportWithConnectionSharding({
|
|
662
|
-
getShard,
|
|
663
|
-
transport
|
|
664
|
-
})
|
|
665
|
-
);
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
// src/transaction-confirmation-strategy-blockheight.ts
|
|
669
|
-
function createBlockHeightExceedencePromiseFactory({
|
|
670
|
-
rpc,
|
|
671
|
-
rpcSubscriptions
|
|
672
|
-
}) {
|
|
673
|
-
return async function getBlockHeightExceedencePromise({
|
|
674
|
-
abortSignal: callerAbortSignal,
|
|
675
|
-
commitment,
|
|
676
|
-
lastValidBlockHeight
|
|
677
|
-
}) {
|
|
678
|
-
const abortController = new AbortController();
|
|
679
|
-
const handleAbort = () => {
|
|
680
|
-
abortController.abort();
|
|
681
|
-
};
|
|
682
|
-
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
683
|
-
async function getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight() {
|
|
684
|
-
const { absoluteSlot, blockHeight } = await rpc.getEpochInfo({ commitment }).send({ abortSignal: abortController.signal });
|
|
685
|
-
return {
|
|
686
|
-
blockHeight,
|
|
687
|
-
differenceBetweenSlotHeightAndBlockHeight: absoluteSlot - blockHeight
|
|
688
|
-
};
|
|
689
|
-
}
|
|
690
|
-
try {
|
|
691
|
-
const [slotNotifications, { blockHeight, differenceBetweenSlotHeightAndBlockHeight }] = await Promise.all([
|
|
692
|
-
rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal }),
|
|
693
|
-
getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight()
|
|
694
|
-
]);
|
|
695
|
-
if (blockHeight <= lastValidBlockHeight) {
|
|
696
|
-
let lastKnownDifferenceBetweenSlotHeightAndBlockHeight = differenceBetweenSlotHeightAndBlockHeight;
|
|
697
|
-
for await (const slotNotification of slotNotifications) {
|
|
698
|
-
const { slot } = slotNotification;
|
|
699
|
-
if (slot - lastKnownDifferenceBetweenSlotHeightAndBlockHeight > lastValidBlockHeight) {
|
|
700
|
-
const {
|
|
701
|
-
blockHeight: currentBlockHeight,
|
|
702
|
-
differenceBetweenSlotHeightAndBlockHeight: currentDifferenceBetweenSlotHeightAndBlockHeight
|
|
703
|
-
} = await getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight();
|
|
704
|
-
if (currentBlockHeight > lastValidBlockHeight) {
|
|
705
|
-
break;
|
|
706
|
-
} else {
|
|
707
|
-
lastKnownDifferenceBetweenSlotHeightAndBlockHeight = currentDifferenceBetweenSlotHeightAndBlockHeight;
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
throw new Error(
|
|
713
|
-
"The network has progressed past the last block for which this transaction could have been committed."
|
|
714
|
-
);
|
|
715
|
-
} finally {
|
|
716
|
-
abortController.abort();
|
|
717
|
-
}
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
var NONCE_VALUE_OFFSET = 4 + // version(u32)
|
|
721
|
-
4 + // state(u32)
|
|
722
|
-
32;
|
|
723
|
-
function createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions) {
|
|
724
|
-
return async function getNonceInvalidationPromise({
|
|
725
|
-
abortSignal: callerAbortSignal,
|
|
726
|
-
commitment,
|
|
727
|
-
currentNonceValue,
|
|
728
|
-
nonceAccountAddress
|
|
729
|
-
}) {
|
|
730
|
-
const abortController = new AbortController();
|
|
731
|
-
function handleAbort() {
|
|
732
|
-
abortController.abort();
|
|
733
|
-
}
|
|
734
|
-
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
735
|
-
const accountNotifications = await rpcSubscriptions.accountNotifications(nonceAccountAddress, { commitment, encoding: "base64" }).subscribe({ abortSignal: abortController.signal });
|
|
736
|
-
const base58Decoder = codecs.getBase58Decoder();
|
|
737
|
-
const base64Encoder = codecs.getBase64Encoder();
|
|
738
|
-
function getNonceFromAccountData([base64EncodedBytes]) {
|
|
739
|
-
const data = base64Encoder.encode(base64EncodedBytes);
|
|
740
|
-
const nonceValueBytes = data.slice(NONCE_VALUE_OFFSET, NONCE_VALUE_OFFSET + 32);
|
|
741
|
-
return base58Decoder.decode(nonceValueBytes);
|
|
742
|
-
}
|
|
743
|
-
const nonceAccountDidAdvancePromise = (async () => {
|
|
744
|
-
for await (const accountNotification of accountNotifications) {
|
|
745
|
-
const nonceValue = getNonceFromAccountData(accountNotification.value.data);
|
|
746
|
-
if (nonceValue !== currentNonceValue) {
|
|
747
|
-
throw new Error(
|
|
748
|
-
`The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
|
|
749
|
-
);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
})();
|
|
753
|
-
const nonceIsAlreadyInvalidPromise = (async () => {
|
|
754
|
-
const { value: nonceAccount } = await rpc.getAccountInfo(nonceAccountAddress, {
|
|
755
|
-
commitment,
|
|
756
|
-
dataSlice: { length: 32, offset: NONCE_VALUE_OFFSET },
|
|
757
|
-
encoding: "base58"
|
|
758
|
-
}).send({ abortSignal: abortController.signal });
|
|
759
|
-
if (!nonceAccount) {
|
|
760
|
-
throw new Error(`No nonce account could be found at address \`${nonceAccountAddress}\`.`);
|
|
761
|
-
}
|
|
762
|
-
const nonceValue = (
|
|
763
|
-
// This works because we asked for the exact slice of data representing the nonce
|
|
764
|
-
// value, and furthermore asked for it in `base58` encoding.
|
|
765
|
-
nonceAccount.data[0]
|
|
766
|
-
);
|
|
767
|
-
if (nonceValue !== currentNonceValue) {
|
|
768
|
-
throw new Error(
|
|
769
|
-
`The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
|
|
770
|
-
);
|
|
771
|
-
} else {
|
|
772
|
-
await new Promise(() => {
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
})();
|
|
776
|
-
try {
|
|
777
|
-
return await Promise.race([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
|
|
778
|
-
} finally {
|
|
779
|
-
abortController.abort();
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
// src/transaction-confirmation.ts
|
|
785
|
-
function createDefaultDurableNonceTransactionConfirmer({
|
|
786
|
-
rpc,
|
|
787
|
-
rpcSubscriptions
|
|
788
|
-
}) {
|
|
789
|
-
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
|
|
790
|
-
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
791
|
-
rpc,
|
|
792
|
-
rpcSubscriptions
|
|
793
|
-
);
|
|
794
|
-
return async function confirmDurableNonceTransaction(config) {
|
|
795
|
-
await waitForDurableNonceTransactionConfirmation({
|
|
796
|
-
...config,
|
|
797
|
-
getNonceInvalidationPromise,
|
|
798
|
-
getRecentSignatureConfirmationPromise
|
|
799
|
-
});
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
function createDefaultRecentTransactionConfirmer({
|
|
803
|
-
rpc,
|
|
804
|
-
rpcSubscriptions
|
|
805
|
-
}) {
|
|
806
|
-
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({
|
|
807
|
-
rpc,
|
|
808
|
-
rpcSubscriptions
|
|
809
|
-
});
|
|
810
|
-
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
811
|
-
rpc,
|
|
812
|
-
rpcSubscriptions
|
|
813
|
-
);
|
|
814
|
-
return async function confirmRecentTransaction(config) {
|
|
815
|
-
await waitForRecentTransactionConfirmation({
|
|
816
|
-
...config,
|
|
817
|
-
getBlockHeightExceedencePromise,
|
|
818
|
-
getRecentSignatureConfirmationPromise
|
|
819
|
-
});
|
|
820
|
-
};
|
|
821
|
-
}
|
|
822
|
-
async function waitForDurableNonceTransactionConfirmation(config) {
|
|
823
|
-
await raceStrategies(
|
|
824
|
-
transactions.getSignatureFromTransaction(config.transaction),
|
|
825
|
-
config,
|
|
826
|
-
function getSpecificStrategiesForRace({ abortSignal, commitment, getNonceInvalidationPromise, transaction }) {
|
|
827
|
-
return [
|
|
828
|
-
getNonceInvalidationPromise({
|
|
829
|
-
abortSignal,
|
|
830
|
-
commitment,
|
|
831
|
-
currentNonceValue: transaction.lifetimeConstraint.nonce,
|
|
832
|
-
nonceAccountAddress: transaction.instructions[0].accounts[0].address
|
|
833
|
-
})
|
|
834
|
-
];
|
|
835
|
-
}
|
|
836
|
-
);
|
|
837
|
-
}
|
|
838
|
-
async function waitForRecentTransactionConfirmation(config) {
|
|
839
|
-
await raceStrategies(
|
|
840
|
-
transactions.getSignatureFromTransaction(config.transaction),
|
|
841
|
-
config,
|
|
842
|
-
function getSpecificStrategiesForRace({
|
|
843
|
-
abortSignal,
|
|
844
|
-
commitment,
|
|
845
|
-
getBlockHeightExceedencePromise,
|
|
846
|
-
transaction
|
|
847
|
-
}) {
|
|
848
|
-
return [
|
|
849
|
-
getBlockHeightExceedencePromise({
|
|
850
|
-
abortSignal,
|
|
851
|
-
commitment,
|
|
852
|
-
lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
|
|
853
|
-
})
|
|
854
|
-
];
|
|
855
|
-
}
|
|
856
|
-
);
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
// src/send-transaction.ts
|
|
860
89
|
function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
|
|
861
90
|
if (
|
|
862
91
|
// The developer has supplied no value for `preflightCommitment`.
|
|
@@ -878,7 +107,7 @@ function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, con
|
|
|
878
107
|
}
|
|
879
108
|
return config;
|
|
880
109
|
}
|
|
881
|
-
async function
|
|
110
|
+
async function sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
882
111
|
abortSignal,
|
|
883
112
|
commitment,
|
|
884
113
|
rpc,
|
|
@@ -891,41 +120,7 @@ async function sendTransaction_INTERNAL({
|
|
|
891
120
|
encoding: "base64"
|
|
892
121
|
}).send({ abortSignal });
|
|
893
122
|
}
|
|
894
|
-
function
|
|
895
|
-
rpc,
|
|
896
|
-
rpcSubscriptions
|
|
897
|
-
}) {
|
|
898
|
-
const confirmDurableNonceTransaction = createDefaultDurableNonceTransactionConfirmer({
|
|
899
|
-
rpc,
|
|
900
|
-
rpcSubscriptions
|
|
901
|
-
});
|
|
902
|
-
return async function sendDurableNonceTransaction(transaction, config) {
|
|
903
|
-
await sendAndConfirmDurableNonceTransaction({
|
|
904
|
-
...config,
|
|
905
|
-
confirmDurableNonceTransaction,
|
|
906
|
-
rpc,
|
|
907
|
-
transaction
|
|
908
|
-
});
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
function createDefaultTransactionSender({
|
|
912
|
-
rpc,
|
|
913
|
-
rpcSubscriptions
|
|
914
|
-
}) {
|
|
915
|
-
const confirmRecentTransaction = createDefaultRecentTransactionConfirmer({
|
|
916
|
-
rpc,
|
|
917
|
-
rpcSubscriptions
|
|
918
|
-
});
|
|
919
|
-
return async function sendTransaction(transaction, config) {
|
|
920
|
-
await sendAndConfirmTransaction({
|
|
921
|
-
...config,
|
|
922
|
-
confirmRecentTransaction,
|
|
923
|
-
rpc,
|
|
924
|
-
transaction
|
|
925
|
-
});
|
|
926
|
-
};
|
|
927
|
-
}
|
|
928
|
-
async function sendAndConfirmDurableNonceTransaction({
|
|
123
|
+
async function sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
929
124
|
abortSignal,
|
|
930
125
|
commitment,
|
|
931
126
|
confirmDurableNonceTransaction,
|
|
@@ -933,7 +128,7 @@ async function sendAndConfirmDurableNonceTransaction({
|
|
|
933
128
|
transaction,
|
|
934
129
|
...sendTransactionConfig
|
|
935
130
|
}) {
|
|
936
|
-
const transactionSignature = await
|
|
131
|
+
const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
937
132
|
...sendTransactionConfig,
|
|
938
133
|
abortSignal,
|
|
939
134
|
commitment,
|
|
@@ -947,7 +142,7 @@ async function sendAndConfirmDurableNonceTransaction({
|
|
|
947
142
|
});
|
|
948
143
|
return transactionSignature;
|
|
949
144
|
}
|
|
950
|
-
async function
|
|
145
|
+
async function sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
951
146
|
abortSignal,
|
|
952
147
|
commitment,
|
|
953
148
|
confirmRecentTransaction,
|
|
@@ -955,7 +150,7 @@ async function sendAndConfirmTransaction({
|
|
|
955
150
|
transaction,
|
|
956
151
|
...sendTransactionConfig
|
|
957
152
|
}) {
|
|
958
|
-
const transactionSignature = await
|
|
153
|
+
const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
959
154
|
...sendTransactionConfig,
|
|
960
155
|
abortSignal,
|
|
961
156
|
commitment,
|
|
@@ -970,25 +165,77 @@ async function sendAndConfirmTransaction({
|
|
|
970
165
|
return transactionSignature;
|
|
971
166
|
}
|
|
972
167
|
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
168
|
+
// src/send-transaction.ts
|
|
169
|
+
function sendTransactionWithoutConfirmingFactory({
|
|
170
|
+
rpc
|
|
171
|
+
}) {
|
|
172
|
+
return async function sendTransactionWithoutConfirming(transaction, config) {
|
|
173
|
+
await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
174
|
+
...config,
|
|
175
|
+
rpc,
|
|
176
|
+
transaction
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function sendAndConfirmDurableNonceTransactionFactory({
|
|
181
|
+
rpc,
|
|
182
|
+
rpcSubscriptions
|
|
183
|
+
}) {
|
|
184
|
+
const getNonceInvalidationPromise = transactionConfirmation.createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
|
|
185
|
+
const getRecentSignatureConfirmationPromise = transactionConfirmation.createRecentSignatureConfirmationPromiseFactory(
|
|
186
|
+
rpc,
|
|
187
|
+
rpcSubscriptions
|
|
188
|
+
);
|
|
189
|
+
async function confirmDurableNonceTransaction(config) {
|
|
190
|
+
await transactionConfirmation.waitForDurableNonceTransactionConfirmation({
|
|
191
|
+
...config,
|
|
192
|
+
getNonceInvalidationPromise,
|
|
193
|
+
getRecentSignatureConfirmationPromise
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return async function sendAndConfirmDurableNonceTransaction(transaction, config) {
|
|
197
|
+
await sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
198
|
+
...config,
|
|
199
|
+
confirmDurableNonceTransaction,
|
|
200
|
+
rpc,
|
|
201
|
+
transaction
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function sendAndConfirmTransactionFactory({
|
|
206
|
+
rpc,
|
|
207
|
+
rpcSubscriptions
|
|
208
|
+
}) {
|
|
209
|
+
const getBlockHeightExceedencePromise = transactionConfirmation.createBlockHeightExceedencePromiseFactory({
|
|
210
|
+
rpc,
|
|
211
|
+
rpcSubscriptions
|
|
212
|
+
});
|
|
213
|
+
const getRecentSignatureConfirmationPromise = transactionConfirmation.createRecentSignatureConfirmationPromiseFactory(
|
|
214
|
+
rpc,
|
|
215
|
+
rpcSubscriptions
|
|
216
|
+
);
|
|
217
|
+
async function confirmRecentTransaction(config) {
|
|
218
|
+
await transactionConfirmation.waitForRecentTransactionConfirmation({
|
|
219
|
+
...config,
|
|
220
|
+
getBlockHeightExceedencePromise,
|
|
221
|
+
getRecentSignatureConfirmationPromise
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
return async function sendAndConfirmTransaction(transaction, config) {
|
|
225
|
+
await sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
226
|
+
...config,
|
|
227
|
+
confirmRecentTransaction,
|
|
228
|
+
rpc,
|
|
229
|
+
transaction
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
exports.airdropFactory = airdropFactory;
|
|
986
235
|
exports.decodeTransaction = decodeTransaction;
|
|
987
|
-
exports.
|
|
988
|
-
exports.
|
|
989
|
-
exports.
|
|
990
|
-
exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
|
|
991
|
-
exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
|
|
236
|
+
exports.sendAndConfirmDurableNonceTransactionFactory = sendAndConfirmDurableNonceTransactionFactory;
|
|
237
|
+
exports.sendAndConfirmTransactionFactory = sendAndConfirmTransactionFactory;
|
|
238
|
+
exports.sendTransactionWithoutConfirmingFactory = sendTransactionWithoutConfirmingFactory;
|
|
992
239
|
Object.keys(accounts).forEach(function (k) {
|
|
993
240
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
994
241
|
enumerable: true,
|
|
@@ -1031,12 +278,24 @@ Object.keys(programs).forEach(function (k) {
|
|
|
1031
278
|
get: function () { return programs[k]; }
|
|
1032
279
|
});
|
|
1033
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
|
+
});
|
|
1034
287
|
Object.keys(rpcParsedTypes).forEach(function (k) {
|
|
1035
288
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1036
289
|
enumerable: true,
|
|
1037
290
|
get: function () { return rpcParsedTypes[k]; }
|
|
1038
291
|
});
|
|
1039
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
|
+
});
|
|
1040
299
|
Object.keys(rpcTypes).forEach(function (k) {
|
|
1041
300
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1042
301
|
enumerable: true,
|