Skip to content

Commit

Permalink
Edits for Community Call demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Nov 17, 2023
1 parent 6628fc3 commit 767fea6
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 5 deletions.
55 changes: 55 additions & 0 deletions convex-core/src/test/resources/examples/asset-demo.cvx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
;; Asset demo

(import convex.asset :as asset)
(import convex.fungible :as fungible)
(import convex.fungible :as fun)
(import asset.box :as box)
(import asset.multi-token :as mt)

;; ===============================================
;; Creating a token: smart contract style
(def MYCOIN
(deploy
[(fun/build-token {:supply 1000})
(fun/add-mint {:minter *address*} )] ))

(asset/balance MYCOIN)
(asset/mint MYCOIN 100)
(asset/balance MYCOIN)

(asset/transfer #13 [MYCOIN 100])


;; ==============================================
;; Creating a token: factory actor style

;; create the token
(call mt (create :FOO))

;; Give it a name for convenience
(def TOK [mt :FOO])

(asset/balance TOK)

;; create some coins)
(asset/mint TOK 1000)

(asset/balance TOK)

(asset/transfer #13 [TOK 150])

;; ===========================================
;; An interesting implementation note

*holdings*

;; ===========================================
;; Now for NFTs

(import asset.nft.basic :as nft)

(def NFT-ID (call nft (create {:url "https://mikera.net/art/img1.jpg" :author "Mike"})))

(call nft (get-metadata NFT-ID))

(asset/balance nft)
1 change: 1 addition & 0 deletions convex-core/src/test/resources/examples/token-demo.cvx
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@
;; =================================
;; Boxing

()
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public class REPLPanel extends JPanel {

private InputListener inputListener=new InputListener();

private Font OUTPUT_FONT=new Font("Monospaced", Font.PLAIN, 16);
private Font INPUT_FONT=new Font("Monospaced", Font.PLAIN, 20);
private Font OUTPUT_FONT=new Font("Monospaced", Font.PLAIN, 24);
private Font INPUT_FONT=new Font("Monospaced", Font.PLAIN, 30);
private Color DEFAULT_OUTPUT_COLOR=Color.LIGHT_GRAY;

private JPanel panel_1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ public class StressPanel extends JPanel {
private JSpinner transactionCountSpinner;
private JSpinner opCountSpinner;
private JSpinner clientCountSpinner;
private JSpinner repeatTimeSpinner;
private JCheckBox syncCheckBox;
private JCheckBox distCheckBox;
private JCheckBox repeatCheckBox;

private JSplitPane splitPane;
private JPanel resultPanel;
Expand Down Expand Up @@ -135,6 +137,17 @@ public StressPanel(Convex peerView) {
distCheckBox=new JCheckBox();
optionPanel.add(distCheckBox);
distCheckBox.setSelected(false);

optionPanel.add(new JLabel("Repeat requests?"));
repeatCheckBox=new JCheckBox();
optionPanel.add(repeatCheckBox);
repeatCheckBox.setSelected(false);

optionPanel.add(new JLabel("Repeat timeout"));
repeatTimeSpinner = new JSpinner();
repeatTimeSpinner.setModel(new SpinnerNumberModel(60, 0, 3600, 1));
optionPanel.add(repeatTimeSpinner);


JLabel lblTxType=new JLabel("Transaction Type");
txTypeBox=new JComboBox<String>();
Expand Down Expand Up @@ -374,9 +387,16 @@ protected void done() {
}

private synchronized void runStressTest() {
Address address=peerConvex.getAddress();
AKeyPair kp=peerConvex.getKeyPair();
while (repeatCheckBox.isSelected()) {
Address address=peerConvex.getAddress();
AKeyPair kp=peerConvex.getKeyPair();

new StressTest(kp, address).execute();
new StressTest(kp, address).execute();
try {
Thread.sleep(((Integer)(repeatTimeSpinner.getValue()))*1000);
} catch (InterruptedException e) {
return;
}
}
}
}

0 comments on commit 767fea6

Please sign in to comment.