@solana/web3.js 1.8.0 → 1.8.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.esm.js +41 -18
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +41 -18
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +41 -18
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +42 -25
- 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/package.json +28 -28
- package/src/message.ts +9 -12
- package/src/transaction.ts +2 -2
- package/src/util/guarded-array-utils.ts +37 -0
- package/src/validator-info.ts +5 -4
package/lib/index.iife.js
CHANGED
|
@@ -10783,6 +10783,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
10783
10783
|
}
|
|
10784
10784
|
}
|
|
10785
10785
|
|
|
10786
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
10787
|
+
/**
|
|
10788
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
10789
|
+
*/
|
|
10790
|
+
|
|
10791
|
+
function guardedShift(byteArray) {
|
|
10792
|
+
if (byteArray.length === 0) {
|
|
10793
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
10794
|
+
}
|
|
10795
|
+
|
|
10796
|
+
return byteArray.shift();
|
|
10797
|
+
}
|
|
10798
|
+
/**
|
|
10799
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
10800
|
+
* the array.
|
|
10801
|
+
*/
|
|
10802
|
+
|
|
10803
|
+
function guardedSplice(byteArray, ...args) {
|
|
10804
|
+
var _args$;
|
|
10805
|
+
|
|
10806
|
+
const [start] = args;
|
|
10807
|
+
|
|
10808
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
10809
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
10810
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
10811
|
+
}
|
|
10812
|
+
|
|
10813
|
+
return byteArray.splice(...args);
|
|
10814
|
+
}
|
|
10815
|
+
|
|
10786
10816
|
/**
|
|
10787
10817
|
* The message header, identifying signed and read-only account
|
|
10788
10818
|
*/
|
|
@@ -10859,32 +10889,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
10859
10889
|
static from(buffer$1) {
|
|
10860
10890
|
// Slice up wire data
|
|
10861
10891
|
let byteArray = [...buffer$1];
|
|
10862
|
-
const numRequiredSignatures = byteArray
|
|
10863
|
-
const numReadonlySignedAccounts = byteArray
|
|
10864
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
10892
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
10893
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
10894
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
10865
10895
|
const accountCount = decodeLength(byteArray);
|
|
10866
10896
|
let accountKeys = [];
|
|
10867
10897
|
|
|
10868
10898
|
for (let i = 0; i < accountCount; i++) {
|
|
10869
|
-
const account = byteArray
|
|
10870
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
10899
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
10871
10900
|
accountKeys.push(bs58.encode(buffer.Buffer.from(account)));
|
|
10872
10901
|
}
|
|
10873
10902
|
|
|
10874
|
-
const recentBlockhash = byteArray
|
|
10875
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
10903
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
10876
10904
|
const instructionCount = decodeLength(byteArray);
|
|
10877
10905
|
let instructions = [];
|
|
10878
10906
|
|
|
10879
10907
|
for (let i = 0; i < instructionCount; i++) {
|
|
10880
|
-
const programIdIndex = byteArray
|
|
10908
|
+
const programIdIndex = guardedShift(byteArray);
|
|
10881
10909
|
const accountCount = decodeLength(byteArray);
|
|
10882
|
-
const accounts = byteArray
|
|
10883
|
-
byteArray = byteArray.slice(accountCount);
|
|
10910
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
10884
10911
|
const dataLength = decodeLength(byteArray);
|
|
10885
|
-
const dataSlice = byteArray
|
|
10912
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
10886
10913
|
const data = bs58.encode(buffer.Buffer.from(dataSlice));
|
|
10887
|
-
byteArray = byteArray.slice(dataLength);
|
|
10888
10914
|
instructions.push({
|
|
10889
10915
|
programIdIndex,
|
|
10890
10916
|
accounts,
|
|
@@ -11494,8 +11520,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
11494
11520
|
let signatures = [];
|
|
11495
11521
|
|
|
11496
11522
|
for (let i = 0; i < signatureCount; i++) {
|
|
11497
|
-
const signature = byteArray
|
|
11498
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
11523
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
11499
11524
|
signatures.push(bs58.encode(buffer.Buffer.from(signature)));
|
|
11500
11525
|
}
|
|
11501
11526
|
|
|
@@ -20645,9 +20670,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
20645
20670
|
"minimalistic-assert": "^1.0.1",
|
|
20646
20671
|
"minimalistic-crypto-utils": "^1.0.1"
|
|
20647
20672
|
};
|
|
20648
|
-
var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
|
|
20649
|
-
var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
|
|
20650
|
-
var _from = "elliptic@6.5.4";
|
|
20651
20673
|
var require$$0 = {
|
|
20652
20674
|
name: name,
|
|
20653
20675
|
version: version,
|
|
@@ -20662,10 +20684,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
20662
20684
|
bugs: bugs,
|
|
20663
20685
|
homepage: homepage,
|
|
20664
20686
|
devDependencies: devDependencies,
|
|
20665
|
-
dependencies: dependencies
|
|
20666
|
-
_resolved: _resolved,
|
|
20667
|
-
_integrity: _integrity,
|
|
20668
|
-
_from: _from
|
|
20687
|
+
dependencies: dependencies
|
|
20669
20688
|
};
|
|
20670
20689
|
|
|
20671
20690
|
var minimalisticAssert = assert$9;
|
|
@@ -27267,10 +27286,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
27267
27286
|
const configKeys = [];
|
|
27268
27287
|
|
|
27269
27288
|
for (let i = 0; i < 2; i++) {
|
|
27270
|
-
const publicKey = new PublicKey(byteArray
|
|
27271
|
-
|
|
27272
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
27273
|
-
byteArray = byteArray.slice(1);
|
|
27289
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
27290
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
27274
27291
|
configKeys.push({
|
|
27275
27292
|
publicKey,
|
|
27276
27293
|
isSigner
|