create-leo-app 0.8.8 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-leo-app",
3
- "version": "0.8.8",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "license": "GPL-3.0",
6
6
  "collaborators": [
@@ -1,47 +0,0 @@
1
- import { Layout, Menu } from 'antd';
2
- import { UserOutlined, CrownOutlined } from '@ant-design/icons';
3
- import { Link, useLocation } from 'react-router-dom';
4
-
5
- const { Sider } = Layout;
6
-
7
- export const Sidebar = () => {
8
- const location = useLocation();
9
-
10
- const items = [
11
- {
12
- key: '/bidder',
13
- icon: <UserOutlined />,
14
- label: <Link to="/bidder">Bidder</Link>,
15
- },
16
- {
17
- key: '/auctioneer',
18
- icon: <CrownOutlined />,
19
- label: <Link to="/auctioneer">Auctioneer</Link>,
20
- }
21
- ];
22
-
23
- return (
24
- <Sider
25
- width={200}
26
- theme="light"
27
- style={{
28
- position: 'fixed',
29
- left: 0,
30
- top: 0,
31
- bottom: 0,
32
- background: '#ffffff'
33
- }}
34
- >
35
- <Menu
36
- mode="inline"
37
- selectedKeys={[location.pathname]}
38
- style={{
39
- height: '100%',
40
- borderRight: '1px solid #f0f0f0',
41
- background: '#ffffff'
42
- }}
43
- items={items}
44
- />
45
- </Sider>
46
- );
47
- };
@@ -1,144 +0,0 @@
1
- import { Card, Form, Input, Button, List, Typography, message } from 'antd';
2
- import { useState } from 'react';
3
- import { AleoWorker } from "../workers/AleoWorker";
4
-
5
- const aleoWorker = AleoWorker();
6
-
7
- export const AuctioneerPage = () => {
8
- const [receivedBids, setReceivedBids] = useState([]);
9
- const [loading, setLoading] = useState(false);
10
- const [resolveForm] = Form.useForm();
11
- const [finishForm] = Form.useForm();
12
-
13
- const layout = {
14
- labelCol: { span: 6 },
15
- wrapperCol: { span: 16 },
16
- };
17
-
18
- const handleResolveBids = async (values) => {
19
- try {
20
- setLoading(true);
21
- const result = await aleoWorker.resolveBids(values.bid1, values.bid2);
22
- message.success('Bids resolved successfully');
23
- resolveForm.resetFields();
24
- } catch (error) {
25
- console.error('Error resolving bids:', error);
26
- message.error('Failed to resolve bids');
27
- } finally {
28
- setLoading(false);
29
- }
30
- };
31
-
32
- const handleFinishAuction = async (values) => {
33
- try {
34
- setLoading(true);
35
- const result = await aleoWorker.finishAuction(values.winningBid);
36
- message.success('Auction finished successfully');
37
- finishForm.resetFields();
38
- } catch (error) {
39
- console.error('Error finishing auction:', error);
40
- message.error('Failed to finish auction');
41
- } finally {
42
- setLoading(false);
43
- }
44
- };
45
-
46
- return (
47
- <div style={{ padding: '24px', maxWidth: '800px', margin: '0 auto' }}>
48
- <Typography.Title level={2}>Auction Management</Typography.Title>
49
-
50
- <Card
51
- title={<Typography.Title level={4}>Current Auction Bids</Typography.Title>}
52
- style={{ marginBottom: '24px' }}
53
- >
54
- <List
55
- dataSource={receivedBids}
56
- renderItem={(bid) => (
57
- <List.Item>
58
- <Typography.Text>
59
- Bid ID: {bid.id} - Amount: {bid.amount}
60
- </Typography.Text>
61
- </List.Item>
62
- )}
63
- locale={{
64
- emptyText: <Typography.Text type="secondary">No bids received yet</Typography.Text>
65
- }}
66
- />
67
- </Card>
68
-
69
- <Card
70
- title={<Typography.Title level={4}>Compare and Resolve Bids</Typography.Title>}
71
- style={{ marginBottom: '24px' }}
72
- >
73
- <Form
74
- {...layout}
75
- form={resolveForm}
76
- onFinish={handleResolveBids}
77
- >
78
- <Form.Item
79
- label="First Bid Record"
80
- name="bid1"
81
- tooltip="Enter the record of the first bid to compare"
82
- rules={[{ required: true, message: 'Please enter the first bid record' }]}
83
- >
84
- <Input.TextArea
85
- placeholder="Enter the complete bid record"
86
- rows={3}
87
- />
88
- </Form.Item>
89
- <Form.Item
90
- label="Second Bid Record"
91
- name="bid2"
92
- tooltip="Enter the record of the second bid to compare"
93
- rules={[{ required: true, message: 'Please enter the second bid record' }]}
94
- >
95
- <Input.TextArea
96
- placeholder="Enter the complete bid record"
97
- rows={3}
98
- />
99
- </Form.Item>
100
- <Form.Item wrapperCol={{ offset: 6, span: 16 }}>
101
- <Button
102
- type="primary"
103
- htmlType="submit"
104
- loading={loading}
105
- >
106
- Compare and Resolve Bids
107
- </Button>
108
- </Form.Item>
109
- </Form>
110
- </Card>
111
-
112
- <Card
113
- title={<Typography.Title level={4}>Finalize Auction</Typography.Title>}
114
- >
115
- <Form
116
- {...layout}
117
- form={finishForm}
118
- onFinish={handleFinishAuction}
119
- >
120
- <Form.Item
121
- label="Winning Bid Record"
122
- name="winningBid"
123
- tooltip="Enter the record of the winning bid"
124
- rules={[{ required: true, message: 'Please enter the winning bid record' }]}
125
- >
126
- <Input.TextArea
127
- placeholder="Enter the complete winning bid record"
128
- rows={3}
129
- />
130
- </Form.Item>
131
- <Form.Item wrapperCol={{ offset: 6, span: 16 }}>
132
- <Button
133
- type="primary"
134
- htmlType="submit"
135
- loading={loading}
136
- >
137
- Finalize Auction with Winner
138
- </Button>
139
- </Form.Item>
140
- </Form>
141
- </Card>
142
- </div>
143
- );
144
- };
@@ -1,142 +0,0 @@
1
- import { Card, Form, Input, Button, List, Typography, message } from 'antd';
2
- import { useState } from 'react';
3
- import { AleoWorker } from "../workers/AleoWorker";
4
-
5
- const aleoWorker = AleoWorker();
6
-
7
- export const BidderPage = () => {
8
- const [account, setAccount] = useState(null);
9
- const [bids, setBids] = useState([]);
10
- const [loading, setLoading] = useState(false);
11
- const [bidForm] = Form.useForm();
12
-
13
- const layout = {
14
- labelCol: { span: 4 },
15
- wrapperCol: { span: 20 },
16
- };
17
-
18
- const handleSetAccount = async (value) => {
19
- try {
20
- setLoading(true);
21
- await aleoWorker.setAccount(value);
22
- setAccount(value);
23
- message.success('Account set successfully');
24
- } catch (error) {
25
- console.error('Error setting account:', error);
26
- message.error('Failed to set account');
27
- setAccount(null);
28
- } finally {
29
- setLoading(false);
30
- }
31
- };
32
-
33
- const handlePlaceBid = async (values) => {
34
- if (!account) {
35
- message.error('Please set your account first');
36
- return;
37
- }
38
-
39
- try {
40
- setLoading(true);
41
- const result = await aleoWorker.placeBid(values.amount, values.auctionId);
42
- message.success('Bid placed successfully');
43
- bidForm.resetFields();
44
-
45
- // Add the new bid to the list
46
- setBids(prevBids => [...prevBids, {
47
- auctionId: values.auctionId,
48
- amount: values.amount,
49
- id: result.id // Assuming the worker returns a bid ID
50
- }]);
51
- } catch (error) {
52
- console.error('Error placing bid:', error);
53
- message.error('Failed to place bid');
54
- } finally {
55
- setLoading(false);
56
- }
57
- };
58
-
59
- return (
60
- <div style={{ padding: '24px' }}>
61
- <Card
62
- title="Aleo Account"
63
- style={{ marginBottom: '24px' }}
64
- >
65
- <Form {...layout}>
66
- <Form.Item
67
- label="Private Key"
68
- required
69
- tooltip="Your Aleo private key is required to place bids"
70
- >
71
- <Input.Password
72
- placeholder="Enter your Aleo private key"
73
- onChange={(e) => handleSetAccount(e.target.value)}
74
- value={account}
75
- disabled={loading}
76
- />
77
- </Form.Item>
78
- {account && (
79
- <Form.Item wrapperCol={{ offset: 4 }}>
80
- <Typography.Text type="success">
81
- Account set ✓
82
- </Typography.Text>
83
- </Form.Item>
84
- )}
85
- </Form>
86
- </Card>
87
-
88
- <Card
89
- title="Place Bid"
90
- style={{ marginBottom: '24px' }}
91
- >
92
- <Form
93
- {...layout}
94
- form={bidForm}
95
- onFinish={handlePlaceBid}
96
- >
97
- <Form.Item
98
- label="Amount"
99
- name="amount"
100
- rules={[
101
- { required: true, message: 'Please enter bid amount' },
102
- { pattern: /^\d+$/, message: 'Please enter a valid number' }
103
- ]}
104
- >
105
- <Input placeholder="Enter bid amount" disabled={!account || loading} />
106
- </Form.Item>
107
- <Form.Item
108
- label="Auction ID"
109
- name="auctionId"
110
- rules={[{ required: true, message: 'Please enter auction ID' }]}
111
- >
112
- <Input placeholder="Enter auction ID" disabled={!account || loading} />
113
- </Form.Item>
114
- <Form.Item wrapperCol={{ offset: 4 }}>
115
- <Button
116
- type="primary"
117
- htmlType="submit"
118
- loading={loading}
119
- disabled={!account}
120
- >
121
- Submit Bid
122
- </Button>
123
- </Form.Item>
124
- </Form>
125
- </Card>
126
-
127
- <Card title="Open Bids">
128
- <List
129
- dataSource={bids}
130
- renderItem={(bid) => (
131
- <List.Item>
132
- <Typography.Text>
133
- Auction ID: {bid.auctionId} - Amount: {bid.amount}
134
- </Typography.Text>
135
- </List.Item>
136
- )}
137
- locale={{ emptyText: 'No bids placed yet' }}
138
- />
139
- </Card>
140
- </div>
141
- );
142
- };