@solana/web3.js 2.0.0-experimental.e0b865d → 2.0.0-experimental.e4483d3
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 +1155 -43
- package/dist/index.browser.cjs +447 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +431 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +2003 -809
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +431 -3
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +447 -4
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +431 -3
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +80 -36
- package/dist/types/airdrop-confirmer.d.ts +19 -0
- package/dist/types/airdrop-confirmer.d.ts.map +1 -0
- package/dist/types/airdrop.d.ts +21 -0
- package/dist/types/airdrop.d.ts.map +1 -0
- package/dist/types/cached-abortable-iterable.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/rpc-default-config.d.ts.map +1 -0
- package/dist/types/rpc-integer-overflow-error.d.ts.map +1 -0
- package/dist/types/rpc-request-coalescer.d.ts +1 -1
- package/dist/types/rpc-request-coalescer.d.ts.map +1 -0
- package/dist/types/rpc-request-deduplication.d.ts.map +1 -0
- package/dist/types/rpc-subscription-coalescer.d.ts +1 -1
- package/dist/types/rpc-subscription-coalescer.d.ts.map +1 -0
- package/dist/types/rpc-transport.d.ts +1 -2
- package/dist/types/rpc-transport.d.ts.map +1 -0
- package/dist/types/rpc-websocket-autopinger.d.ts +1 -1
- package/dist/types/rpc-websocket-autopinger.d.ts.map +1 -0
- package/dist/types/rpc-websocket-connection-sharding.d.ts +1 -1
- package/dist/types/rpc-websocket-connection-sharding.d.ts.map +1 -0
- package/dist/types/rpc-websocket-transport.d.ts +1 -2
- package/dist/types/rpc-websocket-transport.d.ts.map +1 -0
- package/dist/types/rpc.d.ts +1 -2
- package/dist/types/rpc.d.ts.map +1 -0
- package/dist/types/send-transaction.d.ts +38 -0
- package/dist/types/send-transaction.d.ts.map +1 -0
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts +9 -0
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts.map +1 -0
- package/dist/types/transaction-confirmation-strategy-nonce.d.ts +14 -0
- package/dist/types/transaction-confirmation-strategy-nonce.d.ts.map +1 -0
- package/dist/types/transaction-confirmation-strategy-racer.d.ts +14 -0
- package/dist/types/transaction-confirmation-strategy-racer.d.ts.map +1 -0
- package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts +12 -0
- package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts.map +1 -0
- package/dist/types/transaction-confirmation-strategy-timeout.d.ts +8 -0
- package/dist/types/transaction-confirmation-strategy-timeout.d.ts.map +1 -0
- package/dist/types/transaction-confirmation.d.ts +32 -0
- package/dist/types/transaction-confirmation.d.ts.map +1 -0
- package/package.json +19 -17
package/dist/index.browser.cjs
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
var addresses = require('@solana/addresses');
|
|
4
4
|
var instructions = require('@solana/instructions');
|
|
5
5
|
var keys = require('@solana/keys');
|
|
6
|
+
var rpcTypes = require('@solana/rpc-types');
|
|
6
7
|
var transactions = require('@solana/transactions');
|
|
7
8
|
var functional = require('@solana/functional');
|
|
8
9
|
var rpcCore = require('@solana/rpc-core');
|
|
9
10
|
var rpcTransport = require('@solana/rpc-transport');
|
|
10
11
|
var fastStableStringify = require('fast-stable-stringify');
|
|
12
|
+
var codecsStrings = require('@solana/codecs-strings');
|
|
11
13
|
|
|
12
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
15
|
|
|
@@ -16,8 +18,166 @@ var fastStableStringify__default = /*#__PURE__*/_interopDefault(fastStableString
|
|
|
16
18
|
// ../build-scripts/env-shim.ts
|
|
17
19
|
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
18
20
|
|
|
21
|
+
// src/transaction-confirmation-strategy-racer.ts
|
|
22
|
+
async function raceStrategies(signature, config, getSpecificStrategiesForRace) {
|
|
23
|
+
const { abortSignal: callerAbortSignal, commitment, getRecentSignatureConfirmationPromise } = config;
|
|
24
|
+
callerAbortSignal?.throwIfAborted();
|
|
25
|
+
const abortController = new AbortController();
|
|
26
|
+
if (callerAbortSignal) {
|
|
27
|
+
const handleAbort = () => {
|
|
28
|
+
abortController.abort();
|
|
29
|
+
};
|
|
30
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const specificStrategies = getSpecificStrategiesForRace({
|
|
34
|
+
...config,
|
|
35
|
+
abortSignal: abortController.signal
|
|
36
|
+
});
|
|
37
|
+
return await Promise.race([
|
|
38
|
+
getRecentSignatureConfirmationPromise({
|
|
39
|
+
abortSignal: abortController.signal,
|
|
40
|
+
commitment,
|
|
41
|
+
signature
|
|
42
|
+
}),
|
|
43
|
+
...specificStrategies
|
|
44
|
+
]);
|
|
45
|
+
} finally {
|
|
46
|
+
abortController.abort();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function createRecentSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
|
|
50
|
+
return async function getRecentSignatureConfirmationPromise({
|
|
51
|
+
abortSignal: callerAbortSignal,
|
|
52
|
+
commitment,
|
|
53
|
+
signature
|
|
54
|
+
}) {
|
|
55
|
+
const abortController = new AbortController();
|
|
56
|
+
function handleAbort() {
|
|
57
|
+
abortController.abort();
|
|
58
|
+
}
|
|
59
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
60
|
+
const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature, { commitment }).subscribe({ abortSignal: abortController.signal });
|
|
61
|
+
const signatureDidCommitPromise = (async () => {
|
|
62
|
+
for await (const signatureStatusNotification of signatureStatusNotifications) {
|
|
63
|
+
if (signatureStatusNotification.value.err) {
|
|
64
|
+
throw new Error(`The transaction with signature \`${signature}\` failed.`, {
|
|
65
|
+
cause: signatureStatusNotification.value.err
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
})();
|
|
72
|
+
const signatureStatusLookupPromise = (async () => {
|
|
73
|
+
const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature]).send({ abortSignal: abortController.signal });
|
|
74
|
+
const signatureStatus = signatureStatusResults[0];
|
|
75
|
+
if (signatureStatus && signatureStatus.confirmationStatus && rpcTypes.commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
|
|
76
|
+
return;
|
|
77
|
+
} else {
|
|
78
|
+
await new Promise(() => {
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
})();
|
|
82
|
+
try {
|
|
83
|
+
return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
|
|
84
|
+
} finally {
|
|
85
|
+
abortController.abort();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/transaction-confirmation-strategy-timeout.ts
|
|
91
|
+
async function getTimeoutPromise({ abortSignal: callerAbortSignal, commitment }) {
|
|
92
|
+
return await new Promise((_, reject) => {
|
|
93
|
+
const handleAbort = (e) => {
|
|
94
|
+
clearTimeout(timeoutId);
|
|
95
|
+
const abortError = new DOMException(e.target.reason, "AbortError");
|
|
96
|
+
reject(abortError);
|
|
97
|
+
};
|
|
98
|
+
callerAbortSignal.addEventListener("abort", handleAbort);
|
|
99
|
+
const timeoutMs = commitment === "processed" ? 3e4 : 6e4;
|
|
100
|
+
const startMs = performance.now();
|
|
101
|
+
const timeoutId = (
|
|
102
|
+
// We use `setTimeout` instead of `AbortSignal.timeout()` because we want to measure
|
|
103
|
+
// elapsed time instead of active time.
|
|
104
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
const elapsedMs = performance.now() - startMs;
|
|
107
|
+
reject(new DOMException(`Timeout elapsed after ${elapsedMs} ms`, "TimeoutError"));
|
|
108
|
+
}, timeoutMs)
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/airdrop-confirmer.ts
|
|
114
|
+
function createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
115
|
+
rpc,
|
|
116
|
+
rpcSubscriptions
|
|
117
|
+
}) {
|
|
118
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
119
|
+
rpc,
|
|
120
|
+
rpcSubscriptions
|
|
121
|
+
);
|
|
122
|
+
return async function confirmSignatureOnlyRecentTransaction(config) {
|
|
123
|
+
await waitForRecentTransactionConfirmationUntilTimeout({
|
|
124
|
+
...config,
|
|
125
|
+
getRecentSignatureConfirmationPromise,
|
|
126
|
+
getTimeoutPromise
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
async function waitForRecentTransactionConfirmationUntilTimeout(config) {
|
|
131
|
+
await raceStrategies(
|
|
132
|
+
config.signature,
|
|
133
|
+
config,
|
|
134
|
+
function getSpecificStrategiesForRace({ abortSignal, commitment, getTimeoutPromise: getTimeoutPromise2 }) {
|
|
135
|
+
return [
|
|
136
|
+
getTimeoutPromise2({
|
|
137
|
+
abortSignal,
|
|
138
|
+
commitment
|
|
139
|
+
})
|
|
140
|
+
];
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/airdrop.ts
|
|
146
|
+
function createDefaultAirdropRequester({ rpc, rpcSubscriptions }) {
|
|
147
|
+
const confirmSignatureOnlyTransaction = createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
148
|
+
rpc,
|
|
149
|
+
rpcSubscriptions
|
|
150
|
+
});
|
|
151
|
+
return async function requestAirdrop(config) {
|
|
152
|
+
return await requestAndConfirmAirdrop({
|
|
153
|
+
...config,
|
|
154
|
+
confirmSignatureOnlyTransaction,
|
|
155
|
+
rpc
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
async function requestAndConfirmAirdrop({
|
|
160
|
+
abortSignal,
|
|
161
|
+
commitment,
|
|
162
|
+
confirmSignatureOnlyTransaction,
|
|
163
|
+
lamports,
|
|
164
|
+
recipientAddress,
|
|
165
|
+
rpc
|
|
166
|
+
}) {
|
|
167
|
+
const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports, { commitment }).send({ abortSignal });
|
|
168
|
+
await confirmSignatureOnlyTransaction({
|
|
169
|
+
abortSignal,
|
|
170
|
+
commitment,
|
|
171
|
+
signature: airdropTransactionSignature
|
|
172
|
+
});
|
|
173
|
+
return airdropTransactionSignature;
|
|
174
|
+
}
|
|
175
|
+
|
|
19
176
|
// src/rpc-integer-overflow-error.ts
|
|
20
177
|
var SolanaJsonRpcIntegerOverflowError = class extends Error {
|
|
178
|
+
methodName;
|
|
179
|
+
keyPath;
|
|
180
|
+
value;
|
|
21
181
|
constructor(methodName, keyPath, value) {
|
|
22
182
|
const argPosition = (typeof keyPath[0] === "number" ? keyPath[0] : parseInt(keyPath[0], 10)) + 1;
|
|
23
183
|
let ordinal = "";
|
|
@@ -206,11 +366,11 @@ function getRpcSubscriptionsWithSubscriptionCoalescing({
|
|
|
206
366
|
return {
|
|
207
367
|
...iterable,
|
|
208
368
|
async *[Symbol.asyncIterator]() {
|
|
209
|
-
abortPromise
|
|
369
|
+
abortPromise ||= abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN) : new Promise((_, reject) => {
|
|
210
370
|
abortSignal.addEventListener("abort", () => {
|
|
211
371
|
reject(EXPLICIT_ABORT_TOKEN);
|
|
212
372
|
});
|
|
213
|
-
})
|
|
373
|
+
});
|
|
214
374
|
try {
|
|
215
375
|
const iterator = iterable[Symbol.asyncIterator]();
|
|
216
376
|
while (true) {
|
|
@@ -452,11 +612,290 @@ function createDefaultRpcSubscriptionsTransport(config) {
|
|
|
452
612
|
);
|
|
453
613
|
}
|
|
454
614
|
|
|
615
|
+
// src/transaction-confirmation-strategy-blockheight.ts
|
|
616
|
+
function createBlockHeightExceedencePromiseFactory(rpcSubscriptions) {
|
|
617
|
+
return async function getBlockHeightExceedencePromise({ abortSignal: callerAbortSignal, lastValidBlockHeight }) {
|
|
618
|
+
const abortController = new AbortController();
|
|
619
|
+
function handleAbort() {
|
|
620
|
+
abortController.abort();
|
|
621
|
+
}
|
|
622
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
623
|
+
const slotNotifications = await rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal });
|
|
624
|
+
try {
|
|
625
|
+
for await (const slotNotification of slotNotifications) {
|
|
626
|
+
if (slotNotification.slot > lastValidBlockHeight) {
|
|
627
|
+
throw new Error(
|
|
628
|
+
"The network has progressed past the last block for which this transaction could have committed."
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
} finally {
|
|
633
|
+
abortController.abort();
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
var NONCE_VALUE_OFFSET = 4 + // version(u32)
|
|
638
|
+
4 + // state(u32)
|
|
639
|
+
32;
|
|
640
|
+
function createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions) {
|
|
641
|
+
return async function getNonceInvalidationPromise({
|
|
642
|
+
abortSignal: callerAbortSignal,
|
|
643
|
+
commitment,
|
|
644
|
+
currentNonceValue,
|
|
645
|
+
nonceAccountAddress
|
|
646
|
+
}) {
|
|
647
|
+
const abortController = new AbortController();
|
|
648
|
+
function handleAbort() {
|
|
649
|
+
abortController.abort();
|
|
650
|
+
}
|
|
651
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
652
|
+
const accountNotifications = await rpcSubscriptions.accountNotifications(nonceAccountAddress, { commitment, encoding: "base64" }).subscribe({ abortSignal: abortController.signal });
|
|
653
|
+
const base58Decoder = codecsStrings.getBase58Decoder();
|
|
654
|
+
const base64Encoder = codecsStrings.getBase64Encoder();
|
|
655
|
+
function getNonceFromAccountData([base64EncodedBytes]) {
|
|
656
|
+
const data = base64Encoder.encode(base64EncodedBytes);
|
|
657
|
+
const nonceValueBytes = data.slice(NONCE_VALUE_OFFSET, NONCE_VALUE_OFFSET + 32);
|
|
658
|
+
return base58Decoder.decode(nonceValueBytes)[0];
|
|
659
|
+
}
|
|
660
|
+
const nonceAccountDidAdvancePromise = (async () => {
|
|
661
|
+
for await (const accountNotification of accountNotifications) {
|
|
662
|
+
const nonceValue = getNonceFromAccountData(accountNotification.value.data);
|
|
663
|
+
if (nonceValue !== currentNonceValue) {
|
|
664
|
+
throw new Error(
|
|
665
|
+
`The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
})();
|
|
670
|
+
const nonceIsAlreadyInvalidPromise = (async () => {
|
|
671
|
+
const { value: nonceAccount } = await rpc.getAccountInfo(nonceAccountAddress, {
|
|
672
|
+
commitment,
|
|
673
|
+
dataSlice: { length: 32, offset: NONCE_VALUE_OFFSET },
|
|
674
|
+
encoding: "base58"
|
|
675
|
+
}).send({ abortSignal: abortController.signal });
|
|
676
|
+
if (!nonceAccount) {
|
|
677
|
+
throw new Error(`No nonce account could be found at address \`${nonceAccountAddress}\`.`);
|
|
678
|
+
}
|
|
679
|
+
const nonceValue = (
|
|
680
|
+
// This works because we asked for the exact slice of data representing the nonce
|
|
681
|
+
// value, and furthermore asked for it in `base58` encoding.
|
|
682
|
+
nonceAccount.data[0]
|
|
683
|
+
);
|
|
684
|
+
if (nonceValue !== currentNonceValue) {
|
|
685
|
+
throw new Error(
|
|
686
|
+
`The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
|
|
687
|
+
);
|
|
688
|
+
} else {
|
|
689
|
+
await new Promise(() => {
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
})();
|
|
693
|
+
try {
|
|
694
|
+
return await Promise.race([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
|
|
695
|
+
} finally {
|
|
696
|
+
abortController.abort();
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// src/transaction-confirmation.ts
|
|
702
|
+
function createDefaultDurableNonceTransactionConfirmer({
|
|
703
|
+
rpc,
|
|
704
|
+
rpcSubscriptions
|
|
705
|
+
}) {
|
|
706
|
+
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
|
|
707
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
708
|
+
rpc,
|
|
709
|
+
rpcSubscriptions
|
|
710
|
+
);
|
|
711
|
+
return async function confirmDurableNonceTransaction(config) {
|
|
712
|
+
await waitForDurableNonceTransactionConfirmation({
|
|
713
|
+
...config,
|
|
714
|
+
getNonceInvalidationPromise,
|
|
715
|
+
getRecentSignatureConfirmationPromise
|
|
716
|
+
});
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
function createDefaultRecentTransactionConfirmer({
|
|
720
|
+
rpc,
|
|
721
|
+
rpcSubscriptions
|
|
722
|
+
}) {
|
|
723
|
+
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(rpcSubscriptions);
|
|
724
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
725
|
+
rpc,
|
|
726
|
+
rpcSubscriptions
|
|
727
|
+
);
|
|
728
|
+
return async function confirmRecentTransaction(config) {
|
|
729
|
+
await waitForRecentTransactionConfirmation({
|
|
730
|
+
...config,
|
|
731
|
+
getBlockHeightExceedencePromise,
|
|
732
|
+
getRecentSignatureConfirmationPromise
|
|
733
|
+
});
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
async function waitForDurableNonceTransactionConfirmation(config) {
|
|
737
|
+
await raceStrategies(
|
|
738
|
+
transactions.getSignatureFromTransaction(config.transaction),
|
|
739
|
+
config,
|
|
740
|
+
function getSpecificStrategiesForRace({ abortSignal, commitment, getNonceInvalidationPromise, transaction }) {
|
|
741
|
+
return [
|
|
742
|
+
getNonceInvalidationPromise({
|
|
743
|
+
abortSignal,
|
|
744
|
+
commitment,
|
|
745
|
+
currentNonceValue: transaction.lifetimeConstraint.nonce,
|
|
746
|
+
nonceAccountAddress: transaction.instructions[0].accounts[0].address
|
|
747
|
+
})
|
|
748
|
+
];
|
|
749
|
+
}
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
async function waitForRecentTransactionConfirmation(config) {
|
|
753
|
+
await raceStrategies(
|
|
754
|
+
transactions.getSignatureFromTransaction(config.transaction),
|
|
755
|
+
config,
|
|
756
|
+
function getSpecificStrategiesForRace({ abortSignal, getBlockHeightExceedencePromise, transaction }) {
|
|
757
|
+
return [
|
|
758
|
+
getBlockHeightExceedencePromise({
|
|
759
|
+
abortSignal,
|
|
760
|
+
lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
|
|
761
|
+
})
|
|
762
|
+
];
|
|
763
|
+
}
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// src/send-transaction.ts
|
|
768
|
+
function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
|
|
769
|
+
if (
|
|
770
|
+
// The developer has supplied no value for `preflightCommitment`.
|
|
771
|
+
!config?.preflightCommitment && // The value of `commitment` is lower than the server default of `preflightCommitment`.
|
|
772
|
+
rpcTypes.commitmentComparator(
|
|
773
|
+
commitment,
|
|
774
|
+
"finalized"
|
|
775
|
+
/* default value of `preflightCommitment` */
|
|
776
|
+
) < 0
|
|
777
|
+
) {
|
|
778
|
+
return {
|
|
779
|
+
...config,
|
|
780
|
+
// In the common case, it is unlikely that you want to simulate a transaction at
|
|
781
|
+
// `finalized` commitment when your standard of commitment for confirming the
|
|
782
|
+
// transaction is lower. Cap the simulation commitment level to the level of the
|
|
783
|
+
// confirmation commitment.
|
|
784
|
+
preflightCommitment: commitment
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
return config;
|
|
788
|
+
}
|
|
789
|
+
async function sendTransaction_INTERNAL({
|
|
790
|
+
abortSignal,
|
|
791
|
+
commitment,
|
|
792
|
+
rpc,
|
|
793
|
+
transaction,
|
|
794
|
+
...sendTransactionConfig
|
|
795
|
+
}) {
|
|
796
|
+
const base64EncodedWireTransaction = transactions.getBase64EncodedWireTransaction(transaction);
|
|
797
|
+
return await rpc.sendTransaction(base64EncodedWireTransaction, {
|
|
798
|
+
...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),
|
|
799
|
+
encoding: "base64"
|
|
800
|
+
}).send({ abortSignal });
|
|
801
|
+
}
|
|
802
|
+
function createDefaultDurableNonceTransactionSender({
|
|
803
|
+
rpc,
|
|
804
|
+
rpcSubscriptions
|
|
805
|
+
}) {
|
|
806
|
+
const confirmDurableNonceTransaction = createDefaultDurableNonceTransactionConfirmer({
|
|
807
|
+
rpc,
|
|
808
|
+
rpcSubscriptions
|
|
809
|
+
});
|
|
810
|
+
return async function sendDurableNonceTransaction(transaction, config) {
|
|
811
|
+
await sendAndConfirmDurableNonceTransaction({
|
|
812
|
+
...config,
|
|
813
|
+
confirmDurableNonceTransaction,
|
|
814
|
+
rpc,
|
|
815
|
+
transaction
|
|
816
|
+
});
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
function createDefaultTransactionSender({
|
|
820
|
+
rpc,
|
|
821
|
+
rpcSubscriptions
|
|
822
|
+
}) {
|
|
823
|
+
const confirmRecentTransaction = createDefaultRecentTransactionConfirmer({
|
|
824
|
+
rpc,
|
|
825
|
+
rpcSubscriptions
|
|
826
|
+
});
|
|
827
|
+
return async function sendTransaction(transaction, config) {
|
|
828
|
+
await sendAndConfirmTransaction({
|
|
829
|
+
...config,
|
|
830
|
+
confirmRecentTransaction,
|
|
831
|
+
rpc,
|
|
832
|
+
transaction
|
|
833
|
+
});
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
async function sendAndConfirmDurableNonceTransaction({
|
|
837
|
+
abortSignal,
|
|
838
|
+
commitment,
|
|
839
|
+
confirmDurableNonceTransaction,
|
|
840
|
+
rpc,
|
|
841
|
+
transaction,
|
|
842
|
+
...sendTransactionConfig
|
|
843
|
+
}) {
|
|
844
|
+
const transactionSignature = await sendTransaction_INTERNAL({
|
|
845
|
+
...sendTransactionConfig,
|
|
846
|
+
abortSignal,
|
|
847
|
+
commitment,
|
|
848
|
+
rpc,
|
|
849
|
+
transaction
|
|
850
|
+
});
|
|
851
|
+
await confirmDurableNonceTransaction({
|
|
852
|
+
abortSignal,
|
|
853
|
+
commitment,
|
|
854
|
+
transaction
|
|
855
|
+
});
|
|
856
|
+
return transactionSignature;
|
|
857
|
+
}
|
|
858
|
+
async function sendAndConfirmTransaction({
|
|
859
|
+
abortSignal,
|
|
860
|
+
commitment,
|
|
861
|
+
confirmRecentTransaction,
|
|
862
|
+
rpc,
|
|
863
|
+
transaction,
|
|
864
|
+
...sendTransactionConfig
|
|
865
|
+
}) {
|
|
866
|
+
const transactionSignature = await sendTransaction_INTERNAL({
|
|
867
|
+
...sendTransactionConfig,
|
|
868
|
+
abortSignal,
|
|
869
|
+
commitment,
|
|
870
|
+
rpc,
|
|
871
|
+
transaction
|
|
872
|
+
});
|
|
873
|
+
await confirmRecentTransaction({
|
|
874
|
+
abortSignal,
|
|
875
|
+
commitment,
|
|
876
|
+
transaction
|
|
877
|
+
});
|
|
878
|
+
return transactionSignature;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
exports.createBlockHeightExceedencePromiseFactory = createBlockHeightExceedencePromiseFactory;
|
|
882
|
+
exports.createDefaultAirdropRequester = createDefaultAirdropRequester;
|
|
883
|
+
exports.createDefaultDurableNonceTransactionConfirmer = createDefaultDurableNonceTransactionConfirmer;
|
|
884
|
+
exports.createDefaultDurableNonceTransactionSender = createDefaultDurableNonceTransactionSender;
|
|
885
|
+
exports.createDefaultRecentTransactionConfirmer = createDefaultRecentTransactionConfirmer;
|
|
455
886
|
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
|
456
887
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
888
|
+
exports.createDefaultTransactionSender = createDefaultTransactionSender;
|
|
889
|
+
exports.createNonceInvalidationPromiseFactory = createNonceInvalidationPromiseFactory;
|
|
890
|
+
exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureConfirmationPromiseFactory;
|
|
457
891
|
exports.createSolanaRpc = createSolanaRpc;
|
|
458
892
|
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
459
893
|
exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
|
|
894
|
+
exports.requestAndConfirmAirdrop = requestAndConfirmAirdrop;
|
|
895
|
+
exports.sendAndConfirmDurableNonceTransaction = sendAndConfirmDurableNonceTransaction;
|
|
896
|
+
exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
|
|
897
|
+
exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
|
|
898
|
+
exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
|
|
460
899
|
Object.keys(addresses).forEach(function (k) {
|
|
461
900
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
462
901
|
enumerable: true,
|
|
@@ -475,6 +914,12 @@ Object.keys(keys).forEach(function (k) {
|
|
|
475
914
|
get: function () { return keys[k]; }
|
|
476
915
|
});
|
|
477
916
|
});
|
|
917
|
+
Object.keys(rpcTypes).forEach(function (k) {
|
|
918
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
919
|
+
enumerable: true,
|
|
920
|
+
get: function () { return rpcTypes[k]; }
|
|
921
|
+
});
|
|
922
|
+
});
|
|
478
923
|
Object.keys(transactions).forEach(function (k) {
|
|
479
924
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
480
925
|
enumerable: true,
|