@solana/web3.js 2.0.0-experimental.ba46ce1 → 2.0.0-experimental.ba9b4c7
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 +4 -4
- package/dist/index.browser.cjs +436 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +424 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +2214 -819
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +424 -2
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +436 -1
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +424 -2
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +59 -35
- package/dist/types/airdrop-confirmer.d.ts +20 -0
- package/dist/types/airdrop.d.ts +23 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/rpc.d.ts +2 -1
- package/dist/types/send-transaction.d.ts +44 -0
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts +10 -0
- package/dist/types/transaction-confirmation-strategy-nonce.d.ts +15 -0
- package/dist/types/transaction-confirmation-strategy-racer.d.ts +10 -0
- package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts +13 -0
- package/dist/types/transaction-confirmation-strategy-timeout.d.ts +8 -0
- package/dist/types/transaction-confirmation.d.ts +37 -0
- package/package.json +17 -16
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -77,19 +77,19 @@ Unimplemented.
|
|
|
77
77
|
|
|
78
78
|
Client applications primarily deal with addresses and public keys in the form of base58-encoded strings. Addresses and public keys returned from the RPC API conform to the type `Base58EncodedAddress`. You can use a value of that type wherever a base58-encoded address or key is expected.
|
|
79
79
|
|
|
80
|
-
From time to time you might acquire a string, that you expect to validate as an address, from an untrusted network API or user input. To assert that such an arbitrary string is a base58-encoded address, use the `
|
|
80
|
+
From time to time you might acquire a string, that you expect to validate as an address, from an untrusted network API or user input. To assert that such an arbitrary string is a base58-encoded address, use the `assertIsAddress` function.
|
|
81
81
|
|
|
82
82
|
```ts
|
|
83
|
-
import {
|
|
83
|
+
import { assertIsAddress } from '@solana/web3.js';
|
|
84
84
|
|
|
85
85
|
// Imagine a function that fetches an account's balance when a user submits a form.
|
|
86
|
-
function handleSubmit() {
|
|
86
|
+
async function handleSubmit() {
|
|
87
87
|
// We know only that what the user typed conforms to the `string` type.
|
|
88
88
|
const address: string = accountAddressInput.value;
|
|
89
89
|
try {
|
|
90
90
|
// If this type assertion function doesn't throw, then
|
|
91
91
|
// Typescript will upcast `address` to `Base58EncodedAddress`.
|
|
92
|
-
|
|
92
|
+
assertIsAddress(address);
|
|
93
93
|
// At this point, `address` is a `Base58EncodedAddress` that can be used with the RPC.
|
|
94
94
|
const balanceInLamports = await rpc.getBalance(address).send();
|
|
95
95
|
} catch (e) {
|
package/dist/index.browser.cjs
CHANGED
|
@@ -4,10 +4,11 @@ var addresses = require('@solana/addresses');
|
|
|
4
4
|
var instructions = require('@solana/instructions');
|
|
5
5
|
var keys = require('@solana/keys');
|
|
6
6
|
var transactions = require('@solana/transactions');
|
|
7
|
-
var functional = require('@solana/functional');
|
|
8
7
|
var rpcCore = require('@solana/rpc-core');
|
|
8
|
+
var functional = require('@solana/functional');
|
|
9
9
|
var rpcTransport = require('@solana/rpc-transport');
|
|
10
10
|
var fastStableStringify = require('fast-stable-stringify');
|
|
11
|
+
var umiSerializers = require('@metaplex-foundation/umi-serializers');
|
|
11
12
|
|
|
12
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
14
|
|
|
@@ -16,6 +17,159 @@ var fastStableStringify__default = /*#__PURE__*/_interopDefault(fastStableString
|
|
|
16
17
|
// ../build-scripts/env-shim.ts
|
|
17
18
|
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
18
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
|
+
function handleAbort() {
|
|
26
|
+
abortController.abort();
|
|
27
|
+
}
|
|
28
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
29
|
+
try {
|
|
30
|
+
const specificStrategies = getSpecificStrategiesForRace({
|
|
31
|
+
...config,
|
|
32
|
+
abortSignal: abortController.signal
|
|
33
|
+
});
|
|
34
|
+
return await Promise.race([
|
|
35
|
+
getRecentSignatureConfirmationPromise({
|
|
36
|
+
abortSignal: abortController.signal,
|
|
37
|
+
commitment,
|
|
38
|
+
signature
|
|
39
|
+
}),
|
|
40
|
+
...specificStrategies
|
|
41
|
+
]);
|
|
42
|
+
} finally {
|
|
43
|
+
abortController.abort();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function createRecentSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
|
|
47
|
+
return async function getRecentSignatureConfirmationPromise({
|
|
48
|
+
abortSignal: callerAbortSignal,
|
|
49
|
+
commitment,
|
|
50
|
+
signature
|
|
51
|
+
}) {
|
|
52
|
+
const abortController = new AbortController();
|
|
53
|
+
function handleAbort() {
|
|
54
|
+
abortController.abort();
|
|
55
|
+
}
|
|
56
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
57
|
+
const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature, { commitment }).subscribe({ abortSignal: abortController.signal });
|
|
58
|
+
const signatureDidCommitPromise = (async () => {
|
|
59
|
+
for await (const signatureStatusNotification of signatureStatusNotifications) {
|
|
60
|
+
if (signatureStatusNotification.value.err) {
|
|
61
|
+
throw new Error(`The transaction with signature \`${signature}\` failed.`, {
|
|
62
|
+
cause: signatureStatusNotification.value.err
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
})();
|
|
69
|
+
const signatureStatusLookupPromise = (async () => {
|
|
70
|
+
const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature]).send({ abortSignal: abortController.signal });
|
|
71
|
+
const signatureStatus = signatureStatusResults[0];
|
|
72
|
+
if (signatureStatus && signatureStatus.confirmationStatus && rpcCore.commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
|
|
73
|
+
return;
|
|
74
|
+
} else {
|
|
75
|
+
await new Promise(() => {
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
})();
|
|
79
|
+
try {
|
|
80
|
+
return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
|
|
81
|
+
} finally {
|
|
82
|
+
abortController.abort();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/transaction-confirmation-strategy-timeout.ts
|
|
88
|
+
async function getTimeoutPromise({ abortSignal: callerAbortSignal, commitment }) {
|
|
89
|
+
return await new Promise((_, reject) => {
|
|
90
|
+
const handleAbort = (e) => {
|
|
91
|
+
clearTimeout(timeoutId);
|
|
92
|
+
const abortError = new DOMException(e.target.reason, "AbortError");
|
|
93
|
+
reject(abortError);
|
|
94
|
+
};
|
|
95
|
+
callerAbortSignal.addEventListener("abort", handleAbort);
|
|
96
|
+
const timeoutMs = commitment === "processed" ? 3e4 : 6e4;
|
|
97
|
+
const startMs = performance.now();
|
|
98
|
+
const timeoutId = (
|
|
99
|
+
// We use `setTimeout` instead of `AbortSignal.timeout()` because we want to measure
|
|
100
|
+
// elapsed time instead of active time.
|
|
101
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
|
|
102
|
+
setTimeout(() => {
|
|
103
|
+
const elapsedMs = performance.now() - startMs;
|
|
104
|
+
reject(new DOMException(`Timeout elapsed after ${elapsedMs} ms`, "TimeoutError"));
|
|
105
|
+
}, timeoutMs)
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/airdrop-confirmer.ts
|
|
111
|
+
function createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
112
|
+
rpc,
|
|
113
|
+
rpcSubscriptions
|
|
114
|
+
}) {
|
|
115
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
116
|
+
rpc,
|
|
117
|
+
rpcSubscriptions
|
|
118
|
+
);
|
|
119
|
+
return async function confirmSignatureOnlyRecentTransaction(config) {
|
|
120
|
+
await waitForRecentTransactionConfirmationUntilTimeout({
|
|
121
|
+
...config,
|
|
122
|
+
getRecentSignatureConfirmationPromise,
|
|
123
|
+
getTimeoutPromise
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
async function waitForRecentTransactionConfirmationUntilTimeout(config) {
|
|
128
|
+
await raceStrategies(
|
|
129
|
+
config.signature,
|
|
130
|
+
config,
|
|
131
|
+
function getSpecificStrategiesForRace({ abortSignal, commitment, getTimeoutPromise: getTimeoutPromise2 }) {
|
|
132
|
+
return [
|
|
133
|
+
getTimeoutPromise2({
|
|
134
|
+
abortSignal,
|
|
135
|
+
commitment
|
|
136
|
+
})
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/airdrop.ts
|
|
143
|
+
function createDefaultAirdropRequester({ rpc, rpcSubscriptions }) {
|
|
144
|
+
const confirmSignatureOnlyTransaction = createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
145
|
+
rpc,
|
|
146
|
+
rpcSubscriptions
|
|
147
|
+
});
|
|
148
|
+
return async function requestAirdrop(config) {
|
|
149
|
+
return await requestAndConfirmAirdrop({
|
|
150
|
+
...config,
|
|
151
|
+
confirmSignatureOnlyTransaction,
|
|
152
|
+
rpc
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async function requestAndConfirmAirdrop({
|
|
157
|
+
abortSignal,
|
|
158
|
+
commitment,
|
|
159
|
+
confirmSignatureOnlyTransaction,
|
|
160
|
+
lamports,
|
|
161
|
+
recipientAddress,
|
|
162
|
+
rpc
|
|
163
|
+
}) {
|
|
164
|
+
const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports, { commitment }).send({ abortSignal });
|
|
165
|
+
await confirmSignatureOnlyTransaction({
|
|
166
|
+
abortSignal,
|
|
167
|
+
commitment,
|
|
168
|
+
signature: airdropTransactionSignature
|
|
169
|
+
});
|
|
170
|
+
return airdropTransactionSignature;
|
|
171
|
+
}
|
|
172
|
+
|
|
19
173
|
// src/rpc-integer-overflow-error.ts
|
|
20
174
|
var SolanaJsonRpcIntegerOverflowError = class extends Error {
|
|
21
175
|
constructor(methodName, keyPath, value) {
|
|
@@ -258,6 +412,12 @@ function createSolanaRpcSubscriptions(config) {
|
|
|
258
412
|
})
|
|
259
413
|
);
|
|
260
414
|
}
|
|
415
|
+
function createSolanaRpcSubscriptions_UNSTABLE(config) {
|
|
416
|
+
return rpcTransport.createJsonSubscriptionRpc({
|
|
417
|
+
...config,
|
|
418
|
+
api: rpcCore.createSolanaRpcSubscriptionsApi_UNSTABLE(DEFAULT_RPC_CONFIG)
|
|
419
|
+
});
|
|
420
|
+
}
|
|
261
421
|
|
|
262
422
|
// src/rpc-request-coalescer.ts
|
|
263
423
|
function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
|
|
@@ -446,10 +606,285 @@ function createDefaultRpcSubscriptionsTransport(config) {
|
|
|
446
606
|
);
|
|
447
607
|
}
|
|
448
608
|
|
|
609
|
+
// src/transaction-confirmation-strategy-blockheight.ts
|
|
610
|
+
function createBlockHeightExceedencePromiseFactory(rpcSubscriptions) {
|
|
611
|
+
return async function getBlockHeightExceedencePromise({ abortSignal: callerAbortSignal, lastValidBlockHeight }) {
|
|
612
|
+
const abortController = new AbortController();
|
|
613
|
+
function handleAbort() {
|
|
614
|
+
abortController.abort();
|
|
615
|
+
}
|
|
616
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
617
|
+
const slotNotifications = await rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal });
|
|
618
|
+
try {
|
|
619
|
+
for await (const slotNotification of slotNotifications) {
|
|
620
|
+
if (slotNotification.slot > lastValidBlockHeight) {
|
|
621
|
+
throw new Error(
|
|
622
|
+
"The network has progressed past the last block for which this transaction could have committed."
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
} finally {
|
|
627
|
+
abortController.abort();
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
var NONCE_VALUE_OFFSET = 4 + // version(u32)
|
|
632
|
+
4 + // state(u32)
|
|
633
|
+
32;
|
|
634
|
+
function createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions) {
|
|
635
|
+
return async function getNonceInvalidationPromise({
|
|
636
|
+
abortSignal: callerAbortSignal,
|
|
637
|
+
commitment,
|
|
638
|
+
currentNonceValue,
|
|
639
|
+
nonceAccountAddress
|
|
640
|
+
}) {
|
|
641
|
+
const abortController = new AbortController();
|
|
642
|
+
function handleAbort() {
|
|
643
|
+
abortController.abort();
|
|
644
|
+
}
|
|
645
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
646
|
+
const accountNotifications = await rpcSubscriptions.accountNotifications(nonceAccountAddress, { commitment, encoding: "base64" }).subscribe({ abortSignal: abortController.signal });
|
|
647
|
+
function getNonceFromAccountData([base64EncodedBytes]) {
|
|
648
|
+
const data = umiSerializers.base64.serialize(base64EncodedBytes);
|
|
649
|
+
const nonceValueBytes = data.slice(NONCE_VALUE_OFFSET, NONCE_VALUE_OFFSET + 32);
|
|
650
|
+
return umiSerializers.base58.deserialize(nonceValueBytes)[0];
|
|
651
|
+
}
|
|
652
|
+
const nonceAccountDidAdvancePromise = (async () => {
|
|
653
|
+
for await (const accountNotification of accountNotifications) {
|
|
654
|
+
const nonceValue = getNonceFromAccountData(accountNotification.value.data);
|
|
655
|
+
if (nonceValue !== currentNonceValue) {
|
|
656
|
+
throw new Error(
|
|
657
|
+
`The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
})();
|
|
662
|
+
const nonceIsAlreadyInvalidPromise = (async () => {
|
|
663
|
+
const { value: nonceAccount } = await rpc.getAccountInfo(nonceAccountAddress, {
|
|
664
|
+
commitment,
|
|
665
|
+
dataSlice: { length: 32, offset: NONCE_VALUE_OFFSET },
|
|
666
|
+
encoding: "base58"
|
|
667
|
+
}).send({ abortSignal: abortController.signal });
|
|
668
|
+
if (!nonceAccount) {
|
|
669
|
+
throw new Error(`No nonce account could be found at address \`${nonceAccountAddress}\`.`);
|
|
670
|
+
}
|
|
671
|
+
const nonceValue = (
|
|
672
|
+
// This works because we asked for the exact slice of data representing the nonce
|
|
673
|
+
// value, and furthermore asked for it in `base58` encoding.
|
|
674
|
+
nonceAccount.data[0]
|
|
675
|
+
);
|
|
676
|
+
if (nonceValue !== currentNonceValue) {
|
|
677
|
+
throw new Error(
|
|
678
|
+
`The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
|
|
679
|
+
);
|
|
680
|
+
} else {
|
|
681
|
+
await new Promise(() => {
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
})();
|
|
685
|
+
try {
|
|
686
|
+
return await Promise.race([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
|
|
687
|
+
} finally {
|
|
688
|
+
abortController.abort();
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// src/transaction-confirmation.ts
|
|
694
|
+
function createDefaultDurableNonceTransactionConfirmer({
|
|
695
|
+
rpc,
|
|
696
|
+
rpcSubscriptions
|
|
697
|
+
}) {
|
|
698
|
+
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
|
|
699
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
700
|
+
rpc,
|
|
701
|
+
rpcSubscriptions
|
|
702
|
+
);
|
|
703
|
+
return async function confirmDurableNonceTransaction(config) {
|
|
704
|
+
await waitForDurableNonceTransactionConfirmation({
|
|
705
|
+
...config,
|
|
706
|
+
getNonceInvalidationPromise,
|
|
707
|
+
getRecentSignatureConfirmationPromise
|
|
708
|
+
});
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function createDefaultRecentTransactionConfirmer({
|
|
712
|
+
rpc,
|
|
713
|
+
rpcSubscriptions
|
|
714
|
+
}) {
|
|
715
|
+
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(rpcSubscriptions);
|
|
716
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
717
|
+
rpc,
|
|
718
|
+
rpcSubscriptions
|
|
719
|
+
);
|
|
720
|
+
return async function confirmRecentTransaction(config) {
|
|
721
|
+
await waitForRecentTransactionConfirmation({
|
|
722
|
+
...config,
|
|
723
|
+
getBlockHeightExceedencePromise,
|
|
724
|
+
getRecentSignatureConfirmationPromise
|
|
725
|
+
});
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
async function waitForDurableNonceTransactionConfirmation(config) {
|
|
729
|
+
await raceStrategies(
|
|
730
|
+
transactions.getSignatureFromTransaction(config.transaction),
|
|
731
|
+
config,
|
|
732
|
+
function getSpecificStrategiesForRace({ abortSignal, commitment, getNonceInvalidationPromise, transaction }) {
|
|
733
|
+
return [
|
|
734
|
+
getNonceInvalidationPromise({
|
|
735
|
+
abortSignal,
|
|
736
|
+
commitment,
|
|
737
|
+
currentNonceValue: transaction.lifetimeConstraint.nonce,
|
|
738
|
+
nonceAccountAddress: transaction.instructions[0].accounts[0].address
|
|
739
|
+
})
|
|
740
|
+
];
|
|
741
|
+
}
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
async function waitForRecentTransactionConfirmation(config) {
|
|
745
|
+
await raceStrategies(
|
|
746
|
+
transactions.getSignatureFromTransaction(config.transaction),
|
|
747
|
+
config,
|
|
748
|
+
function getSpecificStrategiesForRace({ abortSignal, getBlockHeightExceedencePromise, transaction }) {
|
|
749
|
+
return [
|
|
750
|
+
getBlockHeightExceedencePromise({
|
|
751
|
+
abortSignal,
|
|
752
|
+
lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
|
|
753
|
+
})
|
|
754
|
+
];
|
|
755
|
+
}
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// src/send-transaction.ts
|
|
760
|
+
function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
|
|
761
|
+
if (
|
|
762
|
+
// The developer has supplied no value for `preflightCommitment`.
|
|
763
|
+
!config?.preflightCommitment && // The value of `commitment` is lower than the server default of `preflightCommitment`.
|
|
764
|
+
rpcCore.commitmentComparator(
|
|
765
|
+
commitment,
|
|
766
|
+
"finalized"
|
|
767
|
+
/* default value of `preflightCommitment` */
|
|
768
|
+
) < 0
|
|
769
|
+
) {
|
|
770
|
+
return {
|
|
771
|
+
...config,
|
|
772
|
+
// In the common case, it is unlikely that you want to simulate a transaction at
|
|
773
|
+
// `finalized` commitment when your standard of commitment for confirming the
|
|
774
|
+
// transaction is lower. Cap the simulation commitment level to the level of the
|
|
775
|
+
// confirmation commitment.
|
|
776
|
+
preflightCommitment: commitment
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
return config;
|
|
780
|
+
}
|
|
781
|
+
async function sendTransaction_INTERNAL({
|
|
782
|
+
abortSignal,
|
|
783
|
+
commitment,
|
|
784
|
+
rpc,
|
|
785
|
+
transaction,
|
|
786
|
+
sendTransactionConfig
|
|
787
|
+
}) {
|
|
788
|
+
const base64EncodedWireTransaction = transactions.getBase64EncodedWireTransaction(transaction);
|
|
789
|
+
return await rpc.sendTransaction(base64EncodedWireTransaction, {
|
|
790
|
+
...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),
|
|
791
|
+
encoding: "base64"
|
|
792
|
+
}).send({ abortSignal });
|
|
793
|
+
}
|
|
794
|
+
function createDefaultDurableNonceTransactionSender({
|
|
795
|
+
rpc,
|
|
796
|
+
rpcSubscriptions
|
|
797
|
+
}) {
|
|
798
|
+
const confirmDurableNonceTransaction = createDefaultDurableNonceTransactionConfirmer({
|
|
799
|
+
rpc,
|
|
800
|
+
rpcSubscriptions
|
|
801
|
+
});
|
|
802
|
+
return async function sendDurableNonceTransaction(transaction, config) {
|
|
803
|
+
await sendAndConfirmDurableNonceTransaction({
|
|
804
|
+
...config,
|
|
805
|
+
confirmDurableNonceTransaction,
|
|
806
|
+
rpc,
|
|
807
|
+
transaction
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
function createDefaultTransactionSender({ rpc, rpcSubscriptions }) {
|
|
812
|
+
const confirmRecentTransaction = createDefaultRecentTransactionConfirmer({
|
|
813
|
+
rpc,
|
|
814
|
+
rpcSubscriptions
|
|
815
|
+
});
|
|
816
|
+
return async function sendTransaction(transaction, config) {
|
|
817
|
+
await sendAndConfirmTransaction({
|
|
818
|
+
...config,
|
|
819
|
+
confirmRecentTransaction,
|
|
820
|
+
rpc,
|
|
821
|
+
transaction
|
|
822
|
+
});
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
async function sendAndConfirmDurableNonceTransaction({
|
|
826
|
+
abortSignal,
|
|
827
|
+
commitment,
|
|
828
|
+
confirmDurableNonceTransaction,
|
|
829
|
+
rpc,
|
|
830
|
+
transaction,
|
|
831
|
+
...sendTransactionConfig
|
|
832
|
+
}) {
|
|
833
|
+
const transactionSignature = await sendTransaction_INTERNAL({
|
|
834
|
+
abortSignal,
|
|
835
|
+
commitment,
|
|
836
|
+
rpc,
|
|
837
|
+
sendTransactionConfig,
|
|
838
|
+
transaction
|
|
839
|
+
});
|
|
840
|
+
await confirmDurableNonceTransaction({
|
|
841
|
+
abortSignal,
|
|
842
|
+
commitment,
|
|
843
|
+
transaction
|
|
844
|
+
});
|
|
845
|
+
return transactionSignature;
|
|
846
|
+
}
|
|
847
|
+
async function sendAndConfirmTransaction({
|
|
848
|
+
abortSignal,
|
|
849
|
+
commitment,
|
|
850
|
+
confirmRecentTransaction,
|
|
851
|
+
rpc,
|
|
852
|
+
transaction,
|
|
853
|
+
...sendTransactionConfig
|
|
854
|
+
}) {
|
|
855
|
+
const transactionSignature = await sendTransaction_INTERNAL({
|
|
856
|
+
abortSignal,
|
|
857
|
+
commitment,
|
|
858
|
+
rpc,
|
|
859
|
+
sendTransactionConfig,
|
|
860
|
+
transaction
|
|
861
|
+
});
|
|
862
|
+
await confirmRecentTransaction({
|
|
863
|
+
abortSignal,
|
|
864
|
+
commitment,
|
|
865
|
+
transaction
|
|
866
|
+
});
|
|
867
|
+
return transactionSignature;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
exports.createBlockHeightExceedencePromiseFactory = createBlockHeightExceedencePromiseFactory;
|
|
871
|
+
exports.createDefaultAirdropRequester = createDefaultAirdropRequester;
|
|
872
|
+
exports.createDefaultDurableNonceTransactionConfirmer = createDefaultDurableNonceTransactionConfirmer;
|
|
873
|
+
exports.createDefaultDurableNonceTransactionSender = createDefaultDurableNonceTransactionSender;
|
|
874
|
+
exports.createDefaultRecentTransactionConfirmer = createDefaultRecentTransactionConfirmer;
|
|
449
875
|
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
|
450
876
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
877
|
+
exports.createDefaultTransactionSender = createDefaultTransactionSender;
|
|
878
|
+
exports.createNonceInvalidationPromiseFactory = createNonceInvalidationPromiseFactory;
|
|
879
|
+
exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureConfirmationPromiseFactory;
|
|
451
880
|
exports.createSolanaRpc = createSolanaRpc;
|
|
452
881
|
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
882
|
+
exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
|
|
883
|
+
exports.requestAndConfirmAirdrop = requestAndConfirmAirdrop;
|
|
884
|
+
exports.sendAndConfirmDurableNonceTransaction = sendAndConfirmDurableNonceTransaction;
|
|
885
|
+
exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
|
|
886
|
+
exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
|
|
887
|
+
exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
|
|
453
888
|
Object.keys(addresses).forEach(function (k) {
|
|
454
889
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
455
890
|
enumerable: true,
|