@solana/web3.js 1.7.0 → 1.7.2
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.esm.js +63 -20
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +63 -20
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +15 -3
- package/lib/index.esm.js +63 -20
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +77 -32
- 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/module.flow.js +19 -4
- package/package.json +30 -30
- package/src/message.ts +9 -12
- package/src/publickey.ts +12 -0
- package/src/stake-program.ts +10 -4
- 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
|
@@ -8409,10 +8409,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
8409
8409
|
}
|
|
8410
8410
|
}
|
|
8411
8411
|
/**
|
|
8412
|
-
*
|
|
8412
|
+
* Default public key value. (All zeros)
|
|
8413
8413
|
*/
|
|
8414
8414
|
|
|
8415
8415
|
|
|
8416
|
+
/**
|
|
8417
|
+
* Checks if two publicKeys are equal
|
|
8418
|
+
*/
|
|
8416
8419
|
equals(publicKey) {
|
|
8417
8420
|
return this._bn.eq(publicKey._bn);
|
|
8418
8421
|
}
|
|
@@ -8517,9 +8520,19 @@ var solanaWeb3 = (function (exports) {
|
|
|
8517
8520
|
|
|
8518
8521
|
throw new Error("Unable to find a viable program address nonce");
|
|
8519
8522
|
}
|
|
8523
|
+
/**
|
|
8524
|
+
* Check that a pubkey is on the ed25519 curve.
|
|
8525
|
+
*/
|
|
8526
|
+
|
|
8527
|
+
|
|
8528
|
+
static isOnCurve(pubkey) {
|
|
8529
|
+
return is_on_curve(pubkey) == 1;
|
|
8530
|
+
}
|
|
8520
8531
|
|
|
8521
8532
|
} // @ts-ignore
|
|
8522
8533
|
|
|
8534
|
+
_defineProperty(PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
|
|
8535
|
+
|
|
8523
8536
|
let naclLowLevel = naclFast.lowlevel; // Check that a pubkey is on the curve.
|
|
8524
8537
|
// This function and its dependents were sourced from:
|
|
8525
8538
|
// https://github.com/dchest/tweetnacl-js/blob/f1ec050ceae0861f34280e62498b1d3ed9c350c6/nacl.js#L792
|
|
@@ -10774,6 +10787,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
10774
10787
|
}
|
|
10775
10788
|
}
|
|
10776
10789
|
|
|
10790
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
10791
|
+
/**
|
|
10792
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
10793
|
+
*/
|
|
10794
|
+
|
|
10795
|
+
function guardedShift(byteArray) {
|
|
10796
|
+
if (byteArray.length === 0) {
|
|
10797
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
10798
|
+
}
|
|
10799
|
+
|
|
10800
|
+
return byteArray.shift();
|
|
10801
|
+
}
|
|
10802
|
+
/**
|
|
10803
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
10804
|
+
* the array.
|
|
10805
|
+
*/
|
|
10806
|
+
|
|
10807
|
+
function guardedSplice(byteArray, ...args) {
|
|
10808
|
+
var _args$;
|
|
10809
|
+
|
|
10810
|
+
const [start] = args;
|
|
10811
|
+
|
|
10812
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
10813
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
10814
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
10815
|
+
}
|
|
10816
|
+
|
|
10817
|
+
return byteArray.splice(...args);
|
|
10818
|
+
}
|
|
10819
|
+
|
|
10777
10820
|
/**
|
|
10778
10821
|
* The message header, identifying signed and read-only account
|
|
10779
10822
|
*/
|
|
@@ -10858,32 +10901,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
10858
10901
|
static from(buffer$1) {
|
|
10859
10902
|
// Slice up wire data
|
|
10860
10903
|
let byteArray = [...buffer$1];
|
|
10861
|
-
const numRequiredSignatures = byteArray
|
|
10862
|
-
const numReadonlySignedAccounts = byteArray
|
|
10863
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
10904
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
10905
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
10906
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
10864
10907
|
const accountCount = decodeLength(byteArray);
|
|
10865
10908
|
let accountKeys = [];
|
|
10866
10909
|
|
|
10867
10910
|
for (let i = 0; i < accountCount; i++) {
|
|
10868
|
-
const account = byteArray
|
|
10869
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
10911
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
10870
10912
|
accountKeys.push(bs58.encode(buffer.Buffer.from(account)));
|
|
10871
10913
|
}
|
|
10872
10914
|
|
|
10873
|
-
const recentBlockhash = byteArray
|
|
10874
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
10915
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
10875
10916
|
const instructionCount = decodeLength(byteArray);
|
|
10876
10917
|
let instructions = [];
|
|
10877
10918
|
|
|
10878
10919
|
for (let i = 0; i < instructionCount; i++) {
|
|
10879
|
-
const programIdIndex = byteArray
|
|
10920
|
+
const programIdIndex = guardedShift(byteArray);
|
|
10880
10921
|
const accountCount = decodeLength(byteArray);
|
|
10881
|
-
const accounts = byteArray
|
|
10882
|
-
byteArray = byteArray.slice(accountCount);
|
|
10922
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
10883
10923
|
const dataLength = decodeLength(byteArray);
|
|
10884
|
-
const dataSlice = byteArray
|
|
10924
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
10885
10925
|
const data = bs58.encode(buffer.Buffer.from(dataSlice));
|
|
10886
|
-
byteArray = byteArray.slice(dataLength);
|
|
10887
10926
|
instructions.push({
|
|
10888
10927
|
programIdIndex,
|
|
10889
10928
|
accounts,
|
|
@@ -11503,8 +11542,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
11503
11542
|
let signatures = [];
|
|
11504
11543
|
|
|
11505
11544
|
for (let i = 0; i < signatureCount; i++) {
|
|
11506
|
-
const signature = byteArray
|
|
11507
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
11545
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
11508
11546
|
signatures.push(bs58.encode(buffer.Buffer.from(signature)));
|
|
11509
11547
|
}
|
|
11510
11548
|
|
|
@@ -16566,6 +16604,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
16566
16604
|
* @param {String|Number|null} [id] Request ID can be a string, number, null for explicit notification or left out for automatic generation
|
|
16567
16605
|
* @param {Object} [options]
|
|
16568
16606
|
* @param {Number} [options.version=2] JSON-RPC version to use (1 or 2)
|
|
16607
|
+
* @param {Number} [options.notificationIdNull=false] When version is 2 and this option is true, the id of a notification request will be set to null instead of being omitted
|
|
16569
16608
|
* @param {Function} [options.generator] Passed the request, and the options object and is expected to return a request ID
|
|
16570
16609
|
* @throws {TypeError} If any of the parameters are invalid
|
|
16571
16610
|
* @return {Object} A JSON-RPC 1.0 or 2.0 request
|
|
@@ -16578,30 +16617,37 @@ var solanaWeb3 = (function (exports) {
|
|
|
16578
16617
|
|
|
16579
16618
|
options = options || {};
|
|
16580
16619
|
|
|
16620
|
+
// check valid version provided
|
|
16621
|
+
const version = typeof options.version === 'number' ? options.version : 2;
|
|
16622
|
+
if (version !== 1 && version !== 2) {
|
|
16623
|
+
throw new TypeError(version + ' must be 1 or 2');
|
|
16624
|
+
}
|
|
16625
|
+
|
|
16581
16626
|
const request = {
|
|
16582
16627
|
method: method
|
|
16583
16628
|
};
|
|
16584
16629
|
|
|
16585
|
-
|
|
16586
|
-
if(typeof options.version === 'undefined' || options.version !== 1) {
|
|
16630
|
+
if(version === 2) {
|
|
16587
16631
|
request.jsonrpc = '2.0';
|
|
16588
16632
|
}
|
|
16589
16633
|
|
|
16590
16634
|
if(params) {
|
|
16591
|
-
|
|
16592
16635
|
// params given, but invalid?
|
|
16593
16636
|
if(typeof params !== 'object' && !Array.isArray(params)) {
|
|
16594
16637
|
throw new TypeError(params + ' must be an object, array or omitted');
|
|
16595
16638
|
}
|
|
16596
|
-
|
|
16597
16639
|
request.params = params;
|
|
16598
|
-
|
|
16599
16640
|
}
|
|
16600
16641
|
|
|
16601
16642
|
// if id was left out, generate one (null means explicit notification)
|
|
16602
16643
|
if(typeof(id) === 'undefined') {
|
|
16603
16644
|
const generator = typeof options.generator === 'function' ? options.generator : function() { return v4_1(); };
|
|
16604
16645
|
request.id = generator(request, options);
|
|
16646
|
+
} else if (version === 2 && id === null) {
|
|
16647
|
+
// we have a version 2 notification
|
|
16648
|
+
if (options.notificationIdNull) {
|
|
16649
|
+
request.id = null; // id will not be set at all unless option provided
|
|
16650
|
+
}
|
|
16605
16651
|
} else {
|
|
16606
16652
|
request.id = id;
|
|
16607
16653
|
}
|
|
@@ -19620,12 +19666,18 @@ var solanaWeb3 = (function (exports) {
|
|
|
19620
19666
|
this.epoch = epoch;
|
|
19621
19667
|
this.custodian = custodian;
|
|
19622
19668
|
}
|
|
19669
|
+
/**
|
|
19670
|
+
* Default, inactive Lockup value
|
|
19671
|
+
*/
|
|
19672
|
+
|
|
19623
19673
|
|
|
19624
19674
|
}
|
|
19625
19675
|
/**
|
|
19626
19676
|
* Create stake account transaction params
|
|
19627
19677
|
*/
|
|
19628
19678
|
|
|
19679
|
+
_defineProperty(Lockup, "default", new Lockup(0, 0, PublicKey.default));
|
|
19680
|
+
|
|
19629
19681
|
/**
|
|
19630
19682
|
* Stake Instruction class
|
|
19631
19683
|
*/
|
|
@@ -19901,8 +19953,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
19901
19953
|
const {
|
|
19902
19954
|
stakePubkey,
|
|
19903
19955
|
authorized,
|
|
19904
|
-
lockup
|
|
19956
|
+
lockup: maybeLockup
|
|
19905
19957
|
} = params;
|
|
19958
|
+
const lockup = maybeLockup || Lockup.default;
|
|
19906
19959
|
const type = STAKE_INSTRUCTION_LAYOUTS.Initialize;
|
|
19907
19960
|
const data = encodeData(type, {
|
|
19908
19961
|
authorized: {
|
|
@@ -20649,9 +20702,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
20649
20702
|
"minimalistic-assert": "^1.0.1",
|
|
20650
20703
|
"minimalistic-crypto-utils": "^1.0.1"
|
|
20651
20704
|
};
|
|
20652
|
-
var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
|
|
20653
|
-
var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
|
|
20654
|
-
var _from = "elliptic@6.5.4";
|
|
20655
20705
|
var require$$0 = {
|
|
20656
20706
|
name: name,
|
|
20657
20707
|
version: version,
|
|
@@ -20666,10 +20716,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
20666
20716
|
bugs: bugs,
|
|
20667
20717
|
homepage: homepage,
|
|
20668
20718
|
devDependencies: devDependencies,
|
|
20669
|
-
dependencies: dependencies
|
|
20670
|
-
_resolved: _resolved,
|
|
20671
|
-
_integrity: _integrity,
|
|
20672
|
-
_from: _from
|
|
20719
|
+
dependencies: dependencies
|
|
20673
20720
|
};
|
|
20674
20721
|
|
|
20675
20722
|
var minimalisticAssert = assert$9;
|
|
@@ -27275,10 +27322,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
27275
27322
|
const configKeys = [];
|
|
27276
27323
|
|
|
27277
27324
|
for (let i = 0; i < 2; i++) {
|
|
27278
|
-
const publicKey = new PublicKey(byteArray
|
|
27279
|
-
|
|
27280
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
27281
|
-
byteArray = byteArray.slice(1);
|
|
27325
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
27326
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
27282
27327
|
configKeys.push({
|
|
27283
27328
|
publicKey,
|
|
27284
27329
|
isSigner
|