Skip to content

Commit

Permalink
refactoring: dry-run call
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0olo committed Dec 18, 2021
1 parent b7ff4aa commit b238342
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.kryptokrauts.aeternity.generated.api.InternalApiImpl;
import com.kryptokrauts.aeternity.generated.api.rxjava.ExternalApi;
import com.kryptokrauts.aeternity.generated.api.rxjava.InternalApi;
import com.kryptokrauts.aeternity.sdk.constants.BaseConstants;
import com.kryptokrauts.aeternity.sdk.exception.InvalidParameterException;
import com.kryptokrauts.aeternity.sdk.service.account.AccountService;
import com.kryptokrauts.aeternity.sdk.service.account.impl.AccountServiceImpl;
Expand Down Expand Up @@ -59,7 +58,7 @@ public class AeternityService {

public OracleService oracles;

public String keyPairAddress = BaseConstants.ZERO_ADDRESS_ACCOUNT;
public String keyPairAddress;

public AeternityService(AeternityServiceConfiguration config) {
this.config = config;
Expand All @@ -78,7 +77,7 @@ public AeternityService(AeternityServiceConfiguration config) {
try {
this.keyPairAddress = config.getKeyPair().getAddress();
} catch (InvalidParameterException e) {
log.warn("No KeyPair provided. The Service cannot be used to sign transactions.");
log.info("No KeyPair provided. Initialized AeternityService in read-only mode.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ public interface TransactionService {
* convenience function to perform a dry-run for a single tx by providing one of {@link
* com.kryptokrauts.aeternity.sdk.service.transaction.type.AbstractTransaction}
*
* <p>using the zeroAddress for the dry-run MUST be used if no KeyPair is provided in the {@link
* com.kryptokrauts.aeternity.sdk.service.ServiceConfiguration}
*
* @param contractCall the {@link ContractCallTransactionModel}
* @param staticReadOnly true to use the zero address for a static contract call, false if account
* in configuration should be used to simulate a stateful tx
* @param useZeroAddress true to use the zero address which makes sense for for a non-stateful
* (ready-only) contract call, false if account in configuration should be used to simulate a
* stateful tx
* @return instance of {@link DryRunTransactionResult}
*/
DryRunTransactionResult blockingDryRunContractCall(
ContractCallTransactionModel contractCall, boolean staticReadOnly);
ContractCallTransactionModel contractCall, boolean useZeroAddress);

/**
* synchronously dry run unsigned transactions to estimate gas (!) please make sure to use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ public Single<DryRunTransactionResults> asyncDryRunTransactions(DryRunRequest in

@Override
public DryRunTransactionResult blockingDryRunContractCall(
ContractCallTransactionModel contractCall, boolean staticReadOnly) {
ContractCallTransactionModel contractCall, boolean useZeroAddress) {
DryRunRequest request;
if (staticReadOnly) {
if (useZeroAddress) {
ContractCallTransactionModel contractCallTransactionModel =
contractCall
.toBuilder()
Expand Down

0 comments on commit b238342

Please sign in to comment.