From fe42d505d1f11e77f182890510d9ce9c405dc251 Mon Sep 17 00:00:00 2001 From: Fahd Date: Wed, 9 Oct 2019 16:50:47 -0400 Subject: [PATCH 1/6] add account page with list of tokens wallet owns --- .../polymath-issuer/src/actions/account.js | 17 +++++++++ .../src/pages/account/index.js | 35 +++++++++++++++++++ .../polymath-issuer/src/pages/home/index.js | 2 +- .../polymath-issuer/src/reducers/account.js | 16 +++++++++ packages/polymath-issuer/src/redux/reducer.js | 2 ++ packages/polymath-issuer/src/routes.js | 6 ++++ .../src/contracts/SecurityTokenRegistry.js | 10 ++++++ 7 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 packages/polymath-issuer/src/actions/account.js create mode 100644 packages/polymath-issuer/src/pages/account/index.js create mode 100644 packages/polymath-issuer/src/reducers/account.js diff --git a/packages/polymath-issuer/src/actions/account.js b/packages/polymath-issuer/src/actions/account.js new file mode 100644 index 000000000..2bc2b578d --- /dev/null +++ b/packages/polymath-issuer/src/actions/account.js @@ -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)); +}; diff --git a/packages/polymath-issuer/src/pages/account/index.js b/packages/polymath-issuer/src/pages/account/index.js new file mode 100644 index 000000000..9ec4ba784 --- /dev/null +++ b/packages/polymath-issuer/src/pages/account/index.js @@ -0,0 +1,35 @@ +import React, { Component } from 'react'; +import { Link } from 'react-router-dom'; +import { PageCentered, Button, Toaster, notify } from '@polymathnetwork/ui'; +import { connect } from 'react-redux'; +import { fetchTickerList } from '../../actions/account'; + +class HomePage extends Component { + componentDidMount() { + this.props.fetchTickerList(); + } + + render() { + const { tickers } = this.props; + return ( + + {tickers.map(ticker => { + return {ticker}; + })} + + ); + } +} + +const mapStateToProps = state => ({ + tickers: state.account.tickers, +}); + +const mapDispatchToProps = { + fetchTickerList, +}; + +export default connect( + mapStateToProps, + mapDispatchToProps +)(HomePage); diff --git a/packages/polymath-issuer/src/pages/home/index.js b/packages/polymath-issuer/src/pages/home/index.js index 804ea739c..d61a30a11 100644 --- a/packages/polymath-issuer/src/pages/home/index.js +++ b/packages/polymath-issuer/src/pages/home/index.js @@ -24,7 +24,7 @@ class HomePage extends Component {

- + diff --git a/packages/polymath-issuer/src/reducers/account.js b/packages/polymath-issuer/src/reducers/account.js new file mode 100644 index 000000000..a13dcd0b3 --- /dev/null +++ b/packages/polymath-issuer/src/reducers/account.js @@ -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; + } +}; diff --git a/packages/polymath-issuer/src/redux/reducer.js b/packages/polymath-issuer/src/redux/reducer.js index 6d3794ab1..ed9b384b1 100644 --- a/packages/polymath-issuer/src/redux/reducer.js +++ b/packages/polymath-issuer/src/redux/reducer.js @@ -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'; @@ -47,6 +48,7 @@ export default history => app, session, restrictions, + account, router: connectRouter(history), }); diff --git a/packages/polymath-issuer/src/routes.js b/packages/polymath-issuer/src/routes.js index 049ef0874..f4caa19b2 100644 --- a/packages/polymath-issuer/src/routes.js +++ b/packages/polymath-issuer/src/routes.js @@ -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, diff --git a/packages/polymath-js/src/contracts/SecurityTokenRegistry.js b/packages/polymath-js/src/contracts/SecurityTokenRegistry.js index bbf83d014..693b8a2c0 100644 --- a/packages/polymath-js/src/contracts/SecurityTokenRegistry.js +++ b/packages/polymath-js/src/contracts/SecurityTokenRegistry.js @@ -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 { const fee = await this.registrationFee(); const allowance = await PolyToken.allowance(this.account, this.address); From 27aede73a25348e93b0904351d3aab59e5baca6c Mon Sep 17 00:00:00 2001 From: Fahd Date: Thu, 10 Oct 2019 09:03:16 -0400 Subject: [PATCH 2/6] add create new token link --- packages/polymath-issuer/src/pages/account/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/polymath-issuer/src/pages/account/index.js b/packages/polymath-issuer/src/pages/account/index.js index 9ec4ba784..76bc0f1ab 100644 --- a/packages/polymath-issuer/src/pages/account/index.js +++ b/packages/polymath-issuer/src/pages/account/index.js @@ -16,6 +16,7 @@ class HomePage extends Component { {tickers.map(ticker => { return {ticker}; })} + Create New Token ); } From e9ba566caf7b97ce22a6d7b3ab2426f1dacebe91 Mon Sep 17 00:00:00 2001 From: Fahd Date: Wed, 16 Oct 2019 10:29:50 -0400 Subject: [PATCH 3/6] add ticker card --- .../pages/account/components/TickerCard.js | 36 +++++++++++++++++++ .../src/pages/account/index.js | 30 ++++++++++++---- .../src/pages/token/style.scss | 4 +++ 3 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 packages/polymath-issuer/src/pages/account/components/TickerCard.js diff --git a/packages/polymath-issuer/src/pages/account/components/TickerCard.js b/packages/polymath-issuer/src/pages/account/components/TickerCard.js new file mode 100644 index 000000000..223fe1ed1 --- /dev/null +++ b/packages/polymath-issuer/src/pages/account/components/TickerCard.js @@ -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 ( +

+
+
+
+ + +
+
+
+ + + +
+
+ ); + } +} diff --git a/packages/polymath-issuer/src/pages/account/index.js b/packages/polymath-issuer/src/pages/account/index.js index 76bc0f1ab..2801687db 100644 --- a/packages/polymath-issuer/src/pages/account/index.js +++ b/packages/polymath-issuer/src/pages/account/index.js @@ -1,8 +1,15 @@ import React, { Component } from 'react'; import { Link } from 'react-router-dom'; -import { PageCentered, Button, Toaster, notify } from '@polymathnetwork/ui'; +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 { componentDidMount() { @@ -12,11 +19,18 @@ class HomePage extends Component { render() { const { tickers } = this.props; return ( - - {tickers.map(ticker => { - return {ticker}; - })} - Create New Token + + + + {tickers.map(ticker => { + return ( + + + + ); + })} + + ); } @@ -34,3 +48,7 @@ export default connect( mapStateToProps, mapDispatchToProps )(HomePage); +// return {ticker}; +{ + /* Create New Token */ +} diff --git a/packages/polymath-issuer/src/pages/token/style.scss b/packages/polymath-issuer/src/pages/token/style.scss index b279896e9..44957cc7b 100644 --- a/packages/polymath-issuer/src/pages/token/style.scss +++ b/packages/polymath-issuer/src/pages/token/style.scss @@ -13,6 +13,10 @@ margin-top: 13px; } +.export-tokens-list-btn { + width: 100%; +} + .max-holders-count { .bx--form-item { float: left; From 2f57622239620a8fd2906e41094f915c1ab67712 Mon Sep 17 00:00:00 2001 From: Fahd Date: Mon, 2 Dec 2019 09:51:21 -0500 Subject: [PATCH 4/6] remove comments --- packages/polymath-issuer/src/pages/account/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/polymath-issuer/src/pages/account/index.js b/packages/polymath-issuer/src/pages/account/index.js index 2801687db..579fc33dc 100644 --- a/packages/polymath-issuer/src/pages/account/index.js +++ b/packages/polymath-issuer/src/pages/account/index.js @@ -48,7 +48,3 @@ export default connect( mapStateToProps, mapDispatchToProps )(HomePage); -// return {ticker}; -{ - /* Create New Token */ -} From 55eeac98ff497f25c27e3b61c21af1bbb0111013 Mon Sep 17 00:00:00 2001 From: Fahd Date: Mon, 2 Dec 2019 11:57:36 -0500 Subject: [PATCH 5/6] add logic for when a user has no tokens --- .../polymath-issuer/src/pages/account/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/polymath-issuer/src/pages/account/index.js b/packages/polymath-issuer/src/pages/account/index.js index 579fc33dc..3cdaa7027 100644 --- a/packages/polymath-issuer/src/pages/account/index.js +++ b/packages/polymath-issuer/src/pages/account/index.js @@ -12,8 +12,11 @@ import { fetchTickerList } from '../../actions/account'; import TickerCard from './components/TickerCard'; class HomePage extends Component { - componentDidMount() { - this.props.fetchTickerList(); + async componentDidMount() { + await this.props.fetchTickerList(); + if (this.props.tickers.length === 0) { + this.props.history.push('/ticker'); + } } render() { @@ -21,6 +24,15 @@ class HomePage extends Component { return ( + +

+ + + +

+
{tickers.map(ticker => { return ( From 66c377f08cd336ab3d25d3f570b175fd67d37f08 Mon Sep 17 00:00:00 2001 From: Fahd Date: Tue, 3 Dec 2019 14:16:09 -0500 Subject: [PATCH 6/6] fix copy for buttons --- packages/polymath-issuer/src/pages/account/index.js | 2 +- packages/polymath-issuer/src/pages/home/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/polymath-issuer/src/pages/account/index.js b/packages/polymath-issuer/src/pages/account/index.js index 3cdaa7027..0ab29c0b9 100644 --- a/packages/polymath-issuer/src/pages/account/index.js +++ b/packages/polymath-issuer/src/pages/account/index.js @@ -28,7 +28,7 @@ class HomePage extends Component {

diff --git a/packages/polymath-issuer/src/pages/home/index.js b/packages/polymath-issuer/src/pages/home/index.js index d61a30a11..e8489855a 100644 --- a/packages/polymath-issuer/src/pages/home/index.js +++ b/packages/polymath-issuer/src/pages/home/index.js @@ -26,7 +26,7 @@ class HomePage extends Component {