@solana/web3.js 1.67.1 → 1.67.3
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 +56 -33
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +56 -33
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +56 -33
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.esm.js +56 -33
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +56 -33
- 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 +56 -33
- package/lib/index.native.js.map +1 -1
- package/package.json +22 -22
- package/src/connection.ts +2 -2
- 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
|
@@ -11238,6 +11238,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
11238
11238
|
|
|
11239
11239
|
}
|
|
11240
11240
|
|
|
11241
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
11242
|
+
/**
|
|
11243
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
11244
|
+
*/
|
|
11245
|
+
|
|
11246
|
+
function guardedShift(byteArray) {
|
|
11247
|
+
if (byteArray.length === 0) {
|
|
11248
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11249
|
+
}
|
|
11250
|
+
|
|
11251
|
+
return byteArray.shift();
|
|
11252
|
+
}
|
|
11253
|
+
/**
|
|
11254
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
11255
|
+
* the array.
|
|
11256
|
+
*/
|
|
11257
|
+
|
|
11258
|
+
function guardedSplice(byteArray, ...args) {
|
|
11259
|
+
var _args$;
|
|
11260
|
+
|
|
11261
|
+
const [start] = args;
|
|
11262
|
+
|
|
11263
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
11264
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
11265
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11266
|
+
}
|
|
11267
|
+
|
|
11268
|
+
return byteArray.splice(...args);
|
|
11269
|
+
}
|
|
11270
|
+
|
|
11241
11271
|
/**
|
|
11242
11272
|
* An instruction to execute by a program
|
|
11243
11273
|
*
|
|
@@ -11389,37 +11419,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11389
11419
|
static from(buffer$1) {
|
|
11390
11420
|
// Slice up wire data
|
|
11391
11421
|
let byteArray = [...buffer$1];
|
|
11392
|
-
const numRequiredSignatures = byteArray
|
|
11422
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
11393
11423
|
|
|
11394
11424
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
11395
11425
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
11396
11426
|
}
|
|
11397
11427
|
|
|
11398
|
-
const numReadonlySignedAccounts = byteArray
|
|
11399
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
11428
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
11429
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
11400
11430
|
const accountCount = decodeLength(byteArray);
|
|
11401
11431
|
let accountKeys = [];
|
|
11402
11432
|
|
|
11403
11433
|
for (let i = 0; i < accountCount; i++) {
|
|
11404
|
-
const account = byteArray
|
|
11405
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11434
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11406
11435
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
11407
11436
|
}
|
|
11408
11437
|
|
|
11409
|
-
const recentBlockhash = byteArray
|
|
11410
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11438
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11411
11439
|
const instructionCount = decodeLength(byteArray);
|
|
11412
11440
|
let instructions = [];
|
|
11413
11441
|
|
|
11414
11442
|
for (let i = 0; i < instructionCount; i++) {
|
|
11415
|
-
const programIdIndex = byteArray
|
|
11443
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11416
11444
|
const accountCount = decodeLength(byteArray);
|
|
11417
|
-
const accounts = byteArray
|
|
11418
|
-
byteArray = byteArray.slice(accountCount);
|
|
11445
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
11419
11446
|
const dataLength = decodeLength(byteArray);
|
|
11420
|
-
const dataSlice = byteArray
|
|
11447
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
11421
11448
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
11422
|
-
byteArray = byteArray.slice(dataLength);
|
|
11423
11449
|
instructions.push({
|
|
11424
11450
|
programIdIndex,
|
|
11425
11451
|
accounts,
|
|
@@ -11655,33 +11681,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11655
11681
|
|
|
11656
11682
|
static deserialize(serializedMessage) {
|
|
11657
11683
|
let byteArray = [...serializedMessage];
|
|
11658
|
-
const prefix = byteArray
|
|
11684
|
+
const prefix = guardedShift(byteArray);
|
|
11659
11685
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
11660
11686
|
assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
11661
11687
|
const version = maskedPrefix;
|
|
11662
11688
|
assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
11663
11689
|
const header = {
|
|
11664
|
-
numRequiredSignatures: byteArray
|
|
11665
|
-
numReadonlySignedAccounts: byteArray
|
|
11666
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
11690
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
11691
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
11692
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
11667
11693
|
};
|
|
11668
11694
|
const staticAccountKeys = [];
|
|
11669
11695
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
11670
11696
|
|
|
11671
11697
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
11672
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
11698
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
11673
11699
|
}
|
|
11674
11700
|
|
|
11675
|
-
const recentBlockhash = bs58$1.encode(byteArray
|
|
11701
|
+
const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11676
11702
|
const instructionCount = decodeLength(byteArray);
|
|
11677
11703
|
const compiledInstructions = [];
|
|
11678
11704
|
|
|
11679
11705
|
for (let i = 0; i < instructionCount; i++) {
|
|
11680
|
-
const programIdIndex = byteArray
|
|
11706
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11681
11707
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
11682
|
-
const accountKeyIndexes = byteArray
|
|
11708
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
11683
11709
|
const dataLength = decodeLength(byteArray);
|
|
11684
|
-
const data = new Uint8Array(byteArray
|
|
11710
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
11685
11711
|
compiledInstructions.push({
|
|
11686
11712
|
programIdIndex,
|
|
11687
11713
|
accountKeyIndexes,
|
|
@@ -11693,11 +11719,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
11693
11719
|
const addressTableLookups = [];
|
|
11694
11720
|
|
|
11695
11721
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
11696
|
-
const accountKey = new PublicKey(byteArray
|
|
11722
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11697
11723
|
const writableIndexesLength = decodeLength(byteArray);
|
|
11698
|
-
const writableIndexes = byteArray
|
|
11724
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
11699
11725
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
11700
|
-
const readonlyIndexes = byteArray
|
|
11726
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
11701
11727
|
addressTableLookups.push({
|
|
11702
11728
|
accountKey,
|
|
11703
11729
|
writableIndexes,
|
|
@@ -12437,8 +12463,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12437
12463
|
let signatures = [];
|
|
12438
12464
|
|
|
12439
12465
|
for (let i = 0; i < signatureCount; i++) {
|
|
12440
|
-
const signature = byteArray
|
|
12441
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
12466
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
12442
12467
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
12443
12468
|
}
|
|
12444
12469
|
|
|
@@ -12636,7 +12661,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12636
12661
|
const signaturesLength = decodeLength(byteArray);
|
|
12637
12662
|
|
|
12638
12663
|
for (let i = 0; i < signaturesLength; i++) {
|
|
12639
|
-
signatures.push(new Uint8Array(byteArray
|
|
12664
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
12640
12665
|
}
|
|
12641
12666
|
|
|
12642
12667
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
@@ -18254,7 +18279,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18254
18279
|
|
|
18255
18280
|
/** @internal */
|
|
18256
18281
|
const COMMON_HTTP_HEADERS = {
|
|
18257
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
18282
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.67.3") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
18258
18283
|
};
|
|
18259
18284
|
/**
|
|
18260
18285
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -19636,7 +19661,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
19636
19661
|
|
|
19637
19662
|
|
|
19638
19663
|
async getFeeForMessage(message, commitment) {
|
|
19639
|
-
const wireMessage = message.serialize().toString('base64');
|
|
19664
|
+
const wireMessage = toBuffer(message.serialize()).toString('base64');
|
|
19640
19665
|
|
|
19641
19666
|
const args = this._buildArgs([wireMessage], commitment);
|
|
19642
19667
|
|
|
@@ -24795,10 +24820,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
24795
24820
|
const configKeys = [];
|
|
24796
24821
|
|
|
24797
24822
|
for (let i = 0; i < 2; i++) {
|
|
24798
|
-
const publicKey = new PublicKey(byteArray
|
|
24799
|
-
|
|
24800
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
24801
|
-
byteArray = byteArray.slice(1);
|
|
24823
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
24824
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
24802
24825
|
configKeys.push({
|
|
24803
24826
|
publicKey,
|
|
24804
24827
|
isSigner
|