@solana/web3.js 1.56.2 → 1.56.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 +63 -32
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +63 -32
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +63 -32
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +63 -32
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +63 -32
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -3
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +63 -32
- package/lib/index.native.js.map +1 -1
- package/package.json +22 -22
- 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
|
@@ -11010,6 +11010,44 @@ var solanaWeb3 = (function (exports) {
|
|
|
11010
11010
|
}
|
|
11011
11011
|
}
|
|
11012
11012
|
|
|
11013
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
11014
|
+
/**
|
|
11015
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
11016
|
+
*/
|
|
11017
|
+
|
|
11018
|
+
function guardedShift(byteArray) {
|
|
11019
|
+
if (byteArray.length === 0) {
|
|
11020
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11021
|
+
}
|
|
11022
|
+
|
|
11023
|
+
return byteArray.shift();
|
|
11024
|
+
}
|
|
11025
|
+
/**
|
|
11026
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
11027
|
+
* the array.
|
|
11028
|
+
*/
|
|
11029
|
+
|
|
11030
|
+
function guardedSplice(byteArray, ...args) {
|
|
11031
|
+
var _args$;
|
|
11032
|
+
|
|
11033
|
+
const [start] = args;
|
|
11034
|
+
|
|
11035
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
11036
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
11037
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11038
|
+
}
|
|
11039
|
+
|
|
11040
|
+
return byteArray.splice(...args);
|
|
11041
|
+
}
|
|
11042
|
+
|
|
11043
|
+
/**
|
|
11044
|
+
* An instruction to execute by a program
|
|
11045
|
+
*
|
|
11046
|
+
* @property {number} programIdIndex
|
|
11047
|
+
* @property {number[]} accounts
|
|
11048
|
+
* @property {string} data
|
|
11049
|
+
*/
|
|
11050
|
+
|
|
11013
11051
|
/**
|
|
11014
11052
|
* List of instructions to be processed atomically
|
|
11015
11053
|
*/
|
|
@@ -11122,37 +11160,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11122
11160
|
static from(buffer$1) {
|
|
11123
11161
|
// Slice up wire data
|
|
11124
11162
|
let byteArray = [...buffer$1];
|
|
11125
|
-
const numRequiredSignatures = byteArray
|
|
11163
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
11126
11164
|
|
|
11127
11165
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
11128
11166
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
11129
11167
|
}
|
|
11130
11168
|
|
|
11131
|
-
const numReadonlySignedAccounts = byteArray
|
|
11132
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
11169
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
11170
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
11133
11171
|
const accountCount = decodeLength(byteArray);
|
|
11134
11172
|
let accountKeys = [];
|
|
11135
11173
|
|
|
11136
11174
|
for (let i = 0; i < accountCount; i++) {
|
|
11137
|
-
const account = byteArray
|
|
11138
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11175
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11139
11176
|
accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
|
|
11140
11177
|
}
|
|
11141
11178
|
|
|
11142
|
-
const recentBlockhash = byteArray
|
|
11143
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11179
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11144
11180
|
const instructionCount = decodeLength(byteArray);
|
|
11145
11181
|
let instructions = [];
|
|
11146
11182
|
|
|
11147
11183
|
for (let i = 0; i < instructionCount; i++) {
|
|
11148
|
-
const programIdIndex = byteArray
|
|
11184
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11149
11185
|
const accountCount = decodeLength(byteArray);
|
|
11150
|
-
const accounts = byteArray
|
|
11151
|
-
byteArray = byteArray.slice(accountCount);
|
|
11186
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
11152
11187
|
const dataLength = decodeLength(byteArray);
|
|
11153
|
-
const dataSlice = byteArray
|
|
11188
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
11154
11189
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
11155
|
-
byteArray = byteArray.slice(dataLength);
|
|
11156
11190
|
instructions.push({
|
|
11157
11191
|
programIdIndex,
|
|
11158
11192
|
accounts,
|
|
@@ -11275,33 +11309,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11275
11309
|
|
|
11276
11310
|
static deserialize(serializedMessage) {
|
|
11277
11311
|
let byteArray = [...serializedMessage];
|
|
11278
|
-
const prefix = byteArray
|
|
11312
|
+
const prefix = guardedShift(byteArray);
|
|
11279
11313
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
11280
11314
|
assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
11281
11315
|
const version = maskedPrefix;
|
|
11282
11316
|
assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
11283
11317
|
const header = {
|
|
11284
|
-
numRequiredSignatures: byteArray
|
|
11285
|
-
numReadonlySignedAccounts: byteArray
|
|
11286
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
11318
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
11319
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
11320
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
11287
11321
|
};
|
|
11288
11322
|
const staticAccountKeys = [];
|
|
11289
11323
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
11290
11324
|
|
|
11291
11325
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
11292
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
11326
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
11293
11327
|
}
|
|
11294
11328
|
|
|
11295
|
-
const recentBlockhash = bs58$1.encode(byteArray
|
|
11329
|
+
const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11296
11330
|
const instructionCount = decodeLength(byteArray);
|
|
11297
11331
|
const compiledInstructions = [];
|
|
11298
11332
|
|
|
11299
11333
|
for (let i = 0; i < instructionCount; i++) {
|
|
11300
|
-
const programIdIndex = byteArray
|
|
11334
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11301
11335
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
11302
|
-
const accountKeyIndexes = byteArray
|
|
11336
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
11303
11337
|
const dataLength = decodeLength(byteArray);
|
|
11304
|
-
const data = new Uint8Array(byteArray
|
|
11338
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
11305
11339
|
compiledInstructions.push({
|
|
11306
11340
|
programIdIndex,
|
|
11307
11341
|
accountKeyIndexes,
|
|
@@ -11313,11 +11347,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
11313
11347
|
const addressTableLookups = [];
|
|
11314
11348
|
|
|
11315
11349
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
11316
|
-
const accountKey = new PublicKey(byteArray
|
|
11350
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11317
11351
|
const writableIndexesLength = decodeLength(byteArray);
|
|
11318
|
-
const writableIndexes = byteArray
|
|
11352
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
11319
11353
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
11320
|
-
const readonlyIndexes = byteArray
|
|
11354
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
11321
11355
|
addressTableLookups.push({
|
|
11322
11356
|
accountKey,
|
|
11323
11357
|
writableIndexes,
|
|
@@ -12048,8 +12082,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12048
12082
|
let signatures = [];
|
|
12049
12083
|
|
|
12050
12084
|
for (let i = 0; i < signatureCount; i++) {
|
|
12051
|
-
const signature = byteArray
|
|
12052
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
12085
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
12053
12086
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
12054
12087
|
}
|
|
12055
12088
|
|
|
@@ -12141,7 +12174,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12141
12174
|
const signaturesLength = decodeLength(byteArray);
|
|
12142
12175
|
|
|
12143
12176
|
for (let i = 0; i < signaturesLength; i++) {
|
|
12144
|
-
signatures.push(new Uint8Array(byteArray
|
|
12177
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
12145
12178
|
}
|
|
12146
12179
|
|
|
12147
12180
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
@@ -17705,7 +17738,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
17705
17738
|
|
|
17706
17739
|
/** @internal */
|
|
17707
17740
|
const COMMON_HTTP_HEADERS = {
|
|
17708
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
17741
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.56.3") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
17709
17742
|
};
|
|
17710
17743
|
/**
|
|
17711
17744
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -24155,10 +24188,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
24155
24188
|
const configKeys = [];
|
|
24156
24189
|
|
|
24157
24190
|
for (let i = 0; i < 2; i++) {
|
|
24158
|
-
const publicKey = new PublicKey(byteArray
|
|
24159
|
-
|
|
24160
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
24161
|
-
byteArray = byteArray.slice(1);
|
|
24191
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
24192
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
24162
24193
|
configKeys.push({
|
|
24163
24194
|
publicKey,
|
|
24164
24195
|
isSigner
|