Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
3esmit committed Oct 11, 2018
2 parents 51a7010 + 2330ac9 commit e746f5c
Show file tree
Hide file tree
Showing 23 changed files with 544 additions and 527 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ package-lock.json
.vs/
bin/
.idea/
*.iml
25 changes: 10 additions & 15 deletions app/actions/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ import { actions as accountActions } from '../reducers/accounts'
import { isNil } from 'lodash'

const { receiveAccounts, receiveStatusContactCode } = accountActions
const CONTACT_CODE = 'CONTACT_CODE'
const STATUS_API_REQUEST = 'STATUS_API_REQUEST'
const hasContactCode = () => !isNil(STATUS_API) && !isNil(STATUS_API[CONTACT_CODE])
const statusApiSuccess = event => event.detail.permissions[0] === CONTACT_CODE
const getContactCode = event => event.detail.data[CONTACT_CODE]

export const fetchAndDispatchAccountsWithBalances = (web3, dispatch) => {
web3.eth.getAccounts((err, addresses) => {
Expand All @@ -29,15 +24,15 @@ export const fetchAndDispatchAccountsWithBalances = (web3, dispatch) => {
})
}
export const checkAndDispatchStatusContactCode = dispatch => {
window.addEventListener('statusapi', function (event) {
if (statusApiSuccess(event)) dispatch(receiveStatusContactCode(getContactCode(event)))
});

setTimeout(
() => { window.postMessage({ type: STATUS_API_REQUEST, permissions: ["CONTACT_CODE", "CONTACTS"] }, '*') },
1000
)
}
window.web3.currentProvider.status
.getContactCode()
.then(data => {
dispatch(receiveStatusContactCode(data));
})
.catch(err => {
console.warn('Error:', err);
})
};

export const fetchAndDispatchSNTAllowance = dispatch => {
const { methods: { allowance } } = TestToken;
Expand All @@ -48,4 +43,4 @@ export const fetchAndDispatchSNTAllowance = dispatch => {
.then(allowance => {
dispatch(receiveSntAllowance(allowance))
})
}
};
44 changes: 44 additions & 0 deletions app/components/ens/DisplayBox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';
import { connect } from 'react-redux';
import { YOUR_CONTACT_CODE } from './constants';
import { checkAndDispatchStatusContactCode } from '../../actions/accounts';
import styled from "styled-components";

const DisplayLabel = styled.div`
font-size: 14px;
color: #939BA1;
margin: 0 1em;
`;

const DisplayBox = styled.div`
border: 1px solid #EEF2F5;
border-radius: 8px;
margin: 7px 12px 14px 12px;
display: flex;
flex-direction: column;
justifyContent: space-around;
min-height: 4em;
word-wrap: break-word;
`;

const WrappedDisplayBox = ({displayType, pubKey, getStatusContactCode}) => (
<div>
<DisplayLabel>
{displayType}
</DisplayLabel>
<DisplayBox onClick={() => getStatusContactCode(displayType, pubKey)}>
<div style={{margin: '16px'}}>
<Typography type='body1'>{pubKey}</Typography>
</div>
</DisplayBox>
</div>
);

const mapDispatchToDisplayBoxProps = dispatch => ({
getStatusContactCode(displayType, pubKey) {
if (displayType === YOUR_CONTACT_CODE && !pubKey) checkAndDispatchStatusContactCode(dispatch);
},
});

export default connect(null, mapDispatchToDisplayBoxProps)(WrappedDisplayBox);
6 changes: 3 additions & 3 deletions app/components/ens/EditOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SimpleDialog extends React.Component {
};

render() {
const { classes, onClose, selectedValue, ...other } = this.props;
const { classes, onClose, selectedValue, canBeReleased, ...other } = this.props;

return (
<Dialog classes={{paper: classes.paper,}} onClose={this.handleClose} fullWidth paperFullWidth style={{alignItems: 'flex-end'}} aria-labelledby="simple-dialog-title" {...other}>
Expand All @@ -49,12 +49,12 @@ class SimpleDialog extends React.Component {
</ListItemIcon>
<ListItemText primary="Edit Contact Code" />
</ListItem>
<ListItem button onClick={() => this.handleListItemClick('release')}>
{canBeReleased && <ListItem button onClick={() => this.handleListItemClick('release')}>
<ListItemIcon>
<DeleteOutline />
</ListItemIcon>
<ListItemText primary="Release Name" />
</ListItem>
</ListItem>}
</List>
</Dialog>
);
Expand Down
2 changes: 2 additions & 0 deletions app/components/ens/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const YOUR_CONTACT_CODE = 'Your contact code';
export const YOUR_WALLET_ADDRESS = 'Your wallet address';
Loading

0 comments on commit e746f5c

Please sign in to comment.