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