Skip to content
Open
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
23 changes: 23 additions & 0 deletions app/components/BalanceCell/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
*
* BalanceCell
*
*/

import React from 'react';

import { FormattedMessage } from 'react-intl';
import messages from './messages';
import styles from './styles.css';

class BalanceCell extends React.Component { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<div className={styles.balanceCell}>
{ this.props.name + ": " + this.props.balance }
</div>
);
}
}

export default BalanceCell;
13 changes: 13 additions & 0 deletions app/components/BalanceCell/messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* BalanceCell Messages
*
* This contains all the text for the BalanceCell component.
*/
import { defineMessages } from 'react-intl';

export default defineMessages({
header: {
id: 'app.components.BalanceCell.header',
defaultMessage: 'This is the BalanceCell component !',
},
});
3 changes: 3 additions & 0 deletions app/components/BalanceCell/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.balanceCell { /* stylelint-disable */

}
11 changes: 11 additions & 0 deletions app/components/BalanceCell/tests/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// import BalanceCell from '../index';

import expect from 'expect';
// import { shallow } from 'enzyme';
// import React from 'react';

describe('<BalanceCell />', () => {
// it('Expect to have unit tests specified', () => {
// expect(true).toEqual(false);
// });
});
5 changes: 5 additions & 0 deletions app/components/SideNav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ const buttons = [
id: 'investments',
route: '/investments',
text: messages.investments
},
{
id: 'transactions',
route: '/transactions',
text: messages.transactions
}
];

Expand Down
4 changes: 4 additions & 0 deletions app/components/SideNav/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ export default defineMessages({
investments: {
id: 'app.components.SideNav.investments',
defaultMessage: 'Investments',
},
transactions: {
id: 'app.components.SideNav.transactions',
defaultMessage: 'Transactions',
}
});
50 changes: 50 additions & 0 deletions app/components/TokenForm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
*
* TokenForm
*
*/

import React from 'react';

import { FormattedMessage } from 'react-intl';
import messages from './messages';
import styles from './styles.css';
import Form from "react-jsonschema-form";

const schema = {
title: "Fill token details",
type: "object",
required: ["Symbol", "ContractAddress", "Decimal"],
properties: {
Symbol: {type: "string", title: "Symbol: ", default: ""},
ContractAddress: {type: "string", title: "Contract Address: ", default: "0x"},
Decimal: {type: "string", title: "Decimal: ", default: "0"},
}
};

class TokenForm extends React.Component { // eslint-disable-line react/prefer-stateless-function
constructor(props) {
super(props);
}

render() {
return (
<Form schema={schema}
onSubmit={this.onFormSubmit.bind(this)}
onError={this.onFormError} />
);
}

onFormSubmit(formData) {
this.props.onSubmited(formData.formData.Symbol,
formData.formData.ContractAddress,
formData.formData.Decimal);
}

onFormError(errors) {
console.log("error:");
console.log(errors);
}
}

export default TokenForm;
13 changes: 13 additions & 0 deletions app/components/TokenForm/messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* TokenForm Messages
*
* This contains all the text for the TokenForm component.
*/
import { defineMessages } from 'react-intl';

export default defineMessages({
header: {
id: 'app.components.TokenForm.header',
defaultMessage: 'This is the TokenForm component !',
},
});
3 changes: 3 additions & 0 deletions app/components/TokenForm/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.tokenForm { /* stylelint-disable */

}
11 changes: 11 additions & 0 deletions app/components/TokenForm/tests/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// import TokenForm from '../index';

import expect from 'expect';
// import { shallow } from 'enzyme';
// import React from 'react';

// describe('<TokenForm />', () => {
// it('Expect to have unit tests specified', () => {
// expect(true).toEqual(false);
// });
// });
15 changes: 15 additions & 0 deletions app/containers/BalanceContainer/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
*
* BalanceContainer actions
*
*/

import {
DEFAULT_ACTION,
} from './constants';

export function defaultAction() {
return {
type: DEFAULT_ACTION,
};
}
7 changes: 7 additions & 0 deletions app/containers/BalanceContainer/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
*
* BalanceContainer constants
*
*/

export const DEFAULT_ACTION = 'app/BalanceContainer/DEFAULT_ACTION';
82 changes: 82 additions & 0 deletions app/containers/BalanceContainer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
*
* BalanceContainer
*
*/

import React from 'react';
import { connect } from 'react-redux';
import Helmet from 'react-helmet';
import selectBalanceContainer from './selectors';
import { FormattedMessage } from 'react-intl';
import messages from './messages';
import styles from './styles.css';
import BalanceCell from 'components/BalanceCell';
import BigNumber from 'bignumber.js';
import { AjaxUtils } from '../../utils/AjaxUtils'

export class BalanceContainer extends React.Component { // eslint-disable-line react/prefer-stateless-function
constructor(props) {
super(props);

this.state = {
balance: 0,
name: ""
};
}

componentDidMount() {
if (!this.props.token) {
return;
}

this.setState({name: this.props.token.symbol});

let data = AjaxUtils.queryParams(this.props.token.balanceCallData());
let serverUrl = "https://rpc.myetherwallet.com:8443/api.mew";
let parentObj = this;

fetch(serverUrl, {
method: 'post',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: data
})
.then((response) => response.json())
.then((data) => {
console.log(data);
if (!data.error) {
if (parentObj.props.token.symbol == "ETH") {
parentObj.props.token.balance = data.data.balance;
var _balance = parentObj.props.token.weiBalance();
this.setState({balance: _balance});
}
else {
var decimal = parentObj.props.token.decimal;
var _balance = new BigNumber(data.data).div(new BigNumber(10).pow(decimal));
this.setState({balance: _balance});
}
}
})
.catch((error) => {
console.error(error);
});
}

render() {
return (
<BalanceCell balance={ this.state.balance } name={ this.state.name }/>
);
}
}

const mapStateToProps = selectBalanceContainer();

function mapDispatchToProps(dispatch) {
return {
dispatch,
};
}

export default connect(mapStateToProps, mapDispatchToProps)(BalanceContainer);
13 changes: 13 additions & 0 deletions app/containers/BalanceContainer/messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* BalanceContainer Messages
*
* This contains all the text for the BalanceContainer component.
*/
import { defineMessages } from 'react-intl';

export default defineMessages({
header: {
id: 'app.containers.BalanceContainer.header',
defaultMessage: 'This is BalanceContainer container !',
},
});
23 changes: 23 additions & 0 deletions app/containers/BalanceContainer/reducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
*
* BalanceContainer reducer
*
*/

import { fromJS } from 'immutable';
import {
DEFAULT_ACTION,
} from './constants';

const initialState = fromJS({});

function balanceContainerReducer(state = initialState, action) {
switch (action.type) {
case DEFAULT_ACTION:
return state;
default:
return state;
}
}

export default balanceContainerReducer;
11 changes: 11 additions & 0 deletions app/containers/BalanceContainer/sagas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// import { take, call, put, select } from 'redux-saga/effects';

// Individual exports for testing
export function* defaultSaga() {
return;
}

// All sagas to be loaded
export default [
defaultSaga,
];
25 changes: 25 additions & 0 deletions app/containers/BalanceContainer/selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { createSelector } from 'reselect';

/**
* Direct selector to the balanceContainer state domain
*/
const selectBalanceContainerDomain = () => (state) => state.get('balanceContainer');

/**
* Other specific selectors
*/


/**
* Default selector used by BalanceContainer
*/

const selectBalanceContainer = () => createSelector(
selectBalanceContainerDomain(),
(substate) => substate.toJS()
);

export default selectBalanceContainer;
export {
selectBalanceContainerDomain,
};
3 changes: 3 additions & 0 deletions app/containers/BalanceContainer/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.balanceContainer { /* stylelint-disable */

}
18 changes: 18 additions & 0 deletions app/containers/BalanceContainer/tests/actions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import expect from 'expect';
import {
defaultAction,
} from '../actions';
import {
DEFAULT_ACTION,
} from '../constants';

describe('BalanceContainer actions', () => {
describe('Default Action', () => {
it('has a type of DEFAULT_ACTION', () => {
const expected = {
type: DEFAULT_ACTION,
};
expect(defaultAction()).toEqual(expected);
});
});
});
11 changes: 11 additions & 0 deletions app/containers/BalanceContainer/tests/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// import BalanceContainer from '../index';

import expect from 'expect';
// import { shallow } from 'enzyme';
// import React from 'react';

describe('<BalanceContainer />', () => {
it('Expect to have unit tests specified', () => {
expect(true).toEqual(false);
});
});
9 changes: 9 additions & 0 deletions app/containers/BalanceContainer/tests/reducer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import expect from 'expect';
import balanceContainerReducer from '../reducer';
import { fromJS } from 'immutable';

describe('balanceContainerReducer', () => {
it('returns the initial state', () => {
expect(balanceContainerReducer(undefined, {})).toEqual(fromJS({}));
});
});
Loading