You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* **Important**: If an assertion fails, the code throws an error.
725
725
*
726
-
* @paramvalue - the "field-like" value to compare & assert with this {@link Field}.
727
-
* @param message? - a string error message to print if the assertion fails, optional.
726
+
* @paramy - the "field-like" value to compare & assert with this {@link Field}.
727
+
* @param message - a string error message to print if the assertion fails, optional.
728
728
*/
729
729
assertGreaterThanOrEqual(
730
730
y: Field|bigint|number|string,
@@ -738,6 +738,9 @@ class Field {
738
738
*
739
739
* Note: This uses fewer constraints than `x.equals(y).assertFalse()`.
740
740
*
741
+
* @param y - the "field-like" value to compare & assert with this {@link Field}.
742
+
* @param message - a string error message to print if the assertion fails, optional.
743
+
*
741
744
* @example
742
745
* ```ts
743
746
* x.assertNotEquals(0, "expect x to be non-zero");
@@ -775,7 +778,7 @@ class Field {
775
778
*
776
779
* If the assertion fails, the code throws an error.
777
780
*
778
-
* @param message? - a string error message to print if the assertion fails, optional.
781
+
* @param message - a string error message to print if the assertion fails, optional.
779
782
*/
780
783
assertBool(message?: string){
781
784
try{
@@ -834,11 +837,11 @@ class Field {
834
837
*
835
838
* The method throws if the given bits do not fit in a single Field element. In this case, no more than 254 bits are allowed because some 255 bit integers do not fit into a single Field element.
836
839
*
837
-
* **Important**: If the given `bytes` array is an array of `booleans` or {@link Bool} elements that all are `constant`, the resulting {@link Field} element will be a constant as well. Or else, if the given array is a mixture of constants and variables of {@link Bool} type, the resulting {@link Field} will be a variable as well.
840
+
* **Important**: If the given `bits` array is an array of `booleans` or {@link Bool} elements that all are `constant`, the resulting {@link Field} element will be a constant as well. Or else, if the given array is a mixture of constants and variables of {@link Bool} type, the resulting {@link Field} will be a variable as well.
838
841
*
839
-
* @parambytes - An array of {@link Bool} or `boolean` type.
842
+
* @parambits - An array of {@link Bool} or `boolean` type.
840
843
*
841
-
* @return A {@link Field} element matching the [little endian binary representation](https://en.wikipedia.org/wiki/Endianness) of the given `bytes` array.
844
+
* @return A {@link Field} element matching the [little endian binary representation](https://en.wikipedia.org/wiki/Endianness) of the given `bits` array.
842
845
*/
843
846
staticfromBits(bits: (Bool|boolean)[]){
844
847
constlength=bits.length;
@@ -909,16 +912,14 @@ class Field {
909
912
*
910
913
* @return A {@link Field} array of length 1 created from this {@link Field}.
911
914
*/
912
-
statictoFields(x: Field){
913
-
return[x];
915
+
statictoFields(value: Field){
916
+
return[value];
914
917
}
915
918
916
919
/**
917
920
* This function is the implementation of {@link Provable.toAuxiliary} for the {@link Field} type.
918
921
*
919
922
* As the primitive {@link Field} type has no auxiliary data associated with it, this function will always return an empty array.
920
-
*
921
-
* @param value - The {@link Field} element to get the auxiliary data of, optional. If not provided, the function returns an empty array.
922
923
*/
923
924
statictoAuxiliary(): []{
924
925
return[];
@@ -960,8 +961,6 @@ class Field {
960
961
* This function is the implementation of {@link Provable.check} in {@link Field} type.
961
962
*
962
963
* As any field element can be a {@link Field}, this function does not create any assertions, so it does nothing.
963
-
*
964
-
* @param value - the {@link Field} element to check.
965
964
*/
966
965
staticcheck(){}
967
966
@@ -1044,16 +1043,16 @@ class Field {
1044
1043
*
1045
1044
* @return A string equivalent to the JSON representation of the given {@link Field}.
1046
1045
*/
1047
-
statictoJSON(x: Field){
1048
-
returnx.toJSON();
1046
+
statictoJSON(value: Field){
1047
+
returnvalue.toJSON();
1049
1048
}
1050
1049
1051
1050
/**
1052
1051
* Deserialize a JSON string containing a "field-like" value into a {@link Field} element.
1053
1052
*
1054
1053
* **Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the {@link Field}.
1055
1054
*
1056
-
* @paramvalue - the "field-like" value to coerce the {@link Field} from.
1055
+
* @paramjson - the "field-like" value to coerce the {@link Field} from.
1057
1056
*
1058
1057
* @return A {@link Field} coerced from the given JSON string.
1059
1058
*/
@@ -1071,8 +1070,8 @@ class Field {
1071
1070
* @return An object where the `fields` key is a {@link Field} array of length 1 created from this {@link Field}.
1072
1071
*
1073
1072
*/
1074
-
statictoInput(x: Field){
1075
-
return{fields: [x]};
1073
+
statictoInput(value: Field){
1074
+
return{fields: [value]};
1076
1075
}
1077
1076
1078
1077
// Binable<Field>
@@ -1086,8 +1085,8 @@ class Field {
1086
1085
* @return An array of digits equal to the [little-endian](https://en.wikipedia.org/wiki/Endianness) byte order of the given {@link Field} element.
Copy file name to clipboardExpand all lines: src/lib/provable/types/struct.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,7 @@ type AnyConstructor = Constructor<any>;
71
71
* These composite types can be passed in as arguments to smart contract methods, used for on-chain state variables
72
72
* or as event / action types.
73
73
*
74
+
* @example
74
75
* Here's an example of creating a "Voter" struct, which holds a public key and a collection of votes on 3 different proposals:
75
76
* ```ts
76
77
* let Vote = { hasVoted: Bool, inFavor: Bool };
@@ -131,10 +132,9 @@ type AnyConstructor = Constructor<any>;
131
132
* Again, it's important to note that this doesn't enable you to prove anything about the `fullName` string.
132
133
* From the circuit point of view, it simply doesn't exist!
133
134
*
134
-
* @note Ensure you do not use or extend `Struct` as a type directly. Instead, always call it as a function to construct a type. `Struct` is not a valid provable type itself, types created with `Struct(...)` are.
135
+
* **Note**: Ensure you do not use or extend `Struct` as a type directly. Instead, always call it as a function to construct a type. `Struct` is not a valid provable type itself, types created with `Struct(...)` are.
135
136
*
136
137
* @param type Object specifying the layout of the `Struct`
137
-
* @param options Advanced option which allows you to force a certain order of object keys
0 commit comments