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