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