@solana/web3.js 1.91.8 → 1.91.9
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 +3 -3
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +3 -3
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +3 -3
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +3 -3
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +372 -439
- 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/lib/index.native.js +3 -3
- package/lib/index.native.js.map +1 -1
- package/package.json +4 -4
- package/src/__forks__/browser/rpc-websocket-factory.ts +1 -1
- package/src/__forks__/react-native/rpc-websocket-factory.ts +1 -1
- package/src/rpc-websocket-factory.ts +2 -2
- package/src/rpc-websocket.ts +6 -6
- package/src/utils/makeWebsocketUrl.ts +1 -1
package/lib/index.iife.js
CHANGED
|
@@ -2171,15 +2171,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
2171
2171
|
if (value > max || value < min) {
|
|
2172
2172
|
const n = typeof min === 'bigint' ? 'n' : '';
|
|
2173
2173
|
let range;
|
|
2174
|
-
|
|
2174
|
+
{
|
|
2175
2175
|
if (min === 0 || min === BigInt(0)) {
|
|
2176
2176
|
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
2177
2177
|
} else {
|
|
2178
2178
|
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
2179
2179
|
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
2180
2180
|
}
|
|
2181
|
-
} else {
|
|
2182
|
-
range = `>= ${min}${n} and <= ${max}${n}`;
|
|
2183
2181
|
}
|
|
2184
2182
|
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
2185
2183
|
}
|
|
@@ -2195,15 +2193,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
2195
2193
|
function boundsError (value, length, type) {
|
|
2196
2194
|
if (Math.floor(value) !== value) {
|
|
2197
2195
|
validateNumber(value, type);
|
|
2198
|
-
throw new errors.ERR_OUT_OF_RANGE(
|
|
2196
|
+
throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
|
|
2199
2197
|
}
|
|
2200
2198
|
|
|
2201
2199
|
if (length < 0) {
|
|
2202
2200
|
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
2203
2201
|
}
|
|
2204
2202
|
|
|
2205
|
-
throw new errors.ERR_OUT_OF_RANGE(
|
|
2206
|
-
`>= ${
|
|
2203
|
+
throw new errors.ERR_OUT_OF_RANGE('offset',
|
|
2204
|
+
`>= ${0} and <= ${length}`,
|
|
2207
2205
|
value)
|
|
2208
2206
|
}
|
|
2209
2207
|
|
|
@@ -14636,7 +14634,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
14636
14634
|
/**
|
|
14637
14635
|
* A `StructFailure` represents a single specific failure in validation.
|
|
14638
14636
|
*/
|
|
14639
|
-
|
|
14640
14637
|
/**
|
|
14641
14638
|
* `StructError` objects are thrown (or returned) when validation fails.
|
|
14642
14639
|
*
|
|
@@ -14646,190 +14643,160 @@ var solanaWeb3 = (function (exports) {
|
|
|
14646
14643
|
* continue validation and receive all the failures in the data.
|
|
14647
14644
|
*/
|
|
14648
14645
|
class StructError extends TypeError {
|
|
14649
|
-
|
|
14650
|
-
|
|
14651
|
-
|
|
14652
|
-
|
|
14653
|
-
|
|
14654
|
-
|
|
14655
|
-
|
|
14656
|
-
|
|
14657
|
-
|
|
14658
|
-
|
|
14659
|
-
|
|
14660
|
-
|
|
14661
|
-
|
|
14662
|
-
|
|
14663
|
-
this.failures = () => {
|
|
14664
|
-
var _cached;
|
|
14665
|
-
|
|
14666
|
-
return (_cached = cached) != null ? _cached : cached = [failure, ...failures()];
|
|
14667
|
-
};
|
|
14668
|
-
}
|
|
14669
|
-
|
|
14646
|
+
constructor(failure, failures) {
|
|
14647
|
+
let cached;
|
|
14648
|
+
const { message, explanation, ...rest } = failure;
|
|
14649
|
+
const { path } = failure;
|
|
14650
|
+
const msg = path.length === 0 ? message : `At path: ${path.join('.')} -- ${message}`;
|
|
14651
|
+
super(explanation ?? msg);
|
|
14652
|
+
if (explanation != null)
|
|
14653
|
+
this.cause = msg;
|
|
14654
|
+
Object.assign(this, rest);
|
|
14655
|
+
this.name = this.constructor.name;
|
|
14656
|
+
this.failures = () => {
|
|
14657
|
+
return (cached ?? (cached = [failure, ...failures()]));
|
|
14658
|
+
};
|
|
14659
|
+
}
|
|
14670
14660
|
}
|
|
14671
14661
|
|
|
14672
14662
|
/**
|
|
14673
14663
|
* Check if a value is an iterator.
|
|
14674
14664
|
*/
|
|
14675
14665
|
function isIterable(x) {
|
|
14676
|
-
|
|
14666
|
+
return isObject(x) && typeof x[Symbol.iterator] === 'function';
|
|
14677
14667
|
}
|
|
14678
14668
|
/**
|
|
14679
14669
|
* Check if a value is a plain object.
|
|
14680
14670
|
*/
|
|
14681
|
-
|
|
14682
|
-
|
|
14683
14671
|
function isObject(x) {
|
|
14684
|
-
|
|
14672
|
+
return typeof x === 'object' && x != null;
|
|
14685
14673
|
}
|
|
14686
14674
|
/**
|
|
14687
14675
|
* Return a value as a printable string.
|
|
14688
14676
|
*/
|
|
14689
|
-
|
|
14690
14677
|
function print(value) {
|
|
14691
|
-
|
|
14678
|
+
if (typeof value === 'symbol') {
|
|
14679
|
+
return value.toString();
|
|
14680
|
+
}
|
|
14681
|
+
return typeof value === 'string' ? JSON.stringify(value) : `${value}`;
|
|
14692
14682
|
}
|
|
14693
14683
|
/**
|
|
14694
14684
|
* Shifts (removes and returns) the first value from the `input` iterator.
|
|
14695
14685
|
* Like `Array.prototype.shift()` but for an `Iterator`.
|
|
14696
14686
|
*/
|
|
14697
|
-
|
|
14698
14687
|
function shiftIterator(input) {
|
|
14699
|
-
|
|
14700
|
-
done
|
|
14701
|
-
value
|
|
14702
|
-
} = input.next();
|
|
14703
|
-
return done ? undefined : value;
|
|
14688
|
+
const { done, value } = input.next();
|
|
14689
|
+
return done ? undefined : value;
|
|
14704
14690
|
}
|
|
14705
14691
|
/**
|
|
14706
14692
|
* Convert a single validation result to a failure.
|
|
14707
14693
|
*/
|
|
14708
|
-
|
|
14709
14694
|
function toFailure(result, context, struct, value) {
|
|
14710
|
-
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
result
|
|
14714
|
-
|
|
14715
|
-
|
|
14716
|
-
|
|
14695
|
+
if (result === true) {
|
|
14696
|
+
return;
|
|
14697
|
+
}
|
|
14698
|
+
else if (result === false) {
|
|
14699
|
+
result = {};
|
|
14700
|
+
}
|
|
14701
|
+
else if (typeof result === 'string') {
|
|
14702
|
+
result = { message: result };
|
|
14703
|
+
}
|
|
14704
|
+
const { path, branch } = context;
|
|
14705
|
+
const { type } = struct;
|
|
14706
|
+
const { refinement, message = `Expected a value of type \`${type}\`${refinement ? ` with refinement \`${refinement}\`` : ''}, but received: \`${print(value)}\``, } = result;
|
|
14707
|
+
return {
|
|
14708
|
+
value,
|
|
14709
|
+
type,
|
|
14710
|
+
refinement,
|
|
14711
|
+
key: path[path.length - 1],
|
|
14712
|
+
path,
|
|
14713
|
+
branch,
|
|
14714
|
+
...result,
|
|
14715
|
+
message,
|
|
14717
14716
|
};
|
|
14718
|
-
}
|
|
14719
|
-
|
|
14720
|
-
const {
|
|
14721
|
-
path,
|
|
14722
|
-
branch
|
|
14723
|
-
} = context;
|
|
14724
|
-
const {
|
|
14725
|
-
type
|
|
14726
|
-
} = struct;
|
|
14727
|
-
const {
|
|
14728
|
-
refinement,
|
|
14729
|
-
message = "Expected a value of type `" + type + "`" + (refinement ? " with refinement `" + refinement + "`" : '') + ", but received: `" + print(value) + "`"
|
|
14730
|
-
} = result;
|
|
14731
|
-
return {
|
|
14732
|
-
value,
|
|
14733
|
-
type,
|
|
14734
|
-
refinement,
|
|
14735
|
-
key: path[path.length - 1],
|
|
14736
|
-
path,
|
|
14737
|
-
branch,
|
|
14738
|
-
...result,
|
|
14739
|
-
message
|
|
14740
|
-
};
|
|
14741
14717
|
}
|
|
14742
14718
|
/**
|
|
14743
14719
|
* Convert a validation result to an iterable of failures.
|
|
14744
14720
|
*/
|
|
14745
|
-
|
|
14746
14721
|
function* toFailures(result, context, struct, value) {
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
14751
|
-
|
|
14752
|
-
|
|
14753
|
-
|
|
14754
|
-
|
|
14755
|
-
yield failure;
|
|
14722
|
+
if (!isIterable(result)) {
|
|
14723
|
+
result = [result];
|
|
14724
|
+
}
|
|
14725
|
+
for (const r of result) {
|
|
14726
|
+
const failure = toFailure(r, context, struct, value);
|
|
14727
|
+
if (failure) {
|
|
14728
|
+
yield failure;
|
|
14729
|
+
}
|
|
14756
14730
|
}
|
|
14757
|
-
}
|
|
14758
14731
|
}
|
|
14759
14732
|
/**
|
|
14760
14733
|
* Check a value against a struct, traversing deeply into nested values, and
|
|
14761
14734
|
* returning an iterator of failures or success.
|
|
14762
14735
|
*/
|
|
14763
|
-
|
|
14764
14736
|
function* run(value, struct, options = {}) {
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
if (mask && struct.type !== 'type' && isObject(struct.schema) && isObject(value) && !Array.isArray(value)) {
|
|
14780
|
-
for (const key in value) {
|
|
14781
|
-
if (struct.schema[key] === undefined) {
|
|
14782
|
-
delete value[key];
|
|
14737
|
+
const { path = [], branch = [value], coerce = false, mask = false } = options;
|
|
14738
|
+
const ctx = { path, branch };
|
|
14739
|
+
if (coerce) {
|
|
14740
|
+
value = struct.coercer(value, ctx);
|
|
14741
|
+
if (mask &&
|
|
14742
|
+
struct.type !== 'type' &&
|
|
14743
|
+
isObject(struct.schema) &&
|
|
14744
|
+
isObject(value) &&
|
|
14745
|
+
!Array.isArray(value)) {
|
|
14746
|
+
for (const key in value) {
|
|
14747
|
+
if (struct.schema[key] === undefined) {
|
|
14748
|
+
delete value[key];
|
|
14749
|
+
}
|
|
14750
|
+
}
|
|
14783
14751
|
}
|
|
14784
|
-
}
|
|
14785
14752
|
}
|
|
14786
|
-
|
|
14787
|
-
|
|
14788
|
-
|
|
14789
|
-
|
|
14790
|
-
|
|
14791
|
-
|
|
14792
|
-
|
|
14793
|
-
|
|
14794
|
-
|
|
14795
|
-
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
|
|
14809
|
-
|
|
14810
|
-
|
|
14811
|
-
|
|
14812
|
-
|
|
14813
|
-
|
|
14814
|
-
|
|
14815
|
-
|
|
14816
|
-
|
|
14817
|
-
|
|
14753
|
+
let status = 'valid';
|
|
14754
|
+
for (const failure of struct.validator(value, ctx)) {
|
|
14755
|
+
failure.explanation = options.message;
|
|
14756
|
+
status = 'not_valid';
|
|
14757
|
+
yield [failure, undefined];
|
|
14758
|
+
}
|
|
14759
|
+
for (let [k, v, s] of struct.entries(value, ctx)) {
|
|
14760
|
+
const ts = run(v, s, {
|
|
14761
|
+
path: k === undefined ? path : [...path, k],
|
|
14762
|
+
branch: k === undefined ? branch : [...branch, v],
|
|
14763
|
+
coerce,
|
|
14764
|
+
mask,
|
|
14765
|
+
message: options.message,
|
|
14766
|
+
});
|
|
14767
|
+
for (const t of ts) {
|
|
14768
|
+
if (t[0]) {
|
|
14769
|
+
status = t[0].refinement != null ? 'not_refined' : 'not_valid';
|
|
14770
|
+
yield [t[0], undefined];
|
|
14771
|
+
}
|
|
14772
|
+
else if (coerce) {
|
|
14773
|
+
v = t[1];
|
|
14774
|
+
if (k === undefined) {
|
|
14775
|
+
value = v;
|
|
14776
|
+
}
|
|
14777
|
+
else if (value instanceof Map) {
|
|
14778
|
+
value.set(k, v);
|
|
14779
|
+
}
|
|
14780
|
+
else if (value instanceof Set) {
|
|
14781
|
+
value.add(v);
|
|
14782
|
+
}
|
|
14783
|
+
else if (isObject(value)) {
|
|
14784
|
+
if (v !== undefined || k in value)
|
|
14785
|
+
value[k] = v;
|
|
14786
|
+
}
|
|
14787
|
+
}
|
|
14818
14788
|
}
|
|
14819
|
-
}
|
|
14820
14789
|
}
|
|
14821
|
-
|
|
14822
|
-
|
|
14823
|
-
|
|
14824
|
-
|
|
14825
|
-
|
|
14826
|
-
|
|
14790
|
+
if (status !== 'not_valid') {
|
|
14791
|
+
for (const failure of struct.refiner(value, ctx)) {
|
|
14792
|
+
failure.explanation = options.message;
|
|
14793
|
+
status = 'not_refined';
|
|
14794
|
+
yield [failure, undefined];
|
|
14795
|
+
}
|
|
14796
|
+
}
|
|
14797
|
+
if (status === 'valid') {
|
|
14798
|
+
yield [undefined, value];
|
|
14827
14799
|
}
|
|
14828
|
-
}
|
|
14829
|
-
|
|
14830
|
-
if (valid) {
|
|
14831
|
-
yield [undefined, value];
|
|
14832
|
-
}
|
|
14833
14800
|
}
|
|
14834
14801
|
|
|
14835
14802
|
/**
|
|
@@ -14837,269 +14804,227 @@ var solanaWeb3 = (function (exports) {
|
|
|
14837
14804
|
* values. Once constructed, you use the `assert`, `is` or `validate` helpers to
|
|
14838
14805
|
* validate unknown input data against the struct.
|
|
14839
14806
|
*/
|
|
14840
|
-
|
|
14841
14807
|
class Struct {
|
|
14842
|
-
|
|
14843
|
-
|
|
14844
|
-
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
|
|
14851
|
-
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14856
|
-
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14808
|
+
constructor(props) {
|
|
14809
|
+
const { type, schema, validator, refiner, coercer = (value) => value, entries = function* () { }, } = props;
|
|
14810
|
+
this.type = type;
|
|
14811
|
+
this.schema = schema;
|
|
14812
|
+
this.entries = entries;
|
|
14813
|
+
this.coercer = coercer;
|
|
14814
|
+
if (validator) {
|
|
14815
|
+
this.validator = (value, context) => {
|
|
14816
|
+
const result = validator(value, context);
|
|
14817
|
+
return toFailures(result, context, this, value);
|
|
14818
|
+
};
|
|
14819
|
+
}
|
|
14820
|
+
else {
|
|
14821
|
+
this.validator = () => [];
|
|
14822
|
+
}
|
|
14823
|
+
if (refiner) {
|
|
14824
|
+
this.refiner = (value, context) => {
|
|
14825
|
+
const result = refiner(value, context);
|
|
14826
|
+
return toFailures(result, context, this, value);
|
|
14827
|
+
};
|
|
14828
|
+
}
|
|
14829
|
+
else {
|
|
14830
|
+
this.refiner = () => [];
|
|
14831
|
+
}
|
|
14863
14832
|
}
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
return
|
|
14869
|
-
|
|
14870
|
-
|
|
14871
|
-
|
|
14833
|
+
/**
|
|
14834
|
+
* Assert that a value passes the struct's validation, throwing if it doesn't.
|
|
14835
|
+
*/
|
|
14836
|
+
assert(value, message) {
|
|
14837
|
+
return assert(value, this, message);
|
|
14838
|
+
}
|
|
14839
|
+
/**
|
|
14840
|
+
* Create a value with the struct's coercion logic, then validate it.
|
|
14841
|
+
*/
|
|
14842
|
+
create(value, message) {
|
|
14843
|
+
return create(value, this, message);
|
|
14844
|
+
}
|
|
14845
|
+
/**
|
|
14846
|
+
* Check if a value passes the struct's validation.
|
|
14847
|
+
*/
|
|
14848
|
+
is(value) {
|
|
14849
|
+
return is(value, this);
|
|
14850
|
+
}
|
|
14851
|
+
/**
|
|
14852
|
+
* Mask a value, coercing and validating it, but returning only the subset of
|
|
14853
|
+
* properties defined by the struct's schema.
|
|
14854
|
+
*/
|
|
14855
|
+
mask(value, message) {
|
|
14856
|
+
return mask(value, this, message);
|
|
14857
|
+
}
|
|
14858
|
+
/**
|
|
14859
|
+
* Validate a value with the struct's validation logic, returning a tuple
|
|
14860
|
+
* representing the result.
|
|
14861
|
+
*
|
|
14862
|
+
* You may optionally pass `true` for the `withCoercion` argument to coerce
|
|
14863
|
+
* the value before attempting to validate it. If you do, the result will
|
|
14864
|
+
* contain the coerced result when successful.
|
|
14865
|
+
*/
|
|
14866
|
+
validate(value, options = {}) {
|
|
14867
|
+
return validate$1(value, this, options);
|
|
14872
14868
|
}
|
|
14873
|
-
}
|
|
14874
|
-
/**
|
|
14875
|
-
* Assert that a value passes the struct's validation, throwing if it doesn't.
|
|
14876
|
-
*/
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
assert(value) {
|
|
14880
|
-
return assert(value, this);
|
|
14881
|
-
}
|
|
14882
|
-
/**
|
|
14883
|
-
* Create a value with the struct's coercion logic, then validate it.
|
|
14884
|
-
*/
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
create(value) {
|
|
14888
|
-
return create(value, this);
|
|
14889
|
-
}
|
|
14890
|
-
/**
|
|
14891
|
-
* Check if a value passes the struct's validation.
|
|
14892
|
-
*/
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
is(value) {
|
|
14896
|
-
return is(value, this);
|
|
14897
|
-
}
|
|
14898
|
-
/**
|
|
14899
|
-
* Mask a value, coercing and validating it, but returning only the subset of
|
|
14900
|
-
* properties defined by the struct's schema.
|
|
14901
|
-
*/
|
|
14902
|
-
|
|
14903
|
-
|
|
14904
|
-
mask(value) {
|
|
14905
|
-
return mask(value, this);
|
|
14906
|
-
}
|
|
14907
|
-
/**
|
|
14908
|
-
* Validate a value with the struct's validation logic, returning a tuple
|
|
14909
|
-
* representing the result.
|
|
14910
|
-
*
|
|
14911
|
-
* You may optionally pass `true` for the `withCoercion` argument to coerce
|
|
14912
|
-
* the value before attempting to validate it. If you do, the result will
|
|
14913
|
-
* contain the coerced result when successful.
|
|
14914
|
-
*/
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
validate(value, options = {}) {
|
|
14918
|
-
return validate$1(value, this, options);
|
|
14919
|
-
}
|
|
14920
|
-
|
|
14921
14869
|
}
|
|
14922
14870
|
/**
|
|
14923
14871
|
* Assert that a value passes a struct, throwing if it doesn't.
|
|
14924
14872
|
*/
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
|
|
14930
|
-
throw result[0];
|
|
14931
|
-
}
|
|
14873
|
+
function assert(value, struct, message) {
|
|
14874
|
+
const result = validate$1(value, struct, { message });
|
|
14875
|
+
if (result[0]) {
|
|
14876
|
+
throw result[0];
|
|
14877
|
+
}
|
|
14932
14878
|
}
|
|
14933
14879
|
/**
|
|
14934
14880
|
* Create a value with the coercion logic of struct and validate it.
|
|
14935
14881
|
*/
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
14939
|
-
|
|
14940
|
-
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
|
|
14944
|
-
} else {
|
|
14945
|
-
return result[1];
|
|
14946
|
-
}
|
|
14882
|
+
function create(value, struct, message) {
|
|
14883
|
+
const result = validate$1(value, struct, { coerce: true, message });
|
|
14884
|
+
if (result[0]) {
|
|
14885
|
+
throw result[0];
|
|
14886
|
+
}
|
|
14887
|
+
else {
|
|
14888
|
+
return result[1];
|
|
14889
|
+
}
|
|
14947
14890
|
}
|
|
14948
14891
|
/**
|
|
14949
14892
|
* Mask a value, returning only the subset of properties defined by a struct.
|
|
14950
14893
|
*/
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
|
|
14954
|
-
|
|
14955
|
-
|
|
14956
|
-
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
throw result[0];
|
|
14960
|
-
} else {
|
|
14961
|
-
return result[1];
|
|
14962
|
-
}
|
|
14894
|
+
function mask(value, struct, message) {
|
|
14895
|
+
const result = validate$1(value, struct, { coerce: true, mask: true, message });
|
|
14896
|
+
if (result[0]) {
|
|
14897
|
+
throw result[0];
|
|
14898
|
+
}
|
|
14899
|
+
else {
|
|
14900
|
+
return result[1];
|
|
14901
|
+
}
|
|
14963
14902
|
}
|
|
14964
14903
|
/**
|
|
14965
14904
|
* Check if a value passes a struct.
|
|
14966
14905
|
*/
|
|
14967
|
-
|
|
14968
14906
|
function is(value, struct) {
|
|
14969
|
-
|
|
14970
|
-
|
|
14907
|
+
const result = validate$1(value, struct);
|
|
14908
|
+
return !result[0];
|
|
14971
14909
|
}
|
|
14972
14910
|
/**
|
|
14973
14911
|
* Validate a value against a struct, returning an error if invalid, or the
|
|
14974
14912
|
* value (with potential coercion) if valid.
|
|
14975
14913
|
*/
|
|
14976
|
-
|
|
14977
14914
|
function validate$1(value, struct, options = {}) {
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
|
|
14981
|
-
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
|
|
14987
|
-
|
|
14988
|
-
|
|
14989
|
-
|
|
14990
|
-
|
|
14991
|
-
|
|
14992
|
-
|
|
14993
|
-
|
|
14915
|
+
const tuples = run(value, struct, options);
|
|
14916
|
+
const tuple = shiftIterator(tuples);
|
|
14917
|
+
if (tuple[0]) {
|
|
14918
|
+
const error = new StructError(tuple[0], function* () {
|
|
14919
|
+
for (const t of tuples) {
|
|
14920
|
+
if (t[0]) {
|
|
14921
|
+
yield t[0];
|
|
14922
|
+
}
|
|
14923
|
+
}
|
|
14924
|
+
});
|
|
14925
|
+
return [error, undefined];
|
|
14926
|
+
}
|
|
14927
|
+
else {
|
|
14928
|
+
const v = tuple[1];
|
|
14929
|
+
return [undefined, v];
|
|
14930
|
+
}
|
|
14994
14931
|
}
|
|
14995
14932
|
/**
|
|
14996
14933
|
* Define a new struct type with a custom validation function.
|
|
14997
14934
|
*/
|
|
14998
|
-
|
|
14999
14935
|
function define(name, validator) {
|
|
15000
|
-
|
|
15001
|
-
type: name,
|
|
15002
|
-
schema: null,
|
|
15003
|
-
validator
|
|
15004
|
-
});
|
|
14936
|
+
return new Struct({ type: name, schema: null, validator });
|
|
15005
14937
|
}
|
|
15006
14938
|
|
|
15007
14939
|
/**
|
|
15008
14940
|
* Ensure that any value passes validation.
|
|
15009
14941
|
*/
|
|
15010
|
-
|
|
15011
14942
|
function any() {
|
|
15012
|
-
|
|
14943
|
+
return define('any', () => true);
|
|
15013
14944
|
}
|
|
15014
14945
|
function array(Element) {
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
|
|
15020
|
-
|
|
15021
|
-
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
15026
|
-
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
}
|
|
15034
|
-
|
|
15035
|
-
});
|
|
14946
|
+
return new Struct({
|
|
14947
|
+
type: 'array',
|
|
14948
|
+
schema: Element,
|
|
14949
|
+
*entries(value) {
|
|
14950
|
+
if (Element && Array.isArray(value)) {
|
|
14951
|
+
for (const [i, v] of value.entries()) {
|
|
14952
|
+
yield [i, v, Element];
|
|
14953
|
+
}
|
|
14954
|
+
}
|
|
14955
|
+
},
|
|
14956
|
+
coercer(value) {
|
|
14957
|
+
return Array.isArray(value) ? value.slice() : value;
|
|
14958
|
+
},
|
|
14959
|
+
validator(value) {
|
|
14960
|
+
return (Array.isArray(value) ||
|
|
14961
|
+
`Expected an array value, but received: ${print(value)}`);
|
|
14962
|
+
},
|
|
14963
|
+
});
|
|
15036
14964
|
}
|
|
15037
14965
|
/**
|
|
15038
14966
|
* Ensure that a value is a boolean.
|
|
15039
14967
|
*/
|
|
15040
|
-
|
|
15041
14968
|
function boolean() {
|
|
15042
|
-
|
|
15043
|
-
|
|
15044
|
-
|
|
14969
|
+
return define('boolean', (value) => {
|
|
14970
|
+
return typeof value === 'boolean';
|
|
14971
|
+
});
|
|
15045
14972
|
}
|
|
15046
14973
|
/**
|
|
15047
14974
|
* Ensure that a value is an instance of a specific class.
|
|
15048
14975
|
*/
|
|
15049
|
-
|
|
15050
14976
|
function instance(Class) {
|
|
15051
|
-
|
|
15052
|
-
|
|
15053
|
-
|
|
14977
|
+
return define('instance', (value) => {
|
|
14978
|
+
return (value instanceof Class ||
|
|
14979
|
+
`Expected a \`${Class.name}\` instance, but received: ${print(value)}`);
|
|
14980
|
+
});
|
|
15054
14981
|
}
|
|
15055
14982
|
function literal(constant) {
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
});
|
|
14983
|
+
const description = print(constant);
|
|
14984
|
+
const t = typeof constant;
|
|
14985
|
+
return new Struct({
|
|
14986
|
+
type: 'literal',
|
|
14987
|
+
schema: t === 'string' || t === 'number' || t === 'boolean' ? constant : null,
|
|
14988
|
+
validator(value) {
|
|
14989
|
+
return (value === constant ||
|
|
14990
|
+
`Expected the literal \`${description}\`, but received: ${print(value)}`);
|
|
14991
|
+
},
|
|
14992
|
+
});
|
|
15067
14993
|
}
|
|
15068
14994
|
/**
|
|
15069
14995
|
* Ensure that no value ever passes validation.
|
|
15070
14996
|
*/
|
|
15071
|
-
|
|
15072
14997
|
function never() {
|
|
15073
|
-
|
|
14998
|
+
return define('never', () => false);
|
|
15074
14999
|
}
|
|
15075
15000
|
/**
|
|
15076
15001
|
* Augment an existing struct to allow `null` values.
|
|
15077
15002
|
*/
|
|
15078
|
-
|
|
15079
15003
|
function nullable(struct) {
|
|
15080
|
-
|
|
15081
|
-
|
|
15082
|
-
|
|
15083
|
-
|
|
15004
|
+
return new Struct({
|
|
15005
|
+
...struct,
|
|
15006
|
+
validator: (value, ctx) => value === null || struct.validator(value, ctx),
|
|
15007
|
+
refiner: (value, ctx) => value === null || struct.refiner(value, ctx),
|
|
15008
|
+
});
|
|
15084
15009
|
}
|
|
15085
15010
|
/**
|
|
15086
15011
|
* Ensure that a value is a number.
|
|
15087
15012
|
*/
|
|
15088
|
-
|
|
15089
15013
|
function number() {
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15014
|
+
return define('number', (value) => {
|
|
15015
|
+
return ((typeof value === 'number' && !isNaN(value)) ||
|
|
15016
|
+
`Expected a number, but received: ${print(value)}`);
|
|
15017
|
+
});
|
|
15093
15018
|
}
|
|
15094
15019
|
/**
|
|
15095
15020
|
* Augment a struct to allow `undefined` values.
|
|
15096
15021
|
*/
|
|
15097
|
-
|
|
15098
15022
|
function optional(struct) {
|
|
15099
|
-
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15023
|
+
return new Struct({
|
|
15024
|
+
...struct,
|
|
15025
|
+
validator: (value, ctx) => value === undefined || struct.validator(value, ctx),
|
|
15026
|
+
refiner: (value, ctx) => value === undefined || struct.refiner(value, ctx),
|
|
15027
|
+
});
|
|
15103
15028
|
}
|
|
15104
15029
|
/**
|
|
15105
15030
|
* Ensure that a value is an object with keys and values of specific types, but
|
|
@@ -15107,58 +15032,55 @@ var solanaWeb3 = (function (exports) {
|
|
|
15107
15032
|
*
|
|
15108
15033
|
* Like TypeScript's `Record` utility.
|
|
15109
15034
|
*/
|
|
15110
|
-
|
|
15111
15035
|
function record(Key, Value) {
|
|
15112
|
-
|
|
15113
|
-
|
|
15114
|
-
|
|
15115
|
-
|
|
15116
|
-
|
|
15117
|
-
|
|
15118
|
-
|
|
15119
|
-
|
|
15120
|
-
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
|
|
15128
|
-
}
|
|
15129
|
-
|
|
15130
|
-
});
|
|
15036
|
+
return new Struct({
|
|
15037
|
+
type: 'record',
|
|
15038
|
+
schema: null,
|
|
15039
|
+
*entries(value) {
|
|
15040
|
+
if (isObject(value)) {
|
|
15041
|
+
for (const k in value) {
|
|
15042
|
+
const v = value[k];
|
|
15043
|
+
yield [k, k, Key];
|
|
15044
|
+
yield [k, v, Value];
|
|
15045
|
+
}
|
|
15046
|
+
}
|
|
15047
|
+
},
|
|
15048
|
+
validator(value) {
|
|
15049
|
+
return (isObject(value) || `Expected an object, but received: ${print(value)}`);
|
|
15050
|
+
},
|
|
15051
|
+
});
|
|
15131
15052
|
}
|
|
15132
15053
|
/**
|
|
15133
15054
|
* Ensure that a value is a string.
|
|
15134
15055
|
*/
|
|
15135
|
-
|
|
15136
15056
|
function string() {
|
|
15137
|
-
|
|
15138
|
-
|
|
15139
|
-
|
|
15057
|
+
return define('string', (value) => {
|
|
15058
|
+
return (typeof value === 'string' ||
|
|
15059
|
+
`Expected a string, but received: ${print(value)}`);
|
|
15060
|
+
});
|
|
15140
15061
|
}
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15157
|
-
|
|
15158
|
-
|
|
15159
|
-
|
|
15160
|
-
|
|
15161
|
-
|
|
15062
|
+
/**
|
|
15063
|
+
* Ensure that a value is a tuple of a specific length, and that each of its
|
|
15064
|
+
* elements is of a specific type.
|
|
15065
|
+
*/
|
|
15066
|
+
function tuple(Structs) {
|
|
15067
|
+
const Never = never();
|
|
15068
|
+
return new Struct({
|
|
15069
|
+
type: 'tuple',
|
|
15070
|
+
schema: null,
|
|
15071
|
+
*entries(value) {
|
|
15072
|
+
if (Array.isArray(value)) {
|
|
15073
|
+
const length = Math.max(Structs.length, value.length);
|
|
15074
|
+
for (let i = 0; i < length; i++) {
|
|
15075
|
+
yield [i, value[i], Structs[i] || Never];
|
|
15076
|
+
}
|
|
15077
|
+
}
|
|
15078
|
+
},
|
|
15079
|
+
validator(value) {
|
|
15080
|
+
return (Array.isArray(value) ||
|
|
15081
|
+
`Expected an array, but received: ${print(value)}`);
|
|
15082
|
+
},
|
|
15083
|
+
});
|
|
15162
15084
|
}
|
|
15163
15085
|
/**
|
|
15164
15086
|
* Ensure that a value has a set of known properties of specific types.
|
|
@@ -15166,62 +15088,71 @@ var solanaWeb3 = (function (exports) {
|
|
|
15166
15088
|
* Note: Unrecognized properties are allowed and untouched. This is similar to
|
|
15167
15089
|
* how TypeScript's structural typing works.
|
|
15168
15090
|
*/
|
|
15169
|
-
|
|
15170
15091
|
function type(schema) {
|
|
15171
|
-
|
|
15172
|
-
|
|
15173
|
-
|
|
15174
|
-
|
|
15175
|
-
|
|
15176
|
-
|
|
15177
|
-
|
|
15178
|
-
|
|
15179
|
-
|
|
15180
|
-
|
|
15181
|
-
|
|
15182
|
-
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
|
|
15187
|
-
|
|
15188
|
-
|
|
15092
|
+
const keys = Object.keys(schema);
|
|
15093
|
+
return new Struct({
|
|
15094
|
+
type: 'type',
|
|
15095
|
+
schema,
|
|
15096
|
+
*entries(value) {
|
|
15097
|
+
if (isObject(value)) {
|
|
15098
|
+
for (const k of keys) {
|
|
15099
|
+
yield [k, value[k], schema[k]];
|
|
15100
|
+
}
|
|
15101
|
+
}
|
|
15102
|
+
},
|
|
15103
|
+
validator(value) {
|
|
15104
|
+
return (isObject(value) || `Expected an object, but received: ${print(value)}`);
|
|
15105
|
+
},
|
|
15106
|
+
coercer(value) {
|
|
15107
|
+
return isObject(value) ? { ...value } : value;
|
|
15108
|
+
},
|
|
15109
|
+
});
|
|
15189
15110
|
}
|
|
15111
|
+
/**
|
|
15112
|
+
* Ensure that a value matches one of a set of types.
|
|
15113
|
+
*/
|
|
15190
15114
|
function union(Structs) {
|
|
15191
|
-
|
|
15192
|
-
|
|
15193
|
-
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
const [first] = tuples;
|
|
15202
|
-
|
|
15203
|
-
if (!first[0]) {
|
|
15204
|
-
return [];
|
|
15205
|
-
} else {
|
|
15206
|
-
for (const [failure] of tuples) {
|
|
15207
|
-
if (failure) {
|
|
15208
|
-
failures.push(failure);
|
|
15115
|
+
const description = Structs.map((s) => s.type).join(' | ');
|
|
15116
|
+
return new Struct({
|
|
15117
|
+
type: 'union',
|
|
15118
|
+
schema: null,
|
|
15119
|
+
coercer(value) {
|
|
15120
|
+
for (const S of Structs) {
|
|
15121
|
+
const [error, coerced] = S.validate(value, { coerce: true });
|
|
15122
|
+
if (!error) {
|
|
15123
|
+
return coerced;
|
|
15124
|
+
}
|
|
15209
15125
|
}
|
|
15210
|
-
|
|
15211
|
-
}
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15126
|
+
return value;
|
|
15127
|
+
},
|
|
15128
|
+
validator(value, ctx) {
|
|
15129
|
+
const failures = [];
|
|
15130
|
+
for (const S of Structs) {
|
|
15131
|
+
const [...tuples] = run(value, S, ctx);
|
|
15132
|
+
const [first] = tuples;
|
|
15133
|
+
if (!first[0]) {
|
|
15134
|
+
return [];
|
|
15135
|
+
}
|
|
15136
|
+
else {
|
|
15137
|
+
for (const [failure] of tuples) {
|
|
15138
|
+
if (failure) {
|
|
15139
|
+
failures.push(failure);
|
|
15140
|
+
}
|
|
15141
|
+
}
|
|
15142
|
+
}
|
|
15143
|
+
}
|
|
15144
|
+
return [
|
|
15145
|
+
`Expected the value to satisfy a union of \`${description}\`, but received: ${print(value)}`,
|
|
15146
|
+
...failures,
|
|
15147
|
+
];
|
|
15148
|
+
},
|
|
15149
|
+
});
|
|
15218
15150
|
}
|
|
15219
15151
|
/**
|
|
15220
15152
|
* Ensure that any value passes validation, without widening its type to `any`.
|
|
15221
15153
|
*/
|
|
15222
|
-
|
|
15223
15154
|
function unknown() {
|
|
15224
|
-
|
|
15155
|
+
return define('unknown', () => true);
|
|
15225
15156
|
}
|
|
15226
15157
|
|
|
15227
15158
|
/**
|
|
@@ -15234,13 +15165,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
15234
15165
|
* Note: You must use `create(value, Struct)` on the value to have the coercion
|
|
15235
15166
|
* take effect! Using simply `assert()` or `is()` will not use coercion.
|
|
15236
15167
|
*/
|
|
15237
|
-
|
|
15238
15168
|
function coerce(struct, condition, coercer) {
|
|
15239
|
-
|
|
15240
|
-
|
|
15241
|
-
|
|
15242
|
-
|
|
15243
|
-
|
|
15169
|
+
return new Struct({
|
|
15170
|
+
...struct,
|
|
15171
|
+
coercer: (value, ctx) => {
|
|
15172
|
+
return is(value, condition)
|
|
15173
|
+
? struct.coercer(coercer(value, ctx), ctx)
|
|
15174
|
+
: struct.coercer(value, ctx);
|
|
15175
|
+
},
|
|
15176
|
+
});
|
|
15244
15177
|
}
|
|
15245
15178
|
|
|
15246
15179
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
@@ -16591,7 +16524,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
16591
16524
|
Object.defineProperty(client, "__esModule", { value: true });
|
|
16592
16525
|
// @ts-ignore
|
|
16593
16526
|
const eventemitter3_1$1 = eventemitter3Exports;
|
|
16594
|
-
const
|
|
16527
|
+
const utils_cjs_1 = utils;
|
|
16595
16528
|
class CommonClient extends eventemitter3_1$1.EventEmitter {
|
|
16596
16529
|
address;
|
|
16597
16530
|
rpc_id;
|
|
@@ -16635,7 +16568,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
16635
16568
|
this.current_reconnects = 0;
|
|
16636
16569
|
this.generate_request_id = generate_request_id || (() => ++this.rpc_id);
|
|
16637
16570
|
if (!dataPack)
|
|
16638
|
-
this.dataPack = new
|
|
16571
|
+
this.dataPack = new utils_cjs_1.DefaultDataPack();
|
|
16639
16572
|
else
|
|
16640
16573
|
this.dataPack = dataPack;
|
|
16641
16574
|
if (this.autoconnect)
|
|
@@ -17070,7 +17003,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
17070
17003
|
const websocketPort =
|
|
17071
17004
|
// Only shift the port by +1 as a convention for ws(s) only if given endpoint
|
|
17072
17005
|
// is explicitly specifying the endpoint port (HTTP-based RPC), assuming
|
|
17073
|
-
// we're directly trying to connect to
|
|
17006
|
+
// we're directly trying to connect to agave-validator's ws listening port.
|
|
17074
17007
|
// When the endpoint omits the port, we're connecting to the protocol
|
|
17075
17008
|
// default ports: http(80) or https(443) and it's assumed we're behind a reverse
|
|
17076
17009
|
// proxy which manages WebSocket upgrade and backend port redirection.
|