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