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