Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/polymath-issuer/src/actions/account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { SecurityTokenRegistry } from '@polymathnetwork/js';

export const TICKER_LIST = 'account/TICKER_LIST';
export const getTickerList = tickers => ({
type: TICKER_LIST,
tickers,
});

export const fetchTickerList = () => async (
dispatch: Function,
getState: GetState
) => {
const str = await SecurityTokenRegistry.create();
const walletAddress = getState().session.wallet.address;
const newTokens = await str.getTickersByOwner(walletAddress);
dispatch(getTickerList(newTokens));
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { Component } from 'react';
import { PageCentered, Button, Toaster, notify } from '@polymathnetwork/ui';
import { Link } from 'react-router-dom';

export default class TickerCard extends Component {
render() {
const { ticker } = this.props;
return (
<div className="token-symbol-wrapper">
<div className="pui-page-box">
<div className="ticker-field">
<div className="bx--form-item">
<label htmlFor="ticker" className="bx--label">
Token Symbol
</label>
<input
type="text"
name="ticker"
value={ticker}
id="ticker"
readOnly
className="bx--text-input bx--text__input"
/>
</div>
</div>
<br />
<Link to={`/dashboard/${ticker}`}>
<Button kind="secondary" className="export-tokens-list-btn">
Open Dashboard
</Button>
</Link>
</div>
</div>
);
}
}
62 changes: 62 additions & 0 deletions packages/polymath-issuer/src/pages/account/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import {
PageCentered,
Button,
Toaster,
notify,
Grid,
} from '@polymathnetwork/ui';
import { connect } from 'react-redux';
import { fetchTickerList } from '../../actions/account';
import TickerCard from './components/TickerCard';

class HomePage extends Component {
async componentDidMount() {
await this.props.fetchTickerList();
if (this.props.tickers.length === 0) {
this.props.history.push('/ticker');
}
}

render() {
const { tickers } = this.props;
return (
<PageCentered>
<Grid>
<Grid.Row>
<p>
<Link to="/ticker">
<Button id="create-token-btn" icon="arrow--right">
Continue to configure your security token
</Button>
</Link>
</p>
</Grid.Row>
<Grid.Row>
{tickers.map(ticker => {
return (
<Grid.Col gridSpan={4}>
<TickerCard ticker={ticker} />
</Grid.Col>
);
})}
</Grid.Row>
</Grid>
</PageCentered>
);
}
}

const mapStateToProps = state => ({
tickers: state.account.tickers,
});

const mapDispatchToProps = {
fetchTickerList,
};

export default connect(
mapStateToProps,
mapDispatchToProps
)(HomePage);
4 changes: 2 additions & 2 deletions packages/polymath-issuer/src/pages/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class HomePage extends Component {
<br />
<br />
<p>
<Link to="/ticker">
<Link to="/account">
<Button id="create-token-btn" icon="arrow--right">
Create your security token
Configure your security token
</Button>
</Link>
</p>
Expand Down
4 changes: 4 additions & 0 deletions packages/polymath-issuer/src/pages/token/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
margin-top: 13px;
}

.export-tokens-list-btn {
width: 100%;
}

.max-holders-count {
.bx--form-item {
float: left;
Expand Down
16 changes: 16 additions & 0 deletions packages/polymath-issuer/src/reducers/account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as a from '../actions/account';

const defaultState = {
tickers: [],
};

export default (state = defaultState, action) => {
switch (action.type) {
case a.TICKER_LIST:
return {
tickers: [...action.tickers],
};
default:
return state;
}
};
2 changes: 2 additions & 0 deletions packages/polymath-issuer/src/redux/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import whitelist from '../reducers/compliance';
import stoModules from '../reducers/stoModules';
import ui from '../reducers/ui';
import restrictions from '../reducers/restrictions';
import account from '../reducers/account';

import type { ProvidersState } from '../reducers/providers';
import type { TokenState } from '../reducers/token';
Expand All @@ -47,6 +48,7 @@ export default history =>
app,
session,
restrictions,
account,
router: connectRouter(history),
});

Expand Down
6 changes: 6 additions & 0 deletions packages/polymath-issuer/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ import STOPage from './pages/sto/STOPage';
import DividendsPage from './pages/dividends/DividendsPage';
import DividendsWizardPage from './pages/dividends/DividendsWizardPage';
import DividendDetailsPage from './pages/dividends/DividendDetailsPage';
import AccountPage from './pages/account';

export default [
{
component: App,
routes: [
{
path: '/account',
component: AccountPage,
exact: true,
},
{
path: '/ticker',
component: TickerPage,
Expand Down
10 changes: 10 additions & 0 deletions packages/polymath-js/src/contracts/SecurityTokenRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,16 @@ class SecurityTokenRegistry extends Contract {
return tokens;
}

async getTickersByOwner(owner) {
const tickers = this._methods.getTickersByOwner(owner).call();
const convertedTickers = tickers.reduce((pV, cV) => {
let ticker = this._toAscii(cV);
pV.push(ticker);
return pV;
}, []);
return convertedTickers;
}

async registerTicker(details: SymbolDetails): Promise<Web3Receipt> {
const fee = await this.registrationFee();
const allowance = await PolyToken.allowance(this.account, this.address);
Expand Down