@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.cjs.js
CHANGED
|
@@ -786,6 +786,36 @@ class CompiledKeys {
|
|
|
786
786
|
|
|
787
787
|
}
|
|
788
788
|
|
|
789
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
790
|
+
/**
|
|
791
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
792
|
+
*/
|
|
793
|
+
|
|
794
|
+
function guardedShift(byteArray) {
|
|
795
|
+
if (byteArray.length === 0) {
|
|
796
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
return byteArray.shift();
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
803
|
+
* the array.
|
|
804
|
+
*/
|
|
805
|
+
|
|
806
|
+
function guardedSplice(byteArray, ...args) {
|
|
807
|
+
var _args$;
|
|
808
|
+
|
|
809
|
+
const [start] = args;
|
|
810
|
+
|
|
811
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
812
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
813
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
return byteArray.splice(...args);
|
|
817
|
+
}
|
|
818
|
+
|
|
789
819
|
/**
|
|
790
820
|
* An instruction to execute by a program
|
|
791
821
|
*
|
|
@@ -937,37 +967,33 @@ class Message {
|
|
|
937
967
|
static from(buffer$1) {
|
|
938
968
|
// Slice up wire data
|
|
939
969
|
let byteArray = [...buffer$1];
|
|
940
|
-
const numRequiredSignatures = byteArray
|
|
970
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
941
971
|
|
|
942
972
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
943
973
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
944
974
|
}
|
|
945
975
|
|
|
946
|
-
const numReadonlySignedAccounts = byteArray
|
|
947
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
976
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
977
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
948
978
|
const accountCount = decodeLength(byteArray);
|
|
949
979
|
let accountKeys = [];
|
|
950
980
|
|
|
951
981
|
for (let i = 0; i < accountCount; i++) {
|
|
952
|
-
const account = byteArray
|
|
953
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
982
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
954
983
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
955
984
|
}
|
|
956
985
|
|
|
957
|
-
const recentBlockhash = byteArray
|
|
958
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
986
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
959
987
|
const instructionCount = decodeLength(byteArray);
|
|
960
988
|
let instructions = [];
|
|
961
989
|
|
|
962
990
|
for (let i = 0; i < instructionCount; i++) {
|
|
963
|
-
const programIdIndex = byteArray
|
|
991
|
+
const programIdIndex = guardedShift(byteArray);
|
|
964
992
|
const accountCount = decodeLength(byteArray);
|
|
965
|
-
const accounts = byteArray
|
|
966
|
-
byteArray = byteArray.slice(accountCount);
|
|
993
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
967
994
|
const dataLength = decodeLength(byteArray);
|
|
968
|
-
const dataSlice = byteArray
|
|
995
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
969
996
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
970
|
-
byteArray = byteArray.slice(dataLength);
|
|
971
997
|
instructions.push({
|
|
972
998
|
programIdIndex,
|
|
973
999
|
accounts,
|
|
@@ -1203,33 +1229,33 @@ class MessageV0 {
|
|
|
1203
1229
|
|
|
1204
1230
|
static deserialize(serializedMessage) {
|
|
1205
1231
|
let byteArray = [...serializedMessage];
|
|
1206
|
-
const prefix = byteArray
|
|
1232
|
+
const prefix = guardedShift(byteArray);
|
|
1207
1233
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
1208
1234
|
assert(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
1209
1235
|
const version = maskedPrefix;
|
|
1210
1236
|
assert(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
1211
1237
|
const header = {
|
|
1212
|
-
numRequiredSignatures: byteArray
|
|
1213
|
-
numReadonlySignedAccounts: byteArray
|
|
1214
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
1238
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
1239
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
1240
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
1215
1241
|
};
|
|
1216
1242
|
const staticAccountKeys = [];
|
|
1217
1243
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
1218
1244
|
|
|
1219
1245
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
1220
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
1246
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
1221
1247
|
}
|
|
1222
1248
|
|
|
1223
|
-
const recentBlockhash = bs58__default["default"].encode(byteArray
|
|
1249
|
+
const recentBlockhash = bs58__default["default"].encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1224
1250
|
const instructionCount = decodeLength(byteArray);
|
|
1225
1251
|
const compiledInstructions = [];
|
|
1226
1252
|
|
|
1227
1253
|
for (let i = 0; i < instructionCount; i++) {
|
|
1228
|
-
const programIdIndex = byteArray
|
|
1254
|
+
const programIdIndex = guardedShift(byteArray);
|
|
1229
1255
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
1230
|
-
const accountKeyIndexes = byteArray
|
|
1256
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
1231
1257
|
const dataLength = decodeLength(byteArray);
|
|
1232
|
-
const data = new Uint8Array(byteArray
|
|
1258
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
1233
1259
|
compiledInstructions.push({
|
|
1234
1260
|
programIdIndex,
|
|
1235
1261
|
accountKeyIndexes,
|
|
@@ -1241,11 +1267,11 @@ class MessageV0 {
|
|
|
1241
1267
|
const addressTableLookups = [];
|
|
1242
1268
|
|
|
1243
1269
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
1244
|
-
const accountKey = new PublicKey(byteArray
|
|
1270
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1245
1271
|
const writableIndexesLength = decodeLength(byteArray);
|
|
1246
|
-
const writableIndexes = byteArray
|
|
1272
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
1247
1273
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
1248
|
-
const readonlyIndexes = byteArray
|
|
1274
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
1249
1275
|
addressTableLookups.push({
|
|
1250
1276
|
accountKey,
|
|
1251
1277
|
writableIndexes,
|
|
@@ -1985,8 +2011,7 @@ class Transaction {
|
|
|
1985
2011
|
let signatures = [];
|
|
1986
2012
|
|
|
1987
2013
|
for (let i = 0; i < signatureCount; i++) {
|
|
1988
|
-
const signature = byteArray
|
|
1989
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
2014
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
1990
2015
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
1991
2016
|
}
|
|
1992
2017
|
|
|
@@ -2184,7 +2209,7 @@ class VersionedTransaction {
|
|
|
2184
2209
|
const signaturesLength = decodeLength(byteArray);
|
|
2185
2210
|
|
|
2186
2211
|
for (let i = 0; i < signaturesLength; i++) {
|
|
2187
|
-
signatures.push(new Uint8Array(byteArray
|
|
2212
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
2188
2213
|
}
|
|
2189
2214
|
|
|
2190
2215
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
@@ -4756,7 +4781,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
4756
4781
|
|
|
4757
4782
|
/** @internal */
|
|
4758
4783
|
const COMMON_HTTP_HEADERS = {
|
|
4759
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
4784
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.69.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
4760
4785
|
};
|
|
4761
4786
|
/**
|
|
4762
4787
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -10172,10 +10197,8 @@ class ValidatorInfo {
|
|
|
10172
10197
|
const configKeys = [];
|
|
10173
10198
|
|
|
10174
10199
|
for (let i = 0; i < 2; i++) {
|
|
10175
|
-
const publicKey = new PublicKey(byteArray
|
|
10176
|
-
|
|
10177
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
10178
|
-
byteArray = byteArray.slice(1);
|
|
10200
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
10201
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
10179
10202
|
configKeys.push({
|
|
10180
10203
|
publicKey,
|
|
10181
10204
|
isSigner
|