@solana/web3.js 1.75.0 → 1.75.1
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/lib/index.browser.cjs.js +53 -36
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +53 -36
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +53 -36
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +53 -36
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +53 -36
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +53 -36
- package/lib/index.native.js.map +1 -1
- package/package.json +21 -21
- package/src/message/legacy.ts +9 -12
- package/src/message/v0.ts +29 -12
- package/src/transaction/legacy.ts +2 -2
- package/src/transaction/versioned.ts +2 -1
- package/src/utils/guarded-array-utils.ts +34 -0
- package/src/validator-info.ts +5 -4
package/lib/index.browser.esm.js
CHANGED
|
@@ -602,8 +602,8 @@ class CompiledKeys {
|
|
|
602
602
|
getOrInsertDefault(ix.programId).isInvoked = true;
|
|
603
603
|
for (const accountMeta of ix.keys) {
|
|
604
604
|
const keyMeta = getOrInsertDefault(accountMeta.pubkey);
|
|
605
|
-
keyMeta.isSigner
|
|
606
|
-
keyMeta.isWritable
|
|
605
|
+
keyMeta.isSigner ||= accountMeta.isSigner;
|
|
606
|
+
keyMeta.isWritable ||= accountMeta.isWritable;
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
609
|
return new CompiledKeys(payer, keyMetaMap);
|
|
@@ -668,6 +668,31 @@ class CompiledKeys {
|
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
670
|
|
|
671
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
675
|
+
*/
|
|
676
|
+
function guardedShift(byteArray) {
|
|
677
|
+
if (byteArray.length === 0) {
|
|
678
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
679
|
+
}
|
|
680
|
+
return byteArray.shift();
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
685
|
+
* the array.
|
|
686
|
+
*/
|
|
687
|
+
function guardedSplice(byteArray, ...args) {
|
|
688
|
+
const [start] = args;
|
|
689
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
690
|
+
? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) {
|
|
691
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
692
|
+
}
|
|
693
|
+
return byteArray.splice(...args);
|
|
694
|
+
}
|
|
695
|
+
|
|
671
696
|
/**
|
|
672
697
|
* An instruction to execute by a program
|
|
673
698
|
*
|
|
@@ -805,32 +830,28 @@ class Message {
|
|
|
805
830
|
static from(buffer) {
|
|
806
831
|
// Slice up wire data
|
|
807
832
|
let byteArray = [...buffer];
|
|
808
|
-
const numRequiredSignatures = byteArray
|
|
833
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
809
834
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
810
835
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
811
836
|
}
|
|
812
|
-
const numReadonlySignedAccounts = byteArray
|
|
813
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
837
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
838
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
814
839
|
const accountCount = decodeLength(byteArray);
|
|
815
840
|
let accountKeys = [];
|
|
816
841
|
for (let i = 0; i < accountCount; i++) {
|
|
817
|
-
const account = byteArray
|
|
818
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
842
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
819
843
|
accountKeys.push(new PublicKey(Buffer.from(account)));
|
|
820
844
|
}
|
|
821
|
-
const recentBlockhash = byteArray
|
|
822
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
845
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
823
846
|
const instructionCount = decodeLength(byteArray);
|
|
824
847
|
let instructions = [];
|
|
825
848
|
for (let i = 0; i < instructionCount; i++) {
|
|
826
|
-
const programIdIndex = byteArray
|
|
849
|
+
const programIdIndex = guardedShift(byteArray);
|
|
827
850
|
const accountCount = decodeLength(byteArray);
|
|
828
|
-
const accounts = byteArray
|
|
829
|
-
byteArray = byteArray.slice(accountCount);
|
|
851
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
830
852
|
const dataLength = decodeLength(byteArray);
|
|
831
|
-
const dataSlice = byteArray
|
|
853
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
832
854
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
833
|
-
byteArray = byteArray.slice(dataLength);
|
|
834
855
|
instructions.push({
|
|
835
856
|
programIdIndex,
|
|
836
857
|
accounts,
|
|
@@ -1035,30 +1056,30 @@ class MessageV0 {
|
|
|
1035
1056
|
}
|
|
1036
1057
|
static deserialize(serializedMessage) {
|
|
1037
1058
|
let byteArray = [...serializedMessage];
|
|
1038
|
-
const prefix = byteArray
|
|
1059
|
+
const prefix = guardedShift(byteArray);
|
|
1039
1060
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
1040
1061
|
assert(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
1041
1062
|
const version = maskedPrefix;
|
|
1042
1063
|
assert(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
1043
1064
|
const header = {
|
|
1044
|
-
numRequiredSignatures: byteArray
|
|
1045
|
-
numReadonlySignedAccounts: byteArray
|
|
1046
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
1065
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
1066
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
1067
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
1047
1068
|
};
|
|
1048
1069
|
const staticAccountKeys = [];
|
|
1049
1070
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
1050
1071
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
1051
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
1072
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
1052
1073
|
}
|
|
1053
|
-
const recentBlockhash = bs58.encode(byteArray
|
|
1074
|
+
const recentBlockhash = bs58.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1054
1075
|
const instructionCount = decodeLength(byteArray);
|
|
1055
1076
|
const compiledInstructions = [];
|
|
1056
1077
|
for (let i = 0; i < instructionCount; i++) {
|
|
1057
|
-
const programIdIndex = byteArray
|
|
1078
|
+
const programIdIndex = guardedShift(byteArray);
|
|
1058
1079
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
1059
|
-
const accountKeyIndexes = byteArray
|
|
1080
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
1060
1081
|
const dataLength = decodeLength(byteArray);
|
|
1061
|
-
const data = new Uint8Array(byteArray
|
|
1082
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
1062
1083
|
compiledInstructions.push({
|
|
1063
1084
|
programIdIndex,
|
|
1064
1085
|
accountKeyIndexes,
|
|
@@ -1068,11 +1089,11 @@ class MessageV0 {
|
|
|
1068
1089
|
const addressTableLookupsCount = decodeLength(byteArray);
|
|
1069
1090
|
const addressTableLookups = [];
|
|
1070
1091
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
1071
|
-
const accountKey = new PublicKey(byteArray
|
|
1092
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1072
1093
|
const writableIndexesLength = decodeLength(byteArray);
|
|
1073
|
-
const writableIndexes = byteArray
|
|
1094
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
1074
1095
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
1075
|
-
const readonlyIndexes = byteArray
|
|
1096
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
1076
1097
|
addressTableLookups.push({
|
|
1077
1098
|
accountKey,
|
|
1078
1099
|
writableIndexes,
|
|
@@ -1747,8 +1768,7 @@ class Transaction {
|
|
|
1747
1768
|
const signatureCount = decodeLength(byteArray);
|
|
1748
1769
|
let signatures = [];
|
|
1749
1770
|
for (let i = 0; i < signatureCount; i++) {
|
|
1750
|
-
const signature = byteArray
|
|
1751
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
1771
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
1752
1772
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
1753
1773
|
}
|
|
1754
1774
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -1918,7 +1938,7 @@ class VersionedTransaction {
|
|
|
1918
1938
|
const signatures = [];
|
|
1919
1939
|
const signaturesLength = decodeLength(byteArray);
|
|
1920
1940
|
for (let i = 0; i < signaturesLength; i++) {
|
|
1921
|
-
signatures.push(new Uint8Array(byteArray
|
|
1941
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
1922
1942
|
}
|
|
1923
1943
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
1924
1944
|
return new VersionedTransaction(message, signatures);
|
|
@@ -4408,7 +4428,7 @@ const LogsNotificationResult = type({
|
|
|
4408
4428
|
|
|
4409
4429
|
/** @internal */
|
|
4410
4430
|
const COMMON_HTTP_HEADERS = {
|
|
4411
|
-
'solana-client': `js/${"
|
|
4431
|
+
'solana-client': `js/${"1.75.1" }`
|
|
4412
4432
|
};
|
|
4413
4433
|
|
|
4414
4434
|
/**
|
|
@@ -6637,12 +6657,11 @@ class Connection {
|
|
|
6637
6657
|
* @internal
|
|
6638
6658
|
*/
|
|
6639
6659
|
_onSubscriptionStateChange(clientSubscriptionId, callback) {
|
|
6640
|
-
var _this$_subscriptionSt;
|
|
6641
6660
|
const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
|
|
6642
6661
|
if (hash == null) {
|
|
6643
6662
|
return () => {};
|
|
6644
6663
|
}
|
|
6645
|
-
const stateChangeCallbacks =
|
|
6664
|
+
const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();
|
|
6646
6665
|
stateChangeCallbacks.add(callback);
|
|
6647
6666
|
return () => {
|
|
6648
6667
|
stateChangeCallbacks.delete(callback);
|
|
@@ -9203,10 +9222,8 @@ class ValidatorInfo {
|
|
|
9203
9222
|
if (configKeyCount !== 2) return null;
|
|
9204
9223
|
const configKeys = [];
|
|
9205
9224
|
for (let i = 0; i < 2; i++) {
|
|
9206
|
-
const publicKey = new PublicKey(byteArray
|
|
9207
|
-
|
|
9208
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
9209
|
-
byteArray = byteArray.slice(1);
|
|
9225
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
9226
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
9210
9227
|
configKeys.push({
|
|
9211
9228
|
publicKey,
|
|
9212
9229
|
isSigner
|