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