Skip to content

Commit 48578c0

Browse files
authored
Merge pull request #673 from PolymathNetwork/feat/account-page
Feat/account page
2 parents 98090fa + 66c377f commit 48578c0

9 files changed

Lines changed: 154 additions & 1 deletion

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { SecurityTokenRegistry } from '@polymathnetwork/js';
2+
3+
export const TICKER_LIST = 'account/TICKER_LIST';
4+
export const getTickerList = tickers => ({
5+
type: TICKER_LIST,
6+
tickers,
7+
});
8+
9+
export const fetchTickerList = () => async (
10+
dispatch: Function,
11+
getState: GetState
12+
) => {
13+
const str = await SecurityTokenRegistry.create();
14+
const walletAddress = getState().session.wallet.address;
15+
const newTokens = await str.getTickersByOwner(walletAddress);
16+
dispatch(getTickerList(newTokens));
17+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React, { Component } from 'react';
2+
import { PageCentered, Button, Toaster, notify } from '@polymathnetwork/ui';
3+
import { Link } from 'react-router-dom';
4+
5+
export default class TickerCard extends Component {
6+
render() {
7+
const { ticker } = this.props;
8+
return (
9+
<div className="token-symbol-wrapper">
10+
<div className="pui-page-box">
11+
<div className="ticker-field">
12+
<div className="bx--form-item">
13+
<label htmlFor="ticker" className="bx--label">
14+
Token Symbol
15+
</label>
16+
<input
17+
type="text"
18+
name="ticker"
19+
value={ticker}
20+
id="ticker"
21+
readOnly
22+
className="bx--text-input bx--text__input"
23+
/>
24+
</div>
25+
</div>
26+
<br />
27+
<Link to={`/dashboard/${ticker}`}>
28+
<Button kind="secondary" className="export-tokens-list-btn">
29+
Open Dashboard
30+
</Button>
31+
</Link>
32+
</div>
33+
</div>
34+
);
35+
}
36+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React, { Component } from 'react';
2+
import { Link } from 'react-router-dom';
3+
import {
4+
PageCentered,
5+
Button,
6+
Toaster,
7+
notify,
8+
Grid,
9+
} from '@polymathnetwork/ui';
10+
import { connect } from 'react-redux';
11+
import { fetchTickerList } from '../../actions/account';
12+
import TickerCard from './components/TickerCard';
13+
14+
class HomePage extends Component {
15+
async componentDidMount() {
16+
await this.props.fetchTickerList();
17+
if (this.props.tickers.length === 0) {
18+
this.props.history.push('/ticker');
19+
}
20+
}
21+
22+
render() {
23+
const { tickers } = this.props;
24+
return (
25+
<PageCentered>
26+
<Grid>
27+
<Grid.Row>
28+
<p>
29+
<Link to="/ticker">
30+
<Button id="create-token-btn" icon="arrow--right">
31+
Continue to configure your security token
32+
</Button>
33+
</Link>
34+
</p>
35+
</Grid.Row>
36+
<Grid.Row>
37+
{tickers.map(ticker => {
38+
return (
39+
<Grid.Col gridSpan={4}>
40+
<TickerCard ticker={ticker} />
41+
</Grid.Col>
42+
);
43+
})}
44+
</Grid.Row>
45+
</Grid>
46+
</PageCentered>
47+
);
48+
}
49+
}
50+
51+
const mapStateToProps = state => ({
52+
tickers: state.account.tickers,
53+
});
54+
55+
const mapDispatchToProps = {
56+
fetchTickerList,
57+
};
58+
59+
export default connect(
60+
mapStateToProps,
61+
mapDispatchToProps
62+
)(HomePage);

packages/polymath-issuer/src/pages/home/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class HomePage extends Component {
2424
<br />
2525
<br />
2626
<p>
27-
<Link to="/ticker">
27+
<Link to="/account">
2828
<Button id="create-token-btn" icon="arrow--right">
2929
Configure your security token
3030
</Button>

packages/polymath-issuer/src/pages/token/style.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
margin-top: 13px;
1414
}
1515

16+
.export-tokens-list-btn {
17+
width: 100%;
18+
}
19+
1620
.max-holders-count {
1721
.bx--form-item {
1822
float: left;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as a from '../actions/account';
2+
3+
const defaultState = {
4+
tickers: [],
5+
};
6+
7+
export default (state = defaultState, action) => {
8+
switch (action.type) {
9+
case a.TICKER_LIST:
10+
return {
11+
tickers: [...action.tickers],
12+
};
13+
default:
14+
return state;
15+
}
16+
};

packages/polymath-issuer/src/redux/reducer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import whitelist from '../reducers/compliance';
2121
import stoModules from '../reducers/stoModules';
2222
import ui from '../reducers/ui';
2323
import restrictions from '../reducers/restrictions';
24+
import account from '../reducers/account';
2425

2526
import type { ProvidersState } from '../reducers/providers';
2627
import type { TokenState } from '../reducers/token';
@@ -47,6 +48,7 @@ export default history =>
4748
app,
4849
session,
4950
restrictions,
51+
account,
5052
router: connectRouter(history),
5153
});
5254

packages/polymath-issuer/src/routes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ import STOPage from './pages/sto/STOPage';
1919
import DividendsPage from './pages/dividends/DividendsPage';
2020
import DividendsWizardPage from './pages/dividends/DividendsWizardPage';
2121
import DividendDetailsPage from './pages/dividends/DividendDetailsPage';
22+
import AccountPage from './pages/account';
2223

2324
export default [
2425
{
2526
component: App,
2627
routes: [
28+
{
29+
path: '/account',
30+
component: AccountPage,
31+
exact: true,
32+
},
2733
{
2834
path: '/ticker',
2935
component: TickerPage,

packages/polymath-js/src/contracts/SecurityTokenRegistry.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,16 @@ class SecurityTokenRegistry extends Contract {
289289
return tokens;
290290
}
291291

292+
async getTickersByOwner(owner) {
293+
const tickers = this._methods.getTickersByOwner(owner).call();
294+
const convertedTickers = tickers.reduce((pV, cV) => {
295+
let ticker = this._toAscii(cV);
296+
pV.push(ticker);
297+
return pV;
298+
}, []);
299+
return convertedTickers;
300+
}
301+
292302
async registerTicker(details: SymbolDetails): Promise<Web3Receipt> {
293303
const fee = await this.registrationFee();
294304
const allowance = await PolyToken.allowance(this.account, this.address);

0 commit comments

Comments
 (0)