@solana/web3.js 1.60.0 → 1.60.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.iife.js
CHANGED
|
@@ -11222,6 +11222,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
11222
11222
|
|
|
11223
11223
|
}
|
|
11224
11224
|
|
|
11225
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
11226
|
+
/**
|
|
11227
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
11228
|
+
*/
|
|
11229
|
+
|
|
11230
|
+
function guardedShift(byteArray) {
|
|
11231
|
+
if (byteArray.length === 0) {
|
|
11232
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11233
|
+
}
|
|
11234
|
+
|
|
11235
|
+
return byteArray.shift();
|
|
11236
|
+
}
|
|
11237
|
+
/**
|
|
11238
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
11239
|
+
* the array.
|
|
11240
|
+
*/
|
|
11241
|
+
|
|
11242
|
+
function guardedSplice(byteArray, ...args) {
|
|
11243
|
+
var _args$;
|
|
11244
|
+
|
|
11245
|
+
const [start] = args;
|
|
11246
|
+
|
|
11247
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
11248
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
11249
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11250
|
+
}
|
|
11251
|
+
|
|
11252
|
+
return byteArray.splice(...args);
|
|
11253
|
+
}
|
|
11254
|
+
|
|
11225
11255
|
/**
|
|
11226
11256
|
* An instruction to execute by a program
|
|
11227
11257
|
*
|
|
@@ -11363,37 +11393,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11363
11393
|
static from(buffer$1) {
|
|
11364
11394
|
// Slice up wire data
|
|
11365
11395
|
let byteArray = [...buffer$1];
|
|
11366
|
-
const numRequiredSignatures = byteArray
|
|
11396
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
11367
11397
|
|
|
11368
11398
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
11369
11399
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
11370
11400
|
}
|
|
11371
11401
|
|
|
11372
|
-
const numReadonlySignedAccounts = byteArray
|
|
11373
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
11402
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
11403
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
11374
11404
|
const accountCount = decodeLength(byteArray);
|
|
11375
11405
|
let accountKeys = [];
|
|
11376
11406
|
|
|
11377
11407
|
for (let i = 0; i < accountCount; i++) {
|
|
11378
|
-
const account = byteArray
|
|
11379
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11408
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11380
11409
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
11381
11410
|
}
|
|
11382
11411
|
|
|
11383
|
-
const recentBlockhash = byteArray
|
|
11384
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11412
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11385
11413
|
const instructionCount = decodeLength(byteArray);
|
|
11386
11414
|
let instructions = [];
|
|
11387
11415
|
|
|
11388
11416
|
for (let i = 0; i < instructionCount; i++) {
|
|
11389
|
-
const programIdIndex = byteArray
|
|
11417
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11390
11418
|
const accountCount = decodeLength(byteArray);
|
|
11391
|
-
const accounts = byteArray
|
|
11392
|
-
byteArray = byteArray.slice(accountCount);
|
|
11419
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
11393
11420
|
const dataLength = decodeLength(byteArray);
|
|
11394
|
-
const dataSlice = byteArray
|
|
11421
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
11395
11422
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
11396
|
-
byteArray = byteArray.slice(dataLength);
|
|
11397
11423
|
instructions.push({
|
|
11398
11424
|
programIdIndex,
|
|
11399
11425
|
accounts,
|
|
@@ -11606,33 +11632,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11606
11632
|
|
|
11607
11633
|
static deserialize(serializedMessage) {
|
|
11608
11634
|
let byteArray = [...serializedMessage];
|
|
11609
|
-
const prefix = byteArray
|
|
11635
|
+
const prefix = guardedShift(byteArray);
|
|
11610
11636
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
11611
11637
|
assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
11612
11638
|
const version = maskedPrefix;
|
|
11613
11639
|
assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
11614
11640
|
const header = {
|
|
11615
|
-
numRequiredSignatures: byteArray
|
|
11616
|
-
numReadonlySignedAccounts: byteArray
|
|
11617
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
11641
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
11642
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
11643
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
11618
11644
|
};
|
|
11619
11645
|
const staticAccountKeys = [];
|
|
11620
11646
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
11621
11647
|
|
|
11622
11648
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
11623
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
11649
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
11624
11650
|
}
|
|
11625
11651
|
|
|
11626
|
-
const recentBlockhash = bs58$1.encode(byteArray
|
|
11652
|
+
const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11627
11653
|
const instructionCount = decodeLength(byteArray);
|
|
11628
11654
|
const compiledInstructions = [];
|
|
11629
11655
|
|
|
11630
11656
|
for (let i = 0; i < instructionCount; i++) {
|
|
11631
|
-
const programIdIndex = byteArray
|
|
11657
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11632
11658
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
11633
|
-
const accountKeyIndexes = byteArray
|
|
11659
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
11634
11660
|
const dataLength = decodeLength(byteArray);
|
|
11635
|
-
const data = new Uint8Array(byteArray
|
|
11661
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
11636
11662
|
compiledInstructions.push({
|
|
11637
11663
|
programIdIndex,
|
|
11638
11664
|
accountKeyIndexes,
|
|
@@ -11644,11 +11670,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
11644
11670
|
const addressTableLookups = [];
|
|
11645
11671
|
|
|
11646
11672
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
11647
|
-
const accountKey = new PublicKey(byteArray
|
|
11673
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11648
11674
|
const writableIndexesLength = decodeLength(byteArray);
|
|
11649
|
-
const writableIndexes = byteArray
|
|
11675
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
11650
11676
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
11651
|
-
const readonlyIndexes = byteArray
|
|
11677
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
11652
11678
|
addressTableLookups.push({
|
|
11653
11679
|
accountKey,
|
|
11654
11680
|
writableIndexes,
|
|
@@ -12379,8 +12405,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12379
12405
|
let signatures = [];
|
|
12380
12406
|
|
|
12381
12407
|
for (let i = 0; i < signatureCount; i++) {
|
|
12382
|
-
const signature = byteArray
|
|
12383
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
12408
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
12384
12409
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
12385
12410
|
}
|
|
12386
12411
|
|
|
@@ -12574,7 +12599,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12574
12599
|
const signaturesLength = decodeLength(byteArray);
|
|
12575
12600
|
|
|
12576
12601
|
for (let i = 0; i < signaturesLength; i++) {
|
|
12577
|
-
signatures.push(new Uint8Array(byteArray
|
|
12602
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
12578
12603
|
}
|
|
12579
12604
|
|
|
12580
12605
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
@@ -18139,7 +18164,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18139
18164
|
|
|
18140
18165
|
/** @internal */
|
|
18141
18166
|
const COMMON_HTTP_HEADERS = {
|
|
18142
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
18167
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.60.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
18143
18168
|
};
|
|
18144
18169
|
/**
|
|
18145
18170
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -24271,10 +24296,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
24271
24296
|
const configKeys = [];
|
|
24272
24297
|
|
|
24273
24298
|
for (let i = 0; i < 2; i++) {
|
|
24274
|
-
const publicKey = new PublicKey(byteArray
|
|
24275
|
-
|
|
24276
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
24277
|
-
byteArray = byteArray.slice(1);
|
|
24299
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
24300
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
24278
24301
|
configKeys.push({
|
|
24279
24302
|
publicKey,
|
|
24280
24303
|
isSigner
|