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