Skip to content

Commit 44cbddf

Browse files
committed
Code generator correction
1 parent 2a259ec commit 44cbddf

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.web3j.protocol.core.methods.response.TransactionReceipt;
5656
import org.web3j.tx.Contract;
5757
import org.web3j.tx.TransactionManager;
58+
import org.web3j.tx.gas.ContractGasProvider;
5859
import org.web3j.utils.Collection;
5960
import org.web3j.utils.Strings;
6061
import org.web3j.utils.Version;
@@ -67,6 +68,7 @@ public class SolidityFunctionWrapper extends Generator {
6768
private static final String BINARY = "BINARY";
6869
private static final String WEB3J = "web3j";
6970
private static final String CREDENTIALS = "credentials";
71+
private static final String CONTRACT_GAS_PROVIDER = "contractGasProvider";
7072
private static final String TRANSACTION_MANAGER = "transactionManager";
7173
private static final String INITIAL_VALUE = "initialWeiValue";
7274
private static final String CONTRACT_ADDRESS = "contractAddress";
@@ -122,16 +124,13 @@ void generateJavaFiles(
122124

123125
TypeSpec.Builder classBuilder = createClassBuilder(className, bin);
124126

125-
classBuilder.addMethod(buildConstructor(Credentials.class, CREDENTIALS));
126127
classBuilder.addMethod(buildConstructor(TransactionManager.class,
127128
TRANSACTION_MANAGER));
128129
classBuilder.addFields(buildFuncNameConstants(abi));
129130
classBuilder.addMethods(
130131
buildFunctionDefinitions(className, classBuilder, abi));
131-
classBuilder.addMethod(buildLoad(className, Credentials.class, CREDENTIALS));
132-
classBuilder.addMethod(buildLoad(className, TransactionManager.class,
133-
TRANSACTION_MANAGER));
134-
132+
classBuilder.addMethod(buildLoad(className));
133+
135134
addAddressesSupport(classBuilder, addresses);
136135

137136
write(basePackageName, classBuilder.build(), destinationDir);
@@ -310,10 +309,9 @@ private static MethodSpec buildConstructor(Class authType, String authName) {
310309
.addParameter(String.class, CONTRACT_ADDRESS)
311310
.addParameter(Web3j.class, WEB3J)
312311
.addParameter(authType, authName)
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)
312+
.addParameter(ContractGasProvider.class, CONTRACT_GAS_PROVIDER)
313+
.addStatement("super($N, $N, $N, $N, $N)",
314+
BINARY, CONTRACT_ADDRESS, WEB3J, authName, CONTRACT_GAS_PROVIDER)
317315
.build();
318316
}
319317

@@ -391,17 +389,16 @@ private static MethodSpec.Builder getDeployMethodSpec(
391389
}
392390

393391
private static MethodSpec buildLoad(
394-
String className, Class authType, String authName) {
392+
String className) {
395393
return MethodSpec.methodBuilder("load")
396394
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
397395
.returns(TypeVariableName.get(className, Type.class))
398396
.addParameter(String.class, CONTRACT_ADDRESS)
399397
.addParameter(Web3j.class, WEB3J)
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)
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)
405402
.build();
406403
}
407404

0 commit comments

Comments
 (0)