@solana/web3.js 2.0.0-experimental.e72afd8 → 2.0.0-experimental.e9c1b10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -23
- package/dist/index.browser.cjs +158 -33
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +124 -33
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +4046 -2468
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +124 -33
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +158 -33
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +124 -33
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +270 -80
- package/dist/types/airdrop-confirmer.d.ts +3 -3
- package/dist/types/airdrop-confirmer.d.ts.map +1 -1
- package/dist/types/airdrop.d.ts +2 -2
- package/dist/types/airdrop.d.ts.map +1 -1
- package/dist/types/decode-transaction.d.ts +10 -0
- package/dist/types/decode-transaction.d.ts.map +1 -0
- package/dist/types/index.d.ts +16 -9
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rpc-default-config.d.ts.map +1 -1
- package/dist/types/rpc-integer-overflow-error.d.ts +3 -2
- package/dist/types/rpc-integer-overflow-error.d.ts.map +1 -1
- package/dist/types/rpc-request-coalescer.d.ts.map +1 -1
- package/dist/types/rpc-subscription-coalescer.d.ts +1 -1
- package/dist/types/rpc-subscription-coalescer.d.ts.map +1 -1
- package/dist/types/rpc.d.ts +2 -1
- package/dist/types/rpc.d.ts.map +1 -1
- package/dist/types/send-transaction.d.ts +2 -3
- package/dist/types/send-transaction.d.ts.map +1 -1
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts +9 -4
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts.map +1 -1
- package/dist/types/transaction-confirmation-strategy-nonce.d.ts +1 -2
- package/dist/types/transaction-confirmation-strategy-nonce.d.ts.map +1 -1
- package/dist/types/transaction-confirmation-strategy-racer.d.ts +1 -1
- package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts +1 -2
- package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts.map +1 -1
- package/dist/types/transaction-confirmation.d.ts +6 -6
- package/dist/types/transaction-confirmation.d.ts.map +1 -1
- package/package.json +21 -16
package/dist/index.node.cjs
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
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 rpcParsedTypes = require('@solana/rpc-parsed-types');
|
|
6
11
|
var rpcTypes = require('@solana/rpc-types');
|
|
12
|
+
var signers = require('@solana/signers');
|
|
7
13
|
var transactions = require('@solana/transactions');
|
|
8
|
-
var functional = require('@solana/functional');
|
|
9
14
|
var rpcCore = require('@solana/rpc-core');
|
|
10
15
|
var rpcTransport = require('@solana/rpc-transport');
|
|
11
16
|
var fastStableStringify = require('fast-stable-stringify');
|
|
12
|
-
var codecsStrings = require('@solana/codecs-strings');
|
|
13
17
|
|
|
14
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
19
|
|
|
@@ -172,6 +176,36 @@ async function requestAndConfirmAirdrop({
|
|
|
172
176
|
});
|
|
173
177
|
return airdropTransactionSignature;
|
|
174
178
|
}
|
|
179
|
+
var compiledTransactionDecoder = void 0;
|
|
180
|
+
async function fetchLookupTables(lookupTableAddresses, rpc, config) {
|
|
181
|
+
const fetchedLookupTables = await accounts.fetchJsonParsedAccounts(
|
|
182
|
+
rpc,
|
|
183
|
+
lookupTableAddresses,
|
|
184
|
+
config
|
|
185
|
+
);
|
|
186
|
+
accounts.assertAccountsDecoded(fetchedLookupTables);
|
|
187
|
+
accounts.assertAccountsExist(fetchedLookupTables);
|
|
188
|
+
return fetchedLookupTables.reduce((acc, lookup) => {
|
|
189
|
+
return {
|
|
190
|
+
...acc,
|
|
191
|
+
[lookup.address]: lookup.data.addresses
|
|
192
|
+
};
|
|
193
|
+
}, {});
|
|
194
|
+
}
|
|
195
|
+
async function decodeTransaction(encodedTransaction, rpc, config) {
|
|
196
|
+
const { lastValidBlockHeight, ...fetchAccountsConfig } = config ?? {};
|
|
197
|
+
if (!compiledTransactionDecoder)
|
|
198
|
+
compiledTransactionDecoder = transactions.getCompiledTransactionDecoder();
|
|
199
|
+
const compiledTransaction = compiledTransactionDecoder.decode(encodedTransaction);
|
|
200
|
+
const { compiledMessage } = compiledTransaction;
|
|
201
|
+
const lookupTables = "addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups !== void 0 && compiledMessage.addressTableLookups.length > 0 ? compiledMessage.addressTableLookups : [];
|
|
202
|
+
const lookupTableAddresses = lookupTables.map((l) => l.lookupTableAddress);
|
|
203
|
+
const fetchedLookupTables = lookupTableAddresses.length > 0 ? await fetchLookupTables(lookupTableAddresses, rpc, fetchAccountsConfig) : {};
|
|
204
|
+
return transactions.decompileTransaction(compiledTransaction, {
|
|
205
|
+
addressesByLookupTableAddress: fetchedLookupTables,
|
|
206
|
+
lastValidBlockHeight
|
|
207
|
+
});
|
|
208
|
+
}
|
|
175
209
|
|
|
176
210
|
// src/rpc-integer-overflow-error.ts
|
|
177
211
|
var SolanaJsonRpcIntegerOverflowError = class extends Error {
|
|
@@ -179,22 +213,26 @@ var SolanaJsonRpcIntegerOverflowError = class extends Error {
|
|
|
179
213
|
keyPath;
|
|
180
214
|
value;
|
|
181
215
|
constructor(methodName, keyPath, value) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
216
|
+
let argumentLabel = "";
|
|
217
|
+
if (typeof keyPath[0] === "number") {
|
|
218
|
+
const argPosition = keyPath[0] + 1;
|
|
219
|
+
const lastDigit = argPosition % 10;
|
|
220
|
+
const lastTwoDigits = argPosition % 100;
|
|
221
|
+
if (lastDigit == 1 && lastTwoDigits != 11) {
|
|
222
|
+
argumentLabel = argPosition + "st";
|
|
223
|
+
} else if (lastDigit == 2 && lastTwoDigits != 12) {
|
|
224
|
+
argumentLabel = argPosition + "nd";
|
|
225
|
+
} else if (lastDigit == 3 && lastTwoDigits != 13) {
|
|
226
|
+
argumentLabel = argPosition + "rd";
|
|
227
|
+
} else {
|
|
228
|
+
argumentLabel = argPosition + "th";
|
|
229
|
+
}
|
|
192
230
|
} else {
|
|
193
|
-
|
|
231
|
+
argumentLabel = `\`${keyPath[0].toString()}\``;
|
|
194
232
|
}
|
|
195
233
|
const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : null;
|
|
196
234
|
super(
|
|
197
|
-
`The ${
|
|
235
|
+
`The ${argumentLabel} 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\`.`
|
|
198
236
|
);
|
|
199
237
|
this.keyPath = keyPath;
|
|
200
238
|
this.methodName = methodName;
|
|
@@ -207,6 +245,7 @@ var SolanaJsonRpcIntegerOverflowError = class extends Error {
|
|
|
207
245
|
|
|
208
246
|
// src/rpc-default-config.ts
|
|
209
247
|
var DEFAULT_RPC_CONFIG = {
|
|
248
|
+
defaultCommitment: "confirmed",
|
|
210
249
|
onIntegerOverflow(methodName, keyPath, value) {
|
|
211
250
|
throw new SolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
|
|
212
251
|
}
|
|
@@ -442,13 +481,23 @@ function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
|
|
|
442
481
|
}
|
|
443
482
|
if (coalescedRequestsByDeduplicationKey[deduplicationKey] == null) {
|
|
444
483
|
const abortController = new AbortController();
|
|
484
|
+
const responsePromise = (async () => {
|
|
485
|
+
try {
|
|
486
|
+
return await transport({
|
|
487
|
+
...config,
|
|
488
|
+
signal: abortController.signal
|
|
489
|
+
});
|
|
490
|
+
} catch (e) {
|
|
491
|
+
if (e && typeof e === "object" && "name" in e && e.name === "AbortError") {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
throw e;
|
|
495
|
+
}
|
|
496
|
+
})();
|
|
445
497
|
coalescedRequestsByDeduplicationKey[deduplicationKey] = {
|
|
446
498
|
abortController,
|
|
447
499
|
numConsumers: 0,
|
|
448
|
-
responsePromise
|
|
449
|
-
...config,
|
|
450
|
-
signal: abortController.signal
|
|
451
|
-
})
|
|
500
|
+
responsePromise
|
|
452
501
|
};
|
|
453
502
|
}
|
|
454
503
|
const coalescedRequest = coalescedRequestsByDeduplicationKey[deduplicationKey];
|
|
@@ -602,22 +651,52 @@ function createDefaultRpcSubscriptionsTransport(config) {
|
|
|
602
651
|
}
|
|
603
652
|
|
|
604
653
|
// src/transaction-confirmation-strategy-blockheight.ts
|
|
605
|
-
function createBlockHeightExceedencePromiseFactory(
|
|
606
|
-
|
|
654
|
+
function createBlockHeightExceedencePromiseFactory({
|
|
655
|
+
rpc,
|
|
656
|
+
rpcSubscriptions
|
|
657
|
+
}) {
|
|
658
|
+
return async function getBlockHeightExceedencePromise({
|
|
659
|
+
abortSignal: callerAbortSignal,
|
|
660
|
+
commitment,
|
|
661
|
+
lastValidBlockHeight
|
|
662
|
+
}) {
|
|
607
663
|
const abortController = new AbortController();
|
|
608
|
-
|
|
664
|
+
const handleAbort = () => {
|
|
609
665
|
abortController.abort();
|
|
610
|
-
}
|
|
666
|
+
};
|
|
611
667
|
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
612
|
-
|
|
668
|
+
async function getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight() {
|
|
669
|
+
const { absoluteSlot, blockHeight } = await rpc.getEpochInfo({ commitment }).send({ abortSignal: abortController.signal });
|
|
670
|
+
return {
|
|
671
|
+
blockHeight,
|
|
672
|
+
differenceBetweenSlotHeightAndBlockHeight: absoluteSlot - blockHeight
|
|
673
|
+
};
|
|
674
|
+
}
|
|
613
675
|
try {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
676
|
+
const [slotNotifications, { blockHeight, differenceBetweenSlotHeightAndBlockHeight }] = await Promise.all([
|
|
677
|
+
rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal }),
|
|
678
|
+
getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight()
|
|
679
|
+
]);
|
|
680
|
+
if (blockHeight <= lastValidBlockHeight) {
|
|
681
|
+
let lastKnownDifferenceBetweenSlotHeightAndBlockHeight = differenceBetweenSlotHeightAndBlockHeight;
|
|
682
|
+
for await (const slotNotification of slotNotifications) {
|
|
683
|
+
const { slot } = slotNotification;
|
|
684
|
+
if (slot - lastKnownDifferenceBetweenSlotHeightAndBlockHeight > lastValidBlockHeight) {
|
|
685
|
+
const {
|
|
686
|
+
blockHeight: currentBlockHeight,
|
|
687
|
+
differenceBetweenSlotHeightAndBlockHeight: currentDifferenceBetweenSlotHeightAndBlockHeight
|
|
688
|
+
} = await getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight();
|
|
689
|
+
if (currentBlockHeight > lastValidBlockHeight) {
|
|
690
|
+
break;
|
|
691
|
+
} else {
|
|
692
|
+
lastKnownDifferenceBetweenSlotHeightAndBlockHeight = currentDifferenceBetweenSlotHeightAndBlockHeight;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
619
695
|
}
|
|
620
696
|
}
|
|
697
|
+
throw new Error(
|
|
698
|
+
"The network has progressed past the last block for which this transaction could have been committed."
|
|
699
|
+
);
|
|
621
700
|
} finally {
|
|
622
701
|
abortController.abort();
|
|
623
702
|
}
|
|
@@ -639,12 +718,12 @@ function createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions) {
|
|
|
639
718
|
}
|
|
640
719
|
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
641
720
|
const accountNotifications = await rpcSubscriptions.accountNotifications(nonceAccountAddress, { commitment, encoding: "base64" }).subscribe({ abortSignal: abortController.signal });
|
|
642
|
-
const base58Decoder =
|
|
643
|
-
const base64Encoder =
|
|
721
|
+
const base58Decoder = codecs.getBase58Decoder();
|
|
722
|
+
const base64Encoder = codecs.getBase64Encoder();
|
|
644
723
|
function getNonceFromAccountData([base64EncodedBytes]) {
|
|
645
724
|
const data = base64Encoder.encode(base64EncodedBytes);
|
|
646
725
|
const nonceValueBytes = data.slice(NONCE_VALUE_OFFSET, NONCE_VALUE_OFFSET + 32);
|
|
647
|
-
return base58Decoder.decode(nonceValueBytes)
|
|
726
|
+
return base58Decoder.decode(nonceValueBytes);
|
|
648
727
|
}
|
|
649
728
|
const nonceAccountDidAdvancePromise = (async () => {
|
|
650
729
|
for await (const accountNotification of accountNotifications) {
|
|
@@ -709,7 +788,10 @@ function createDefaultRecentTransactionConfirmer({
|
|
|
709
788
|
rpc,
|
|
710
789
|
rpcSubscriptions
|
|
711
790
|
}) {
|
|
712
|
-
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(
|
|
791
|
+
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({
|
|
792
|
+
rpc,
|
|
793
|
+
rpcSubscriptions
|
|
794
|
+
});
|
|
713
795
|
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
714
796
|
rpc,
|
|
715
797
|
rpcSubscriptions
|
|
@@ -742,10 +824,16 @@ async function waitForRecentTransactionConfirmation(config) {
|
|
|
742
824
|
await raceStrategies(
|
|
743
825
|
transactions.getSignatureFromTransaction(config.transaction),
|
|
744
826
|
config,
|
|
745
|
-
function getSpecificStrategiesForRace({
|
|
827
|
+
function getSpecificStrategiesForRace({
|
|
828
|
+
abortSignal,
|
|
829
|
+
commitment,
|
|
830
|
+
getBlockHeightExceedencePromise,
|
|
831
|
+
transaction
|
|
832
|
+
}) {
|
|
746
833
|
return [
|
|
747
834
|
getBlockHeightExceedencePromise({
|
|
748
835
|
abortSignal,
|
|
836
|
+
commitment,
|
|
749
837
|
lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
|
|
750
838
|
})
|
|
751
839
|
];
|
|
@@ -880,17 +968,36 @@ exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureC
|
|
|
880
968
|
exports.createSolanaRpc = createSolanaRpc;
|
|
881
969
|
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
882
970
|
exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
|
|
971
|
+
exports.decodeTransaction = decodeTransaction;
|
|
883
972
|
exports.requestAndConfirmAirdrop = requestAndConfirmAirdrop;
|
|
884
973
|
exports.sendAndConfirmDurableNonceTransaction = sendAndConfirmDurableNonceTransaction;
|
|
885
974
|
exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
|
|
886
975
|
exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
|
|
887
976
|
exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
|
|
977
|
+
Object.keys(accounts).forEach(function (k) {
|
|
978
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
979
|
+
enumerable: true,
|
|
980
|
+
get: function () { return accounts[k]; }
|
|
981
|
+
});
|
|
982
|
+
});
|
|
888
983
|
Object.keys(addresses).forEach(function (k) {
|
|
889
984
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
890
985
|
enumerable: true,
|
|
891
986
|
get: function () { return addresses[k]; }
|
|
892
987
|
});
|
|
893
988
|
});
|
|
989
|
+
Object.keys(codecs).forEach(function (k) {
|
|
990
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
991
|
+
enumerable: true,
|
|
992
|
+
get: function () { return codecs[k]; }
|
|
993
|
+
});
|
|
994
|
+
});
|
|
995
|
+
Object.keys(functional).forEach(function (k) {
|
|
996
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
997
|
+
enumerable: true,
|
|
998
|
+
get: function () { return functional[k]; }
|
|
999
|
+
});
|
|
1000
|
+
});
|
|
894
1001
|
Object.keys(instructions).forEach(function (k) {
|
|
895
1002
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
896
1003
|
enumerable: true,
|
|
@@ -903,12 +1010,30 @@ Object.keys(keys).forEach(function (k) {
|
|
|
903
1010
|
get: function () { return keys[k]; }
|
|
904
1011
|
});
|
|
905
1012
|
});
|
|
1013
|
+
Object.keys(programs).forEach(function (k) {
|
|
1014
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1015
|
+
enumerable: true,
|
|
1016
|
+
get: function () { return programs[k]; }
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
1019
|
+
Object.keys(rpcParsedTypes).forEach(function (k) {
|
|
1020
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1021
|
+
enumerable: true,
|
|
1022
|
+
get: function () { return rpcParsedTypes[k]; }
|
|
1023
|
+
});
|
|
1024
|
+
});
|
|
906
1025
|
Object.keys(rpcTypes).forEach(function (k) {
|
|
907
1026
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
908
1027
|
enumerable: true,
|
|
909
1028
|
get: function () { return rpcTypes[k]; }
|
|
910
1029
|
});
|
|
911
1030
|
});
|
|
1031
|
+
Object.keys(signers).forEach(function (k) {
|
|
1032
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1033
|
+
enumerable: true,
|
|
1034
|
+
get: function () { return signers[k]; }
|
|
1035
|
+
});
|
|
1036
|
+
});
|
|
912
1037
|
Object.keys(transactions).forEach(function (k) {
|
|
913
1038
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
914
1039
|
enumerable: true,
|