@solana/web3.js 1.37.2 → 1.37.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 +45 -18
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +45 -18
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +45 -18
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +45 -18
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +45 -18
- 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 +24 -24
- 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
|
@@ -13845,6 +13845,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
13845
13845
|
}
|
|
13846
13846
|
}
|
|
13847
13847
|
|
|
13848
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
13849
|
+
/**
|
|
13850
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
13851
|
+
*/
|
|
13852
|
+
|
|
13853
|
+
function guardedShift(byteArray) {
|
|
13854
|
+
if (byteArray.length === 0) {
|
|
13855
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
13856
|
+
}
|
|
13857
|
+
|
|
13858
|
+
return byteArray.shift();
|
|
13859
|
+
}
|
|
13860
|
+
/**
|
|
13861
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
13862
|
+
* the array.
|
|
13863
|
+
*/
|
|
13864
|
+
|
|
13865
|
+
function guardedSplice(byteArray, ...args) {
|
|
13866
|
+
var _args$;
|
|
13867
|
+
|
|
13868
|
+
const [start] = args;
|
|
13869
|
+
|
|
13870
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
13871
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
13872
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
13873
|
+
}
|
|
13874
|
+
|
|
13875
|
+
return byteArray.splice(...args);
|
|
13876
|
+
}
|
|
13877
|
+
|
|
13848
13878
|
/**
|
|
13849
13879
|
* The message header, identifying signed and read-only account
|
|
13850
13880
|
*/
|
|
@@ -13943,32 +13973,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
13943
13973
|
static from(buffer$1) {
|
|
13944
13974
|
// Slice up wire data
|
|
13945
13975
|
let byteArray = [...buffer$1];
|
|
13946
|
-
const numRequiredSignatures = byteArray
|
|
13947
|
-
const numReadonlySignedAccounts = byteArray
|
|
13948
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
13976
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
13977
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
13978
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
13949
13979
|
const accountCount = decodeLength(byteArray);
|
|
13950
13980
|
let accountKeys = [];
|
|
13951
13981
|
|
|
13952
13982
|
for (let i = 0; i < accountCount; i++) {
|
|
13953
|
-
const account = byteArray
|
|
13954
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
13983
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
13955
13984
|
accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
|
|
13956
13985
|
}
|
|
13957
13986
|
|
|
13958
|
-
const recentBlockhash = byteArray
|
|
13959
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
13987
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
13960
13988
|
const instructionCount = decodeLength(byteArray);
|
|
13961
13989
|
let instructions = [];
|
|
13962
13990
|
|
|
13963
13991
|
for (let i = 0; i < instructionCount; i++) {
|
|
13964
|
-
const programIdIndex = byteArray
|
|
13992
|
+
const programIdIndex = guardedShift(byteArray);
|
|
13965
13993
|
const accountCount = decodeLength(byteArray);
|
|
13966
|
-
const accounts = byteArray
|
|
13967
|
-
byteArray = byteArray.slice(accountCount);
|
|
13994
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
13968
13995
|
const dataLength = decodeLength(byteArray);
|
|
13969
|
-
const dataSlice = byteArray
|
|
13996
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
13970
13997
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
13971
|
-
byteArray = byteArray.slice(dataLength);
|
|
13972
13998
|
instructions.push({
|
|
13973
13999
|
programIdIndex,
|
|
13974
14000
|
accounts,
|
|
@@ -13997,6 +14023,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
13997
14023
|
}
|
|
13998
14024
|
}
|
|
13999
14025
|
|
|
14026
|
+
/**
|
|
14027
|
+
* Transaction signature as base-58 encoded string
|
|
14028
|
+
*/
|
|
14029
|
+
|
|
14000
14030
|
/**
|
|
14001
14031
|
* Default (empty) signature
|
|
14002
14032
|
*
|
|
@@ -14591,8 +14621,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
14591
14621
|
let signatures = [];
|
|
14592
14622
|
|
|
14593
14623
|
for (let i = 0; i < signatureCount; i++) {
|
|
14594
|
-
const signature = byteArray
|
|
14595
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
14624
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
14596
14625
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
14597
14626
|
}
|
|
14598
14627
|
|
|
@@ -29350,10 +29379,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
29350
29379
|
const configKeys = [];
|
|
29351
29380
|
|
|
29352
29381
|
for (let i = 0; i < 2; i++) {
|
|
29353
|
-
const publicKey = new PublicKey(byteArray
|
|
29354
|
-
|
|
29355
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
29356
|
-
byteArray = byteArray.slice(1);
|
|
29382
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
29383
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
29357
29384
|
configKeys.push({
|
|
29358
29385
|
publicKey,
|
|
29359
29386
|
isSigner
|