@solana/web3.js 1.90.1 → 1.90.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 +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 +78 -20
- 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
|
@@ -12061,6 +12061,31 @@ var solanaWeb3 = (function (exports) {
|
|
|
12061
12061
|
}
|
|
12062
12062
|
}
|
|
12063
12063
|
|
|
12064
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
12065
|
+
|
|
12066
|
+
/**
|
|
12067
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
12068
|
+
*/
|
|
12069
|
+
function guardedShift(byteArray) {
|
|
12070
|
+
if (byteArray.length === 0) {
|
|
12071
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
12072
|
+
}
|
|
12073
|
+
return byteArray.shift();
|
|
12074
|
+
}
|
|
12075
|
+
|
|
12076
|
+
/**
|
|
12077
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
12078
|
+
* the array.
|
|
12079
|
+
*/
|
|
12080
|
+
function guardedSplice(byteArray, ...args) {
|
|
12081
|
+
const [start] = args;
|
|
12082
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
12083
|
+
? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) {
|
|
12084
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
12085
|
+
}
|
|
12086
|
+
return byteArray.splice(...args);
|
|
12087
|
+
}
|
|
12088
|
+
|
|
12064
12089
|
/**
|
|
12065
12090
|
* An instruction to execute by a program
|
|
12066
12091
|
*
|
|
@@ -12202,32 +12227,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
12202
12227
|
static from(buffer$1) {
|
|
12203
12228
|
// Slice up wire data
|
|
12204
12229
|
let byteArray = [...buffer$1];
|
|
12205
|
-
const numRequiredSignatures = byteArray
|
|
12230
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
12206
12231
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
12207
12232
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
12208
12233
|
}
|
|
12209
|
-
const numReadonlySignedAccounts = byteArray
|
|
12210
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
12234
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
12235
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
12211
12236
|
const accountCount = decodeLength(byteArray);
|
|
12212
12237
|
let accountKeys = [];
|
|
12213
12238
|
for (let i = 0; i < accountCount; i++) {
|
|
12214
|
-
const account = byteArray
|
|
12215
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
12239
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
12216
12240
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
12217
12241
|
}
|
|
12218
|
-
const recentBlockhash = byteArray
|
|
12219
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
12242
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
12220
12243
|
const instructionCount = decodeLength(byteArray);
|
|
12221
12244
|
let instructions = [];
|
|
12222
12245
|
for (let i = 0; i < instructionCount; i++) {
|
|
12223
|
-
const programIdIndex = byteArray
|
|
12246
|
+
const programIdIndex = guardedShift(byteArray);
|
|
12224
12247
|
const accountCount = decodeLength(byteArray);
|
|
12225
|
-
const accounts = byteArray
|
|
12226
|
-
byteArray = byteArray.slice(accountCount);
|
|
12248
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
12227
12249
|
const dataLength = decodeLength(byteArray);
|
|
12228
|
-
const dataSlice = byteArray
|
|
12250
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
12229
12251
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
12230
|
-
byteArray = byteArray.slice(dataLength);
|
|
12231
12252
|
instructions.push({
|
|
12232
12253
|
programIdIndex,
|
|
12233
12254
|
accounts,
|
|
@@ -12432,30 +12453,30 @@ var solanaWeb3 = (function (exports) {
|
|
|
12432
12453
|
}
|
|
12433
12454
|
static deserialize(serializedMessage) {
|
|
12434
12455
|
let byteArray = [...serializedMessage];
|
|
12435
|
-
const prefix = byteArray
|
|
12456
|
+
const prefix = guardedShift(byteArray);
|
|
12436
12457
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
12437
12458
|
assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
12438
12459
|
const version = maskedPrefix;
|
|
12439
12460
|
assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
12440
12461
|
const header = {
|
|
12441
|
-
numRequiredSignatures: byteArray
|
|
12442
|
-
numReadonlySignedAccounts: byteArray
|
|
12443
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
12462
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
12463
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
12464
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
12444
12465
|
};
|
|
12445
12466
|
const staticAccountKeys = [];
|
|
12446
12467
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
12447
12468
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
12448
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
12469
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
12449
12470
|
}
|
|
12450
|
-
const recentBlockhash = bs58$1.encode(byteArray
|
|
12471
|
+
const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
12451
12472
|
const instructionCount = decodeLength(byteArray);
|
|
12452
12473
|
const compiledInstructions = [];
|
|
12453
12474
|
for (let i = 0; i < instructionCount; i++) {
|
|
12454
|
-
const programIdIndex = byteArray
|
|
12475
|
+
const programIdIndex = guardedShift(byteArray);
|
|
12455
12476
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
12456
|
-
const accountKeyIndexes = byteArray
|
|
12477
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
12457
12478
|
const dataLength = decodeLength(byteArray);
|
|
12458
|
-
const data = new Uint8Array(byteArray
|
|
12479
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
12459
12480
|
compiledInstructions.push({
|
|
12460
12481
|
programIdIndex,
|
|
12461
12482
|
accountKeyIndexes,
|
|
@@ -12465,11 +12486,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
12465
12486
|
const addressTableLookupsCount = decodeLength(byteArray);
|
|
12466
12487
|
const addressTableLookups = [];
|
|
12467
12488
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
12468
|
-
const accountKey = new PublicKey(byteArray
|
|
12489
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
12469
12490
|
const writableIndexesLength = decodeLength(byteArray);
|
|
12470
|
-
const writableIndexes = byteArray
|
|
12491
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
12471
12492
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
12472
|
-
const readonlyIndexes = byteArray
|
|
12493
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
12473
12494
|
addressTableLookups.push({
|
|
12474
12495
|
accountKey,
|
|
12475
12496
|
writableIndexes,
|
|
@@ -13260,8 +13281,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
13260
13281
|
const signatureCount = decodeLength(byteArray);
|
|
13261
13282
|
let signatures = [];
|
|
13262
13283
|
for (let i = 0; i < signatureCount; i++) {
|
|
13263
|
-
const signature = byteArray
|
|
13264
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
13284
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
13265
13285
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
13266
13286
|
}
|
|
13267
13287
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -13436,7 +13456,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
13436
13456
|
const signatures = [];
|
|
13437
13457
|
const signaturesLength = decodeLength(byteArray);
|
|
13438
13458
|
for (let i = 0; i < signaturesLength; i++) {
|
|
13439
|
-
signatures.push(new Uint8Array(byteArray
|
|
13459
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
13440
13460
|
}
|
|
13441
13461
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
13442
13462
|
return new VersionedTransaction(message, signatures);
|
|
@@ -19568,7 +19588,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
19568
19588
|
|
|
19569
19589
|
/** @internal */
|
|
19570
19590
|
const COMMON_HTTP_HEADERS = {
|
|
19571
|
-
'solana-client': `js/${"
|
|
19591
|
+
'solana-client': `js/${"1.90.2" }`
|
|
19572
19592
|
};
|
|
19573
19593
|
|
|
19574
19594
|
/**
|
|
@@ -25952,10 +25972,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
25952
25972
|
if (configKeyCount !== 2) return null;
|
|
25953
25973
|
const configKeys = [];
|
|
25954
25974
|
for (let i = 0; i < 2; i++) {
|
|
25955
|
-
const publicKey = new PublicKey(byteArray
|
|
25956
|
-
|
|
25957
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
25958
|
-
byteArray = byteArray.slice(1);
|
|
25975
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
25976
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
25959
25977
|
configKeys.push({
|
|
25960
25978
|
publicKey,
|
|
25961
25979
|
isSigner
|