@solana/web3.js 1.74.0 → 1.74.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.cjs.js
CHANGED
|
@@ -648,8 +648,8 @@ class CompiledKeys {
|
|
|
648
648
|
getOrInsertDefault(ix.programId).isInvoked = true;
|
|
649
649
|
for (const accountMeta of ix.keys) {
|
|
650
650
|
const keyMeta = getOrInsertDefault(accountMeta.pubkey);
|
|
651
|
-
keyMeta.isSigner
|
|
652
|
-
keyMeta.isWritable
|
|
651
|
+
keyMeta.isSigner ||= accountMeta.isSigner;
|
|
652
|
+
keyMeta.isWritable ||= accountMeta.isWritable;
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
655
|
return new CompiledKeys(payer, keyMetaMap);
|
|
@@ -714,6 +714,31 @@ class CompiledKeys {
|
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
716
|
|
|
717
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
721
|
+
*/
|
|
722
|
+
function guardedShift(byteArray) {
|
|
723
|
+
if (byteArray.length === 0) {
|
|
724
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
725
|
+
}
|
|
726
|
+
return byteArray.shift();
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
731
|
+
* the array.
|
|
732
|
+
*/
|
|
733
|
+
function guardedSplice(byteArray, ...args) {
|
|
734
|
+
const [start] = args;
|
|
735
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
736
|
+
? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) {
|
|
737
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
738
|
+
}
|
|
739
|
+
return byteArray.splice(...args);
|
|
740
|
+
}
|
|
741
|
+
|
|
717
742
|
/**
|
|
718
743
|
* An instruction to execute by a program
|
|
719
744
|
*
|
|
@@ -851,32 +876,28 @@ class Message {
|
|
|
851
876
|
static from(buffer$1) {
|
|
852
877
|
// Slice up wire data
|
|
853
878
|
let byteArray = [...buffer$1];
|
|
854
|
-
const numRequiredSignatures = byteArray
|
|
879
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
855
880
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
856
881
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
857
882
|
}
|
|
858
|
-
const numReadonlySignedAccounts = byteArray
|
|
859
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
883
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
884
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
860
885
|
const accountCount = decodeLength(byteArray);
|
|
861
886
|
let accountKeys = [];
|
|
862
887
|
for (let i = 0; i < accountCount; i++) {
|
|
863
|
-
const account = byteArray
|
|
864
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
888
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
865
889
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
866
890
|
}
|
|
867
|
-
const recentBlockhash = byteArray
|
|
868
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
891
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
869
892
|
const instructionCount = decodeLength(byteArray);
|
|
870
893
|
let instructions = [];
|
|
871
894
|
for (let i = 0; i < instructionCount; i++) {
|
|
872
|
-
const programIdIndex = byteArray
|
|
895
|
+
const programIdIndex = guardedShift(byteArray);
|
|
873
896
|
const accountCount = decodeLength(byteArray);
|
|
874
|
-
const accounts = byteArray
|
|
875
|
-
byteArray = byteArray.slice(accountCount);
|
|
897
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
876
898
|
const dataLength = decodeLength(byteArray);
|
|
877
|
-
const dataSlice = byteArray
|
|
899
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
878
900
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
879
|
-
byteArray = byteArray.slice(dataLength);
|
|
880
901
|
instructions.push({
|
|
881
902
|
programIdIndex,
|
|
882
903
|
accounts,
|
|
@@ -1081,30 +1102,30 @@ class MessageV0 {
|
|
|
1081
1102
|
}
|
|
1082
1103
|
static deserialize(serializedMessage) {
|
|
1083
1104
|
let byteArray = [...serializedMessage];
|
|
1084
|
-
const prefix = byteArray
|
|
1105
|
+
const prefix = guardedShift(byteArray);
|
|
1085
1106
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
1086
1107
|
assert(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
1087
1108
|
const version = maskedPrefix;
|
|
1088
1109
|
assert(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
1089
1110
|
const header = {
|
|
1090
|
-
numRequiredSignatures: byteArray
|
|
1091
|
-
numReadonlySignedAccounts: byteArray
|
|
1092
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
1111
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
1112
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
1113
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
1093
1114
|
};
|
|
1094
1115
|
const staticAccountKeys = [];
|
|
1095
1116
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
1096
1117
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
1097
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
1118
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
1098
1119
|
}
|
|
1099
|
-
const recentBlockhash = bs58__default["default"].encode(byteArray
|
|
1120
|
+
const recentBlockhash = bs58__default["default"].encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1100
1121
|
const instructionCount = decodeLength(byteArray);
|
|
1101
1122
|
const compiledInstructions = [];
|
|
1102
1123
|
for (let i = 0; i < instructionCount; i++) {
|
|
1103
|
-
const programIdIndex = byteArray
|
|
1124
|
+
const programIdIndex = guardedShift(byteArray);
|
|
1104
1125
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
1105
|
-
const accountKeyIndexes = byteArray
|
|
1126
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
1106
1127
|
const dataLength = decodeLength(byteArray);
|
|
1107
|
-
const data = new Uint8Array(byteArray
|
|
1128
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
1108
1129
|
compiledInstructions.push({
|
|
1109
1130
|
programIdIndex,
|
|
1110
1131
|
accountKeyIndexes,
|
|
@@ -1114,11 +1135,11 @@ class MessageV0 {
|
|
|
1114
1135
|
const addressTableLookupsCount = decodeLength(byteArray);
|
|
1115
1136
|
const addressTableLookups = [];
|
|
1116
1137
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
1117
|
-
const accountKey = new PublicKey(byteArray
|
|
1138
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1118
1139
|
const writableIndexesLength = decodeLength(byteArray);
|
|
1119
|
-
const writableIndexes = byteArray
|
|
1140
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
1120
1141
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
1121
|
-
const readonlyIndexes = byteArray
|
|
1142
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
1122
1143
|
addressTableLookups.push({
|
|
1123
1144
|
accountKey,
|
|
1124
1145
|
writableIndexes,
|
|
@@ -1793,8 +1814,7 @@ class Transaction {
|
|
|
1793
1814
|
const signatureCount = decodeLength(byteArray);
|
|
1794
1815
|
let signatures = [];
|
|
1795
1816
|
for (let i = 0; i < signatureCount; i++) {
|
|
1796
|
-
const signature = byteArray
|
|
1797
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
1817
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
1798
1818
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
1799
1819
|
}
|
|
1800
1820
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -1964,7 +1984,7 @@ class VersionedTransaction {
|
|
|
1964
1984
|
const signatures = [];
|
|
1965
1985
|
const signaturesLength = decodeLength(byteArray);
|
|
1966
1986
|
for (let i = 0; i < signaturesLength; i++) {
|
|
1967
|
-
signatures.push(new Uint8Array(byteArray
|
|
1987
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
1968
1988
|
}
|
|
1969
1989
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
1970
1990
|
return new VersionedTransaction(message, signatures);
|
|
@@ -6952,7 +6972,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
6952
6972
|
|
|
6953
6973
|
/** @internal */
|
|
6954
6974
|
const COMMON_HTTP_HEADERS = {
|
|
6955
|
-
'solana-client': `js/${"
|
|
6975
|
+
'solana-client': `js/${"1.74.1" }`
|
|
6956
6976
|
};
|
|
6957
6977
|
|
|
6958
6978
|
/**
|
|
@@ -9168,12 +9188,11 @@ class Connection {
|
|
|
9168
9188
|
* @internal
|
|
9169
9189
|
*/
|
|
9170
9190
|
_onSubscriptionStateChange(clientSubscriptionId, callback) {
|
|
9171
|
-
var _this$_subscriptionSt;
|
|
9172
9191
|
const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
|
|
9173
9192
|
if (hash == null) {
|
|
9174
9193
|
return () => {};
|
|
9175
9194
|
}
|
|
9176
|
-
const stateChangeCallbacks =
|
|
9195
|
+
const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();
|
|
9177
9196
|
stateChangeCallbacks.add(callback);
|
|
9178
9197
|
return () => {
|
|
9179
9198
|
stateChangeCallbacks.delete(callback);
|
|
@@ -11734,10 +11753,8 @@ class ValidatorInfo {
|
|
|
11734
11753
|
if (configKeyCount !== 2) return null;
|
|
11735
11754
|
const configKeys = [];
|
|
11736
11755
|
for (let i = 0; i < 2; i++) {
|
|
11737
|
-
const publicKey = new PublicKey(byteArray
|
|
11738
|
-
|
|
11739
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
11740
|
-
byteArray = byteArray.slice(1);
|
|
11756
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11757
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
11741
11758
|
configKeys.push({
|
|
11742
11759
|
publicKey,
|
|
11743
11760
|
isSigner
|