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