@solana/web3.js 1.3.0 → 1.3.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
|
@@ -10774,6 +10774,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
10774
10774
|
}
|
|
10775
10775
|
}
|
|
10776
10776
|
|
|
10777
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
10778
|
+
/**
|
|
10779
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
10780
|
+
*/
|
|
10781
|
+
|
|
10782
|
+
function guardedShift(byteArray) {
|
|
10783
|
+
if (byteArray.length === 0) {
|
|
10784
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
10785
|
+
}
|
|
10786
|
+
|
|
10787
|
+
return byteArray.shift();
|
|
10788
|
+
}
|
|
10789
|
+
/**
|
|
10790
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
10791
|
+
* the array.
|
|
10792
|
+
*/
|
|
10793
|
+
|
|
10794
|
+
function guardedSplice(byteArray, ...args) {
|
|
10795
|
+
var _args$;
|
|
10796
|
+
|
|
10797
|
+
const [start] = args;
|
|
10798
|
+
|
|
10799
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
10800
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
10801
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
10802
|
+
}
|
|
10803
|
+
|
|
10804
|
+
return byteArray.splice(...args);
|
|
10805
|
+
}
|
|
10806
|
+
|
|
10777
10807
|
/**
|
|
10778
10808
|
* The message header, identifying signed and read-only account
|
|
10779
10809
|
*/
|
|
@@ -10858,32 +10888,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
10858
10888
|
static from(buffer$1) {
|
|
10859
10889
|
// Slice up wire data
|
|
10860
10890
|
let byteArray = [...buffer$1];
|
|
10861
|
-
const numRequiredSignatures = byteArray
|
|
10862
|
-
const numReadonlySignedAccounts = byteArray
|
|
10863
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
10891
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
10892
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
10893
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
10864
10894
|
const accountCount = decodeLength(byteArray);
|
|
10865
10895
|
let accountKeys = [];
|
|
10866
10896
|
|
|
10867
10897
|
for (let i = 0; i < accountCount; i++) {
|
|
10868
|
-
const account = byteArray
|
|
10869
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
10898
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
10870
10899
|
accountKeys.push(bs58.encode(buffer.Buffer.from(account)));
|
|
10871
10900
|
}
|
|
10872
10901
|
|
|
10873
|
-
const recentBlockhash = byteArray
|
|
10874
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
10902
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
10875
10903
|
const instructionCount = decodeLength(byteArray);
|
|
10876
10904
|
let instructions = [];
|
|
10877
10905
|
|
|
10878
10906
|
for (let i = 0; i < instructionCount; i++) {
|
|
10879
|
-
const programIdIndex = byteArray
|
|
10907
|
+
const programIdIndex = guardedShift(byteArray);
|
|
10880
10908
|
const accountCount = decodeLength(byteArray);
|
|
10881
|
-
const accounts = byteArray
|
|
10882
|
-
byteArray = byteArray.slice(accountCount);
|
|
10909
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
10883
10910
|
const dataLength = decodeLength(byteArray);
|
|
10884
|
-
const dataSlice = byteArray
|
|
10911
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
10885
10912
|
const data = bs58.encode(buffer.Buffer.from(dataSlice));
|
|
10886
|
-
byteArray = byteArray.slice(dataLength);
|
|
10887
10913
|
instructions.push({
|
|
10888
10914
|
programIdIndex,
|
|
10889
10915
|
accounts,
|
|
@@ -11503,8 +11529,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
11503
11529
|
let signatures = [];
|
|
11504
11530
|
|
|
11505
11531
|
for (let i = 0; i < signatureCount; i++) {
|
|
11506
|
-
const signature = byteArray
|
|
11507
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
11532
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
11508
11533
|
signatures.push(bs58.encode(buffer.Buffer.from(signature)));
|
|
11509
11534
|
}
|
|
11510
11535
|
|
|
@@ -20525,9 +20550,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
20525
20550
|
"minimalistic-assert": "^1.0.1",
|
|
20526
20551
|
"minimalistic-crypto-utils": "^1.0.1"
|
|
20527
20552
|
};
|
|
20528
|
-
var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
|
|
20529
|
-
var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
|
|
20530
|
-
var _from = "elliptic@6.5.4";
|
|
20531
20553
|
var require$$0 = {
|
|
20532
20554
|
name: name,
|
|
20533
20555
|
version: version,
|
|
@@ -20542,10 +20564,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
20542
20564
|
bugs: bugs,
|
|
20543
20565
|
homepage: homepage,
|
|
20544
20566
|
devDependencies: devDependencies,
|
|
20545
|
-
dependencies: dependencies
|
|
20546
|
-
_resolved: _resolved,
|
|
20547
|
-
_integrity: _integrity,
|
|
20548
|
-
_from: _from
|
|
20567
|
+
dependencies: dependencies
|
|
20549
20568
|
};
|
|
20550
20569
|
|
|
20551
20570
|
var minimalisticAssert = assert$9;
|
|
@@ -27151,10 +27170,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
27151
27170
|
const configKeys = [];
|
|
27152
27171
|
|
|
27153
27172
|
for (let i = 0; i < 2; i++) {
|
|
27154
|
-
const publicKey = new PublicKey(byteArray
|
|
27155
|
-
|
|
27156
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
27157
|
-
byteArray = byteArray.slice(1);
|
|
27173
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
27174
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
27158
27175
|
configKeys.push({
|
|
27159
27176
|
publicKey,
|
|
27160
27177
|
isSigner
|