mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #8186 from MetaMask/Version-v7.7.8
Version v7.7.8 RC
This commit is contained in:
parent
0b54b99087
commit
a7bcc17f9b
@ -2,6 +2,10 @@
|
||||
|
||||
## Current Develop Branch
|
||||
|
||||
## 7.7.8 Wed Mar 11 2020
|
||||
- [#8176](https://github.com/MetaMask/metamask-extension/pull/8176): Handle and set gas estimation when max mode is clicked
|
||||
- [#8178](https://github.com/MetaMask/metamask-extension/pull/8178): Use specified gas limit when speeding up a transaction
|
||||
|
||||
## 7.7.7 Wed Mar 04 2020
|
||||
- [#8162](https://github.com/MetaMask/metamask-extension/pull/8162): Remove invalid Ledger accounts
|
||||
- [#8163](https://github.com/MetaMask/metamask-extension/pull/8163): Fix account index check
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "__MSG_appName__",
|
||||
"short_name": "__MSG_appName__",
|
||||
"version": "7.7.7",
|
||||
"version": "7.7.8",
|
||||
"manifest_version": 2,
|
||||
"author": "https://metamask.io",
|
||||
"description": "__MSG_appDescription__",
|
||||
|
@ -312,7 +312,17 @@ class TransactionController extends EventEmitter {
|
||||
return newTxMeta
|
||||
}
|
||||
|
||||
async createSpeedUpTransaction (originalTxId, customGasPrice) {
|
||||
/**
|
||||
* Creates a new approved transaction to attempt to speed up a previously submitted transaction. The
|
||||
* new transaction contains the same nonce as the previous. By default, the new transaction will use
|
||||
* the same gas limit and a 10% higher gas price, though it is possible to set a custom value for
|
||||
* each instead.
|
||||
* @param {number} originalTxId - the id of the txMeta that you want to speed up
|
||||
* @param {string} [customGasPrice] - The new custom gas price, in hex
|
||||
* @param {string} [customGasLimit] - The new custom gas limt, in hex
|
||||
* @returns {txMeta}
|
||||
*/
|
||||
async createSpeedUpTransaction (originalTxId, customGasPrice, customGasLimit) {
|
||||
const originalTxMeta = this.txStateManager.getTx(originalTxId)
|
||||
const { txParams } = originalTxMeta
|
||||
const { gasPrice: lastGasPrice } = txParams
|
||||
@ -330,6 +340,10 @@ class TransactionController extends EventEmitter {
|
||||
type: TRANSACTION_TYPE_RETRY,
|
||||
})
|
||||
|
||||
if (customGasLimit) {
|
||||
newTxMeta.txParams.gas = customGasLimit
|
||||
}
|
||||
|
||||
this.addTx(newTxMeta)
|
||||
await this.approveTransaction(newTxMeta.id)
|
||||
return newTxMeta
|
||||
|
@ -1286,8 +1286,8 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
async createSpeedUpTransaction (originalTxId, customGasPrice) {
|
||||
await this.txController.createSpeedUpTransaction(originalTxId, customGasPrice)
|
||||
async createSpeedUpTransaction (originalTxId, customGasPrice, customGasLimit) {
|
||||
await this.txController.createSpeedUpTransaction(originalTxId, customGasPrice, customGasLimit)
|
||||
const state = await this.getState()
|
||||
return state
|
||||
}
|
||||
|
@ -108,9 +108,11 @@ const mapStateToProps = (state, ownProps) => {
|
||||
const isMainnet = getIsMainnet(state)
|
||||
const showFiat = Boolean(isMainnet || showFiatInTestnets)
|
||||
|
||||
const newTotalEth = maxModeOn ? addHexWEIsToRenderableEth(balance, '0x0') : addHexWEIsToRenderableEth(value, customGasTotal)
|
||||
const isTokenSelected = Boolean(getSelectedToken(state))
|
||||
|
||||
const sendAmount = maxModeOn ? subtractHexWEIsFromRenderableEth(balance, customGasTotal) : addHexWEIsToRenderableEth(value, '0x0')
|
||||
const newTotalEth = maxModeOn && !isTokenSelected ? addHexWEIsToRenderableEth(balance, '0x0') : addHexWEIsToRenderableEth(value, customGasTotal)
|
||||
|
||||
const sendAmount = maxModeOn && !isTokenSelected ? subtractHexWEIsFromRenderableEth(balance, customGasTotal) : addHexWEIsToRenderableEth(value, '0x0')
|
||||
|
||||
const insufficientBalance = maxModeOn ? false : !isBalanceSufficient({
|
||||
amount: value,
|
||||
@ -187,11 +189,11 @@ const mapDispatchToProps = dispatch => {
|
||||
dispatch(setCustomGasLimit(addHexPrefix(gasLimit.toString(16))))
|
||||
return dispatch(updateTransaction(updatedTx))
|
||||
},
|
||||
createSpeedUpTransaction: (txId, gasPrice) => {
|
||||
return dispatch(createSpeedUpTransaction(txId, gasPrice))
|
||||
createRetryTransaction: (txId, gasPrice, gasLimit) => {
|
||||
return dispatch(createRetryTransaction(txId, gasPrice, gasLimit))
|
||||
},
|
||||
createRetryTransaction: (txId, gasPrice) => {
|
||||
return dispatch(createRetryTransaction(txId, gasPrice))
|
||||
createSpeedUpTransaction: (txId, gasPrice, gasLimit) => {
|
||||
return dispatch(createSpeedUpTransaction(txId, gasPrice, gasLimit))
|
||||
},
|
||||
hideGasButtonGroup: () => dispatch(hideGasButtonGroup()),
|
||||
setCustomTimeEstimate: (timeEstimateInSeconds) => dispatch(setCustomTimeEstimate(timeEstimateInSeconds)),
|
||||
@ -253,11 +255,11 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
||||
dispatchUpdateConfirmTxGasAndCalculate(gasLimit, gasPrice, updatedTx)
|
||||
dispatchHideModal()
|
||||
} else if (isSpeedUp) {
|
||||
dispatchCreateSpeedUpTransaction(txId, gasPrice)
|
||||
dispatchCreateSpeedUpTransaction(txId, gasPrice, gasLimit)
|
||||
dispatchHideSidebar()
|
||||
dispatchCancelAndClose()
|
||||
} else if (isRetry) {
|
||||
dispatchCreateRetryTransaction(txId, gasPrice)
|
||||
dispatchCreateRetryTransaction(txId, gasPrice, gasLimit)
|
||||
dispatchHideSidebar()
|
||||
dispatchCancelAndClose()
|
||||
} else {
|
||||
|
@ -27,12 +27,26 @@ export default class SendAmountRow extends Component {
|
||||
updateSendAmount: PropTypes.func,
|
||||
updateSendAmountError: PropTypes.func,
|
||||
updateGas: PropTypes.func,
|
||||
maxModeOn: PropTypes.bool,
|
||||
}
|
||||
|
||||
static contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
componentDidUpdate (prevProps) {
|
||||
const { maxModeOn: prevMaxModeOn, gasTotal: prevGasTotal } = prevProps
|
||||
const { maxModeOn, amount, gasTotal, selectedToken } = this.props
|
||||
|
||||
if (maxModeOn && selectedToken && !prevMaxModeOn) {
|
||||
this.updateGas(amount)
|
||||
}
|
||||
|
||||
if (prevGasTotal !== gasTotal) {
|
||||
this.validateAmount(amount)
|
||||
}
|
||||
}
|
||||
|
||||
updateGas = debounce(this.updateGas.bind(this), 500)
|
||||
|
||||
validateAmount (amount) {
|
||||
@ -87,17 +101,19 @@ export default class SendAmountRow extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
handleChange = (newAmount) => {
|
||||
this.validateAmount(newAmount)
|
||||
this.updateGas(newAmount)
|
||||
this.updateAmount(newAmount)
|
||||
}
|
||||
|
||||
renderInput () {
|
||||
const { amount, inError, selectedToken } = this.props
|
||||
const Component = selectedToken ? UserPreferencedTokenInput : UserPreferencedCurrencyInput
|
||||
|
||||
return (
|
||||
<Component
|
||||
onChange={newAmount => {
|
||||
this.validateAmount(newAmount)
|
||||
this.updateGas(newAmount)
|
||||
this.updateAmount(newAmount)
|
||||
}}
|
||||
onChange={this.handleChange}
|
||||
error={inError}
|
||||
value={amount}
|
||||
/>
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
getSendAmount,
|
||||
getSendFromBalance,
|
||||
getTokenBalance,
|
||||
getSendMaxModeState,
|
||||
} from '../../send.selectors'
|
||||
import {
|
||||
sendAmountIsInError,
|
||||
@ -37,6 +38,7 @@ function mapStateToProps (state) {
|
||||
primaryCurrency: getPrimaryCurrency(state),
|
||||
selectedToken: getSelectedToken(state),
|
||||
tokenBalance: getTokenBalance(state),
|
||||
maxModeOn: getSendMaxModeState(state),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ import assert from 'assert'
|
||||
import proxyquire from 'proxyquire'
|
||||
import sinon from 'sinon'
|
||||
|
||||
let mapStateToProps
|
||||
let mapDispatchToProps
|
||||
|
||||
const actionSpies = {
|
||||
@ -15,23 +14,11 @@ const duckActionSpies = {
|
||||
|
||||
proxyquire('../send-amount-row.container.js', {
|
||||
'react-redux': {
|
||||
connect: (ms, md) => {
|
||||
mapStateToProps = ms
|
||||
connect: (_, md) => {
|
||||
mapDispatchToProps = md
|
||||
return () => ({})
|
||||
},
|
||||
},
|
||||
'../../send.selectors': {
|
||||
getAmountConversionRate: (s) => `mockAmountConversionRate:${s}`,
|
||||
getConversionRate: (s) => `mockConversionRate:${s}`,
|
||||
getCurrentCurrency: (s) => `mockConvertedCurrency:${s}`,
|
||||
getGasTotal: (s) => `mockGasTotal:${s}`,
|
||||
getPrimaryCurrency: (s) => `mockPrimaryCurrency:${s}`,
|
||||
getSelectedToken: (s) => `mockSelectedToken:${s}`,
|
||||
getSendAmount: (s) => `mockAmount:${s}`,
|
||||
getSendFromBalance: (s) => `mockBalance:${s}`,
|
||||
getTokenBalance: (s) => `mockTokenBalance:${s}`,
|
||||
},
|
||||
'./send-amount-row.selectors': { sendAmountIsInError: (s) => `mockInError:${s}` },
|
||||
'../../send.utils': {
|
||||
getAmountErrorObject: (mockDataObject) => ({ ...mockDataObject, mockChange: true }),
|
||||
@ -43,25 +30,6 @@ proxyquire('../send-amount-row.container.js', {
|
||||
|
||||
describe('send-amount-row container', () => {
|
||||
|
||||
describe('mapStateToProps()', () => {
|
||||
|
||||
it('should map the correct properties to props', () => {
|
||||
assert.deepEqual(mapStateToProps('mockState'), {
|
||||
amount: 'mockAmount:mockState',
|
||||
amountConversionRate: 'mockAmountConversionRate:mockState',
|
||||
balance: 'mockBalance:mockState',
|
||||
conversionRate: 'mockConversionRate:mockState',
|
||||
convertedCurrency: 'mockConvertedCurrency:mockState',
|
||||
gasTotal: 'mockGasTotal:mockState',
|
||||
inError: 'mockInError:mockState',
|
||||
primaryCurrency: 'mockPrimaryCurrency:mockState',
|
||||
selectedToken: 'mockSelectedToken:mockState',
|
||||
tokenBalance: 'mockTokenBalance:mockState',
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('mapDispatchToProps()', () => {
|
||||
let dispatchSpy
|
||||
let mapDispatchToPropsObject
|
||||
|
@ -1843,13 +1843,13 @@ function createCancelTransaction (txId, customGasPrice) {
|
||||
}
|
||||
}
|
||||
|
||||
function createSpeedUpTransaction (txId, customGasPrice) {
|
||||
function createSpeedUpTransaction (txId, customGasPrice, customGasLimit) {
|
||||
log.debug('background.createSpeedUpTransaction')
|
||||
let newTx
|
||||
|
||||
return dispatch => {
|
||||
return new Promise((resolve, reject) => {
|
||||
background.createSpeedUpTransaction(txId, customGasPrice, (err, newState) => {
|
||||
background.createSpeedUpTransaction(txId, customGasPrice, customGasLimit, (err, newState) => {
|
||||
if (err) {
|
||||
dispatch(actions.displayWarning(err.message))
|
||||
return reject(err)
|
||||
@ -1865,13 +1865,13 @@ function createSpeedUpTransaction (txId, customGasPrice) {
|
||||
}
|
||||
}
|
||||
|
||||
function createRetryTransaction (txId, customGasPrice) {
|
||||
function createRetryTransaction (txId, customGasPrice, customGasLimit) {
|
||||
log.debug('background.createRetryTransaction')
|
||||
let newTx
|
||||
|
||||
return dispatch => {
|
||||
return new Promise((resolve, reject) => {
|
||||
background.createSpeedUpTransaction(txId, customGasPrice, (err, newState) => {
|
||||
background.createSpeedUpTransaction(txId, customGasPrice, customGasLimit, (err, newState) => {
|
||||
if (err) {
|
||||
dispatch(actions.displayWarning(err.message))
|
||||
return reject(err)
|
||||
|
Loading…
Reference in New Issue
Block a user