Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private network support #49

Merged
merged 11 commits into from
Jan 21, 2018
Merged

Private network support #49

merged 11 commits into from
Jan 21, 2018

Conversation

slipo
Copy link
Collaborator

@slipo slipo commented Jan 15, 2018

Adds configuration panes to add/delete private networks.

Can be used by developers running NeonDB + a private NEO blockchain.

This PR also adds the CoZ Testnet as a third default option.

To test, if you don't have a private network set up you can add a copy of testnet with URL:
http://testnet-api.wallet.cityofzion.io

Here's what the add page looks like:
screen shot 2018-01-15 at 3 36 16 pm

Some things to test:

  • Adding network
  • Deleting network
  • Getting balance and other per-network functionality of the extension (except test invoke which I think needs work outside the scope of this PR)
  • The Send Invoke popup window.

@austinhinderer
Copy link

I noticed that there is a generated sass cache file being committed here. Should we be avoiding committing generated files other than the package lock files?

@@ -6,7 +6,12 @@ import NetworkSwitcher from '../../src/app/components/NetworkSwitcher'

const setup = () => {
const props = {
network: { name: 'MainNet' },
networkId: 0,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the difference between the networkId and the networks map below it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

network/networkId is the currently selected network. Networks is a listing of all available networks.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right but I'm wondering how they map to each other, or if they do at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state.network.id is the id for accessing the config object states.config.networks. you think we should just add it to state.config.currentNetworkId or something like that?

@@ -0,0 +1,2 @@
import AddCustomNetwork from './AddCustomNetwork'
export default AddCustomNetwork

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be condensed to export { default as AddCustomNetwork } from './AddCustomNetwork'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

}
})

let content = (<div>You have no custom networks defined</div>)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be condensed a bit.

const content = networkRows.length
  ? <div>{ networkRows }</div>
  : <div>You have no custom networks defined</div>

or even

const content = networkRows.length ? { networkRows } : 'You have no custom networks defined'


const networkRows = []

networks.forEach((network, index) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to keep this kind of logic outside of the render function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're saying just throw it in a different method of the same class?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, render functions are ideally just template expressions. All of the generation of children are best abstracted out to their own methods for easy testing and clear understanding of their functionality.

@@ -0,0 +1,2 @@
import CustomNetworkList from './CustomNetworkList'
export default CustomNetworkList

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

<div>
<TabBar
style={ {
position: 'absolute',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be moved to a stylesheet?

</div>
)
}
import { connect } from 'react-redux'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job here

@@ -61,7 +62,14 @@ export default class Transactions extends Component {
)
return (
// <ul style="overflow: hidden;">{listItems}</ul>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed?

<textarea readOnly style='border: 0; bottom: 0;' rows='20' cols='40' name='transactionList'>{listItems}</textarea>
<textarea
readOnly
style={ { border: 0, bottom: 0 } }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be handled in some sort of reset or moved to CSS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. I was just fixing this part so it worked. I think transactions needs a good once over in general.

@@ -1,2 +1,3 @@
**/*.html
build/*
coverage/*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that is generated by the package or your local environment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you run tests with coverage, yes

@slipo
Copy link
Collaborator Author

slipo commented Jan 17, 2018

For the sass file, I agree it shouldn't be in the repo. Removing causes builds to fail. I think it should be handled separately.

delete = (index) => {
const { deleteCustomNetwork, setNetwork, selectedNetworkId } = this.props

// If this is the current network they're using, reset to MainNet (index 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still valid?

import PropTypes from 'prop-types'

import { TabBar, Tab } from 'rmwc/Tabs'
import '@material/tabs/dist/mdc.tabs.min.css'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in progress on cleaning up some code, and I haven't needed to include the component CSS along with it. Have you tried without?

activeTabIndex={ this.state.activeTabIndex || 0 }
onChange={ evt => this.setState({ 'activeTabIndex': evt.target.value }) }
>
<Tab style={ { display: 'table-cell' } }>Networks</Tab>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use css classes for any styling we need to do. In addition table-cell isn't the best for layout, have you considered a flexbox alternative?

<textarea readOnly style='border: 0; bottom: 0;' rows='20' cols='40' name='transactionList'>{listItems}</textarea>
<textarea
readOnly
style={ { border: 0, bottom: 0 } }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put this in our stylesheet or a reset?

},
[ActionTypes.ADD_CUSTOM_NETWORK] (state, action) {
const networks = { ...state.networks }
networks[uuidv4()] = { name: action.name, url: action.url, canDelete: true }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@slipo slipo mentioned this pull request Jan 19, 2018
@slipo slipo merged commit 3171aaf into CityOfZion:development Jan 21, 2018
@slipo slipo deleted the privnet branch January 21, 2018 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants