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