@solana/web3.js 1.91.5 → 1.91.7
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 +78 -72
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +78 -72
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +78 -4
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +78 -3
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +222 -181
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +5 -5
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +78 -72
- package/lib/index.native.js.map +1 -1
- package/package.json +3 -3
- package/src/connection.ts +2 -1
package/lib/index.iife.js
CHANGED
|
@@ -2383,19 +2383,24 @@ var solanaWeb3 = (function (exports) {
|
|
|
2383
2383
|
|
|
2384
2384
|
function number$2(n) {
|
|
2385
2385
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
2386
|
-
throw new Error(`
|
|
2386
|
+
throw new Error(`positive integer expected, not ${n}`);
|
|
2387
|
+
}
|
|
2388
|
+
// copied from utils
|
|
2389
|
+
function isBytes$3(a) {
|
|
2390
|
+
return (a instanceof Uint8Array ||
|
|
2391
|
+
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
2387
2392
|
}
|
|
2388
2393
|
function bytes$1(b, ...lengths) {
|
|
2389
|
-
if (!(b
|
|
2390
|
-
throw new Error('
|
|
2394
|
+
if (!isBytes$3(b))
|
|
2395
|
+
throw new Error('Uint8Array expected');
|
|
2391
2396
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
2392
|
-
throw new Error(`
|
|
2397
|
+
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
2393
2398
|
}
|
|
2394
|
-
function hash(
|
|
2395
|
-
if (typeof
|
|
2399
|
+
function hash(h) {
|
|
2400
|
+
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
2396
2401
|
throw new Error('Hash should be wrapped by utils.wrapConstructor');
|
|
2397
|
-
number$2(
|
|
2398
|
-
number$2(
|
|
2402
|
+
number$2(h.outputLen);
|
|
2403
|
+
number$2(h.blockLen);
|
|
2399
2404
|
}
|
|
2400
2405
|
function exists$1(instance, checkFinished = true) {
|
|
2401
2406
|
if (instance.destroyed)
|
|
@@ -2419,17 +2424,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
2419
2424
|
// For node.js, package.json#exports field mapping rewrites import
|
|
2420
2425
|
// from `crypto` to `cryptoNode`, which imports native module.
|
|
2421
2426
|
// Makes the utils un-importable in browsers without a bundler.
|
|
2422
|
-
// Once node.js 18 is deprecated, we can just drop the import.
|
|
2423
|
-
const u8a$1 = (a) => a instanceof Uint8Array;
|
|
2427
|
+
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
2424
2428
|
// Cast array to view
|
|
2425
2429
|
const createView$1 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
2426
2430
|
// The rotate right (circular right shift) operation for uint32
|
|
2427
2431
|
const rotr$1 = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
2428
|
-
|
|
2429
|
-
// early-throw an error because we don't support BE yet.
|
|
2430
|
-
const isLE$1 = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
2431
|
-
if (!isLE$1)
|
|
2432
|
-
throw new Error('Non little-endian hardware is not supported');
|
|
2432
|
+
new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
2433
2433
|
/**
|
|
2434
2434
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
2435
2435
|
*/
|
|
@@ -2446,23 +2446,26 @@ var solanaWeb3 = (function (exports) {
|
|
|
2446
2446
|
function toBytes$1(data) {
|
|
2447
2447
|
if (typeof data === 'string')
|
|
2448
2448
|
data = utf8ToBytes$2(data);
|
|
2449
|
-
|
|
2450
|
-
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
2449
|
+
bytes$1(data);
|
|
2451
2450
|
return data;
|
|
2452
2451
|
}
|
|
2453
2452
|
/**
|
|
2454
2453
|
* Copies several Uint8Arrays into one.
|
|
2455
2454
|
*/
|
|
2456
2455
|
function concatBytes$1(...arrays) {
|
|
2457
|
-
|
|
2458
|
-
let
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2456
|
+
let sum = 0;
|
|
2457
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
2458
|
+
const a = arrays[i];
|
|
2459
|
+
bytes$1(a);
|
|
2460
|
+
sum += a.length;
|
|
2461
|
+
}
|
|
2462
|
+
const res = new Uint8Array(sum);
|
|
2463
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
2464
|
+
const a = arrays[i];
|
|
2465
|
+
res.set(a, pad);
|
|
2463
2466
|
pad += a.length;
|
|
2464
|
-
}
|
|
2465
|
-
return
|
|
2467
|
+
}
|
|
2468
|
+
return res;
|
|
2466
2469
|
}
|
|
2467
2470
|
// For runtime check if class implements interface
|
|
2468
2471
|
let Hash$1 = class Hash {
|
|
@@ -2502,8 +2505,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
2502
2505
|
view.setUint32(byteOffset + h, wh, isLE);
|
|
2503
2506
|
view.setUint32(byteOffset + l, wl, isLE);
|
|
2504
2507
|
}
|
|
2505
|
-
//
|
|
2506
|
-
|
|
2508
|
+
// Choice: a ? b : c
|
|
2509
|
+
const Chi$1 = (a, b, c) => (a & b) ^ (~a & c);
|
|
2510
|
+
// Majority function, true if any two inpust is true
|
|
2511
|
+
const Maj$1 = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
2512
|
+
/**
|
|
2513
|
+
* Merkle-Damgard hash construction base class.
|
|
2514
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
2515
|
+
*/
|
|
2516
|
+
class HashMD extends Hash$1 {
|
|
2507
2517
|
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
2508
2518
|
super();
|
|
2509
2519
|
this.blockLen = blockLen;
|
|
@@ -2555,7 +2565,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
2555
2565
|
// append the bit '1' to the message
|
|
2556
2566
|
buffer[pos++] = 0b10000000;
|
|
2557
2567
|
this.buffer.subarray(pos).fill(0);
|
|
2558
|
-
// we have less than padOffset left in buffer, so we cannot put length in
|
|
2568
|
+
// we have less than padOffset left in buffer, so we cannot put length in
|
|
2569
|
+
// current block, need process it and pad again
|
|
2559
2570
|
if (this.padOffset > blockLen - pos) {
|
|
2560
2571
|
this.process(view, 0);
|
|
2561
2572
|
pos = 0;
|
|
@@ -2599,7 +2610,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2599
2610
|
to.buffer.set(buffer);
|
|
2600
2611
|
return to;
|
|
2601
2612
|
}
|
|
2602
|
-
}
|
|
2613
|
+
}
|
|
2603
2614
|
|
|
2604
2615
|
const U32_MASK64$1 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
2605
2616
|
const _32n$1 = /* @__PURE__ */ BigInt(32);
|
|
@@ -2687,7 +2698,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2687
2698
|
// Temporary buffer, not used to store anything between runs
|
|
2688
2699
|
const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
2689
2700
|
const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
2690
|
-
class SHA512 extends
|
|
2701
|
+
class SHA512 extends HashMD {
|
|
2691
2702
|
constructor() {
|
|
2692
2703
|
super(128, 64, 16, false);
|
|
2693
2704
|
// We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.
|
|
@@ -2824,14 +2835,21 @@ var solanaWeb3 = (function (exports) {
|
|
|
2824
2835
|
const _0n$5 = BigInt(0);
|
|
2825
2836
|
const _1n$7 = BigInt(1);
|
|
2826
2837
|
const _2n$5 = BigInt(2);
|
|
2827
|
-
|
|
2838
|
+
function isBytes$2(a) {
|
|
2839
|
+
return (a instanceof Uint8Array ||
|
|
2840
|
+
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
2841
|
+
}
|
|
2842
|
+
function abytes(item) {
|
|
2843
|
+
if (!isBytes$2(item))
|
|
2844
|
+
throw new Error('Uint8Array expected');
|
|
2845
|
+
}
|
|
2846
|
+
// Array where index 0xf0 (240) is mapped to string 'f0'
|
|
2828
2847
|
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
|
|
2829
2848
|
/**
|
|
2830
2849
|
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
2831
2850
|
*/
|
|
2832
2851
|
function bytesToHex(bytes) {
|
|
2833
|
-
|
|
2834
|
-
throw new Error('Uint8Array expected');
|
|
2852
|
+
abytes(bytes);
|
|
2835
2853
|
// pre-caching improves the speed 6x
|
|
2836
2854
|
let hex = '';
|
|
2837
2855
|
for (let i = 0; i < bytes.length; i++) {
|
|
@@ -2849,23 +2867,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
2849
2867
|
// Big Endian
|
|
2850
2868
|
return BigInt(hex === '' ? '0' : `0x${hex}`);
|
|
2851
2869
|
}
|
|
2870
|
+
// We use optimized technique to convert hex string to byte array
|
|
2871
|
+
const asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };
|
|
2872
|
+
function asciiToBase16(char) {
|
|
2873
|
+
if (char >= asciis._0 && char <= asciis._9)
|
|
2874
|
+
return char - asciis._0;
|
|
2875
|
+
if (char >= asciis._A && char <= asciis._F)
|
|
2876
|
+
return char - (asciis._A - 10);
|
|
2877
|
+
if (char >= asciis._a && char <= asciis._f)
|
|
2878
|
+
return char - (asciis._a - 10);
|
|
2879
|
+
return;
|
|
2880
|
+
}
|
|
2852
2881
|
/**
|
|
2853
2882
|
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
2854
2883
|
*/
|
|
2855
2884
|
function hexToBytes(hex) {
|
|
2856
2885
|
if (typeof hex !== 'string')
|
|
2857
2886
|
throw new Error('hex string expected, got ' + typeof hex);
|
|
2858
|
-
const
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
const
|
|
2865
|
-
const
|
|
2866
|
-
if (
|
|
2867
|
-
|
|
2868
|
-
|
|
2887
|
+
const hl = hex.length;
|
|
2888
|
+
const al = hl / 2;
|
|
2889
|
+
if (hl % 2)
|
|
2890
|
+
throw new Error('padded hex string expected, got unpadded hex of length ' + hl);
|
|
2891
|
+
const array = new Uint8Array(al);
|
|
2892
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
2893
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
2894
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
2895
|
+
if (n1 === undefined || n2 === undefined) {
|
|
2896
|
+
const char = hex[hi] + hex[hi + 1];
|
|
2897
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
2898
|
+
}
|
|
2899
|
+
array[ai] = n1 * 16 + n2;
|
|
2869
2900
|
}
|
|
2870
2901
|
return array;
|
|
2871
2902
|
}
|
|
@@ -2874,8 +2905,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2874
2905
|
return hexToNumber(bytesToHex(bytes));
|
|
2875
2906
|
}
|
|
2876
2907
|
function bytesToNumberLE(bytes) {
|
|
2877
|
-
|
|
2878
|
-
throw new Error('Uint8Array expected');
|
|
2908
|
+
abytes(bytes);
|
|
2879
2909
|
return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse()));
|
|
2880
2910
|
}
|
|
2881
2911
|
function numberToBytesBE(n, len) {
|
|
@@ -2907,7 +2937,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2907
2937
|
throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
|
|
2908
2938
|
}
|
|
2909
2939
|
}
|
|
2910
|
-
else if (
|
|
2940
|
+
else if (isBytes$2(hex)) {
|
|
2911
2941
|
// Uint8Array.from() instead of hash.slice() because node.js Buffer
|
|
2912
2942
|
// is instance of Uint8Array, and its slice() creates **mutable** copy
|
|
2913
2943
|
res = Uint8Array.from(hex);
|
|
@@ -2924,24 +2954,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
2924
2954
|
* Copies several Uint8Arrays into one.
|
|
2925
2955
|
*/
|
|
2926
2956
|
function concatBytes(...arrays) {
|
|
2927
|
-
|
|
2928
|
-
let
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2957
|
+
let sum = 0;
|
|
2958
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
2959
|
+
const a = arrays[i];
|
|
2960
|
+
abytes(a);
|
|
2961
|
+
sum += a.length;
|
|
2962
|
+
}
|
|
2963
|
+
const res = new Uint8Array(sum);
|
|
2964
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
2965
|
+
const a = arrays[i];
|
|
2966
|
+
res.set(a, pad);
|
|
2933
2967
|
pad += a.length;
|
|
2934
|
-
}
|
|
2935
|
-
return
|
|
2968
|
+
}
|
|
2969
|
+
return res;
|
|
2936
2970
|
}
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
if (
|
|
2971
|
+
// Compares 2 u8a-s in kinda constant time
|
|
2972
|
+
function equalBytes(a, b) {
|
|
2973
|
+
if (a.length !== b.length)
|
|
2940
2974
|
return false;
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
return
|
|
2975
|
+
let diff = 0;
|
|
2976
|
+
for (let i = 0; i < a.length; i++)
|
|
2977
|
+
diff |= a[i] ^ b[i];
|
|
2978
|
+
return diff === 0;
|
|
2945
2979
|
}
|
|
2946
2980
|
/**
|
|
2947
2981
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
@@ -2973,9 +3007,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
2973
3007
|
/**
|
|
2974
3008
|
* Sets single bit at position.
|
|
2975
3009
|
*/
|
|
2976
|
-
|
|
3010
|
+
function bitSet(n, pos, value) {
|
|
2977
3011
|
return n | ((value ? _1n$7 : _0n$5) << BigInt(pos));
|
|
2978
|
-
}
|
|
3012
|
+
}
|
|
2979
3013
|
/**
|
|
2980
3014
|
* Calculate mask for N bits. Not using ** operator with bigints because of old engines.
|
|
2981
3015
|
* Same as BigInt(`0b${Array(i).fill('1').join('')}`)
|
|
@@ -3048,7 +3082,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3048
3082
|
function: (val) => typeof val === 'function',
|
|
3049
3083
|
boolean: (val) => typeof val === 'boolean',
|
|
3050
3084
|
string: (val) => typeof val === 'string',
|
|
3051
|
-
stringOrUint8Array: (val) => typeof val === 'string' || val
|
|
3085
|
+
stringOrUint8Array: (val) => typeof val === 'string' || isBytes$2(val),
|
|
3052
3086
|
isSafeInteger: (val) => Number.isSafeInteger(val),
|
|
3053
3087
|
array: (val) => Array.isArray(val),
|
|
3054
3088
|
field: (val, object) => object.Fp.isValid(val),
|
|
@@ -3084,6 +3118,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3084
3118
|
|
|
3085
3119
|
var ut = /*#__PURE__*/Object.freeze({
|
|
3086
3120
|
__proto__: null,
|
|
3121
|
+
abytes: abytes,
|
|
3087
3122
|
bitGet: bitGet,
|
|
3088
3123
|
bitLen: bitLen,
|
|
3089
3124
|
bitMask: bitMask,
|
|
@@ -3097,6 +3132,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3097
3132
|
equalBytes: equalBytes,
|
|
3098
3133
|
hexToBytes: hexToBytes,
|
|
3099
3134
|
hexToNumber: hexToNumber,
|
|
3135
|
+
isBytes: isBytes$2,
|
|
3100
3136
|
numberToBytesBE: numberToBytesBE,
|
|
3101
3137
|
numberToBytesLE: numberToBytesLE,
|
|
3102
3138
|
numberToHexUnpadded: numberToHexUnpadded,
|
|
@@ -4104,7 +4140,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
4104
4140
|
const Fp$1 = Field(ED25519_P, undefined, true);
|
|
4105
4141
|
const ed25519Defaults = {
|
|
4106
4142
|
// Param: a
|
|
4107
|
-
a: BigInt(-1),
|
|
4143
|
+
a: BigInt(-1), // Fp.create(-1) is proper; our way still works and is faster
|
|
4108
4144
|
// d is equal to -121665/121666 over finite field.
|
|
4109
4145
|
// Negative number is P - number, and division is invert(number, P)
|
|
4110
4146
|
d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'),
|
|
@@ -7973,9 +8009,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
7973
8009
|
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
7974
8010
|
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
7975
8011
|
// Choice: a ? b : c
|
|
7976
|
-
const Chi
|
|
8012
|
+
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
7977
8013
|
// Majority function, true if any two inpust is true
|
|
7978
|
-
const Maj
|
|
8014
|
+
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
7979
8015
|
// Round constants:
|
|
7980
8016
|
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
7981
8017
|
// prettier-ignore
|
|
@@ -7991,7 +8027,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
7991
8027
|
]);
|
|
7992
8028
|
// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
|
7993
8029
|
// prettier-ignore
|
|
7994
|
-
const IV
|
|
8030
|
+
const IV = /* @__PURE__ */ new Uint32Array([
|
|
7995
8031
|
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
7996
8032
|
]);
|
|
7997
8033
|
// Temporary buffer, not used to store anything between runs
|
|
@@ -8002,14 +8038,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
8002
8038
|
super(64, 32, 8, false);
|
|
8003
8039
|
// We cannot use array here since array allows indexing by variable
|
|
8004
8040
|
// which means optimizer/compiler cannot use registers.
|
|
8005
|
-
this.A = IV
|
|
8006
|
-
this.B = IV
|
|
8007
|
-
this.C = IV
|
|
8008
|
-
this.D = IV
|
|
8009
|
-
this.E = IV
|
|
8010
|
-
this.F = IV
|
|
8011
|
-
this.G = IV
|
|
8012
|
-
this.H = IV
|
|
8041
|
+
this.A = IV[0] | 0;
|
|
8042
|
+
this.B = IV[1] | 0;
|
|
8043
|
+
this.C = IV[2] | 0;
|
|
8044
|
+
this.D = IV[3] | 0;
|
|
8045
|
+
this.E = IV[4] | 0;
|
|
8046
|
+
this.F = IV[5] | 0;
|
|
8047
|
+
this.G = IV[6] | 0;
|
|
8048
|
+
this.H = IV[7] | 0;
|
|
8013
8049
|
}
|
|
8014
8050
|
get() {
|
|
8015
8051
|
const { A, B, C, D, E, F, G, H } = this;
|
|
@@ -8041,9 +8077,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
8041
8077
|
let { A, B, C, D, E, F, G, H } = this;
|
|
8042
8078
|
for (let i = 0; i < 64; i++) {
|
|
8043
8079
|
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
8044
|
-
const T1 = (H + sigma1 + Chi
|
|
8080
|
+
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i]) | 0;
|
|
8045
8081
|
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
8046
|
-
const T2 = (sigma0 + Maj
|
|
8082
|
+
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
8047
8083
|
H = G;
|
|
8048
8084
|
G = F;
|
|
8049
8085
|
F = E;
|
|
@@ -14714,80 +14750,82 @@ var solanaWeb3 = (function (exports) {
|
|
|
14714
14750
|
}
|
|
14715
14751
|
}
|
|
14716
14752
|
|
|
14717
|
-
// src/index.ts
|
|
14718
14753
|
var objToString = Object.prototype.toString;
|
|
14719
|
-
var objKeys = Object.keys || function
|
|
14720
|
-
|
|
14721
|
-
|
|
14722
|
-
|
|
14723
|
-
|
|
14724
|
-
|
|
14725
|
-
|
|
14754
|
+
var objKeys = Object.keys || function(obj) {
|
|
14755
|
+
var keys = [];
|
|
14756
|
+
for (var name in obj) {
|
|
14757
|
+
keys.push(name);
|
|
14758
|
+
}
|
|
14759
|
+
return keys;
|
|
14760
|
+
};
|
|
14761
|
+
|
|
14726
14762
|
function stringify$1(val, isArrayProp) {
|
|
14727
|
-
|
|
14728
|
-
|
|
14729
|
-
|
|
14730
|
-
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
|
|
14740
|
-
|
|
14741
|
-
|
|
14742
|
-
|
|
14743
|
-
|
|
14744
|
-
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
14751
|
-
|
|
14752
|
-
|
|
14753
|
-
|
|
14754
|
-
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14760
|
-
|
|
14761
|
-
|
|
14762
|
-
|
|
14763
|
-
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
|
|
14782
|
-
}
|
|
14783
|
-
}
|
|
14784
|
-
function src_default(val) {
|
|
14785
|
-
const returnVal = stringify$1(val, false);
|
|
14786
|
-
if (returnVal !== void 0) {
|
|
14787
|
-
return "" + returnVal;
|
|
14788
|
-
}
|
|
14763
|
+
var i, max, str, keys, key, propVal, toStr;
|
|
14764
|
+
if (val === true) {
|
|
14765
|
+
return "true";
|
|
14766
|
+
}
|
|
14767
|
+
if (val === false) {
|
|
14768
|
+
return "false";
|
|
14769
|
+
}
|
|
14770
|
+
switch (typeof val) {
|
|
14771
|
+
case "object":
|
|
14772
|
+
if (val === null) {
|
|
14773
|
+
return null;
|
|
14774
|
+
} else if (val.toJSON && typeof val.toJSON === "function") {
|
|
14775
|
+
return stringify$1(val.toJSON(), isArrayProp);
|
|
14776
|
+
} else {
|
|
14777
|
+
toStr = objToString.call(val);
|
|
14778
|
+
if (toStr === "[object Array]") {
|
|
14779
|
+
str = '[';
|
|
14780
|
+
max = val.length - 1;
|
|
14781
|
+
for(i = 0; i < max; i++) {
|
|
14782
|
+
str += stringify$1(val[i], true) + ',';
|
|
14783
|
+
}
|
|
14784
|
+
if (max > -1) {
|
|
14785
|
+
str += stringify$1(val[i], true);
|
|
14786
|
+
}
|
|
14787
|
+
return str + ']';
|
|
14788
|
+
} else if (toStr === "[object Object]") {
|
|
14789
|
+
// only object is left
|
|
14790
|
+
keys = objKeys(val).sort();
|
|
14791
|
+
max = keys.length;
|
|
14792
|
+
str = "";
|
|
14793
|
+
i = 0;
|
|
14794
|
+
while (i < max) {
|
|
14795
|
+
key = keys[i];
|
|
14796
|
+
propVal = stringify$1(val[key], false);
|
|
14797
|
+
if (propVal !== undefined) {
|
|
14798
|
+
if (str) {
|
|
14799
|
+
str += ',';
|
|
14800
|
+
}
|
|
14801
|
+
str += JSON.stringify(key) + ':' + propVal;
|
|
14802
|
+
}
|
|
14803
|
+
i++;
|
|
14804
|
+
}
|
|
14805
|
+
return '{' + str + '}';
|
|
14806
|
+
} else {
|
|
14807
|
+
return JSON.stringify(val);
|
|
14808
|
+
}
|
|
14809
|
+
}
|
|
14810
|
+
case "function":
|
|
14811
|
+
case "undefined":
|
|
14812
|
+
return isArrayProp ? null : undefined;
|
|
14813
|
+
case "string":
|
|
14814
|
+
return JSON.stringify(val);
|
|
14815
|
+
default:
|
|
14816
|
+
return isFinite(val) ? val : null;
|
|
14817
|
+
}
|
|
14789
14818
|
}
|
|
14790
14819
|
|
|
14820
|
+
var fastStableStringify = function(val) {
|
|
14821
|
+
var returnVal = stringify$1(val, false);
|
|
14822
|
+
if (returnVal !== undefined) {
|
|
14823
|
+
return ''+ returnVal;
|
|
14824
|
+
}
|
|
14825
|
+
};
|
|
14826
|
+
|
|
14827
|
+
var fastStableStringify$1 = /*@__PURE__*/getDefaultExportFromCjs(fastStableStringify);
|
|
14828
|
+
|
|
14791
14829
|
/**
|
|
14792
14830
|
* A `StructFailure` represents a single specific failure in validation.
|
|
14793
14831
|
*/
|
|
@@ -19678,7 +19716,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
19678
19716
|
config
|
|
19679
19717
|
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
19680
19718
|
const args = this._buildArgs([], commitment, undefined /* encoding */, config);
|
|
19681
|
-
const requestHash =
|
|
19719
|
+
const requestHash = fastStableStringify$1(args);
|
|
19682
19720
|
requestPromises[requestHash] = requestPromises[requestHash] ?? (async () => {
|
|
19683
19721
|
try {
|
|
19684
19722
|
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
@@ -22114,7 +22152,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
22114
22152
|
*/
|
|
22115
22153
|
args) {
|
|
22116
22154
|
const clientSubscriptionId = this._nextClientSubscriptionId++;
|
|
22117
|
-
const hash =
|
|
22155
|
+
const hash = fastStableStringify$1([subscriptionConfig.method, args]);
|
|
22118
22156
|
const existingSubscription = this._subscriptionsByHash[hash];
|
|
22119
22157
|
if (existingSubscription === undefined) {
|
|
22120
22158
|
this._subscriptionsByHash[hash] = {
|
|
@@ -23351,10 +23389,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
23351
23389
|
|
|
23352
23390
|
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
23353
23391
|
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
23354
|
-
// Choice: a ? b : c
|
|
23355
|
-
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
23356
|
-
// Majority function, true if any two inpust is true
|
|
23357
|
-
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
23358
23392
|
// Round constants:
|
|
23359
23393
|
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
23360
23394
|
// prettier-ignore
|
|
@@ -23368,27 +23402,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
23368
23402
|
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
23369
23403
|
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
23370
23404
|
]);
|
|
23371
|
-
// Initial state
|
|
23405
|
+
// Initial state:
|
|
23406
|
+
// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
|
|
23372
23407
|
// prettier-ignore
|
|
23373
|
-
const
|
|
23408
|
+
const SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
|
23374
23409
|
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
23375
23410
|
]);
|
|
23376
23411
|
// Temporary buffer, not used to store anything between runs
|
|
23377
23412
|
// Named this way because it matches specification.
|
|
23378
23413
|
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
23379
|
-
class SHA256 extends
|
|
23414
|
+
class SHA256 extends HashMD {
|
|
23380
23415
|
constructor() {
|
|
23381
23416
|
super(64, 32, 8, false);
|
|
23382
23417
|
// We cannot use array here since array allows indexing by variable
|
|
23383
23418
|
// which means optimizer/compiler cannot use registers.
|
|
23384
|
-
this.A =
|
|
23385
|
-
this.B =
|
|
23386
|
-
this.C =
|
|
23387
|
-
this.D =
|
|
23388
|
-
this.E =
|
|
23389
|
-
this.F =
|
|
23390
|
-
this.G =
|
|
23391
|
-
this.H =
|
|
23419
|
+
this.A = SHA256_IV[0] | 0;
|
|
23420
|
+
this.B = SHA256_IV[1] | 0;
|
|
23421
|
+
this.C = SHA256_IV[2] | 0;
|
|
23422
|
+
this.D = SHA256_IV[3] | 0;
|
|
23423
|
+
this.E = SHA256_IV[4] | 0;
|
|
23424
|
+
this.F = SHA256_IV[5] | 0;
|
|
23425
|
+
this.G = SHA256_IV[6] | 0;
|
|
23426
|
+
this.H = SHA256_IV[7] | 0;
|
|
23392
23427
|
}
|
|
23393
23428
|
get() {
|
|
23394
23429
|
const { A, B, C, D, E, F, G, H } = this;
|
|
@@ -23420,9 +23455,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
23420
23455
|
let { A, B, C, D, E, F, G, H } = this;
|
|
23421
23456
|
for (let i = 0; i < 64; i++) {
|
|
23422
23457
|
const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
|
|
23423
|
-
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
23458
|
+
const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
23424
23459
|
const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);
|
|
23425
|
-
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
23460
|
+
const T2 = (sigma0 + Maj$1(A, B, C)) | 0;
|
|
23426
23461
|
H = G;
|
|
23427
23462
|
G = F;
|
|
23428
23463
|
F = E;
|
|
@@ -23517,8 +23552,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
23517
23552
|
// parse DER signature
|
|
23518
23553
|
const { Err: E } = DER;
|
|
23519
23554
|
const data = typeof hex === 'string' ? h2b(hex) : hex;
|
|
23520
|
-
|
|
23521
|
-
throw new Error('ui8a expected');
|
|
23555
|
+
abytes(data);
|
|
23522
23556
|
let l = data.length;
|
|
23523
23557
|
if (l < 2 || data[0] != 0x30)
|
|
23524
23558
|
throw new E('Invalid signature tag');
|
|
@@ -23595,7 +23629,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
23595
23629
|
function normPrivateKeyToScalar(key) {
|
|
23596
23630
|
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE;
|
|
23597
23631
|
if (lengths && typeof key !== 'bigint') {
|
|
23598
|
-
if (key
|
|
23632
|
+
if (isBytes$2(key))
|
|
23599
23633
|
key = bytesToHex(key);
|
|
23600
23634
|
// Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes
|
|
23601
23635
|
if (typeof key !== 'string' || !lengths.includes(key.length))
|
|
@@ -24026,7 +24060,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
24026
24060
|
if (!isValidFieldElement(x))
|
|
24027
24061
|
throw new Error('Point is not on curve');
|
|
24028
24062
|
const y2 = weierstrassEquation(x); // y² = x³ + ax + b
|
|
24029
|
-
let y
|
|
24063
|
+
let y;
|
|
24064
|
+
try {
|
|
24065
|
+
y = Fp.sqrt(y2); // y = y² ^ (p+1)/4
|
|
24066
|
+
}
|
|
24067
|
+
catch (sqrtError) {
|
|
24068
|
+
const suffix = sqrtError instanceof Error ? ': ' + sqrtError.message : '';
|
|
24069
|
+
throw new Error('Point is not on curve' + suffix);
|
|
24070
|
+
}
|
|
24030
24071
|
const isYOdd = (y & _1n$1) === _1n$1;
|
|
24031
24072
|
// ECDSA
|
|
24032
24073
|
const isHeadOdd = (head & 1) === 1;
|
|
@@ -24173,7 +24214,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24173
24214
|
* Quick and dirty check for item being public key. Does not validate hex, or being on-curve.
|
|
24174
24215
|
*/
|
|
24175
24216
|
function isProbPub(item) {
|
|
24176
|
-
const arr = item
|
|
24217
|
+
const arr = isBytes$2(item);
|
|
24177
24218
|
const str = typeof item === 'string';
|
|
24178
24219
|
const len = (arr || str) && item.length;
|
|
24179
24220
|
if (arr)
|
|
@@ -24253,7 +24294,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24253
24294
|
const d = normPrivateKeyToScalar(privateKey); // validate private key, convert to bigint
|
|
24254
24295
|
const seedArgs = [int2octets(d), int2octets(h1int)];
|
|
24255
24296
|
// extraEntropy. RFC6979 3.6: additional k' (optional).
|
|
24256
|
-
if (ent != null) {
|
|
24297
|
+
if (ent != null && ent !== false) {
|
|
24257
24298
|
// K = HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1) || k')
|
|
24258
24299
|
const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is
|
|
24259
24300
|
seedArgs.push(ensureBytes('extraEntropy', e)); // check for being bytes
|
|
@@ -24334,7 +24375,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24334
24375
|
let _sig = undefined;
|
|
24335
24376
|
let P;
|
|
24336
24377
|
try {
|
|
24337
|
-
if (typeof sg === 'string' || sg
|
|
24378
|
+
if (typeof sg === 'string' || isBytes$2(sg)) {
|
|
24338
24379
|
// Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length).
|
|
24339
24380
|
// Since DER can also be 2*nByteLength bytes, we check for it first.
|
|
24340
24381
|
try {
|
|
@@ -24512,15 +24553,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
24512
24553
|
}
|
|
24513
24554
|
const Fp = Field(secp256k1P, undefined, undefined, { sqrt: sqrtMod });
|
|
24514
24555
|
const secp256k1 = createCurve({
|
|
24515
|
-
a: BigInt(0),
|
|
24516
|
-
b: BigInt(7),
|
|
24517
|
-
Fp,
|
|
24518
|
-
n: secp256k1N,
|
|
24556
|
+
a: BigInt(0), // equation params: a, b
|
|
24557
|
+
b: BigInt(7), // Seem to be rigid: bitcointalk.org/index.php?topic=289795.msg3183975#msg3183975
|
|
24558
|
+
Fp, // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n
|
|
24559
|
+
n: secp256k1N, // Curve order, total count of valid points in the field
|
|
24519
24560
|
// Base point (x, y) aka generator point
|
|
24520
24561
|
Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'),
|
|
24521
24562
|
Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'),
|
|
24522
|
-
h: BigInt(1),
|
|
24523
|
-
lowS: true,
|
|
24563
|
+
h: BigInt(1), // Cofactor
|
|
24564
|
+
lowS: true, // Allow only low-S signatures by default in sign() and verify()
|
|
24524
24565
|
/**
|
|
24525
24566
|
* secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism.
|
|
24526
24567
|
* Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%.
|