@solana/web3.js 2.0.0-experimental.e0b865d → 2.0.0-experimental.e15a66f
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/LICENSE +1 -1
- package/README.md +1153 -43
- package/dist/index.browser.cjs +260 -427
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +205 -419
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +4865 -1992
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +205 -408
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +260 -416
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +205 -408
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +278 -36
- 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 +12 -0
- package/dist/types/airdrop.d.ts.map +1 -0
- 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 -3
- package/dist/types/index.d.ts.map +1 -0
- 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 +23 -0
- package/dist/types/send-transaction.d.ts.map +1 -0
- package/package.json +27 -41
- package/dist/types/cached-abortable-iterable.d.ts +0 -11
- package/dist/types/rpc-default-config.d.ts +0 -3
- package/dist/types/rpc-integer-overflow-error.d.ts +0 -8
- package/dist/types/rpc-request-coalescer.d.ts +0 -5
- package/dist/types/rpc-request-deduplication.d.ts +0 -2
- package/dist/types/rpc-subscription-coalescer.d.ts +0 -10
- package/dist/types/rpc-transport.d.ts +0 -4
- package/dist/types/rpc-websocket-autopinger.d.ts +0 -8
- package/dist/types/rpc-websocket-connection-sharding.d.ts +0 -13
- package/dist/types/rpc-websocket-transport.d.ts +0 -13
- package/dist/types/rpc.d.ts +0 -7
package/dist/index.node.js
CHANGED
|
@@ -1,440 +1,237 @@
|
|
|
1
|
+
import { fetchJsonParsedAccounts, assertAccountsDecoded, assertAccountsExist } from '@solana/accounts';
|
|
2
|
+
export * from '@solana/accounts';
|
|
1
3
|
export * from '@solana/addresses';
|
|
4
|
+
export * from '@solana/codecs';
|
|
5
|
+
export * from '@solana/functional';
|
|
2
6
|
export * from '@solana/instructions';
|
|
3
7
|
export * from '@solana/keys';
|
|
8
|
+
export * from '@solana/programs';
|
|
9
|
+
export * from '@solana/rpc';
|
|
10
|
+
export * from '@solana/rpc-parsed-types';
|
|
11
|
+
export * from '@solana/rpc-subscriptions';
|
|
12
|
+
import { commitmentComparator } from '@solana/rpc-types';
|
|
13
|
+
export * from '@solana/rpc-types';
|
|
14
|
+
export * from '@solana/signers';
|
|
15
|
+
import { getCompiledTransactionDecoder, decompileTransaction, getBase64EncodedWireTransaction } from '@solana/transactions';
|
|
4
16
|
export * from '@solana/transactions';
|
|
5
|
-
import {
|
|
6
|
-
import { createSolanaRpcApi, createSolanaRpcSubscriptionsApi, createSolanaRpcSubscriptionsApi_UNSTABLE } from '@solana/rpc-core';
|
|
7
|
-
import { createJsonRpc, createJsonSubscriptionRpc, createHttpTransport, createWebSocketTransport } from '@solana/rpc-transport';
|
|
8
|
-
import fastStableStringify from 'fast-stable-stringify';
|
|
17
|
+
import { createRecentSignatureConfirmationPromiseFactory, createNonceInvalidationPromiseFactory, createBlockHeightExceedencePromiseFactory, waitForRecentTransactionConfirmationUntilTimeout, getTimeoutPromise, waitForDurableNonceTransactionConfirmation, waitForRecentTransactionConfirmation } from '@solana/transaction-confirmation';
|
|
9
18
|
|
|
10
|
-
//
|
|
11
|
-
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
19
|
+
// src/index.ts
|
|
12
20
|
|
|
13
|
-
// src/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
super(
|
|
31
|
-
`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\`.`
|
|
32
|
-
);
|
|
33
|
-
this.keyPath = keyPath;
|
|
34
|
-
this.methodName = methodName;
|
|
35
|
-
this.value = value;
|
|
36
|
-
}
|
|
37
|
-
get name() {
|
|
38
|
-
return "SolanaJsonRpcIntegerOverflowError";
|
|
39
|
-
}
|
|
40
|
-
};
|
|
21
|
+
// src/airdrop-internal.ts
|
|
22
|
+
async function requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
23
|
+
abortSignal,
|
|
24
|
+
commitment,
|
|
25
|
+
confirmSignatureOnlyTransaction,
|
|
26
|
+
lamports,
|
|
27
|
+
recipientAddress,
|
|
28
|
+
rpc
|
|
29
|
+
}) {
|
|
30
|
+
const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports, { commitment }).send({ abortSignal });
|
|
31
|
+
await confirmSignatureOnlyTransaction({
|
|
32
|
+
abortSignal,
|
|
33
|
+
commitment,
|
|
34
|
+
signature: airdropTransactionSignature
|
|
35
|
+
});
|
|
36
|
+
return airdropTransactionSignature;
|
|
37
|
+
}
|
|
41
38
|
|
|
42
|
-
// src/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
// src/airdrop.ts
|
|
40
|
+
function airdropFactory({ rpc, rpcSubscriptions }) {
|
|
41
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
42
|
+
rpc,
|
|
43
|
+
rpcSubscriptions
|
|
44
|
+
);
|
|
45
|
+
async function confirmSignatureOnlyTransaction(config) {
|
|
46
|
+
await waitForRecentTransactionConfirmationUntilTimeout({
|
|
47
|
+
...config,
|
|
48
|
+
getRecentSignatureConfirmationPromise,
|
|
49
|
+
getTimeoutPromise
|
|
50
|
+
});
|
|
46
51
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
;
|
|
55
|
-
} catch {
|
|
56
|
-
} finally {
|
|
57
|
-
cleanupFn();
|
|
58
|
-
}
|
|
59
|
-
})();
|
|
52
|
+
return async function airdrop(config) {
|
|
53
|
+
return await requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
54
|
+
...config,
|
|
55
|
+
confirmSignatureOnlyTransaction,
|
|
56
|
+
rpc
|
|
57
|
+
});
|
|
58
|
+
};
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return currentCacheEntry;
|
|
75
|
-
}
|
|
76
|
-
return async (...args) => {
|
|
77
|
-
const cacheKey = getCacheKeyFromInputArgs(...args);
|
|
78
|
-
const signal = getAbortSignalFromInputArgs(...args);
|
|
79
|
-
if (cacheKey === void 0) {
|
|
80
|
-
return await onCreateIterable(signal, ...args);
|
|
81
|
-
}
|
|
82
|
-
const cleanup = () => {
|
|
83
|
-
cache.delete(cacheKey);
|
|
84
|
-
signal.removeEventListener("abort", handleAbort);
|
|
60
|
+
var compiledTransactionDecoder = void 0;
|
|
61
|
+
async function fetchLookupTables(lookupTableAddresses, rpc, config) {
|
|
62
|
+
const fetchedLookupTables = await fetchJsonParsedAccounts(
|
|
63
|
+
rpc,
|
|
64
|
+
lookupTableAddresses,
|
|
65
|
+
config
|
|
66
|
+
);
|
|
67
|
+
assertAccountsDecoded(fetchedLookupTables);
|
|
68
|
+
assertAccountsExist(fetchedLookupTables);
|
|
69
|
+
return fetchedLookupTables.reduce((acc, lookup) => {
|
|
70
|
+
return {
|
|
71
|
+
...acc,
|
|
72
|
+
[lookup.address]: lookup.data.addresses
|
|
85
73
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
74
|
+
}, {});
|
|
75
|
+
}
|
|
76
|
+
async function decodeTransaction(encodedTransaction, rpc, config) {
|
|
77
|
+
const { lastValidBlockHeight, ...fetchAccountsConfig } = config ?? {};
|
|
78
|
+
if (!compiledTransactionDecoder)
|
|
79
|
+
compiledTransactionDecoder = getCompiledTransactionDecoder();
|
|
80
|
+
const compiledTransaction = compiledTransactionDecoder.decode(encodedTransaction);
|
|
81
|
+
const { compiledMessage } = compiledTransaction;
|
|
82
|
+
const lookupTables = "addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups !== void 0 && compiledMessage.addressTableLookups.length > 0 ? compiledMessage.addressTableLookups : [];
|
|
83
|
+
const lookupTableAddresses = lookupTables.map((l) => l.lookupTableAddress);
|
|
84
|
+
const fetchedLookupTables = lookupTableAddresses.length > 0 ? await fetchLookupTables(lookupTableAddresses, rpc, fetchAccountsConfig) : {};
|
|
85
|
+
return decompileTransaction(compiledTransaction, {
|
|
86
|
+
addressesByLookupTableAddress: fetchedLookupTables,
|
|
87
|
+
lastValidBlockHeight
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
|
|
91
|
+
if (
|
|
92
|
+
// The developer has supplied no value for `preflightCommitment`.
|
|
93
|
+
!config?.preflightCommitment && // The value of `commitment` is lower than the server default of `preflightCommitment`.
|
|
94
|
+
commitmentComparator(
|
|
95
|
+
commitment,
|
|
96
|
+
"finalized"
|
|
97
|
+
/* default value of `preflightCommitment` */
|
|
98
|
+
) < 0
|
|
99
|
+
) {
|
|
100
|
+
return {
|
|
101
|
+
...config,
|
|
102
|
+
// In the common case, it is unlikely that you want to simulate a transaction at
|
|
103
|
+
// `finalized` commitment when your standard of commitment for confirming the
|
|
104
|
+
// transaction is lower. Cap the simulation commitment level to the level of the
|
|
105
|
+
// confirmation commitment.
|
|
106
|
+
preflightCommitment: commitment
|
|
99
107
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const cacheEntry = cache.get(cacheKey);
|
|
103
|
-
if (!cacheEntry) {
|
|
104
|
-
const singletonAbortController = new AbortController();
|
|
105
|
-
const newIterablePromise = onCreateIterable(singletonAbortController.signal, ...args);
|
|
106
|
-
const newCacheEntry = {
|
|
107
|
-
abortController: singletonAbortController,
|
|
108
|
-
iterable: newIterablePromise,
|
|
109
|
-
purgeScheduled: false,
|
|
110
|
-
referenceCount: 1
|
|
111
|
-
};
|
|
112
|
-
cache.set(cacheKey, newCacheEntry);
|
|
113
|
-
const newIterable = await newIterablePromise;
|
|
114
|
-
registerIterableCleanup(newIterable, cleanup);
|
|
115
|
-
newCacheEntry.iterable = newIterable;
|
|
116
|
-
return newIterable;
|
|
117
|
-
} else {
|
|
118
|
-
cacheEntry.referenceCount++;
|
|
119
|
-
const iterableOrIterablePromise = cacheEntry.iterable;
|
|
120
|
-
const cachedIterable = "then" in iterableOrIterablePromise ? await iterableOrIterablePromise : iterableOrIterablePromise;
|
|
121
|
-
await onCacheHit(cachedIterable, ...args);
|
|
122
|
-
return cachedIterable;
|
|
123
|
-
}
|
|
124
|
-
} catch (e) {
|
|
125
|
-
cleanup();
|
|
126
|
-
throw e;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
108
|
+
}
|
|
109
|
+
return config;
|
|
129
110
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
cleanupFn();
|
|
143
|
-
}
|
|
144
|
-
})();
|
|
111
|
+
async function sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
112
|
+
abortSignal,
|
|
113
|
+
commitment,
|
|
114
|
+
rpc,
|
|
115
|
+
transaction,
|
|
116
|
+
...sendTransactionConfig
|
|
117
|
+
}) {
|
|
118
|
+
const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);
|
|
119
|
+
return await rpc.sendTransaction(base64EncodedWireTransaction, {
|
|
120
|
+
...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),
|
|
121
|
+
encoding: "base64"
|
|
122
|
+
}).send({ abortSignal });
|
|
145
123
|
}
|
|
146
|
-
function
|
|
147
|
-
|
|
148
|
-
|
|
124
|
+
async function sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
125
|
+
abortSignal,
|
|
126
|
+
commitment,
|
|
127
|
+
confirmDurableNonceTransaction,
|
|
128
|
+
rpc,
|
|
129
|
+
transaction,
|
|
130
|
+
...sendTransactionConfig
|
|
149
131
|
}) {
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return false;
|
|
157
|
-
},
|
|
158
|
-
get(target, p, receiver) {
|
|
159
|
-
const subscriptionMethod = Reflect.get(target, p, receiver);
|
|
160
|
-
if (typeof subscriptionMethod !== "function") {
|
|
161
|
-
return subscriptionMethod;
|
|
162
|
-
}
|
|
163
|
-
return function(...rawParams) {
|
|
164
|
-
const deduplicationKey = getDeduplicationKey(p, rawParams);
|
|
165
|
-
if (deduplicationKey === void 0) {
|
|
166
|
-
return subscriptionMethod(...rawParams);
|
|
167
|
-
}
|
|
168
|
-
if (cache.has(deduplicationKey)) {
|
|
169
|
-
return cache.get(deduplicationKey);
|
|
170
|
-
}
|
|
171
|
-
const iterableFactory = getCachedAbortableIterableFactory({
|
|
172
|
-
getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
|
|
173
|
-
getCacheEntryMissingError(deduplicationKey2) {
|
|
174
|
-
return new Error(
|
|
175
|
-
`Found no cache entry for subscription with deduplication key \`${deduplicationKey2?.toString()}\``
|
|
176
|
-
);
|
|
177
|
-
},
|
|
178
|
-
getCacheKeyFromInputArgs: () => deduplicationKey,
|
|
179
|
-
async onCacheHit(_iterable, _config) {
|
|
180
|
-
},
|
|
181
|
-
async onCreateIterable(abortSignal, config) {
|
|
182
|
-
const pendingSubscription2 = subscriptionMethod(
|
|
183
|
-
...rawParams
|
|
184
|
-
);
|
|
185
|
-
const iterable = await pendingSubscription2.subscribe({
|
|
186
|
-
...config,
|
|
187
|
-
abortSignal
|
|
188
|
-
});
|
|
189
|
-
registerIterableCleanup2(iterable, () => {
|
|
190
|
-
cache.delete(deduplicationKey);
|
|
191
|
-
});
|
|
192
|
-
return iterable;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
const pendingSubscription = {
|
|
196
|
-
async subscribe(...args) {
|
|
197
|
-
const iterable = await iterableFactory(...args);
|
|
198
|
-
const { abortSignal } = args[0];
|
|
199
|
-
let abortPromise;
|
|
200
|
-
return {
|
|
201
|
-
...iterable,
|
|
202
|
-
async *[Symbol.asyncIterator]() {
|
|
203
|
-
abortPromise || (abortPromise = abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN) : new Promise((_, reject) => {
|
|
204
|
-
abortSignal.addEventListener("abort", () => {
|
|
205
|
-
reject(EXPLICIT_ABORT_TOKEN);
|
|
206
|
-
});
|
|
207
|
-
}));
|
|
208
|
-
try {
|
|
209
|
-
const iterator = iterable[Symbol.asyncIterator]();
|
|
210
|
-
while (true) {
|
|
211
|
-
const iteratorResult = await Promise.race([iterator.next(), abortPromise]);
|
|
212
|
-
if (iteratorResult.done) {
|
|
213
|
-
return;
|
|
214
|
-
} else {
|
|
215
|
-
yield iteratorResult.value;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
} catch (e) {
|
|
219
|
-
if (e === EXPLICIT_ABORT_TOKEN) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
cache.delete(deduplicationKey);
|
|
223
|
-
throw e;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
cache.set(deduplicationKey, pendingSubscription);
|
|
230
|
-
return pendingSubscription;
|
|
231
|
-
};
|
|
232
|
-
}
|
|
132
|
+
const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
133
|
+
...sendTransactionConfig,
|
|
134
|
+
abortSignal,
|
|
135
|
+
commitment,
|
|
136
|
+
rpc,
|
|
137
|
+
transaction
|
|
233
138
|
});
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return createJsonRpc({
|
|
239
|
-
...config,
|
|
240
|
-
api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
|
|
139
|
+
await confirmDurableNonceTransaction({
|
|
140
|
+
abortSignal,
|
|
141
|
+
commitment,
|
|
142
|
+
transaction
|
|
241
143
|
});
|
|
144
|
+
return transactionSignature;
|
|
242
145
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
146
|
+
async function sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
147
|
+
abortSignal,
|
|
148
|
+
commitment,
|
|
149
|
+
confirmRecentTransaction,
|
|
150
|
+
rpc,
|
|
151
|
+
transaction,
|
|
152
|
+
...sendTransactionConfig
|
|
153
|
+
}) {
|
|
154
|
+
const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
155
|
+
...sendTransactionConfig,
|
|
156
|
+
abortSignal,
|
|
157
|
+
commitment,
|
|
158
|
+
rpc,
|
|
159
|
+
transaction
|
|
160
|
+
});
|
|
161
|
+
await confirmRecentTransaction({
|
|
162
|
+
abortSignal,
|
|
163
|
+
commitment,
|
|
164
|
+
transaction
|
|
259
165
|
});
|
|
166
|
+
return transactionSignature;
|
|
260
167
|
}
|
|
261
168
|
|
|
262
|
-
// src/
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
Promise.resolve().then(() => {
|
|
273
|
-
coalescedRequestsByDeduplicationKey = void 0;
|
|
274
|
-
});
|
|
275
|
-
coalescedRequestsByDeduplicationKey = {};
|
|
276
|
-
}
|
|
277
|
-
if (coalescedRequestsByDeduplicationKey[deduplicationKey] == null) {
|
|
278
|
-
const abortController = new AbortController();
|
|
279
|
-
coalescedRequestsByDeduplicationKey[deduplicationKey] = {
|
|
280
|
-
abortController,
|
|
281
|
-
numConsumers: 0,
|
|
282
|
-
responsePromise: transport({
|
|
283
|
-
...config,
|
|
284
|
-
signal: abortController.signal
|
|
285
|
-
})
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
const coalescedRequest = coalescedRequestsByDeduplicationKey[deduplicationKey];
|
|
289
|
-
coalescedRequest.numConsumers++;
|
|
290
|
-
if (signal) {
|
|
291
|
-
const responsePromise = coalescedRequest.responsePromise;
|
|
292
|
-
return await new Promise((resolve, reject) => {
|
|
293
|
-
const handleAbort = (e) => {
|
|
294
|
-
signal.removeEventListener("abort", handleAbort);
|
|
295
|
-
coalescedRequest.numConsumers -= 1;
|
|
296
|
-
if (coalescedRequest.numConsumers === 0) {
|
|
297
|
-
const abortController = coalescedRequest.abortController;
|
|
298
|
-
abortController.abort();
|
|
299
|
-
}
|
|
300
|
-
const abortError = new DOMException(e.target.reason, "AbortError");
|
|
301
|
-
reject(abortError);
|
|
302
|
-
};
|
|
303
|
-
signal.addEventListener("abort", handleAbort);
|
|
304
|
-
responsePromise.then(resolve).finally(() => {
|
|
305
|
-
signal.removeEventListener("abort", handleAbort);
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
} else {
|
|
309
|
-
return await coalescedRequest.responsePromise;
|
|
310
|
-
}
|
|
169
|
+
// src/send-transaction.ts
|
|
170
|
+
function sendTransactionWithoutConfirmingFactory({
|
|
171
|
+
rpc
|
|
172
|
+
}) {
|
|
173
|
+
return async function sendTransactionWithoutConfirming(transaction, config) {
|
|
174
|
+
await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
175
|
+
...config,
|
|
176
|
+
rpc,
|
|
177
|
+
transaction
|
|
178
|
+
});
|
|
311
179
|
};
|
|
312
180
|
}
|
|
313
|
-
function
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
181
|
+
function sendAndConfirmDurableNonceTransactionFactory({
|
|
182
|
+
rpc,
|
|
183
|
+
rpcSubscriptions
|
|
184
|
+
}) {
|
|
185
|
+
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
|
|
186
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
187
|
+
rpc,
|
|
188
|
+
rpcSubscriptions
|
|
189
|
+
);
|
|
190
|
+
async function confirmDurableNonceTransaction(config) {
|
|
191
|
+
await waitForDurableNonceTransactionConfirmation({
|
|
192
|
+
...config,
|
|
193
|
+
getNonceInvalidationPromise,
|
|
194
|
+
getRecentSignatureConfirmationPromise
|
|
195
|
+
});
|
|
328
196
|
}
|
|
329
|
-
return
|
|
330
|
-
|
|
331
|
-
function createDefaultRpcTransport(config) {
|
|
332
|
-
return pipe(
|
|
333
|
-
createHttpTransport({
|
|
197
|
+
return async function sendAndConfirmDurableNonceTransaction(transaction, config) {
|
|
198
|
+
await sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
334
199
|
...config,
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
"solana-client": `js/${"2.0.0-development"}` ?? "UNKNOWN"
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}),
|
|
343
|
-
(transport) => getRpcTransportWithRequestCoalescing(transport, getSolanaRpcPayloadDeduplicationKey)
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// src/rpc-websocket-autopinger.ts
|
|
348
|
-
var PING_PAYLOAD = {
|
|
349
|
-
jsonrpc: "2.0",
|
|
350
|
-
method: "ping"
|
|
351
|
-
};
|
|
352
|
-
function getWebSocketTransportWithAutoping({ intervalMs, transport }) {
|
|
353
|
-
const pingableConnections = /* @__PURE__ */ new Map();
|
|
354
|
-
return async (...args) => {
|
|
355
|
-
const connection = await transport(...args);
|
|
356
|
-
let intervalId;
|
|
357
|
-
function sendPing() {
|
|
358
|
-
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(PING_PAYLOAD);
|
|
359
|
-
}
|
|
360
|
-
function restartPingTimer() {
|
|
361
|
-
clearInterval(intervalId);
|
|
362
|
-
intervalId = setInterval(sendPing, intervalMs);
|
|
363
|
-
}
|
|
364
|
-
if (pingableConnections.has(connection) === false) {
|
|
365
|
-
pingableConnections.set(connection, {
|
|
366
|
-
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
367
|
-
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...args2) => {
|
|
368
|
-
restartPingTimer();
|
|
369
|
-
return connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...args2);
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
(async () => {
|
|
373
|
-
try {
|
|
374
|
-
for await (const _ of connection) {
|
|
375
|
-
restartPingTimer();
|
|
376
|
-
}
|
|
377
|
-
} catch {
|
|
378
|
-
} finally {
|
|
379
|
-
pingableConnections.delete(connection);
|
|
380
|
-
clearInterval(intervalId);
|
|
381
|
-
if (handleOffline) {
|
|
382
|
-
globalThis.window.removeEventListener("offline", handleOffline);
|
|
383
|
-
}
|
|
384
|
-
if (handleOnline) {
|
|
385
|
-
globalThis.window.removeEventListener("online", handleOnline);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
})();
|
|
389
|
-
{
|
|
390
|
-
restartPingTimer();
|
|
391
|
-
}
|
|
392
|
-
let handleOffline;
|
|
393
|
-
let handleOnline;
|
|
394
|
-
}
|
|
395
|
-
return pingableConnections.get(connection);
|
|
200
|
+
confirmDurableNonceTransaction,
|
|
201
|
+
rpc,
|
|
202
|
+
transaction
|
|
203
|
+
});
|
|
396
204
|
};
|
|
397
205
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
getAbortSignalFromInputArgs: ({ signal }) => signal,
|
|
406
|
-
getCacheEntryMissingError(shardKey) {
|
|
407
|
-
return new Error(`Found no cache entry for connection with shard key \`${shardKey?.toString()}\``);
|
|
408
|
-
},
|
|
409
|
-
getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
|
|
410
|
-
onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
|
|
411
|
-
onCreateIterable: (abortSignal, config) => transport({
|
|
412
|
-
...config,
|
|
413
|
-
signal: abortSignal
|
|
414
|
-
})
|
|
206
|
+
function sendAndConfirmTransactionFactory({
|
|
207
|
+
rpc,
|
|
208
|
+
rpcSubscriptions
|
|
209
|
+
}) {
|
|
210
|
+
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({
|
|
211
|
+
rpc,
|
|
212
|
+
rpcSubscriptions
|
|
415
213
|
});
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
function createDefaultRpcSubscriptionsTransport(config) {
|
|
420
|
-
const { getShard, intervalMs, ...rest } = config;
|
|
421
|
-
return pipe(
|
|
422
|
-
createWebSocketTransport({
|
|
423
|
-
...rest,
|
|
424
|
-
sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
|
|
425
|
-
131072
|
|
426
|
-
}),
|
|
427
|
-
(transport) => getWebSocketTransportWithAutoping({
|
|
428
|
-
intervalMs: intervalMs ?? 5e3,
|
|
429
|
-
transport
|
|
430
|
-
}),
|
|
431
|
-
(transport) => getWebSocketTransportWithConnectionSharding({
|
|
432
|
-
getShard,
|
|
433
|
-
transport
|
|
434
|
-
})
|
|
214
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
215
|
+
rpc,
|
|
216
|
+
rpcSubscriptions
|
|
435
217
|
);
|
|
218
|
+
async function confirmRecentTransaction(config) {
|
|
219
|
+
await waitForRecentTransactionConfirmation({
|
|
220
|
+
...config,
|
|
221
|
+
getBlockHeightExceedencePromise,
|
|
222
|
+
getRecentSignatureConfirmationPromise
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return async function sendAndConfirmTransaction(transaction, config) {
|
|
226
|
+
await sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({
|
|
227
|
+
...config,
|
|
228
|
+
confirmRecentTransaction,
|
|
229
|
+
rpc,
|
|
230
|
+
transaction
|
|
231
|
+
});
|
|
232
|
+
};
|
|
436
233
|
}
|
|
437
234
|
|
|
438
|
-
export {
|
|
235
|
+
export { airdropFactory, decodeTransaction, sendAndConfirmDurableNonceTransactionFactory, sendAndConfirmTransactionFactory, sendTransactionWithoutConfirmingFactory };
|
|
439
236
|
//# sourceMappingURL=out.js.map
|
|
440
237
|
//# sourceMappingURL=index.node.js.map
|