Skip to content

Commit

Permalink
Merge pull request #264 from poanetwork/develop
Browse files Browse the repository at this point in the history
NW release 4.11.0
  • Loading branch information
vbaranov committed Feb 8, 2019
2 parents 70ed737 + 2f6a987 commit 7397335
Show file tree
Hide file tree
Showing 111 changed files with 6,654 additions and 4,773 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ workflows:
requires:
- prep-deps-npm
- prep-build
- test-e2e-firefox:
requires:
- prep-deps-npm
- prep-build
# - test-e2e-firefox:
# requires:
# - prep-deps-npm
# - prep-build
- test-unit:
requires:
- prep-deps-npm
Expand All @@ -52,7 +52,7 @@ workflows:
- test-lint
- test-unit
- test-e2e-chrome
- test-e2e-firefox
# - test-e2e-firefox
- test-integration-mascara-chrome
- test-integration-mascara-firefox
- test-integration-flat-chrome
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
key: dependency-cache-{{ .Revision }}
- run:
name: Test
command: sudo npm install -g npm@6 && npm audit
command: sudo npm install -g npm@6.4.1 && npm audit

test-e2e-chrome:
docker:
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ development/publish-release.js

app/scripts/lib/extension-instance.js
app/scripts/chromereload.js
app/vendor/**

ui/lib/blockies.js

Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@

## Current Master

## 4.11.0 Fri Feb 08 2019

### Features

- [#262](https://github.com/poanetwork/nifty-wallet/pull/262): (Feature) Add native support of Görli testnet
- [#254](https://github.com/poanetwork/nifty-wallet/pull/254): (Feature) HitBTC exchange for core POA network
- [#251](https://github.com/poanetwork/nifty-wallet/pull/251): (Feature) Delegate Proxy contract type (EIP-897)
- [#252](https://github.com/poanetwork/nifty-wallet/pull/252): (Feature) Simultaneous support of Trezor and Ledger HD wallets
- [#250](https://github.com/poanetwork/nifty-wallet/pull/250): (Feature) Support of multiple accounts from Trezor HD wallet for single session
- [#237](https://github.com/poanetwork/nifty-wallet/pull/237): (Feature) Multiple Ledger accounts for one session
- [#249](https://github.com/poanetwork/nifty-wallet/pull/249): (Feature) Textarea instead of input for array type outputs in contract calls
- [#247](https://github.com/poanetwork/nifty-wallet/pull/247): (Update) Change exchange rate API endpoint

### Fixes

- [#261](https://github.com/poanetwork/nifty-wallet/pull/261): (Fix) Clear timeout on componentWillUnmount in connect hardware screen
- [#260](https://github.com/poanetwork/nifty-wallet/pull/260): (Fix) Remove unit && integration tests for unused components
- [#258](https://github.com/poanetwork/nifty-wallet/pull/258): (Fix) ENS validation fix for Send transaction screen
- [#257](https://github.com/poanetwork/nifty-wallet/pull/257): (Fix) Replace poa.infura.io with core.poa.network in e2e
- [#248](https://github.com/poanetwork/nifty-wallet/pull/248): (Fix) validation for calling data from contract: Default `0x` value for _bytes_ field type should be set only for input fields

### Refactoring

- [#259](https://github.com/poanetwork/nifty-wallet/pull/259): (Refactoring) Refactor copy component
- [#256](https://github.com/poanetwork/nifty-wallet/pull/256): (Refactoring) Send-token component
- [#253](https://github.com/poanetwork/nifty-wallet/pull/253): (Refactoring) Refactor network props enums

## 4.10.1 Sat Dec 29 2018

- [#219](https://github.com/poanetwork/nifty-wallet/pull/219): (Feature) Multiple output fields support for contract call
Expand Down
10 changes: 9 additions & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
"version": "4.10.1",
"version": "4.11.0",
"manifest_version": 2,
"author": "POA Network",
"description": "__MSG_appDescription__",
Expand Down Expand Up @@ -52,6 +52,14 @@
],
"run_at": "document_start",
"all_frames": true
},
{
"matches": [
"*://connect.trezor.io/*/popup.html"
],
"js": [
"vendor/trezor/content-script.js"
]
}
],
"permissions": [
Expand Down
83 changes: 83 additions & 0 deletions app/scripts/controllers/cached-balances.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')

/**
* @typedef {Object} CachedBalancesOptions
* @property {Object} accountTracker An {@code AccountTracker} reference
* @property {Function} getNetwork A function to get the current network
* @property {Object} initState The initial controller state
*/

/**
* Background controller responsible for maintaining
* a cache of account balances in local storage
*/
class CachedBalancesController {
/**
* Creates a new controller instance
*
* @param {CachedBalancesOptions} [opts] Controller configuration parameters
*/
constructor (opts = {}) {
const { accountTracker, getNetwork } = opts

this.accountTracker = accountTracker
this.getNetwork = getNetwork

const initState = extend({
cachedBalances: {},
}, opts.initState)
this.store = new ObservableStore(initState)

this._registerUpdates()
}

/**
* Updates the cachedBalances property for the current network. Cached balances will be updated to those in the passed accounts
* if balances in the passed accounts are truthy.
*
* @param {Object} obj The the recently updated accounts object for the current network
* @returns {Promise<void>}
*/
async updateCachedBalances ({ accounts }) {
const network = await this.getNetwork()
const balancesToCache = await this._generateBalancesToCache(accounts, network)
this.store.updateState({
cachedBalances: balancesToCache,
})
}

_generateBalancesToCache (newAccounts, currentNetwork) {
const { cachedBalances } = this.store.getState()
const currentNetworkBalancesToCache = { ...cachedBalances[currentNetwork] }

Object.keys(newAccounts).forEach(accountID => {
const account = newAccounts[accountID]

if (account.balance) {
currentNetworkBalancesToCache[accountID] = account.balance
}
})
const balancesToCache = {
...cachedBalances,
[currentNetwork]: currentNetworkBalancesToCache,
}

return balancesToCache
}

/**
* Sets up listeners and subscriptions which should trigger an update of cached balances. These updates will
* happen when the current account changes. Which happens on block updates, as well as on network and account
* selections.
*
* @private
*
*/
_registerUpdates () {
const update = this.updateCachedBalances.bind(this)
this.accountTracker.store.subscribe(update)
}
}

module.exports = CachedBalancesController
18 changes: 4 additions & 14 deletions app/scripts/controllers/currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ class CurrencyController {
currentCoin = this.getCurrentCoin()
let conversionRate, conversionDate
if (currentCoin === 'poa') {
const coinId = await this.getCoinMarketCapId(currentCoin)
const response = await fetch(`https://api.coinmarketcap.com/v2/ticker/${coinId}/?convert=${currentCurrency.toLowerCase()}`)
const apiLink = `https://min-api.cryptocompare.com/data/price?fsym=${currentCoin.toUpperCase()}&tsyms=${currentCurrency.toUpperCase()}`
const response = await fetch(apiLink)
const parsedResponse = await response.json()
conversionRate = Number(parsedResponse.data.quotes[currentCurrency.toUpperCase()].price)
conversionDate = Number(parsedResponse.metadata.timestamp)
conversionRate = Number(parsedResponse[currentCurrency.toUpperCase()])
conversionDate = parseInt((new Date()).getTime() / 1000)
} else {
const response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`)
const parsedResponse = await response.json()
Expand Down Expand Up @@ -166,16 +166,6 @@ class CurrencyController {
}, POLLING_INTERVAL)
}

async getCoinMarketCapId (symbol) {
const response = await fetch(`https://api.coinmarketcap.com/v2/listings/`)
const parsedResponse = await response.json()
const results = parsedResponse.data.filter(coin => coin.symbol === symbol.toUpperCase())
if (!results.length) {
throw new Error(`Nifty Wallet - Failed to fetch ${symbol} from coinmarketcap listings`)
}
return results[0].id
}

}

module.exports = CurrencyController
72 changes: 40 additions & 32 deletions app/scripts/controllers/network/enums.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,72 @@
const POA = 'poa'
const DAI = 'dai'
const POA_SOKOL = 'sokol'
const MAINNET = 'mainnet'
const ROPSTEN = 'ropsten'
const RINKEBY = 'rinkeby'
const KOVAN = 'kovan'
const MAINNET = 'mainnet'
const POA_SOKOL = 'sokol'
const POA = 'poa'
const DAI = 'dai'
const GOERLI_TESTNET = 'goerli_testnet'
const LOCALHOST = 'localhost'

const POA_CODE = 99
const DAI_CODE = 100
const POA_SOKOL_CODE = 77
const MAINNET_CODE = 1
const ROPSTEN_CODE = 3
const RINKEYBY_CODE = 4
const RINKEBY_CODE = 4
const KOVAN_CODE = 42
const POA_SOKOL_CODE = 77
const POA_CODE = 99
const DAI_CODE = 100
const GOERLI_TESTNET_CODE = 5

const ROPSTEN_DISPLAY_NAME = 'Ropsten'
const RINKEBY_DISPLAY_NAME = 'Rinkeby'
const KOVAN_DISPLAY_NAME = 'Kovan'
const POA_SOKOL_DISPLAY_NAME = 'Sokol'
const POA_DISPLAY_NAME = 'POA Network'
const DAI_DISPLAY_NAME = 'xDai Chain'
const POA_SOKOL_DISPLAY_NAME = 'Sokol'
const MAINNET_DISPLAY_NAME = 'Main Ethereum Network'
const ROPSTEN_DISPLAY_NAME = 'Ropsten'
const RINKEBY_DISPLAY_NAME = 'Rinkeby'
const KOVAN_DISPLAY_NAME = 'Kovan'
const GOERLI_TESTNET_DISPLAY_NAME = 'Görli Testnet'

const DROPDOWN_ROPSTEN_DISPLAY_NAME = 'Ropsten Test Net'
const DROPDOWN_RINKEBY_DISPLAY_NAME = 'Rinkeby Test Net'
const DROPDOWN_KOVAN_DISPLAY_NAME = 'Kovan Test Net'
const DROPDOWN_POA_SOKOL_DISPLAY_NAME = 'Sokol Network'
const DROPDOWN_POA_DISPLAY_NAME = POA_DISPLAY_NAME
const DROPDOWN_DAI_DISPLAY_NAME = DAI_DISPLAY_NAME
const DROPDOWN_POA_SOKOL_DISPLAY_NAME = 'Sokol Network'
const DROPDOWN_MAINNET_DISPLAY_NAME = 'Main Network'
const DROPDOWN_ROPSTEN_DISPLAY_NAME = 'Ropsten Test Net'
const DROPDOWN_RINKEBY_DISPLAY_NAME = 'Rinkeby Test Net'
const DROPDOWN_KOVAN_DISPLAY_NAME = 'Kovan Test Net'
const DROPDOWN_GOERLI_TESTNET_DISPLAY_NAME = 'Görli Test Net'

module.exports = {
POA,
DAI,
POA_SOKOL,
MAINNET,
ROPSTEN,
RINKEBY,
KOVAN,
MAINNET,
POA_SOKOL,
POA,
DAI,
GOERLI_TESTNET,
LOCALHOST,
POA_CODE,
DAI_CODE,
POA_SOKOL_CODE,
MAINNET_CODE,
ROPSTEN_CODE,
RINKEYBY_CODE,
RINKEBY_CODE,
KOVAN_CODE,
POA_SOKOL_CODE,
POA_CODE,
DAI_CODE,
GOERLI_TESTNET_CODE,
POA_DISPLAY_NAME,
DAI_DISPLAY_NAME,
POA_SOKOL_DISPLAY_NAME,
MAINNET_DISPLAY_NAME,
ROPSTEN_DISPLAY_NAME,
RINKEBY_DISPLAY_NAME,
KOVAN_DISPLAY_NAME,
MAINNET_DISPLAY_NAME,
POA_SOKOL_DISPLAY_NAME,
POA_DISPLAY_NAME,
DAI_DISPLAY_NAME,
DROPDOWN_ROPSTEN_DISPLAY_NAME,
DROPDOWN_RINKEBY_DISPLAY_NAME,
DROPDOWN_KOVAN_DISPLAY_NAME,
DROPDOWN_POA_SOKOL_DISPLAY_NAME,
GOERLI_TESTNET_DISPLAY_NAME,
DROPDOWN_POA_DISPLAY_NAME,
DROPDOWN_DAI_DISPLAY_NAME,
DROPDOWN_POA_SOKOL_DISPLAY_NAME,
DROPDOWN_MAINNET_DISPLAY_NAME,
DROPDOWN_ROPSTEN_DISPLAY_NAME,
DROPDOWN_RINKEBY_DISPLAY_NAME,
DROPDOWN_KOVAN_DISPLAY_NAME,
DROPDOWN_GOERLI_TESTNET_DISPLAY_NAME,
}
25 changes: 18 additions & 7 deletions app/scripts/controllers/network/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const createInfuraClient = require('./createInfuraClient')
const createJsonRpcClient = require('./createJsonRpcClient')
const createLocalhostClient = require('./createLocalhostClient')
const { createSwappableProxy, createEventEmitterProxy } = require('swappable-obj-proxy')
const ethNetProps = require('eth-net-props')

const {
ROPSTEN,
Expand All @@ -21,10 +22,12 @@ const {
POA_SOKOL,
POA,
DAI,
GOERLI_TESTNET,
POA_CODE,
DAI_CODE,
POA_SOKOL_CODE,
GOERLI_TESTNET_CODE,
} = require('./enums')
const POA_RPC_URL = 'https://core.poa.network'
const DAI_RPC_URL = 'https://dai.poa.network'
const SOKOL_RPC_URL = 'https://sokol.poa.network'
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET]

const env = process.env.METAMASK_ENV
Expand Down Expand Up @@ -109,7 +112,13 @@ module.exports = class NetworkController extends EventEmitter {

async setProviderType (type) {
assert.notEqual(type, 'rpc', `NetworkController - cannot call "setProviderType" with type 'rpc'. use "setRpcTarget"`)
assert(INFURA_PROVIDER_TYPES.includes(type) || type === LOCALHOST || type === POA_SOKOL || type === POA || type === DAI, `NetworkController - Unknown rpc type "${type}"`)
assert(INFURA_PROVIDER_TYPES.includes(type) ||
type === LOCALHOST ||
type === POA_SOKOL ||
type === POA ||
type === DAI ||
type === GOERLI_TESTNET
, `NetworkController - Unknown rpc type "${type}"`)
const providerConfig = { type }
this.providerConfig = providerConfig
}
Expand Down Expand Up @@ -145,11 +154,13 @@ module.exports = class NetworkController extends EventEmitter {
this._configureInfuraProvider(opts)
// other type-based rpc endpoints
} else if (type === POA) {
this._configureStandardProvider({ rpcUrl: POA_RPC_URL })
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(POA_CODE)[0] })
} else if (type === DAI) {
this._configureStandardProvider({ rpcUrl: DAI_RPC_URL })
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(DAI_CODE)[0] })
} else if (type === POA_SOKOL) {
this._configureStandardProvider({ rpcUrl: SOKOL_RPC_URL })
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(POA_SOKOL_CODE)[0] })
} else if (type === GOERLI_TESTNET) {
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(GOERLI_TESTNET_CODE)[0] })
} else if (type === LOCALHOST) {
this._configureLocalhostProvider()
// url-based rpc endpoints
Expand Down
Loading

0 comments on commit 7397335

Please sign in to comment.