Skip to content

Commit

Permalink
Misc updates and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Sep 27, 2023
1 parent 051aafb commit e2eaa9a
Show file tree
Hide file tree
Showing 34 changed files with 45 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class CVMBenchmark {

// Move some USD to Hero
Context ctx=Context.createFake(STATE, Init.MAINBANK_ADDRESS);
ctx=ctx.eval(Reader.read("(do (import currency.USD :as usd) (fun/transfer usd "+HERO+" 1000000000))"));
ctx=ctx.eval(Reader.read("(do (import currency.USD :as usd) (fun/transfer usd "+HERO+" 100000000))"));
if (ctx.isError()) throw new Error("Problem moving USD: "+ctx.getError().toString());
STATE=ctx.getState();

Expand Down
2 changes: 1 addition & 1 deletion convex-cli/src/main/java/convex/cli/LocalGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void run() {
log.warn("You will not be able to use some of the CLI 'account' and 'peer' commands.");
// sub command to launch peer manager
try {
Applications.launchApp(convex.gui.manager.PeerGUI.class);
Applications.launchApp(convex.gui.PeerGUI.class);
} catch (Throwable t) {
throw new CLIError("Error launching GUI",t);
}
Expand Down
20 changes: 10 additions & 10 deletions convex-core/src/main/cvx/torus/currencies.cvx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[
["USD" "US Dollar" "US National Currency" "$" 10000000 2 1.00]
["JPY" "Japanese Yen" "Japanese National Currency" "¥" 5000000 0 0.0092]
["EUR" "Euro" "European Union Currency" "" 5000000 2 1.18819]
["GBP" "Pound Sterling" "UK National Currency" "£" 6000000 2 1.38700]
["THB" "Thai Baht" "Thai National Currency" "฿" 1000000 2 0.03244]
["VND" "Vietnamese Dong" "Vietnamese National Currency" "" 2000000 2 0.00004]
["MYR" "Malaysian Ringgit" "Malaysian National Currency" "RM" 800000 2 0.24260]
["CHF" "Swiss Franc" "Swiss National Currency" "Fr." 2000000 2 1.07269]
["HKD" "Hong Kong Dollar" "Hong Kong Currency" "HK$" 2000000 2 0.12879]
["SGD" "Singapore Dollar" "Singapore National Currency" "S$" 3000000 2 0.751]
["USD" "US Dollar" "US National Currency" "$" 100000000 2 1.00]
["JPY" "Japanese Yen" "Japanese National Currency" "¥" 50000000 0 0.0092]
["EUR" "Euro" "European Union Currency" "" 50000000 2 1.18819]
["GBP" "Pound Sterling" "UK National Currency" "£" 60000000 2 1.38700]
["THB" "Thai Baht" "Thai National Currency" "฿" 10000000 2 0.03244]
["VND" "Vietnamese Dong" "Vietnamese National Currency" "" 20000000 2 0.00004]
["MYR" "Malaysian Ringgit" "Malaysian National Currency" "RM" 8000000 2 0.24260]
["CHF" "Swiss Franc" "Swiss National Currency" "Fr." 20000000 2 1.07269]
["HKD" "Hong Kong Dollar" "Hong Kong Currency" "HK$" 20000000 2 0.12879]
["SGD" "Singapore Dollar" "Singapore National Currency" "S$" 30000000 2 0.751]
]
2 changes: 1 addition & 1 deletion convex-core/src/main/java/convex/core/init/Init.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private static State doCurrencyDeploy(State s, AVector<ACell> row) {
.read("(do (import convex.fungible :as fun) (deploy (fun/build-token {:supply " + supply + "})))"));
Address addr = ctx.getResult();
ctx = ctx.eval(Reader.read("(do (import torus.exchange :as torus) (torus/add-liquidity " + addr + " "
+ liquidity + " " + cvx + "))"));
+ (supply / 2) + " " + (cvx / 2) + "))"));
if (ctx.isExceptional()) throw new Error("Error adding market liquidity: " + ctx.getValue());

Symbol sym=Symbol.create("currency."+symName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected ATransaction(long count,Address origin, long sequence) {
@Override
public int encodeRaw(byte[] bs, int pos) {
pos = Format.writeVLCCount(bs,pos, origin.longValue());
pos = Format.writeVLCCount(bs,pos, sequence);
pos = Format.writeVLCLong(bs,pos, sequence);
return pos;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public static Invoke read(Blob b, int pos) throws BadFormatException {
Address address=Address.create(aval);
epos+=Format.getVLCCountLength(aval);

long sequence = Format.readVLCCount(b,epos);
epos+=Format.getVLCCountLength(sequence);
long sequence = Format.readVLCLong(b,epos);
epos+=Format.getVLCLength(sequence);

ACell args=Format.read(b, epos);
epos+=Format.getEncodingLength(args);
Expand Down
4 changes: 2 additions & 2 deletions convex-core/src/main/java/convex/core/transactions/Multi.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public static Multi read(Blob b, int pos) throws BadFormatException {
Address origin=Address.create(aval);
epos+=Format.getVLCCountLength(aval);

long sequence = Format.readVLCCount(b,epos);
epos+=Format.getVLCCountLength(sequence);
long sequence = Format.readVLCLong(b,epos);
epos+=Format.getVLCLength(sequence);

long mode = Format.readVLCLong(b,epos);
if (!isValidMode(mode)) throw new BadFormatException("Invalid Multi transaction mode: "+mode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public static ATransaction read(Blob b, int pos) throws BadFormatException {
Address origin=Address.create(aval);
epos+=Format.getVLCCountLength(aval);

long sequence = Format.readVLCCount(b,epos);
epos+=Format.getVLCCountLength(sequence);
long sequence = Format.readVLCLong(b,epos);
epos+=Format.getVLCLength(sequence);

long tval=Format.readVLCCount(b,epos);
Address target=Address.create(tval);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package convex.gui.manager;
package convex.gui;

import java.awt.BorderLayout;
import java.awt.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import convex.core.crypto.WalletEntry;
import convex.core.data.Address;
import convex.core.util.Text;
import convex.gui.manager.PeerGUI;
import convex.gui.PeerGUI;
import convex.gui.manager.mainpanels.WalletPanel;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import convex.core.data.SignedData;
import convex.core.store.AStore;
import convex.core.store.Stores;
import convex.gui.manager.PeerGUI;
import convex.gui.PeerGUI;
import convex.peer.Server;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import convex.core.data.Address;
import convex.core.data.PeerStatus;
import convex.core.util.Text;
import convex.gui.PeerGUI;
import convex.gui.client.ConvexClient;
import convex.gui.components.models.StateModel;
import convex.gui.manager.PeerGUI;
import convex.gui.manager.windows.etch.EtchWindow;
import convex.gui.manager.windows.peer.PeerWindow;
import convex.gui.manager.windows.state.StateWindow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import convex.core.data.AccountStatus;
import convex.core.data.Address;
import convex.core.util.Text;
import convex.gui.PeerGUI;
import convex.gui.client.ConvexClient;
import convex.gui.manager.PeerGUI;
import convex.gui.utils.Toolkit;
import net.miginfocom.swing.MigLayout;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import convex.core.data.prim.CVMLong;
import convex.core.util.Counters;
import convex.core.util.Text;
import convex.gui.PeerGUI;
import convex.gui.components.ActionPanel;
import convex.gui.manager.PeerGUI;
import convex.gui.utils.Toolkit;

@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import convex.core.State;
import convex.core.data.AccountStatus;
import convex.core.data.Address;
import convex.gui.PeerGUI;
import convex.gui.components.ActionPanel;
import convex.gui.components.models.AccountsTableModel;
import convex.gui.manager.PeerGUI;
import convex.gui.manager.windows.actor.ActorWindow;
import convex.gui.utils.Toolkit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import convex.gui.manager.PeerGUI;
import convex.gui.PeerGUI;
import convex.gui.manager.mainpanels.actors.DeployPanel;
import convex.gui.manager.mainpanels.actors.MarketsPanel;
import convex.gui.manager.mainpanels.actors.OraclePanel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import convex.core.data.Blob;
import convex.core.data.Blobs;
import convex.core.util.Utils;
import convex.gui.PeerGUI;
import convex.gui.components.ActionPanel;
import convex.gui.manager.PeerGUI;
import convex.gui.utils.Toolkit;

@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import convex.core.lang.RT;
import convex.core.lang.Reader;
import convex.core.util.Utils;
import convex.gui.PeerGUI;
import convex.gui.components.ActionPanel;
import convex.gui.manager.PeerGUI;
import convex.gui.utils.Toolkit;

@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import convex.core.data.Address;
import convex.core.data.Keyword;
import convex.core.data.Keywords;
import convex.gui.PeerGUI;
import convex.gui.components.ActionPanel;
import convex.gui.components.PeerComponent;
import convex.gui.components.ScrollyList;
import convex.gui.manager.PeerGUI;
import convex.peer.API;
import convex.peer.Server;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import javax.swing.table.TableColumnModel;

import convex.core.State;
import convex.gui.PeerGUI;
import convex.gui.components.ActionPanel;
import convex.gui.components.models.TorusTableModel;
import convex.gui.manager.PeerGUI;
import convex.gui.utils.Toolkit;

@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import convex.core.crypto.AKeyPair;
import convex.core.crypto.WalletEntry;
import convex.core.data.Address;
import convex.gui.PeerGUI;
import convex.gui.components.ActionPanel;
import convex.gui.components.ScrollyList;
import convex.gui.components.WalletComponent;
import convex.gui.manager.PeerGUI;

@SuppressWarnings("serial")
public class WalletPanel extends JPanel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import convex.core.lang.Context;
import convex.core.lang.RT;
import convex.core.lang.Symbols;
import convex.gui.PeerGUI;
import convex.gui.components.BaseListComponent;
import convex.gui.components.CodeLabel;
import convex.gui.components.DefaultReceiveAction;
import convex.gui.manager.PeerGUI;
import convex.gui.utils.Toolkit;

@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import javax.swing.JPanel;

import convex.core.data.Address;
import convex.gui.PeerGUI;
import convex.gui.components.AccountChooserPanel;
import convex.gui.components.ActionPanel;
import convex.gui.components.ScrollyList;
import convex.gui.manager.PeerGUI;

/**
* Panel displaying current prediction markets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import convex.core.lang.RT;
import convex.core.lang.Reader;
import convex.core.util.Utils;
import convex.gui.PeerGUI;
import convex.gui.components.ActionPanel;
import convex.gui.components.CodeLabel;
import convex.gui.components.DefaultReceiveAction;
import convex.gui.components.Toast;
import convex.gui.components.models.OracleTableModel;
import convex.gui.manager.PeerGUI;
import convex.gui.manager.mainpanels.WalletPanel;
import convex.gui.utils.Toolkit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import javax.swing.JFrame;
import javax.swing.JPanel;

import convex.gui.manager.PeerGUI;
import convex.gui.PeerGUI;

@SuppressWarnings("serial")
public abstract class BaseWindow extends JPanel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import convex.core.State;
import convex.core.data.AccountStatus;
import convex.core.data.Address;
import convex.gui.manager.PeerGUI;
import convex.gui.PeerGUI;
import convex.gui.utils.Toolkit;

@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import convex.core.data.AccountStatus;
import convex.core.data.Address;
import convex.core.data.Symbol;
import convex.gui.PeerGUI;
import convex.gui.components.AccountChooserPanel;
import convex.gui.components.ScrollyList;
import convex.gui.manager.PeerGUI;

@SuppressWarnings("serial")
public class ActorInvokePanel extends JPanel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import convex.core.data.AccountStatus;
import convex.core.data.Address;
import convex.gui.manager.PeerGUI;
import convex.gui.PeerGUI;
import convex.gui.manager.windows.BaseWindow;
import convex.gui.manager.windows.state.StateTreePanel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
import convex.core.lang.impl.Fn;
import convex.core.transactions.ATransaction;
import convex.core.transactions.Invoke;
import convex.gui.PeerGUI;
import convex.gui.components.AccountChooserPanel;
import convex.gui.components.BaseListComponent;
import convex.gui.components.CodeLabel;
import convex.gui.components.Toast;
import convex.gui.manager.PeerGUI;
import convex.gui.utils.Toolkit;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import javax.swing.JTabbedPane;

import convex.api.Convex;
import convex.gui.PeerGUI;
import convex.gui.components.PeerComponent;
import convex.gui.manager.PeerGUI;
import convex.gui.manager.windows.BaseWindow;
import etch.EtchStore;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.slf4j.LoggerFactory;

import convex.api.Convex;
import convex.gui.PeerGUI;
import convex.gui.components.PeerComponent;
import convex.gui.manager.PeerGUI;
import convex.gui.manager.windows.BaseWindow;
import convex.peer.Server;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
import convex.core.transactions.Transfer;
import convex.core.util.Text;
import convex.core.util.Utils;
import convex.gui.PeerGUI;
import convex.gui.components.ActionPanel;
import convex.gui.manager.PeerGUI;
import convex.gui.utils.Toolkit;

@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import javax.swing.JTabbedPane;

import convex.core.data.ACell;
import convex.gui.manager.PeerGUI;
import convex.gui.PeerGUI;
import convex.gui.manager.windows.BaseWindow;

@SuppressWarnings("serial")
Expand Down
1 change: 0 additions & 1 deletion convex-gui/src/test/java/convex/gui/GUITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import convex.core.State;
import convex.core.exceptions.InvalidDataException;
import convex.gui.manager.PeerGUI;

/**
* We can't test much of the GUI easily in unit tests, but we can at least test
Expand Down

0 comments on commit e2eaa9a

Please sign in to comment.