@solana/web3.js 1.69.0 → 1.69.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 +55 -32
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +55 -32
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +55 -32
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +55 -32
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +55 -32
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -3
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +55 -32
- package/lib/index.native.js.map +1 -1
- package/package.json +22 -22
- 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.cjs.js
CHANGED
|
@@ -780,6 +780,36 @@ class CompiledKeys {
|
|
|
780
780
|
|
|
781
781
|
}
|
|
782
782
|
|
|
783
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
784
|
+
/**
|
|
785
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
786
|
+
*/
|
|
787
|
+
|
|
788
|
+
function guardedShift(byteArray) {
|
|
789
|
+
if (byteArray.length === 0) {
|
|
790
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
return byteArray.shift();
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
797
|
+
* the array.
|
|
798
|
+
*/
|
|
799
|
+
|
|
800
|
+
function guardedSplice(byteArray, ...args) {
|
|
801
|
+
var _args$;
|
|
802
|
+
|
|
803
|
+
const [start] = args;
|
|
804
|
+
|
|
805
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
806
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
807
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
return byteArray.splice(...args);
|
|
811
|
+
}
|
|
812
|
+
|
|
783
813
|
/**
|
|
784
814
|
* An instruction to execute by a program
|
|
785
815
|
*
|
|
@@ -931,37 +961,33 @@ class Message {
|
|
|
931
961
|
static from(buffer$1) {
|
|
932
962
|
// Slice up wire data
|
|
933
963
|
let byteArray = [...buffer$1];
|
|
934
|
-
const numRequiredSignatures = byteArray
|
|
964
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
935
965
|
|
|
936
966
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
937
967
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
938
968
|
}
|
|
939
969
|
|
|
940
|
-
const numReadonlySignedAccounts = byteArray
|
|
941
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
970
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
971
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
942
972
|
const accountCount = decodeLength(byteArray);
|
|
943
973
|
let accountKeys = [];
|
|
944
974
|
|
|
945
975
|
for (let i = 0; i < accountCount; i++) {
|
|
946
|
-
const account = byteArray
|
|
947
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
976
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
948
977
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
949
978
|
}
|
|
950
979
|
|
|
951
|
-
const recentBlockhash = byteArray
|
|
952
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
980
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
953
981
|
const instructionCount = decodeLength(byteArray);
|
|
954
982
|
let instructions = [];
|
|
955
983
|
|
|
956
984
|
for (let i = 0; i < instructionCount; i++) {
|
|
957
|
-
const programIdIndex = byteArray
|
|
985
|
+
const programIdIndex = guardedShift(byteArray);
|
|
958
986
|
const accountCount = decodeLength(byteArray);
|
|
959
|
-
const accounts = byteArray
|
|
960
|
-
byteArray = byteArray.slice(accountCount);
|
|
987
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
961
988
|
const dataLength = decodeLength(byteArray);
|
|
962
|
-
const dataSlice = byteArray
|
|
989
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
963
990
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
964
|
-
byteArray = byteArray.slice(dataLength);
|
|
965
991
|
instructions.push({
|
|
966
992
|
programIdIndex,
|
|
967
993
|
accounts,
|
|
@@ -1197,33 +1223,33 @@ class MessageV0 {
|
|
|
1197
1223
|
|
|
1198
1224
|
static deserialize(serializedMessage) {
|
|
1199
1225
|
let byteArray = [...serializedMessage];
|
|
1200
|
-
const prefix = byteArray
|
|
1226
|
+
const prefix = guardedShift(byteArray);
|
|
1201
1227
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
1202
1228
|
assert(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
1203
1229
|
const version = maskedPrefix;
|
|
1204
1230
|
assert(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
1205
1231
|
const header = {
|
|
1206
|
-
numRequiredSignatures: byteArray
|
|
1207
|
-
numReadonlySignedAccounts: byteArray
|
|
1208
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
1232
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
1233
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
1234
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
1209
1235
|
};
|
|
1210
1236
|
const staticAccountKeys = [];
|
|
1211
1237
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
1212
1238
|
|
|
1213
1239
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
1214
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
1240
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
1215
1241
|
}
|
|
1216
1242
|
|
|
1217
|
-
const recentBlockhash = bs58__default["default"].encode(byteArray
|
|
1243
|
+
const recentBlockhash = bs58__default["default"].encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1218
1244
|
const instructionCount = decodeLength(byteArray);
|
|
1219
1245
|
const compiledInstructions = [];
|
|
1220
1246
|
|
|
1221
1247
|
for (let i = 0; i < instructionCount; i++) {
|
|
1222
|
-
const programIdIndex = byteArray
|
|
1248
|
+
const programIdIndex = guardedShift(byteArray);
|
|
1223
1249
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
1224
|
-
const accountKeyIndexes = byteArray
|
|
1250
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
1225
1251
|
const dataLength = decodeLength(byteArray);
|
|
1226
|
-
const data = new Uint8Array(byteArray
|
|
1252
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
1227
1253
|
compiledInstructions.push({
|
|
1228
1254
|
programIdIndex,
|
|
1229
1255
|
accountKeyIndexes,
|
|
@@ -1235,11 +1261,11 @@ class MessageV0 {
|
|
|
1235
1261
|
const addressTableLookups = [];
|
|
1236
1262
|
|
|
1237
1263
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
1238
|
-
const accountKey = new PublicKey(byteArray
|
|
1264
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1239
1265
|
const writableIndexesLength = decodeLength(byteArray);
|
|
1240
|
-
const writableIndexes = byteArray
|
|
1266
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
1241
1267
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
1242
|
-
const readonlyIndexes = byteArray
|
|
1268
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
1243
1269
|
addressTableLookups.push({
|
|
1244
1270
|
accountKey,
|
|
1245
1271
|
writableIndexes,
|
|
@@ -1979,8 +2005,7 @@ class Transaction {
|
|
|
1979
2005
|
let signatures = [];
|
|
1980
2006
|
|
|
1981
2007
|
for (let i = 0; i < signatureCount; i++) {
|
|
1982
|
-
const signature = byteArray
|
|
1983
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
2008
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
1984
2009
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
1985
2010
|
}
|
|
1986
2011
|
|
|
@@ -2178,7 +2203,7 @@ class VersionedTransaction {
|
|
|
2178
2203
|
const signaturesLength = decodeLength(byteArray);
|
|
2179
2204
|
|
|
2180
2205
|
for (let i = 0; i < signaturesLength; i++) {
|
|
2181
|
-
signatures.push(new Uint8Array(byteArray
|
|
2206
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
2182
2207
|
}
|
|
2183
2208
|
|
|
2184
2209
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
@@ -4690,7 +4715,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
4690
4715
|
|
|
4691
4716
|
/** @internal */
|
|
4692
4717
|
const COMMON_HTTP_HEADERS = {
|
|
4693
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
4718
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.69.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
4694
4719
|
};
|
|
4695
4720
|
/**
|
|
4696
4721
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -10106,10 +10131,8 @@ class ValidatorInfo {
|
|
|
10106
10131
|
const configKeys = [];
|
|
10107
10132
|
|
|
10108
10133
|
for (let i = 0; i < 2; i++) {
|
|
10109
|
-
const publicKey = new PublicKey(byteArray
|
|
10110
|
-
|
|
10111
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
10112
|
-
byteArray = byteArray.slice(1);
|
|
10134
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
10135
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
10113
10136
|
configKeys.push({
|
|
10114
10137
|
publicKey,
|
|
10115
10138
|
isSigner
|