Skip to content

Commit

Permalink
Support transfer transaction type in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Jul 25, 2023
1 parent ab9cf2b commit 900b32b
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import convex.core.transactions.ATransaction;
import convex.core.transactions.Invoke;
import convex.core.transactions.Multi;
import convex.core.transactions.Transfer;
import convex.core.util.Text;
import convex.core.util.Utils;
import convex.gui.components.ActionPanel;
Expand Down Expand Up @@ -138,7 +139,7 @@ public StressPanel(Convex peerView) {
JLabel lblTxType=new JLabel("Transaction Type");
txTypeBox=new JComboBox<String>();
txTypeBox.addItem("Define Data");
// txTypeBox.addItem("Transfer");
txTypeBox.addItem("Transfer");
// txTypeBox.addItem("AMM Trade");
txTypeBox.addItem("Null Op");
optionPanel.add(lblTxType);
Expand Down Expand Up @@ -341,16 +342,21 @@ protected ATransaction buildTransaction(Address origin, int reqNo) {
}

protected ATransaction buildSubTransaction(int reqNo, int txNo, Address origin) {
if (type.equals("Transfer")) {
ATransaction t = Transfer.create(origin,-1, origin, 100);
return t;
}

StringBuilder tsb = new StringBuilder();
if (opCount>1) tsb.append("(do ");
if (opCount>1) tsb.append("(loop [i 0] ");
for (int j = 0; j < opCount; j++) {
switch(type) {
case "Define Data": tsb.append("(def a"+j+" "+reqNo+") "); break;
case "Define Data": tsb.append("(def a"+txNo+" "+reqNo+") "); break;
case "Null Op": tsb.append("nil "); break;
default: throw new Error("Bad TX type: "+type);
}
}
if (opCount>1) tsb.append(")");
if (opCount>1) tsb.append(" (cond (> i "+opCount+") nil (recur (inc i)) ) )");
String source = tsb.toString();
ATransaction t = Invoke.create(origin,-1, Reader.read(source));
return t;
Expand Down

0 comments on commit 900b32b

Please sign in to comment.