@solana/web3.js 1.63.1 → 1.63.2
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
|
*
|
|
@@ -11373,37 +11403,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11373
11403
|
static from(buffer$1) {
|
|
11374
11404
|
// Slice up wire data
|
|
11375
11405
|
let byteArray = [...buffer$1];
|
|
11376
|
-
const numRequiredSignatures = byteArray
|
|
11406
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
11377
11407
|
|
|
11378
11408
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
11379
11409
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
11380
11410
|
}
|
|
11381
11411
|
|
|
11382
|
-
const numReadonlySignedAccounts = byteArray
|
|
11383
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
11412
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
11413
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
11384
11414
|
const accountCount = decodeLength(byteArray);
|
|
11385
11415
|
let accountKeys = [];
|
|
11386
11416
|
|
|
11387
11417
|
for (let i = 0; i < accountCount; i++) {
|
|
11388
|
-
const account = byteArray
|
|
11389
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11418
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11390
11419
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
11391
11420
|
}
|
|
11392
11421
|
|
|
11393
|
-
const recentBlockhash = byteArray
|
|
11394
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11422
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11395
11423
|
const instructionCount = decodeLength(byteArray);
|
|
11396
11424
|
let instructions = [];
|
|
11397
11425
|
|
|
11398
11426
|
for (let i = 0; i < instructionCount; i++) {
|
|
11399
|
-
const programIdIndex = byteArray
|
|
11427
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11400
11428
|
const accountCount = decodeLength(byteArray);
|
|
11401
|
-
const accounts = byteArray
|
|
11402
|
-
byteArray = byteArray.slice(accountCount);
|
|
11429
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
11403
11430
|
const dataLength = decodeLength(byteArray);
|
|
11404
|
-
const dataSlice = byteArray
|
|
11431
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
11405
11432
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
11406
|
-
byteArray = byteArray.slice(dataLength);
|
|
11407
11433
|
instructions.push({
|
|
11408
11434
|
programIdIndex,
|
|
11409
11435
|
accounts,
|
|
@@ -11639,33 +11665,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11639
11665
|
|
|
11640
11666
|
static deserialize(serializedMessage) {
|
|
11641
11667
|
let byteArray = [...serializedMessage];
|
|
11642
|
-
const prefix = byteArray
|
|
11668
|
+
const prefix = guardedShift(byteArray);
|
|
11643
11669
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
11644
11670
|
assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
11645
11671
|
const version = maskedPrefix;
|
|
11646
11672
|
assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
11647
11673
|
const header = {
|
|
11648
|
-
numRequiredSignatures: byteArray
|
|
11649
|
-
numReadonlySignedAccounts: byteArray
|
|
11650
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
11674
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
11675
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
11676
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
11651
11677
|
};
|
|
11652
11678
|
const staticAccountKeys = [];
|
|
11653
11679
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
11654
11680
|
|
|
11655
11681
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
11656
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
11682
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
11657
11683
|
}
|
|
11658
11684
|
|
|
11659
|
-
const recentBlockhash = bs58$1.encode(byteArray
|
|
11685
|
+
const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11660
11686
|
const instructionCount = decodeLength(byteArray);
|
|
11661
11687
|
const compiledInstructions = [];
|
|
11662
11688
|
|
|
11663
11689
|
for (let i = 0; i < instructionCount; i++) {
|
|
11664
|
-
const programIdIndex = byteArray
|
|
11690
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11665
11691
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
11666
|
-
const accountKeyIndexes = byteArray
|
|
11692
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
11667
11693
|
const dataLength = decodeLength(byteArray);
|
|
11668
|
-
const data = new Uint8Array(byteArray
|
|
11694
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
11669
11695
|
compiledInstructions.push({
|
|
11670
11696
|
programIdIndex,
|
|
11671
11697
|
accountKeyIndexes,
|
|
@@ -11677,11 +11703,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
11677
11703
|
const addressTableLookups = [];
|
|
11678
11704
|
|
|
11679
11705
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
11680
|
-
const accountKey = new PublicKey(byteArray
|
|
11706
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11681
11707
|
const writableIndexesLength = decodeLength(byteArray);
|
|
11682
|
-
const writableIndexes = byteArray
|
|
11708
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
11683
11709
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
11684
|
-
const readonlyIndexes = byteArray
|
|
11710
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
11685
11711
|
addressTableLookups.push({
|
|
11686
11712
|
accountKey,
|
|
11687
11713
|
writableIndexes,
|
|
@@ -12412,8 +12438,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12412
12438
|
let signatures = [];
|
|
12413
12439
|
|
|
12414
12440
|
for (let i = 0; i < signatureCount; i++) {
|
|
12415
|
-
const signature = byteArray
|
|
12416
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
12441
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
12417
12442
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
12418
12443
|
}
|
|
12419
12444
|
|
|
@@ -12611,7 +12636,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12611
12636
|
const signaturesLength = decodeLength(byteArray);
|
|
12612
12637
|
|
|
12613
12638
|
for (let i = 0; i < signaturesLength; i++) {
|
|
12614
|
-
signatures.push(new Uint8Array(byteArray
|
|
12639
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
12615
12640
|
}
|
|
12616
12641
|
|
|
12617
12642
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
@@ -18184,7 +18209,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18184
18209
|
|
|
18185
18210
|
/** @internal */
|
|
18186
18211
|
const COMMON_HTTP_HEADERS = {
|
|
18187
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
18212
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.63.2") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
18188
18213
|
};
|
|
18189
18214
|
/**
|
|
18190
18215
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -24319,10 +24344,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
24319
24344
|
const configKeys = [];
|
|
24320
24345
|
|
|
24321
24346
|
for (let i = 0; i < 2; i++) {
|
|
24322
|
-
const publicKey = new PublicKey(byteArray
|
|
24323
|
-
|
|
24324
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
24325
|
-
byteArray = byteArray.slice(1);
|
|
24347
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
24348
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
24326
24349
|
configKeys.push({
|
|
24327
24350
|
publicKey,
|
|
24328
24351
|
isSigner
|