@solana/web3.js 1.87.6 → 1.87.7
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 +50 -32
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +50 -32
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +50 -32
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +50 -32
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +50 -32
- 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 +50 -32
- 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.iife.js
CHANGED
|
@@ -12079,6 +12079,31 @@ var solanaWeb3 = (function (exports) {
|
|
|
12079
12079
|
}
|
|
12080
12080
|
}
|
|
12081
12081
|
|
|
12082
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
12083
|
+
|
|
12084
|
+
/**
|
|
12085
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
12086
|
+
*/
|
|
12087
|
+
function guardedShift(byteArray) {
|
|
12088
|
+
if (byteArray.length === 0) {
|
|
12089
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
12090
|
+
}
|
|
12091
|
+
return byteArray.shift();
|
|
12092
|
+
}
|
|
12093
|
+
|
|
12094
|
+
/**
|
|
12095
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
12096
|
+
* the array.
|
|
12097
|
+
*/
|
|
12098
|
+
function guardedSplice(byteArray, ...args) {
|
|
12099
|
+
const [start] = args;
|
|
12100
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
12101
|
+
? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) {
|
|
12102
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
12103
|
+
}
|
|
12104
|
+
return byteArray.splice(...args);
|
|
12105
|
+
}
|
|
12106
|
+
|
|
12082
12107
|
/**
|
|
12083
12108
|
* An instruction to execute by a program
|
|
12084
12109
|
*
|
|
@@ -12220,32 +12245,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
12220
12245
|
static from(buffer$1) {
|
|
12221
12246
|
// Slice up wire data
|
|
12222
12247
|
let byteArray = [...buffer$1];
|
|
12223
|
-
const numRequiredSignatures = byteArray
|
|
12248
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
12224
12249
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
12225
12250
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
12226
12251
|
}
|
|
12227
|
-
const numReadonlySignedAccounts = byteArray
|
|
12228
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
12252
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
12253
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
12229
12254
|
const accountCount = decodeLength(byteArray);
|
|
12230
12255
|
let accountKeys = [];
|
|
12231
12256
|
for (let i = 0; i < accountCount; i++) {
|
|
12232
|
-
const account = byteArray
|
|
12233
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
12257
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
12234
12258
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
12235
12259
|
}
|
|
12236
|
-
const recentBlockhash = byteArray
|
|
12237
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
12260
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
12238
12261
|
const instructionCount = decodeLength(byteArray);
|
|
12239
12262
|
let instructions = [];
|
|
12240
12263
|
for (let i = 0; i < instructionCount; i++) {
|
|
12241
|
-
const programIdIndex = byteArray
|
|
12264
|
+
const programIdIndex = guardedShift(byteArray);
|
|
12242
12265
|
const accountCount = decodeLength(byteArray);
|
|
12243
|
-
const accounts = byteArray
|
|
12244
|
-
byteArray = byteArray.slice(accountCount);
|
|
12266
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
12245
12267
|
const dataLength = decodeLength(byteArray);
|
|
12246
|
-
const dataSlice = byteArray
|
|
12268
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
12247
12269
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
12248
|
-
byteArray = byteArray.slice(dataLength);
|
|
12249
12270
|
instructions.push({
|
|
12250
12271
|
programIdIndex,
|
|
12251
12272
|
accounts,
|
|
@@ -12450,30 +12471,30 @@ var solanaWeb3 = (function (exports) {
|
|
|
12450
12471
|
}
|
|
12451
12472
|
static deserialize(serializedMessage) {
|
|
12452
12473
|
let byteArray = [...serializedMessage];
|
|
12453
|
-
const prefix = byteArray
|
|
12474
|
+
const prefix = guardedShift(byteArray);
|
|
12454
12475
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
12455
12476
|
assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
12456
12477
|
const version = maskedPrefix;
|
|
12457
12478
|
assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
12458
12479
|
const header = {
|
|
12459
|
-
numRequiredSignatures: byteArray
|
|
12460
|
-
numReadonlySignedAccounts: byteArray
|
|
12461
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
12480
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
12481
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
12482
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
12462
12483
|
};
|
|
12463
12484
|
const staticAccountKeys = [];
|
|
12464
12485
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
12465
12486
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
12466
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
12487
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
12467
12488
|
}
|
|
12468
|
-
const recentBlockhash = bs58$1.encode(byteArray
|
|
12489
|
+
const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
12469
12490
|
const instructionCount = decodeLength(byteArray);
|
|
12470
12491
|
const compiledInstructions = [];
|
|
12471
12492
|
for (let i = 0; i < instructionCount; i++) {
|
|
12472
|
-
const programIdIndex = byteArray
|
|
12493
|
+
const programIdIndex = guardedShift(byteArray);
|
|
12473
12494
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
12474
|
-
const accountKeyIndexes = byteArray
|
|
12495
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
12475
12496
|
const dataLength = decodeLength(byteArray);
|
|
12476
|
-
const data = new Uint8Array(byteArray
|
|
12497
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
12477
12498
|
compiledInstructions.push({
|
|
12478
12499
|
programIdIndex,
|
|
12479
12500
|
accountKeyIndexes,
|
|
@@ -12483,11 +12504,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
12483
12504
|
const addressTableLookupsCount = decodeLength(byteArray);
|
|
12484
12505
|
const addressTableLookups = [];
|
|
12485
12506
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
12486
|
-
const accountKey = new PublicKey(byteArray
|
|
12507
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
12487
12508
|
const writableIndexesLength = decodeLength(byteArray);
|
|
12488
|
-
const writableIndexes = byteArray
|
|
12509
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
12489
12510
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
12490
|
-
const readonlyIndexes = byteArray
|
|
12511
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
12491
12512
|
addressTableLookups.push({
|
|
12492
12513
|
accountKey,
|
|
12493
12514
|
writableIndexes,
|
|
@@ -13259,8 +13280,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
13259
13280
|
const signatureCount = decodeLength(byteArray);
|
|
13260
13281
|
let signatures = [];
|
|
13261
13282
|
for (let i = 0; i < signatureCount; i++) {
|
|
13262
|
-
const signature = byteArray
|
|
13263
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
13283
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
13264
13284
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
13265
13285
|
}
|
|
13266
13286
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -13435,7 +13455,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
13435
13455
|
const signatures = [];
|
|
13436
13456
|
const signaturesLength = decodeLength(byteArray);
|
|
13437
13457
|
for (let i = 0; i < signaturesLength; i++) {
|
|
13438
|
-
signatures.push(new Uint8Array(byteArray
|
|
13458
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
13439
13459
|
}
|
|
13440
13460
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
13441
13461
|
return new VersionedTransaction(message, signatures);
|
|
@@ -19538,7 +19558,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
19538
19558
|
|
|
19539
19559
|
/** @internal */
|
|
19540
19560
|
const COMMON_HTTP_HEADERS = {
|
|
19541
|
-
'solana-client': `js/${"
|
|
19561
|
+
'solana-client': `js/${"1.87.7" }`
|
|
19542
19562
|
};
|
|
19543
19563
|
|
|
19544
19564
|
/**
|
|
@@ -25946,10 +25966,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
25946
25966
|
if (configKeyCount !== 2) return null;
|
|
25947
25967
|
const configKeys = [];
|
|
25948
25968
|
for (let i = 0; i < 2; i++) {
|
|
25949
|
-
const publicKey = new PublicKey(byteArray
|
|
25950
|
-
|
|
25951
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
25952
|
-
byteArray = byteArray.slice(1);
|
|
25969
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
25970
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
25953
25971
|
configKeys.push({
|
|
25954
25972
|
publicKey,
|
|
25955
25973
|
isSigner
|