Skip to content

Commit

Permalink
Refactor Tx sender wallet handling and clean up AbstractTx.
Browse files Browse the repository at this point in the history
Changed the sender wallet handling to return null instead of throwing an exception in Tx.java to allow flexibility in error management. Also, removed redundant 'amounts' field and its initialization from AbstractTx.java for a cleaner codebase.
  • Loading branch information
satran004 committed Nov 24, 2024
1 parent 41c2615 commit 588d3ae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public abstract class AbstractTx<T> {
//custom change address
protected String changeAddress;
protected List<Utxo> inputUtxos;
protected List<Amount> amounts;

//Required for script
protected PlutusData changeData;
Expand Down Expand Up @@ -214,9 +213,7 @@ protected T payToAddress(String address, List<Amount> amounts, byte[] datumHash,
.address(address)
.value(Value.builder().coin(BigInteger.ZERO).build())
.build();
if(this.amounts == null)
this.amounts = new ArrayList<>();
this.amounts.addAll(amounts);

for (Amount amount : amounts) {
String unit = amount.getUnit();
if (unit.equals(LOVELACE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ protected Wallet getFromWallet() {
if(senderWallet != null)
return senderWallet;
else
throw new TxBuildException("No sender wallet defined");
return null;
}

@Override
Expand Down

0 comments on commit 588d3ae

Please sign in to comment.