@solana/web3.js 1.71.0 → 1.71.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 +278 -80
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +273 -75
- 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.iife.js
CHANGED
|
@@ -11245,6 +11245,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
11245
11245
|
|
|
11246
11246
|
}
|
|
11247
11247
|
|
|
11248
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
11249
|
+
/**
|
|
11250
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
11251
|
+
*/
|
|
11252
|
+
|
|
11253
|
+
function guardedShift(byteArray) {
|
|
11254
|
+
if (byteArray.length === 0) {
|
|
11255
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11256
|
+
}
|
|
11257
|
+
|
|
11258
|
+
return byteArray.shift();
|
|
11259
|
+
}
|
|
11260
|
+
/**
|
|
11261
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
11262
|
+
* the array.
|
|
11263
|
+
*/
|
|
11264
|
+
|
|
11265
|
+
function guardedSplice(byteArray, ...args) {
|
|
11266
|
+
var _args$;
|
|
11267
|
+
|
|
11268
|
+
const [start] = args;
|
|
11269
|
+
|
|
11270
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
11271
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
11272
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11273
|
+
}
|
|
11274
|
+
|
|
11275
|
+
return byteArray.splice(...args);
|
|
11276
|
+
}
|
|
11277
|
+
|
|
11248
11278
|
/**
|
|
11249
11279
|
* An instruction to execute by a program
|
|
11250
11280
|
*
|
|
@@ -11396,37 +11426,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11396
11426
|
static from(buffer$1) {
|
|
11397
11427
|
// Slice up wire data
|
|
11398
11428
|
let byteArray = [...buffer$1];
|
|
11399
|
-
const numRequiredSignatures = byteArray
|
|
11429
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
11400
11430
|
|
|
11401
11431
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
11402
11432
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
11403
11433
|
}
|
|
11404
11434
|
|
|
11405
|
-
const numReadonlySignedAccounts = byteArray
|
|
11406
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
11435
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
11436
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
11407
11437
|
const accountCount = decodeLength(byteArray);
|
|
11408
11438
|
let accountKeys = [];
|
|
11409
11439
|
|
|
11410
11440
|
for (let i = 0; i < accountCount; i++) {
|
|
11411
|
-
const account = byteArray
|
|
11412
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11441
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11413
11442
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
11414
11443
|
}
|
|
11415
11444
|
|
|
11416
|
-
const recentBlockhash = byteArray
|
|
11417
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11445
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11418
11446
|
const instructionCount = decodeLength(byteArray);
|
|
11419
11447
|
let instructions = [];
|
|
11420
11448
|
|
|
11421
11449
|
for (let i = 0; i < instructionCount; i++) {
|
|
11422
|
-
const programIdIndex = byteArray
|
|
11450
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11423
11451
|
const accountCount = decodeLength(byteArray);
|
|
11424
|
-
const accounts = byteArray
|
|
11425
|
-
byteArray = byteArray.slice(accountCount);
|
|
11452
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
11426
11453
|
const dataLength = decodeLength(byteArray);
|
|
11427
|
-
const dataSlice = byteArray
|
|
11454
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
11428
11455
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
11429
|
-
byteArray = byteArray.slice(dataLength);
|
|
11430
11456
|
instructions.push({
|
|
11431
11457
|
programIdIndex,
|
|
11432
11458
|
accounts,
|
|
@@ -11662,33 +11688,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11662
11688
|
|
|
11663
11689
|
static deserialize(serializedMessage) {
|
|
11664
11690
|
let byteArray = [...serializedMessage];
|
|
11665
|
-
const prefix = byteArray
|
|
11691
|
+
const prefix = guardedShift(byteArray);
|
|
11666
11692
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
11667
11693
|
assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
11668
11694
|
const version = maskedPrefix;
|
|
11669
11695
|
assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
11670
11696
|
const header = {
|
|
11671
|
-
numRequiredSignatures: byteArray
|
|
11672
|
-
numReadonlySignedAccounts: byteArray
|
|
11673
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
11697
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
11698
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
11699
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
11674
11700
|
};
|
|
11675
11701
|
const staticAccountKeys = [];
|
|
11676
11702
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
11677
11703
|
|
|
11678
11704
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
11679
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
11705
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
11680
11706
|
}
|
|
11681
11707
|
|
|
11682
|
-
const recentBlockhash = bs58$1.encode(byteArray
|
|
11708
|
+
const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11683
11709
|
const instructionCount = decodeLength(byteArray);
|
|
11684
11710
|
const compiledInstructions = [];
|
|
11685
11711
|
|
|
11686
11712
|
for (let i = 0; i < instructionCount; i++) {
|
|
11687
|
-
const programIdIndex = byteArray
|
|
11713
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11688
11714
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
11689
|
-
const accountKeyIndexes = byteArray
|
|
11715
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
11690
11716
|
const dataLength = decodeLength(byteArray);
|
|
11691
|
-
const data = new Uint8Array(byteArray
|
|
11717
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
11692
11718
|
compiledInstructions.push({
|
|
11693
11719
|
programIdIndex,
|
|
11694
11720
|
accountKeyIndexes,
|
|
@@ -11700,11 +11726,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
11700
11726
|
const addressTableLookups = [];
|
|
11701
11727
|
|
|
11702
11728
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
11703
|
-
const accountKey = new PublicKey(byteArray
|
|
11729
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11704
11730
|
const writableIndexesLength = decodeLength(byteArray);
|
|
11705
|
-
const writableIndexes = byteArray
|
|
11731
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
11706
11732
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
11707
|
-
const readonlyIndexes = byteArray
|
|
11733
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
11708
11734
|
addressTableLookups.push({
|
|
11709
11735
|
accountKey,
|
|
11710
11736
|
writableIndexes,
|
|
@@ -12446,8 +12472,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12446
12472
|
let signatures = [];
|
|
12447
12473
|
|
|
12448
12474
|
for (let i = 0; i < signatureCount; i++) {
|
|
12449
|
-
const signature = byteArray
|
|
12450
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
12475
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
12451
12476
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
12452
12477
|
}
|
|
12453
12478
|
|
|
@@ -12645,7 +12670,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12645
12670
|
const signaturesLength = decodeLength(byteArray);
|
|
12646
12671
|
|
|
12647
12672
|
for (let i = 0; i < signaturesLength; i++) {
|
|
12648
|
-
signatures.push(new Uint8Array(byteArray
|
|
12673
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
12649
12674
|
}
|
|
12650
12675
|
|
|
12651
12676
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
@@ -18327,7 +18352,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18327
18352
|
|
|
18328
18353
|
/** @internal */
|
|
18329
18354
|
const COMMON_HTTP_HEADERS = {
|
|
18330
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
18355
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.71.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
18331
18356
|
};
|
|
18332
18357
|
/**
|
|
18333
18358
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -24963,10 +24988,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
24963
24988
|
const configKeys = [];
|
|
24964
24989
|
|
|
24965
24990
|
for (let i = 0; i < 2; i++) {
|
|
24966
|
-
const publicKey = new PublicKey(byteArray
|
|
24967
|
-
|
|
24968
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
24969
|
-
byteArray = byteArray.slice(1);
|
|
24991
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
24992
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
24970
24993
|
configKeys.push({
|
|
24971
24994
|
publicKey,
|
|
24972
24995
|
isSigner
|