@solana/web3.js 1.91.2 → 1.91.4
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 +51 -25
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +51 -25
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +51 -25
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +51 -25
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +75 -50
- 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 +51 -25
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +3 -1
- package/src/message/legacy.ts +9 -8
- package/src/message/v0.ts +29 -12
- package/src/transaction/legacy.ts +2 -1
- package/src/transaction/versioned.ts +2 -1
- package/src/utils/guarded-array-utils.ts +34 -0
- package/src/validator-info.ts +5 -2
package/lib/index.iife.js
CHANGED
|
@@ -2659,11 +2659,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
2659
2659
|
rotlSH: rotlSH$1, rotlSL: rotlSL$1, rotlBH: rotlBH$1, rotlBL: rotlBL$1,
|
|
2660
2660
|
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
2661
2661
|
};
|
|
2662
|
-
var u64$2 = u64$1;
|
|
2663
2662
|
|
|
2664
2663
|
// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):
|
|
2665
2664
|
// prettier-ignore
|
|
2666
|
-
const [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64$
|
|
2665
|
+
const [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64$1.split([
|
|
2667
2666
|
'0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',
|
|
2668
2667
|
'0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',
|
|
2669
2668
|
'0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',
|
|
@@ -2746,16 +2745,16 @@ var solanaWeb3 = (function (exports) {
|
|
|
2746
2745
|
// s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)
|
|
2747
2746
|
const W15h = SHA512_W_H[i - 15] | 0;
|
|
2748
2747
|
const W15l = SHA512_W_L[i - 15] | 0;
|
|
2749
|
-
const s0h = u64$
|
|
2750
|
-
const s0l = u64$
|
|
2748
|
+
const s0h = u64$1.rotrSH(W15h, W15l, 1) ^ u64$1.rotrSH(W15h, W15l, 8) ^ u64$1.shrSH(W15h, W15l, 7);
|
|
2749
|
+
const s0l = u64$1.rotrSL(W15h, W15l, 1) ^ u64$1.rotrSL(W15h, W15l, 8) ^ u64$1.shrSL(W15h, W15l, 7);
|
|
2751
2750
|
// s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)
|
|
2752
2751
|
const W2h = SHA512_W_H[i - 2] | 0;
|
|
2753
2752
|
const W2l = SHA512_W_L[i - 2] | 0;
|
|
2754
|
-
const s1h = u64$
|
|
2755
|
-
const s1l = u64$
|
|
2753
|
+
const s1h = u64$1.rotrSH(W2h, W2l, 19) ^ u64$1.rotrBH(W2h, W2l, 61) ^ u64$1.shrSH(W2h, W2l, 6);
|
|
2754
|
+
const s1l = u64$1.rotrSL(W2h, W2l, 19) ^ u64$1.rotrBL(W2h, W2l, 61) ^ u64$1.shrSL(W2h, W2l, 6);
|
|
2756
2755
|
// SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];
|
|
2757
|
-
const SUMl = u64$
|
|
2758
|
-
const SUMh = u64$
|
|
2756
|
+
const SUMl = u64$1.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
2757
|
+
const SUMh = u64$1.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
|
|
2759
2758
|
SHA512_W_H[i] = SUMh | 0;
|
|
2760
2759
|
SHA512_W_L[i] = SUMl | 0;
|
|
2761
2760
|
}
|
|
@@ -2763,19 +2762,19 @@ var solanaWeb3 = (function (exports) {
|
|
|
2763
2762
|
// Compression function main loop, 80 rounds
|
|
2764
2763
|
for (let i = 0; i < 80; i++) {
|
|
2765
2764
|
// S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)
|
|
2766
|
-
const sigma1h = u64$
|
|
2767
|
-
const sigma1l = u64$
|
|
2765
|
+
const sigma1h = u64$1.rotrSH(Eh, El, 14) ^ u64$1.rotrSH(Eh, El, 18) ^ u64$1.rotrBH(Eh, El, 41);
|
|
2766
|
+
const sigma1l = u64$1.rotrSL(Eh, El, 14) ^ u64$1.rotrSL(Eh, El, 18) ^ u64$1.rotrBL(Eh, El, 41);
|
|
2768
2767
|
//const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
2769
2768
|
const CHIh = (Eh & Fh) ^ (~Eh & Gh);
|
|
2770
2769
|
const CHIl = (El & Fl) ^ (~El & Gl);
|
|
2771
2770
|
// T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]
|
|
2772
2771
|
// prettier-ignore
|
|
2773
|
-
const T1ll = u64$
|
|
2774
|
-
const T1h = u64$
|
|
2772
|
+
const T1ll = u64$1.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
2773
|
+
const T1h = u64$1.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
2775
2774
|
const T1l = T1ll | 0;
|
|
2776
2775
|
// S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)
|
|
2777
|
-
const sigma0h = u64$
|
|
2778
|
-
const sigma0l = u64$
|
|
2776
|
+
const sigma0h = u64$1.rotrSH(Ah, Al, 28) ^ u64$1.rotrBH(Ah, Al, 34) ^ u64$1.rotrBH(Ah, Al, 39);
|
|
2777
|
+
const sigma0l = u64$1.rotrSL(Ah, Al, 28) ^ u64$1.rotrBL(Ah, Al, 34) ^ u64$1.rotrBL(Ah, Al, 39);
|
|
2779
2778
|
const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);
|
|
2780
2779
|
const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);
|
|
2781
2780
|
Hh = Gh | 0;
|
|
@@ -2784,26 +2783,26 @@ var solanaWeb3 = (function (exports) {
|
|
|
2784
2783
|
Gl = Fl | 0;
|
|
2785
2784
|
Fh = Eh | 0;
|
|
2786
2785
|
Fl = El | 0;
|
|
2787
|
-
({ h: Eh, l: El } = u64$
|
|
2786
|
+
({ h: Eh, l: El } = u64$1.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
2788
2787
|
Dh = Ch | 0;
|
|
2789
2788
|
Dl = Cl | 0;
|
|
2790
2789
|
Ch = Bh | 0;
|
|
2791
2790
|
Cl = Bl | 0;
|
|
2792
2791
|
Bh = Ah | 0;
|
|
2793
2792
|
Bl = Al | 0;
|
|
2794
|
-
const All = u64$
|
|
2795
|
-
Ah = u64$
|
|
2793
|
+
const All = u64$1.add3L(T1l, sigma0l, MAJl);
|
|
2794
|
+
Ah = u64$1.add3H(All, T1h, sigma0h, MAJh);
|
|
2796
2795
|
Al = All | 0;
|
|
2797
2796
|
}
|
|
2798
2797
|
// Add the compressed chunk to the current hash value
|
|
2799
|
-
({ h: Ah, l: Al } = u64$
|
|
2800
|
-
({ h: Bh, l: Bl } = u64$
|
|
2801
|
-
({ h: Ch, l: Cl } = u64$
|
|
2802
|
-
({ h: Dh, l: Dl } = u64$
|
|
2803
|
-
({ h: Eh, l: El } = u64$
|
|
2804
|
-
({ h: Fh, l: Fl } = u64$
|
|
2805
|
-
({ h: Gh, l: Gl } = u64$
|
|
2806
|
-
({ h: Hh, l: Hl } = u64$
|
|
2798
|
+
({ h: Ah, l: Al } = u64$1.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
2799
|
+
({ h: Bh, l: Bl } = u64$1.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
2800
|
+
({ h: Ch, l: Cl } = u64$1.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
2801
|
+
({ h: Dh, l: Dl } = u64$1.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
2802
|
+
({ h: Eh, l: El } = u64$1.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
2803
|
+
({ h: Fh, l: Fl } = u64$1.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
2804
|
+
({ h: Gh, l: Gl } = u64$1.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
2805
|
+
({ h: Hh, l: Hl } = u64$1.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
2807
2806
|
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
2808
2807
|
}
|
|
2809
2808
|
roundClean() {
|
|
@@ -12061,6 +12060,31 @@ var solanaWeb3 = (function (exports) {
|
|
|
12061
12060
|
}
|
|
12062
12061
|
}
|
|
12063
12062
|
|
|
12063
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
12064
|
+
|
|
12065
|
+
/**
|
|
12066
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
12067
|
+
*/
|
|
12068
|
+
function guardedShift(byteArray) {
|
|
12069
|
+
if (byteArray.length === 0) {
|
|
12070
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
12071
|
+
}
|
|
12072
|
+
return byteArray.shift();
|
|
12073
|
+
}
|
|
12074
|
+
|
|
12075
|
+
/**
|
|
12076
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
12077
|
+
* the array.
|
|
12078
|
+
*/
|
|
12079
|
+
function guardedSplice(byteArray, ...args) {
|
|
12080
|
+
const [start] = args;
|
|
12081
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
12082
|
+
? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) {
|
|
12083
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
12084
|
+
}
|
|
12085
|
+
return byteArray.splice(...args);
|
|
12086
|
+
}
|
|
12087
|
+
|
|
12064
12088
|
/**
|
|
12065
12089
|
* An instruction to execute by a program
|
|
12066
12090
|
*
|
|
@@ -12202,27 +12226,27 @@ var solanaWeb3 = (function (exports) {
|
|
|
12202
12226
|
static from(buffer$1) {
|
|
12203
12227
|
// Slice up wire data
|
|
12204
12228
|
let byteArray = [...buffer$1];
|
|
12205
|
-
const numRequiredSignatures = byteArray
|
|
12229
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
12206
12230
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
12207
12231
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
12208
12232
|
}
|
|
12209
|
-
const numReadonlySignedAccounts = byteArray
|
|
12210
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
12233
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
12234
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
12211
12235
|
const accountCount = decodeLength(byteArray);
|
|
12212
12236
|
let accountKeys = [];
|
|
12213
12237
|
for (let i = 0; i < accountCount; i++) {
|
|
12214
|
-
const account = byteArray
|
|
12238
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
12215
12239
|
accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
|
|
12216
12240
|
}
|
|
12217
|
-
const recentBlockhash = byteArray
|
|
12241
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
12218
12242
|
const instructionCount = decodeLength(byteArray);
|
|
12219
12243
|
let instructions = [];
|
|
12220
12244
|
for (let i = 0; i < instructionCount; i++) {
|
|
12221
|
-
const programIdIndex = byteArray
|
|
12245
|
+
const programIdIndex = guardedShift(byteArray);
|
|
12222
12246
|
const accountCount = decodeLength(byteArray);
|
|
12223
|
-
const accounts = byteArray
|
|
12247
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
12224
12248
|
const dataLength = decodeLength(byteArray);
|
|
12225
|
-
const dataSlice = byteArray
|
|
12249
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
12226
12250
|
const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
|
|
12227
12251
|
instructions.push({
|
|
12228
12252
|
programIdIndex,
|
|
@@ -12428,30 +12452,30 @@ var solanaWeb3 = (function (exports) {
|
|
|
12428
12452
|
}
|
|
12429
12453
|
static deserialize(serializedMessage) {
|
|
12430
12454
|
let byteArray = [...serializedMessage];
|
|
12431
|
-
const prefix = byteArray
|
|
12455
|
+
const prefix = guardedShift(byteArray);
|
|
12432
12456
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
12433
12457
|
assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
12434
12458
|
const version = maskedPrefix;
|
|
12435
12459
|
assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
12436
12460
|
const header = {
|
|
12437
|
-
numRequiredSignatures: byteArray
|
|
12438
|
-
numReadonlySignedAccounts: byteArray
|
|
12439
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
12461
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
12462
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
12463
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
12440
12464
|
};
|
|
12441
12465
|
const staticAccountKeys = [];
|
|
12442
12466
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
12443
12467
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
12444
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
12468
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
12445
12469
|
}
|
|
12446
|
-
const recentBlockhash = bs58$1.encode(byteArray
|
|
12470
|
+
const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
12447
12471
|
const instructionCount = decodeLength(byteArray);
|
|
12448
12472
|
const compiledInstructions = [];
|
|
12449
12473
|
for (let i = 0; i < instructionCount; i++) {
|
|
12450
|
-
const programIdIndex = byteArray
|
|
12474
|
+
const programIdIndex = guardedShift(byteArray);
|
|
12451
12475
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
12452
|
-
const accountKeyIndexes = byteArray
|
|
12476
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
12453
12477
|
const dataLength = decodeLength(byteArray);
|
|
12454
|
-
const data = new Uint8Array(byteArray
|
|
12478
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
12455
12479
|
compiledInstructions.push({
|
|
12456
12480
|
programIdIndex,
|
|
12457
12481
|
accountKeyIndexes,
|
|
@@ -12461,11 +12485,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
12461
12485
|
const addressTableLookupsCount = decodeLength(byteArray);
|
|
12462
12486
|
const addressTableLookups = [];
|
|
12463
12487
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
12464
|
-
const accountKey = new PublicKey(byteArray
|
|
12488
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
12465
12489
|
const writableIndexesLength = decodeLength(byteArray);
|
|
12466
|
-
const writableIndexes = byteArray
|
|
12490
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
12467
12491
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
12468
|
-
const readonlyIndexes = byteArray
|
|
12492
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
12469
12493
|
addressTableLookups.push({
|
|
12470
12494
|
accountKey,
|
|
12471
12495
|
writableIndexes,
|
|
@@ -13256,7 +13280,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
13256
13280
|
const signatureCount = decodeLength(byteArray);
|
|
13257
13281
|
let signatures = [];
|
|
13258
13282
|
for (let i = 0; i < signatureCount; i++) {
|
|
13259
|
-
const signature = byteArray
|
|
13283
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
13260
13284
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
13261
13285
|
}
|
|
13262
13286
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -13431,7 +13455,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
13431
13455
|
const signatures = [];
|
|
13432
13456
|
const signaturesLength = decodeLength(byteArray);
|
|
13433
13457
|
for (let i = 0; i < signaturesLength; i++) {
|
|
13434
|
-
signatures.push(new Uint8Array(byteArray
|
|
13458
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
13435
13459
|
}
|
|
13436
13460
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
13437
13461
|
return new VersionedTransaction(message, signatures);
|
|
@@ -21747,7 +21771,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
21747
21771
|
encoding: 'base64'
|
|
21748
21772
|
};
|
|
21749
21773
|
const skipPreflight = options && options.skipPreflight;
|
|
21750
|
-
const preflightCommitment =
|
|
21774
|
+
const preflightCommitment = skipPreflight === true ? 'processed' // FIXME Remove when https://github.com/anza-xyz/agave/pull/483 is deployed.
|
|
21775
|
+
: options && options.preflightCommitment || this.commitment;
|
|
21751
21776
|
if (options && options.maxRetries != null) {
|
|
21752
21777
|
config.maxRetries = options.maxRetries;
|
|
21753
21778
|
}
|
|
@@ -25986,8 +26011,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
25986
26011
|
if (configKeyCount !== 2) return null;
|
|
25987
26012
|
const configKeys = [];
|
|
25988
26013
|
for (let i = 0; i < 2; i++) {
|
|
25989
|
-
const publicKey = new PublicKey(byteArray
|
|
25990
|
-
const isSigner = byteArray
|
|
26014
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
26015
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
25991
26016
|
configKeys.push({
|
|
25992
26017
|
publicKey,
|
|
25993
26018
|
isSigner
|