5555import org .web3j .protocol .core .methods .response .TransactionReceipt ;
5656import org .web3j .tx .Contract ;
5757import org .web3j .tx .TransactionManager ;
58- import org .web3j .tx .gas .ContractGasProvider ;
5958import org .web3j .utils .Collection ;
6059import org .web3j .utils .Strings ;
6160import org .web3j .utils .Version ;
@@ -68,7 +67,6 @@ public class SolidityFunctionWrapper extends Generator {
6867 private static final String BINARY = "BINARY" ;
6968 private static final String WEB3J = "web3j" ;
7069 private static final String CREDENTIALS = "credentials" ;
71- private static final String CONTRACT_GAS_PROVIDER = "contractGasProvider" ;
7270 private static final String TRANSACTION_MANAGER = "transactionManager" ;
7371 private static final String INITIAL_VALUE = "initialWeiValue" ;
7472 private static final String CONTRACT_ADDRESS = "contractAddress" ;
@@ -124,13 +122,16 @@ void generateJavaFiles(
124122
125123 TypeSpec .Builder classBuilder = createClassBuilder (className , bin );
126124
125+ classBuilder .addMethod (buildConstructor (Credentials .class , CREDENTIALS ));
127126 classBuilder .addMethod (buildConstructor (TransactionManager .class ,
128127 TRANSACTION_MANAGER ));
129128 classBuilder .addFields (buildFuncNameConstants (abi ));
130129 classBuilder .addMethods (
131130 buildFunctionDefinitions (className , classBuilder , abi ));
132- classBuilder .addMethod (buildLoad (className ));
133-
131+ classBuilder .addMethod (buildLoad (className , Credentials .class , CREDENTIALS ));
132+ classBuilder .addMethod (buildLoad (className , TransactionManager .class ,
133+ TRANSACTION_MANAGER ));
134+
134135 addAddressesSupport (classBuilder , addresses );
135136
136137 write (basePackageName , classBuilder .build (), destinationDir );
@@ -309,9 +310,10 @@ private static MethodSpec buildConstructor(Class authType, String authName) {
309310 .addParameter (String .class , CONTRACT_ADDRESS )
310311 .addParameter (Web3j .class , WEB3J )
311312 .addParameter (authType , authName )
312- .addParameter (ContractGasProvider .class , CONTRACT_GAS_PROVIDER )
313- .addStatement ("super($N, $N, $N, $N, $N)" ,
314- BINARY , CONTRACT_ADDRESS , WEB3J , authName , CONTRACT_GAS_PROVIDER )
313+ .addParameter (BigInteger .class , GAS_PRICE )
314+ .addParameter (BigInteger .class , GAS_LIMIT )
315+ .addStatement ("super($N, $N, $N, $N, $N, $N)" ,
316+ BINARY , CONTRACT_ADDRESS , WEB3J , authName , GAS_PRICE , GAS_LIMIT )
315317 .build ();
316318 }
317319
@@ -389,16 +391,17 @@ private static MethodSpec.Builder getDeployMethodSpec(
389391 }
390392
391393 private static MethodSpec buildLoad (
392- String className ) {
394+ String className , Class authType , String authName ) {
393395 return MethodSpec .methodBuilder ("load" )
394396 .addModifiers (Modifier .PUBLIC , Modifier .STATIC )
395397 .returns (TypeVariableName .get (className , Type .class ))
396398 .addParameter (String .class , CONTRACT_ADDRESS )
397399 .addParameter (Web3j .class , WEB3J )
398- .addParameter (TransactionManager .class , TRANSACTION_MANAGER )
399- .addParameter (ContractGasProvider .class , CONTRACT_GAS_PROVIDER )
400- .addStatement ("return new $L($L, $L, $L, $L)" , className ,
401- CONTRACT_ADDRESS , WEB3J , TRANSACTION_MANAGER , CONTRACT_GAS_PROVIDER )
400+ .addParameter (authType , authName )
401+ .addParameter (BigInteger .class , GAS_PRICE )
402+ .addParameter (BigInteger .class , GAS_LIMIT )
403+ .addStatement ("return new $L($L, $L, $L, $L, $L)" , className ,
404+ CONTRACT_ADDRESS , WEB3J , authName , GAS_PRICE , GAS_LIMIT )
402405 .build ();
403406 }
404407
@@ -641,7 +644,7 @@ Function.class, Function.class, funcNameToConst(functionName),
641644 CodeBlock .Builder callCode = CodeBlock .builder ();
642645 callCode .addStatement (
643646 "$T result = "
644- + "($T) executeCallSingleValueReturn(function, $T.class)" ,
647+ + "($T) executeCallSingleValueReturn(function, $T.class)" ,
645648 listType , listType , nativeReturnTypeName );
646649 callCode .addStatement ("return convertToNative(result)" );
647650
@@ -845,7 +848,7 @@ MethodSpec buildEventTransactionReceiptFunction(
845848 transactionMethodBuilder .addStatement ("$T valueList = extractEventParametersWithLog("
846849 + buildEventDefinitionName (functionName ) + ", "
847850 + "transactionReceipt)" , ParameterizedTypeName .get (List .class ,
848- Contract .EventValuesWithLog .class ))
851+ Contract .EventValuesWithLog .class ))
849852 .addStatement ("$1T responses = new $1T(valueList.size())" ,
850853 ParameterizedTypeName .get (ClassName .get (ArrayList .class ),
851854 ClassName .get ("" , responseClassName )))
@@ -876,10 +879,10 @@ List<MethodSpec> buildEventFunctions(
876879
877880 for (AbiDefinition .NamedType namedType : inputs ) {
878881 NamedTypeName parameter = new NamedTypeName (
879- namedType .getName (),
880- buildTypeName (namedType .getType ()),
881- namedType .isIndexed ()
882- );
882+ namedType .getName (),
883+ buildTypeName (namedType .getType ()),
884+ namedType .isIndexed ()
885+ );
883886 if (namedType .isIndexed ()) {
884887 indexedParameters .add (parameter );
885888 } else {
@@ -1078,7 +1081,7 @@ private void buildTupleResultContainer(
10781081 }
10791082
10801083 tupleConstructor
1081- .add (resultString , convertTo , i );
1084+ .add (resultString , convertTo , i );
10821085 tupleConstructor .add (i < size - 1 ? ", " : ");\n " );
10831086 }
10841087 tupleConstructor .add ("$<$<" );
0 commit comments