@solana/web3.js 1.74.0 → 1.74.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 +53 -36
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +53 -36
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +53 -36
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +53 -36
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +53 -36
- 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 +53 -36
- package/lib/index.native.js.map +1 -1
- package/package.json +21 -21
- 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
|
@@ -11296,8 +11296,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
11296
11296
|
getOrInsertDefault(ix.programId).isInvoked = true;
|
|
11297
11297
|
for (const accountMeta of ix.keys) {
|
|
11298
11298
|
const keyMeta = getOrInsertDefault(accountMeta.pubkey);
|
|
11299
|
-
keyMeta.isSigner
|
|
11300
|
-
keyMeta.isWritable
|
|
11299
|
+
keyMeta.isSigner ||= accountMeta.isSigner;
|
|
11300
|
+
keyMeta.isWritable ||= accountMeta.isWritable;
|
|
11301
11301
|
}
|
|
11302
11302
|
}
|
|
11303
11303
|
return new CompiledKeys(payer, keyMetaMap);
|
|
@@ -11362,6 +11362,31 @@ var solanaWeb3 = (function (exports) {
|
|
|
11362
11362
|
}
|
|
11363
11363
|
}
|
|
11364
11364
|
|
|
11365
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
11366
|
+
|
|
11367
|
+
/**
|
|
11368
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
11369
|
+
*/
|
|
11370
|
+
function guardedShift(byteArray) {
|
|
11371
|
+
if (byteArray.length === 0) {
|
|
11372
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11373
|
+
}
|
|
11374
|
+
return byteArray.shift();
|
|
11375
|
+
}
|
|
11376
|
+
|
|
11377
|
+
/**
|
|
11378
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
11379
|
+
* the array.
|
|
11380
|
+
*/
|
|
11381
|
+
function guardedSplice(byteArray, ...args) {
|
|
11382
|
+
const [start] = args;
|
|
11383
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
11384
|
+
? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) {
|
|
11385
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11386
|
+
}
|
|
11387
|
+
return byteArray.splice(...args);
|
|
11388
|
+
}
|
|
11389
|
+
|
|
11365
11390
|
/**
|
|
11366
11391
|
* An instruction to execute by a program
|
|
11367
11392
|
*
|
|
@@ -11499,32 +11524,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
11499
11524
|
static from(buffer$1) {
|
|
11500
11525
|
// Slice up wire data
|
|
11501
11526
|
let byteArray = [...buffer$1];
|
|
11502
|
-
const numRequiredSignatures = byteArray
|
|
11527
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
11503
11528
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
11504
11529
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
11505
11530
|
}
|
|
11506
|
-
const numReadonlySignedAccounts = byteArray
|
|
11507
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
11531
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
11532
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
11508
11533
|
const accountCount = decodeLength(byteArray);
|
|
11509
11534
|
let accountKeys = [];
|
|
11510
11535
|
for (let i = 0; i < accountCount; i++) {
|
|
11511
|
-
const account = byteArray
|
|
11512
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11536
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11513
11537
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
11514
11538
|
}
|
|
11515
|
-
const recentBlockhash = byteArray
|
|
11516
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11539
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11517
11540
|
const instructionCount = decodeLength(byteArray);
|
|
11518
11541
|
let instructions = [];
|
|
11519
11542
|
for (let i = 0; i < instructionCount; i++) {
|
|
11520
|
-
const programIdIndex = byteArray
|
|
11543
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11521
11544
|
const accountCount = decodeLength(byteArray);
|
|
11522
|
-
const accounts = byteArray
|
|
11523
|
-
byteArray = byteArray.slice(accountCount);
|
|
11545
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
11524
11546
|
const dataLength = decodeLength(byteArray);
|
|
11525
|
-
const dataSlice = byteArray
|
|
11547
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
11526
11548
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
11527
|
-
byteArray = byteArray.slice(dataLength);
|
|
11528
11549
|
instructions.push({
|
|
11529
11550
|
programIdIndex,
|
|
11530
11551
|
accounts,
|
|
@@ -11729,30 +11750,30 @@ var solanaWeb3 = (function (exports) {
|
|
|
11729
11750
|
}
|
|
11730
11751
|
static deserialize(serializedMessage) {
|
|
11731
11752
|
let byteArray = [...serializedMessage];
|
|
11732
|
-
const prefix = byteArray
|
|
11753
|
+
const prefix = guardedShift(byteArray);
|
|
11733
11754
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
11734
11755
|
assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
11735
11756
|
const version = maskedPrefix;
|
|
11736
11757
|
assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
11737
11758
|
const header = {
|
|
11738
|
-
numRequiredSignatures: byteArray
|
|
11739
|
-
numReadonlySignedAccounts: byteArray
|
|
11740
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
11759
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
11760
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
11761
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
11741
11762
|
};
|
|
11742
11763
|
const staticAccountKeys = [];
|
|
11743
11764
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
11744
11765
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
11745
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
11766
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
11746
11767
|
}
|
|
11747
|
-
const recentBlockhash = bs58$1.encode(byteArray
|
|
11768
|
+
const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11748
11769
|
const instructionCount = decodeLength(byteArray);
|
|
11749
11770
|
const compiledInstructions = [];
|
|
11750
11771
|
for (let i = 0; i < instructionCount; i++) {
|
|
11751
|
-
const programIdIndex = byteArray
|
|
11772
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11752
11773
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
11753
|
-
const accountKeyIndexes = byteArray
|
|
11774
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
11754
11775
|
const dataLength = decodeLength(byteArray);
|
|
11755
|
-
const data = new Uint8Array(byteArray
|
|
11776
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
11756
11777
|
compiledInstructions.push({
|
|
11757
11778
|
programIdIndex,
|
|
11758
11779
|
accountKeyIndexes,
|
|
@@ -11762,11 +11783,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
11762
11783
|
const addressTableLookupsCount = decodeLength(byteArray);
|
|
11763
11784
|
const addressTableLookups = [];
|
|
11764
11785
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
11765
|
-
const accountKey = new PublicKey(byteArray
|
|
11786
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11766
11787
|
const writableIndexesLength = decodeLength(byteArray);
|
|
11767
|
-
const writableIndexes = byteArray
|
|
11788
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
11768
11789
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
11769
|
-
const readonlyIndexes = byteArray
|
|
11790
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
11770
11791
|
addressTableLookups.push({
|
|
11771
11792
|
accountKey,
|
|
11772
11793
|
writableIndexes,
|
|
@@ -12441,8 +12462,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12441
12462
|
const signatureCount = decodeLength(byteArray);
|
|
12442
12463
|
let signatures = [];
|
|
12443
12464
|
for (let i = 0; i < signatureCount; i++) {
|
|
12444
|
-
const signature = byteArray
|
|
12445
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
12465
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
12446
12466
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
12447
12467
|
}
|
|
12448
12468
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -12612,7 +12632,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12612
12632
|
const signatures = [];
|
|
12613
12633
|
const signaturesLength = decodeLength(byteArray);
|
|
12614
12634
|
for (let i = 0; i < signaturesLength; i++) {
|
|
12615
|
-
signatures.push(new Uint8Array(byteArray
|
|
12635
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
12616
12636
|
}
|
|
12617
12637
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
12618
12638
|
return new VersionedTransaction(message, signatures);
|
|
@@ -18229,7 +18249,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18229
18249
|
|
|
18230
18250
|
/** @internal */
|
|
18231
18251
|
const COMMON_HTTP_HEADERS = {
|
|
18232
|
-
'solana-client': `js/${"
|
|
18252
|
+
'solana-client': `js/${"1.74.1" }`
|
|
18233
18253
|
};
|
|
18234
18254
|
|
|
18235
18255
|
/**
|
|
@@ -20445,12 +20465,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
20445
20465
|
* @internal
|
|
20446
20466
|
*/
|
|
20447
20467
|
_onSubscriptionStateChange(clientSubscriptionId, callback) {
|
|
20448
|
-
var _this$_subscriptionSt;
|
|
20449
20468
|
const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
|
|
20450
20469
|
if (hash == null) {
|
|
20451
20470
|
return () => {};
|
|
20452
20471
|
}
|
|
20453
|
-
const stateChangeCallbacks =
|
|
20472
|
+
const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();
|
|
20454
20473
|
stateChangeCallbacks.add(callback);
|
|
20455
20474
|
return () => {
|
|
20456
20475
|
stateChangeCallbacks.delete(callback);
|
|
@@ -24287,10 +24306,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
24287
24306
|
if (configKeyCount !== 2) return null;
|
|
24288
24307
|
const configKeys = [];
|
|
24289
24308
|
for (let i = 0; i < 2; i++) {
|
|
24290
|
-
const publicKey = new PublicKey(byteArray
|
|
24291
|
-
|
|
24292
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
24293
|
-
byteArray = byteArray.slice(1);
|
|
24309
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
24310
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
24294
24311
|
configKeys.push({
|
|
24295
24312
|
publicKey,
|
|
24296
24313
|
isSigner
|