Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into master-sync
Browse files Browse the repository at this point in the history
* origin/develop:
  Fix SimpleDropdown event bubbling (#7627)
  Remove unneeded store connections (#7625)
  Replace wild random number key with index (#7629)
  Use ES6 exports for selectors (#7626)
  Fix a typo made comparing previous prop (#7628)
  Connect distinct accounts per site (#7004)
  eslint: Enable more react/jsx-* rules (#7592)
  Enable react/no-unused-state rule for ESLint (#7609)
  Enable no-var rule for ESLint (#7590)
  Process URL fragment for ens-ipfs redirects (#7604)
  add locale fix script (#7580)
  Prevent redux state mutation (#7598)
  • Loading branch information
Gudahtt committed Dec 3, 2019
2 parents 1110287 + 4ec92ce commit dfb63ee
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 161 deletions.
16 changes: 8 additions & 8 deletions app/scripts/lib/ens-ipfs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ function setupEnsIpfsResolver ({ provider }) {
}
// parse ens name
const urlData = urlUtil.parse(url)
const { hostname: name, path, search } = urlData
const { hostname: name, path, search, hash: fragment } = urlData
const domainParts = name.split('.')
const topLevelDomain = domainParts[domainParts.length - 1]
// if unsupported TLD, abort
if (!supportedTopLevelDomains.includes(topLevelDomain)) {
return
}
// otherwise attempt resolve
attemptResolve({ tabId, name, path, search })
attemptResolve({ tabId, name, path, search, fragment })
}

async function attemptResolve ({ tabId, name, path, search }) {
async function attemptResolve ({ tabId, name, path, search, fragment }) {
extension.tabs.update(tabId, { url: `loading.html` })
let url = `https://manager.ens.domains/name/${name}`
let url = `https://app.ens.domains/name/${name}`
try {
const {type, hash} = await resolveEnsToIpfsContentId({ provider, name })
if (type === 'ipfs-ns') {
const resolvedUrl = `https://gateway.ipfs.io/ipfs/${hash}${path}${search || ''}`
const resolvedUrl = `https://gateway.ipfs.io/ipfs/${hash}${path}${search || ''}${fragment || ''}`
try {
// check if ipfs gateway has result
const response = await fetch(resolvedUrl, { method: 'HEAD' })
Expand All @@ -56,11 +56,11 @@ function setupEnsIpfsResolver ({ provider }) {
console.warn(err)
}
} else if (type === 'swarm-ns') {
url = `https://swarm-gateways.net/bzz:/${hash}${path}${search || ''}`
url = `https://swarm-gateways.net/bzz:/${hash}${path}${search || ''}${fragment || ''}`
} else if (type === 'onion' || type === 'onion3') {
url = `http://${hash}.onion${path}${search || ''}`
url = `http://${hash}.onion${path}${search || ''}${fragment || ''}`
} else if (type === 'zeronet') {
url = `http://127.0.0.1:43110/${hash}${path}${search || ''}`
url = `http://127.0.0.1:43110/${hash}${path}${search || ''}${fragment || ''}`
}
} catch (err) {
console.warn(err)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/ui/app/selectors.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert')
const selectors = require('../../../../ui/app/selectors/selectors')
import * as selectors from '../../../../ui/app/selectors/selectors'
const mockState = require('../../../data/mock-state.json')
const Eth = require('ethjs')

Expand Down
3 changes: 1 addition & 2 deletions ui/app/components/app/account-menu/account-menu.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default class AccountMenu extends PureComponent {
history: PropTypes.object,
identities: PropTypes.object,
isAccountMenuOpen: PropTypes.bool,
prevIsAccountMenuOpen: PropTypes.bool,
keyrings: PropTypes.array,
lockMetamask: PropTypes.func,
selectedAddress: PropTypes.string,
Expand All @@ -45,7 +44,7 @@ export default class AccountMenu extends PureComponent {
}

componentDidUpdate (prevProps) {
const { prevIsAccountMenuOpen } = prevProps
const { isAccountMenuOpen: prevIsAccountMenuOpen } = prevProps
const { isAccountMenuOpen } = this.props

if (!prevIsAccountMenuOpen && isAccountMenuOpen) {
Expand Down
4 changes: 2 additions & 2 deletions ui/app/components/app/account-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ AccountPanel.prototype.render = function () {
<span className="font-small">{panelState.identiconLabel.substring(0, 7) + '...'}</span>
</div>
<div className="identity-data flex-column flex-justify-center flex-grow select-none">
{panelState.attributes.map((attr) => (
<div className="flex-row flex-space-between" key={'' + Math.round(Math.random() * 1000000)}>
{panelState.attributes.map((attr, index) => (
<div className="flex-row flex-space-between" key={index}>
<label className="font-small no-select">{attr.key}</label>
<span className="font-small">{attr.value}</span>
</div>
Expand Down
3 changes: 2 additions & 1 deletion ui/app/components/app/dropdowns/simple-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class SimpleDropdown extends Component {
'simple-dropdown__option--selected': option.value === selectedOption,
})}
key={option.value}
onClick={() => {
onClick={(event) => {
event.stopPropagation()
if (option.value !== selectedOption) {
onSelect(option.value)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { connect } from 'react-redux'
import SelectedAccount from './selected-account.component'

const selectors = require('../../../selectors/selectors')
const { getSelectedAddress, getSelectedIdentity } = require('../../../selectors/selectors')

const mapStateToProps = state => {
return {
selectedAddress: selectors.getSelectedAddress(state),
selectedIdentity: selectors.getSelectedIdentity(state),
selectedAddress: getSelectedAddress(state),
selectedIdentity: getSelectedIdentity(state),
network: state.metamask.network,
}
}
Expand Down
4 changes: 2 additions & 2 deletions ui/app/components/app/token-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import TokenCell from './token-cell'
const inherits = require('util').inherits
const TokenTracker = require('eth-token-tracker')
const connect = require('react-redux').connect
const selectors = require('../../selectors/selectors')
const { getSelectedAddress } = require('../../selectors/selectors')
const log = require('loglevel')

function mapStateToProps (state) {
return {
network: state.metamask.network,
tokens: state.metamask.tokens,
userAddress: selectors.getSelectedAddress(state),
userAddress: getSelectedAddress(state),
assetImages: state.metamask.assetImages,
}
}
Expand Down
8 changes: 4 additions & 4 deletions ui/app/components/app/wallet-view/wallet-view.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { withRouter } from 'react-router-dom'
import { compose } from 'recompose'
import WalletView from './wallet-view.component'
import {showSendPage, hideSidebar, setSelectedToken, showAddTokenPage} from '../../../store/actions'
import * as selectors from '../../../selectors/selectors'
import { getMetaMaskAccounts, getSelectedAddress, getSelectedAccount } from '../../../selectors/selectors'

function mapStateToProps (state) {
return {
network: state.metamask.network,
sidebarOpen: state.appState.sidebar.isOpen,
identities: state.metamask.identities,
accounts: selectors.getMetaMaskAccounts(state),
accounts: getMetaMaskAccounts(state),
keyrings: state.metamask.keyrings,
selectedAddress: selectors.getSelectedAddress(state),
selectedAccount: selectors.getSelectedAccount(state),
selectedAddress: getSelectedAddress(state),
selectedAccount: getSelectedAccount(state),
selectedTokenAddress: state.metamask.selectedTokenAddress,
}
}
Expand Down
3 changes: 1 addition & 2 deletions ui/app/components/ui/copyButton.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'

const copyToClipboard = require('copy-to-clipboard')
const Tooltip = require('./tooltip')
Expand Down Expand Up @@ -63,4 +62,4 @@ class CopyButton extends Component {
}
}

module.exports = connect()(CopyButton)
module.exports = CopyButton
4 changes: 2 additions & 2 deletions ui/app/components/ui/token-balance/token-balance.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { connect } from 'react-redux'
import { compose } from 'recompose'
import withTokenTracker from '../../../helpers/higher-order-components/with-token-tracker'
import TokenBalance from './token-balance.component'
import selectors from '../../../selectors/selectors'
import { getSelectedAddress } from '../../../selectors/selectors'

const mapStateToProps = state => {
return {
userAddress: selectors.getSelectedAddress(state),
userAddress: getSelectedAddress(state),
}
}

Expand Down
4 changes: 3 additions & 1 deletion ui/app/ducks/metamask/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ function reduceMetamask (state, action) {
let { selectedAddressTxList } = metamaskState
selectedAddressTxList = selectedAddressTxList.map(tx => {
if (tx.id === txId) {
tx.txParams = value
const newTx = Object.assign({}, tx)
newTx.txParams = value
return newTx
}
return tx
})
Expand Down
3 changes: 1 addition & 2 deletions ui/app/pages/create-account/import-account/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component } from 'react'
const inherits = require('util').inherits
const PropTypes = require('prop-types')
const connect = require('react-redux').connect
import Select from 'react-select'

// Subviews
Expand All @@ -13,7 +12,7 @@ AccountImportSubview.contextTypes = {
t: PropTypes.func,
}

module.exports = connect()(AccountImportSubview)
module.exports = AccountImportSubview


inherits(AccountImportSubview, Component)
Expand Down
Loading

0 comments on commit dfb63ee

Please sign in to comment.