Skip to content

Commit

Permalink
Merge pull request #395 from poanetwork/develop
Browse files Browse the repository at this point in the history
NW release 5.1.1
  • Loading branch information
vbaranov committed Jun 15, 2020
2 parents cb1169a + db7543d commit 7f46b1c
Show file tree
Hide file tree
Showing 47 changed files with 2,565 additions and 1,546 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

## Current Master

## 5.1.1 Mon Jun 15 2020

- [#393](https://github.com/poanetwork/nifty-wallet/pull/393) - (Feature) "Send all" option for tokens transfer
- [#391](https://github.com/poanetwork/nifty-wallet/pull/391) - (Feature) Gas price oracles npm package integration
- [#389](https://github.com/poanetwork/nifty-wallet/pull/389) - (Feature) Support 24 words mnemonic phrase
- [#388](https://github.com/poanetwork/nifty-wallet/pull/388) - (Feature) "Send all" option for simple coin transfers
- [#385](https://github.com/poanetwork/nifty-wallet/pull/385) - (Feature) Display value of current pending tx's nonce on send tx screen
- [#384](https://github.com/poanetwork/nifty-wallet/pull/384) - (Fix) placement of HW Connect button title
- [#383](https://github.com/poanetwork/nifty-wallet/pull/383) - (Chore) Replace POA-ETH Binance link to POA-BTC
- [#382](https://github.com/poanetwork/nifty-wallet/pull/382) - (Fix) replace vulnerable npm dependencies with newer versions of packages, update chromedriver to match the latest Google Chrome release
- [#381](https://github.com/poanetwork/nifty-wallet/pull/381) - (Feature) Add RNS integration
- [#381](https://github.com/poanetwork/nifty-wallet/pull/381) - (Fix) ENS/RNS integration when sending tokens

## 5.1.0 Tue May 12 2020

- [#356](https://github.com/poanetwork/nifty-wallet/pull/356) - (Backwards-compatibility feature) Custom derivation paths and access to funds in accounts derived from ETH dPath
Expand Down
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@
"ensNameNotFound": {
"message": "ENS name not found"
},
"rnsNameNotFound": {
"message": "RNS name not found"
},
"enterPassword": {
"message": "Enter password"
},
Expand Down
3 changes: 3 additions & 0 deletions app/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@
"ensNameNotFound": {
"message": "Nom ENS inconnu"
},
"rnsNameNotFound": {
"message": "Nom RNS inconnu"
},
"enterPassword": {
"message": "Entrez votre mot de passe"
},
Expand Down
3 changes: 3 additions & 0 deletions app/_locales/ht/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@
"ensNameNotFound": {
"message": "Nou pa jwenn non ENS ou a"
},
"rnsNameNotFound": {
"message": "Nou pa jwenn non RNS ou a"
},
"enterPassword": {
"message": "Mete modpas"
},
Expand Down
3 changes: 3 additions & 0 deletions app/_locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@
"ensNameNotFound": {
"message": "Nome ENS non trovato"
},
"rnsNameNotFound": {
"message": "Nome RNS non trovato"
},
"enterPassword": {
"message": "Inserisci password"
},
Expand Down
3 changes: 3 additions & 0 deletions app/_locales/ko/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@
"ensNameNotFound": {
"message": "ENS 이름을 찾을 수 없습니다"
},
"rnsNameNotFound": {
"message": "RNS 이름을 찾을 수 없습니다"
},
"enterPassword": {
"message": "비밀번호를 입력해주세요"
},
Expand Down
3 changes: 3 additions & 0 deletions app/_locales/pl/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@
"ensNameNotFound": {
"message": "Nie znaleziono nazwy ENS"
},
"rnsNameNotFound": {
"message": "Nie znaleziono nazwy RNS"
},
"enterPassword": {
"message": "Wpisz hasło"
},
Expand Down
2 changes: 1 addition & 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": "5.1.0",
"version": "5.1.1",
"manifest_version": 2,
"author": "POA Network",
"description": "__MSG_appDescription__",
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import abiDecoder from 'abi-decoder'
abiDecoder.addABI(abi)

import TransactionStateManager from './tx-state-manager'
const TxGasUtil = require('./tx-gas-utils')
import TxGasUtil from './tx-gas-utils'
const PendingTransactionTracker = require('./pending-tx-tracker')
import NonceTracker from 'nonce-tracker'
import * as txUtils from './lib/util'
Expand Down
52 changes: 29 additions & 23 deletions app/scripts/controllers/transactions/tx-gas-utils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
const EthQuery = require('ethjs-query')
const {
hexToBn,
BnMultiplyByFraction,
bnToHex,
} = require('../../lib/util')
const { addHexPrefix } = require('ethereumjs-util')
const SIMPLE_GAS_COST = '0x5208' // Hex for 21000, cost of a simple send.
import EthQuery from 'ethjs-query'
import { hexToBn, BnMultiplyByFraction, bnToHex } from '../../lib/util'
import { addHexPrefix } from 'ethereumjs-util'
import { MIN_GAS_LIMIT_HEX } from '../../../../ui/app/components/send/send.constants'
import log from 'loglevel'

/**
tx-gas-utils are gas utility methods for Transaction manager
Expand All @@ -14,24 +11,31 @@ and used to do things like calculate gas of a tx.
@param {Object} provider - A network provider.
*/

class TxGasUtil {
export default class TxGasUtil {

constructor (provider) {
this.query = new EthQuery(provider)
}

/**
@param txMeta {Object} - the txMeta object
@returns {object} the txMeta object with the gas written to the txParams
@param {Object} txMeta - the txMeta object
@returns {GasAnalysisResult} The result of the gas analysis
*/
async analyzeGasUsage (txMeta) {
const block = await this.query.getBlockByNumber('latest', false)
let estimatedGasHex

// fallback to block gasLimit
const blockGasLimitBN = hexToBn(block.gasLimit)
const saferGasLimitBN = BnMultiplyByFraction(blockGasLimitBN, 19, 20)
let estimatedGasHex = bnToHex(saferGasLimitBN)
try {
estimatedGasHex = await this.estimateTxGas(txMeta, block.gasLimit)
} catch (err) {
} catch (error) {
log.warn(error)
txMeta.simulationFails = {
reason: err.message,
reason: error.message,
errorKey: error.errorKey,
debug: { blockNumber: block.number, blockGasLimit: block.gasLimit },
}
return txMeta
}
Expand Down Expand Up @@ -63,9 +67,9 @@ class TxGasUtil {
if (recipient) code = await this.query.getCode(recipient)

if (hasRecipient && (!code || code === '0x' || code === '0x0')) {
txParams.gas = SIMPLE_GAS_COST
txParams.gas = MIN_GAS_LIMIT_HEX
txMeta.simpleSend = true // Prevents buffer addition
return SIMPLE_GAS_COST
return MIN_GAS_LIMIT_HEX
}

// if not, fall back to block gasLimit
Expand Down Expand Up @@ -103,9 +107,9 @@ class TxGasUtil {
/**
Adds a gas buffer with out exceeding the block gas limit
@param initialGasLimitHex {string} - the initial gas limit to add the buffer too
@param blockGasLimitHex {string} - the block gas limit
@returns {string} the buffered gas limit as a hex string
@param {string} initialGasLimitHex - the initial gas limit to add the buffer too
@param {string} blockGasLimitHex - the block gas limit
@returns {string} - the buffered gas limit as a hex string
*/
addGasBuffer (initialGasLimitHex, blockGasLimitHex) {
const initialGasLimitBn = hexToBn(initialGasLimitHex)
Expand All @@ -114,12 +118,14 @@ class TxGasUtil {
const bufferedGasLimitBn = initialGasLimitBn.muln(1.5)

// if initialGasLimit is above blockGasLimit, dont modify it
if (initialGasLimitBn.gt(upperGasLimitBn)) return bnToHex(initialGasLimitBn)
if (initialGasLimitBn.gt(upperGasLimitBn)) {
return bnToHex(initialGasLimitBn)
}
// if bufferedGasLimit is below blockGasLimit, use bufferedGasLimit
if (bufferedGasLimitBn.lt(upperGasLimitBn)) return bnToHex(bufferedGasLimitBn)
if (bufferedGasLimitBn.lt(upperGasLimitBn)) {
return bnToHex(bufferedGasLimitBn)
}
// otherwise use blockGasLimit
return bnToHex(upperGasLimitBn)
}
}

module.exports = TxGasUtil
2 changes: 1 addition & 1 deletion app/scripts/lib/buy-eth-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function getExchanges ({network, amount, address}) {
return [
{
name: 'Binance',
link: 'https://www.binance.com/en/trade/POA_ETH',
link: 'https://www.binance.com/en/trade/POA_BTC',
},
{
name: 'BiBox',
Expand Down
36 changes: 22 additions & 14 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import nanoid from 'nanoid'
const { importTypes } = require('../../old-ui/app/accounts/import/enums')
const { LEDGER, TREZOR } = require('../../old-ui/app/components/connect-hardware/enum')
const { ifPOA, ifRSK, getNetworkID, getDPath, setDPath } = require('../../old-ui/app/util')
const { GasPriceOracle } = require('gas-price-oracle')

import {
PhishingController,
Expand Down Expand Up @@ -443,7 +444,8 @@ module.exports = class MetamaskController extends EventEmitter {
setDProvider: this.setDProvider.bind(this),
markPasswordForgotten: this.markPasswordForgotten.bind(this),
unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this),
getGasPrice: (cb) => cb(null, this.getGasPrice()),
getGasPrice: nodeify(this.getGasPrice, this),
getPendingNonce: nodeify(this.getPendingNonce, this),

// shapeshift
createShapeShiftTx: this.createShapeShiftTx.bind(this),
Expand Down Expand Up @@ -1869,10 +1871,9 @@ module.exports = class MetamaskController extends EventEmitter {
* @returns {string} A hex representation of the suggested wei gas price.
*/
async getGasPrice () {
return new Promise(async (resolve, reject) => {
return new Promise(async (resolve) => {
const { networkController } = this


const networkIdStr = networkController.store.getState().network
const networkId = parseInt(networkIdStr)
const isETHC = networkId === CLASSIC_CODE || networkId === MAINNET_CODE
Expand Down Expand Up @@ -1967,23 +1968,30 @@ module.exports = class MetamaskController extends EventEmitter {
*/
getGasPriceFromOracles (networkId) {
return new Promise(async (resolve, reject) => {
const gasPriceOracleETC = 'https://gasprice-etc.poa.network'
const gasPriceOracleETH = 'https://gasprice.poa.network'
const gasPriceOracle = networkId === CLASSIC_CODE ?
gasPriceOracleETC : networkId === MAINNET_CODE ? gasPriceOracleETH : null

try {
if (gasPriceOracle) {
const response = await fetch(gasPriceOracle)
if (networkId === MAINNET_CODE) {
const oracle = new GasPriceOracle()
// optional fallbackGasPrices
const fallbackGasPrices = {
instant: 70, fast: 31, standard: 20, low: 7,
}
oracle.gasPrices(fallbackGasPrices).then((gasPrices) => {
gasPrices && (gasPrices.standard || gasPrices.fast) ? resolve(gasPrices.standard || gasPrices.fast) : reject()
})
} else if (networkId === CLASSIC_CODE) {
const gasPriceOracleETC = 'https://gasprice-etc.poa.network'
try {
const response = await fetch(gasPriceOracleETC)
const parsedResponse = await response.json()
if (parsedResponse && (parsedResponse.standard || parsedResponse.fast)) {
resolve(parsedResponse.standard || parsedResponse.fast)
} else {
reject()
reject('Empty response from gas price oracle')
}
} catch (error) {
reject(error)
}
} catch (error) {
reject(error)
} else {
reject(`No gas price oracles for ${networkId}`)
}
})
}
Expand Down
3 changes: 2 additions & 1 deletion mascara/src/app/first-time/confirm-seed-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class ConfirmSeedScreen extends Component {
}
}

componentWillMount () {
// eslint-disable-next-line camelcase
UNSAFE_componentWillMount () {
const { seedWords, history } = this.props

if (!seedWords) {
Expand Down
3 changes: 2 additions & 1 deletion mascara/src/app/first-time/create-password-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class CreatePasswordScreen extends Component {
this.animationEventEmitter = new EventEmitter()
}

componentWillMount () {
// eslint-disable-next-line camelcase
UNSAFE_componentWillMount () {
const { isInitialized, history } = this.props

if (isInitialized) {
Expand Down
3 changes: 2 additions & 1 deletion mascara/src/app/first-time/import-seed-phrase-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class ImportSeedPhraseScreen extends Component {
let seedPhraseError = null

if (seedPhrase) {
if (this.parseSeedPhrase(seedPhrase).split(' ').length !== 12) {
const wordsCount = this.parseSeedPhrase(seedPhrase).split(' ').length
if (wordsCount !== 12 && wordsCount !== 24) {
seedPhraseError = this.context.t('seedPhraseReq')
} else if (!validateMnemonic(seedPhrase)) {
seedPhraseError = this.context.t('invalidSeedPhrase')
Expand Down
3 changes: 2 additions & 1 deletion mascara/src/app/first-time/seed-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class BackupPhraseScreen extends Component {
}
}

componentWillMount () {
// eslint-disable-next-line camelcase
UNSAFE_componentWillMount () {
const { seedWords, history } = this.props

if (!seedWords) {
Expand Down
3 changes: 2 additions & 1 deletion mascara/src/app/shapeshift-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export class ShapeShiftForm extends Component {
isLoading: false,
};

componentWillMount () {
// eslint-disable-next-line camelcase
UNSAFE_componentWillMount () {
this.props.shapeShiftSubview()
}

Expand Down
2 changes: 1 addition & 1 deletion old-ui/app/add-suggested-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ AddSuggestedTokenScreen.prototype.render = function () {
)
}

AddSuggestedTokenScreen.prototype.componentWillMount = function () {
AddSuggestedTokenScreen.prototype.UNSAFE_componentWillMount = function () {
if (typeof global.ethereumProvider === 'undefined') return
}

Expand Down
3 changes: 2 additions & 1 deletion old-ui/app/components/add-token/add-token.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ export default class AddTokenScreen extends Component {
])
}

componentWillMount () {
// eslint-disable-next-line camelcase
UNSAFE_componentWillMount () {
if (typeof global.ethereumProvider === 'undefined') return

this.eth = new Eth(global.ethereumProvider)
Expand Down
Loading

0 comments on commit 7f46b1c

Please sign in to comment.