@@ -17,6 +17,7 @@ public class Signature {
1717 private final List <String > _outputParamTypes ;
1818 private final String _fullSignature ;
1919 private final String _selector ;
20+ private final String _stateMutability ;
2021 private Set <Statement > _entryPoints ;
2122 private Set <Statement > _exitPoints ;
2223 private boolean _isProtected ;
@@ -31,9 +32,10 @@ public class Signature {
3132 * @param fullSignature the full signature string
3233 * @param selector the selector (first 4 bytes of the Keccak-256
3334 * hash)
35+ * @param stateMutability the state mutability of the signature
3436 */
3537 public Signature (String name , String type , List <String > inputParamTypes , List <String > outputParamTypes ,
36- String fullSignature , String selector ) {
38+ String fullSignature , String selector , String stateMutability ) {
3739 this ._name = name ;
3840 this ._type = type ;
3941 this ._inputParamTypes = inputParamTypes ;
@@ -43,6 +45,23 @@ public Signature(String name, String type, List<String> inputParamTypes, List<St
4345 this ._entryPoints = new HashSet <>();
4446 this ._exitPoints = new HashSet <>();
4547 this ._isProtected = false ;
48+ this ._stateMutability = stateMutability ;
49+ }
50+
51+ /**
52+ * Constructs a Signature with the specified properties.
53+ *
54+ * @param name the name of the function or event
55+ * @param type the type (e.g., "function", "event")
56+ * @param inputParamTypes the list of input parameter types
57+ * @param outputParamTypes the list of output parameter types
58+ * @param fullSignature the full signature string
59+ * @param selector the selector (first 4 bytes of the Keccak-256
60+ * hash)
61+ */
62+ public Signature (String name , String type , List <String > inputParamTypes , List <String > outputParamTypes ,
63+ String fullSignature , String selector ) {
64+ this (name , type , inputParamTypes , outputParamTypes , fullSignature , selector , "view" );
4665 }
4766
4867 /**
@@ -117,6 +136,15 @@ public Set<Statement> getEntryPoints() {
117136 return _entryPoints ;
118137 }
119138
139+ /**
140+ * Gets the state mutability for this signature.
141+ *
142+ * @return the state mutability
143+ */
144+ public String getStateMutability () {
145+ return _stateMutability ;
146+ }
147+
120148 /**
121149 * Sets the entry points for this signature.
122150 *
@@ -196,12 +224,13 @@ public boolean equals(Object obj) {
196224 Objects .equals (_type , other ._type ) &&
197225 Objects .equals (_fullSignature , other ._fullSignature ) &&
198226 Objects .equals (_selector , other ._selector ) &&
199- _isProtected == other ._isProtected ;
227+ _isProtected == other ._isProtected &&
228+ Objects .equals (_stateMutability , other ._stateMutability );
200229 }
201230
202231 @ Override
203232 public int hashCode () {
204- return Objects .hash (_name , _type , _fullSignature , _selector , _isProtected );
233+ return Objects .hash (_name , _type , _fullSignature , _selector , _isProtected , _stateMutability );
205234 }
206235
207236 /**
@@ -244,6 +273,8 @@ public JSONObject toJson() {
244273
245274 json .put ("is_protected" , _isProtected );
246275
276+ json .put ("state_mutability" , _stateMutability );
277+
247278 return json ;
248279 }
249280
0 commit comments