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