@solana/web3.js 1.66.4 → 1.66.6
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 +90 -37
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +90 -37
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +90 -37
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +90 -37
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +90 -37
- 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 +90 -37
- package/lib/index.native.js.map +1 -1
- package/package.json +22 -22
- package/src/connection.ts +31 -5
- 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
|
@@ -11223,6 +11223,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
11223
11223
|
|
|
11224
11224
|
}
|
|
11225
11225
|
|
|
11226
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
11227
|
+
/**
|
|
11228
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
11229
|
+
*/
|
|
11230
|
+
|
|
11231
|
+
function guardedShift(byteArray) {
|
|
11232
|
+
if (byteArray.length === 0) {
|
|
11233
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11234
|
+
}
|
|
11235
|
+
|
|
11236
|
+
return byteArray.shift();
|
|
11237
|
+
}
|
|
11238
|
+
/**
|
|
11239
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
11240
|
+
* the array.
|
|
11241
|
+
*/
|
|
11242
|
+
|
|
11243
|
+
function guardedSplice(byteArray, ...args) {
|
|
11244
|
+
var _args$;
|
|
11245
|
+
|
|
11246
|
+
const [start] = args;
|
|
11247
|
+
|
|
11248
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
11249
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
11250
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
11251
|
+
}
|
|
11252
|
+
|
|
11253
|
+
return byteArray.splice(...args);
|
|
11254
|
+
}
|
|
11255
|
+
|
|
11226
11256
|
/**
|
|
11227
11257
|
* An instruction to execute by a program
|
|
11228
11258
|
*
|
|
@@ -11374,37 +11404,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11374
11404
|
static from(buffer$1) {
|
|
11375
11405
|
// Slice up wire data
|
|
11376
11406
|
let byteArray = [...buffer$1];
|
|
11377
|
-
const numRequiredSignatures = byteArray
|
|
11407
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
11378
11408
|
|
|
11379
11409
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
11380
11410
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
11381
11411
|
}
|
|
11382
11412
|
|
|
11383
|
-
const numReadonlySignedAccounts = byteArray
|
|
11384
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
11413
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
11414
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
11385
11415
|
const accountCount = decodeLength(byteArray);
|
|
11386
11416
|
let accountKeys = [];
|
|
11387
11417
|
|
|
11388
11418
|
for (let i = 0; i < accountCount; i++) {
|
|
11389
|
-
const account = byteArray
|
|
11390
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11419
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11391
11420
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
11392
11421
|
}
|
|
11393
11422
|
|
|
11394
|
-
const recentBlockhash = byteArray
|
|
11395
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
11423
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
11396
11424
|
const instructionCount = decodeLength(byteArray);
|
|
11397
11425
|
let instructions = [];
|
|
11398
11426
|
|
|
11399
11427
|
for (let i = 0; i < instructionCount; i++) {
|
|
11400
|
-
const programIdIndex = byteArray
|
|
11428
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11401
11429
|
const accountCount = decodeLength(byteArray);
|
|
11402
|
-
const accounts = byteArray
|
|
11403
|
-
byteArray = byteArray.slice(accountCount);
|
|
11430
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
11404
11431
|
const dataLength = decodeLength(byteArray);
|
|
11405
|
-
const dataSlice = byteArray
|
|
11432
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
11406
11433
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
11407
|
-
byteArray = byteArray.slice(dataLength);
|
|
11408
11434
|
instructions.push({
|
|
11409
11435
|
programIdIndex,
|
|
11410
11436
|
accounts,
|
|
@@ -11640,33 +11666,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
11640
11666
|
|
|
11641
11667
|
static deserialize(serializedMessage) {
|
|
11642
11668
|
let byteArray = [...serializedMessage];
|
|
11643
|
-
const prefix = byteArray
|
|
11669
|
+
const prefix = guardedShift(byteArray);
|
|
11644
11670
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
11645
11671
|
assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
11646
11672
|
const version = maskedPrefix;
|
|
11647
11673
|
assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
11648
11674
|
const header = {
|
|
11649
|
-
numRequiredSignatures: byteArray
|
|
11650
|
-
numReadonlySignedAccounts: byteArray
|
|
11651
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
11675
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
11676
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
11677
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
11652
11678
|
};
|
|
11653
11679
|
const staticAccountKeys = [];
|
|
11654
11680
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
11655
11681
|
|
|
11656
11682
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
11657
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
11683
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
11658
11684
|
}
|
|
11659
11685
|
|
|
11660
|
-
const recentBlockhash = bs58$1.encode(byteArray
|
|
11686
|
+
const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11661
11687
|
const instructionCount = decodeLength(byteArray);
|
|
11662
11688
|
const compiledInstructions = [];
|
|
11663
11689
|
|
|
11664
11690
|
for (let i = 0; i < instructionCount; i++) {
|
|
11665
|
-
const programIdIndex = byteArray
|
|
11691
|
+
const programIdIndex = guardedShift(byteArray);
|
|
11666
11692
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
11667
|
-
const accountKeyIndexes = byteArray
|
|
11693
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
11668
11694
|
const dataLength = decodeLength(byteArray);
|
|
11669
|
-
const data = new Uint8Array(byteArray
|
|
11695
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
11670
11696
|
compiledInstructions.push({
|
|
11671
11697
|
programIdIndex,
|
|
11672
11698
|
accountKeyIndexes,
|
|
@@ -11678,11 +11704,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
11678
11704
|
const addressTableLookups = [];
|
|
11679
11705
|
|
|
11680
11706
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
11681
|
-
const accountKey = new PublicKey(byteArray
|
|
11707
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11682
11708
|
const writableIndexesLength = decodeLength(byteArray);
|
|
11683
|
-
const writableIndexes = byteArray
|
|
11709
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
11684
11710
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
11685
|
-
const readonlyIndexes = byteArray
|
|
11711
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
11686
11712
|
addressTableLookups.push({
|
|
11687
11713
|
accountKey,
|
|
11688
11714
|
writableIndexes,
|
|
@@ -12413,8 +12439,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12413
12439
|
let signatures = [];
|
|
12414
12440
|
|
|
12415
12441
|
for (let i = 0; i < signatureCount; i++) {
|
|
12416
|
-
const signature = byteArray
|
|
12417
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
12442
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
12418
12443
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
12419
12444
|
}
|
|
12420
12445
|
|
|
@@ -12612,7 +12637,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12612
12637
|
const signaturesLength = decodeLength(byteArray);
|
|
12613
12638
|
|
|
12614
12639
|
for (let i = 0; i < signaturesLength; i++) {
|
|
12615
|
-
signatures.push(new Uint8Array(byteArray
|
|
12640
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
12616
12641
|
}
|
|
12617
12642
|
|
|
12618
12643
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
@@ -18207,7 +18232,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18207
18232
|
|
|
18208
18233
|
/** @internal */
|
|
18209
18234
|
const COMMON_HTTP_HEADERS = {
|
|
18210
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
18235
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.66.6") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
18211
18236
|
};
|
|
18212
18237
|
/**
|
|
18213
18238
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -18836,7 +18861,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18836
18861
|
}
|
|
18837
18862
|
|
|
18838
18863
|
assert$1(decodedSignature.length === 64, 'signature has invalid length');
|
|
18839
|
-
const
|
|
18864
|
+
const confirmationCommitment = commitment || this.commitment;
|
|
18840
18865
|
let timeoutId;
|
|
18841
18866
|
let signatureSubscriptionId;
|
|
18842
18867
|
let disposeSignatureSubscriptionStateChangeObserver;
|
|
@@ -18854,7 +18879,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18854
18879
|
__type: exports.TransactionStatus.PROCESSED,
|
|
18855
18880
|
response
|
|
18856
18881
|
});
|
|
18857
|
-
},
|
|
18882
|
+
}, confirmationCommitment);
|
|
18858
18883
|
const subscriptionSetupPromise = new Promise(resolveSubscriptionSetup => {
|
|
18859
18884
|
if (signatureSubscriptionId == null) {
|
|
18860
18885
|
resolveSubscriptionSetup();
|
|
@@ -18882,11 +18907,41 @@ var solanaWeb3 = (function (exports) {
|
|
|
18882
18907
|
value
|
|
18883
18908
|
} = response;
|
|
18884
18909
|
|
|
18910
|
+
if (value == null) {
|
|
18911
|
+
return;
|
|
18912
|
+
}
|
|
18913
|
+
|
|
18885
18914
|
if (value !== null && value !== void 0 && value.err) {
|
|
18886
18915
|
reject(value.err);
|
|
18887
|
-
}
|
|
18916
|
+
} else {
|
|
18917
|
+
switch (confirmationCommitment) {
|
|
18918
|
+
case 'confirmed':
|
|
18919
|
+
case 'single':
|
|
18920
|
+
case 'singleGossip':
|
|
18921
|
+
{
|
|
18922
|
+
if (value.confirmationStatus === 'processed') {
|
|
18923
|
+
return;
|
|
18924
|
+
}
|
|
18925
|
+
|
|
18926
|
+
break;
|
|
18927
|
+
}
|
|
18928
|
+
|
|
18929
|
+
case 'finalized':
|
|
18930
|
+
case 'max':
|
|
18931
|
+
case 'root':
|
|
18932
|
+
{
|
|
18933
|
+
if (value.confirmationStatus === 'processed' || value.confirmationStatus === 'confirmed') {
|
|
18934
|
+
return;
|
|
18935
|
+
}
|
|
18936
|
+
|
|
18937
|
+
break;
|
|
18938
|
+
}
|
|
18939
|
+
// exhaust enums to ensure full coverage
|
|
18940
|
+
|
|
18941
|
+
case 'processed':
|
|
18942
|
+
case 'recent':
|
|
18943
|
+
}
|
|
18888
18944
|
|
|
18889
|
-
if (value) {
|
|
18890
18945
|
done = true;
|
|
18891
18946
|
resolve({
|
|
18892
18947
|
__type: exports.TransactionStatus.PROCESSED,
|
|
@@ -18905,7 +18960,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18905
18960
|
if (typeof strategy === 'string') {
|
|
18906
18961
|
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
|
|
18907
18962
|
|
|
18908
|
-
switch (
|
|
18963
|
+
switch (confirmationCommitment) {
|
|
18909
18964
|
case 'processed':
|
|
18910
18965
|
case 'recent':
|
|
18911
18966
|
case 'single':
|
|
@@ -24500,10 +24555,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
24500
24555
|
const configKeys = [];
|
|
24501
24556
|
|
|
24502
24557
|
for (let i = 0; i < 2; i++) {
|
|
24503
|
-
const publicKey = new PublicKey(byteArray
|
|
24504
|
-
|
|
24505
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
24506
|
-
byteArray = byteArray.slice(1);
|
|
24558
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
24559
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
24507
24560
|
configKeys.push({
|
|
24508
24561
|
publicKey,
|
|
24509
24562
|
isSigner
|