|
26 | 26 | import org.awaitility.core.ConditionTimeoutException; |
27 | 27 | import org.web3j.crypto.Credentials; |
28 | 28 | import org.web3j.ens.EnsResolutionException; |
| 29 | +import org.web3j.protocol.core.DefaultBlockParameterName; |
29 | 30 | import org.web3j.protocol.core.RemoteCall; |
30 | 31 | import org.web3j.protocol.core.methods.response.TransactionReceipt; |
31 | 32 | import org.web3j.tuples.generated.Tuple3; |
32 | 33 | import org.web3j.tx.RawTransactionManager; |
33 | 34 | import org.web3j.tx.gas.ContractGasProvider; |
34 | 35 | import org.web3j.tx.gas.DefaultGasProvider; |
| 36 | +import org.web3j.utils.Numeric; |
35 | 37 |
|
| 38 | +import java.io.IOException; |
36 | 39 | import java.math.BigInteger; |
37 | 40 | import java.nio.charset.StandardCharsets; |
38 | 41 | import java.util.HashMap; |
|
41 | 44 | import java.util.concurrent.Callable; |
42 | 45 | import java.util.concurrent.TimeUnit; |
43 | 46 |
|
| 47 | +import static com.iexec.commons.poco.encoding.AccessorsEncoder.*; |
44 | 48 | import static com.iexec.commons.poco.encoding.AssetDataEncoder.getAssetAddressFromReceipt; |
45 | 49 | import static com.iexec.commons.poco.tee.TeeEnclaveConfiguration.buildEnclaveConfigurationFromJsonString; |
46 | 50 | import static com.iexec.commons.poco.utils.BytesUtils.isNonZeroedBytes32; |
@@ -889,7 +893,7 @@ public long getMaxNbOfPeriodsForConsensus() { |
889 | 893 |
|
890 | 894 | private void setMaxNbOfPeriodsForConsensus() { |
891 | 895 | try { |
892 | | - maxNbOfPeriodsForConsensus = iexecHubContract.contribution_deadline_ratio().send().longValue(); |
| 896 | + maxNbOfPeriodsForConsensus = getContributionDeadlineRatio().longValue(); |
893 | 897 | } catch (Exception e) { |
894 | 898 | log.error("Failed to get maxNbOfPeriodsForConsensus from the chain", e); |
895 | 899 | maxNbOfPeriodsForConsensus = -1; |
@@ -951,6 +955,45 @@ public boolean isTeeTask(String chainTaskId) { |
951 | 955 | return taskDescription.isTeeTask(); |
952 | 956 | } |
953 | 957 |
|
| 958 | + // region accessors |
| 959 | + |
| 960 | + /** |
| 961 | + * Send call to callbackgas() PoCo method. |
| 962 | + * |
| 963 | + * @return callbackgas value |
| 964 | + * @throws IOException if communication fails |
| 965 | + */ |
| 966 | + public BigInteger getCallbackGas() throws IOException { |
| 967 | + return sendCallWithFunctionSelector(CALLBACKGAS_SELECTOR); |
| 968 | + } |
| 969 | + |
| 970 | + /** |
| 971 | + * Send call to contribution_deadline_ratio() PoCo method. |
| 972 | + * |
| 973 | + * @return contribution_deadline_ratio value |
| 974 | + * @throws IOException if communication fails |
| 975 | + */ |
| 976 | + public BigInteger getContributionDeadlineRatio() throws IOException { |
| 977 | + return sendCallWithFunctionSelector(CONTRIBUTION_DEADLINE_RATIO_SELECTOR); |
| 978 | + } |
| 979 | + |
| 980 | + /** |
| 981 | + * Send call to final_deadline_ratio() PoCo method. |
| 982 | + * |
| 983 | + * @return final_deadline_ratio value |
| 984 | + * @throws IOException if communication fails |
| 985 | + */ |
| 986 | + public BigInteger getFinalDeadlineRatio() throws IOException { |
| 987 | + return sendCallWithFunctionSelector(FINAL_DEADLINE_RATIO_SELECTOR); |
| 988 | + } |
| 989 | + |
| 990 | + private BigInteger sendCallWithFunctionSelector(final String functionSelector) throws IOException { |
| 991 | + return Numeric.toBigInt( |
| 992 | + txManager.sendCall(iexecHubAddress, functionSelector, DefaultBlockParameterName.LATEST)); |
| 993 | + } |
| 994 | + |
| 995 | + // endregion |
| 996 | + |
954 | 997 | // region Purge |
955 | 998 |
|
956 | 999 | /** |
|
0 commit comments