mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
Merge pull request #2848 from MetaMask/NewUI-flat
[NewUI] Merge NewUI-flat into uat
This commit is contained in:
commit
be398500de
@ -2,8 +2,10 @@
|
||||
|
||||
## Current Master
|
||||
|
||||
- Throw an error if a application tries to submit a tx whose value is a decimal, and inform that it should be in wei.
|
||||
- Fix bug that prevented updating custom token details.
|
||||
- No longer mark long-pending transactions as failed, since we now have button to retry with higher gas.
|
||||
- Fix rounding error when specifying an ether amount that has too much precision.
|
||||
|
||||
## 3.13.3 2017-12-14
|
||||
|
||||
|
@ -178,7 +178,8 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
||||
}
|
||||
|
||||
async _checkIfNonceIsTaken (txMeta) {
|
||||
const completed = this.getCompletedTransactions()
|
||||
const address = txMeta.txParams.from
|
||||
const completed = this.getCompletedTransactions(address)
|
||||
const sameNonce = completed.filter((otherMeta) => {
|
||||
return otherMeta.txParams.nonce === txMeta.txParams.nonce
|
||||
})
|
||||
|
@ -81,8 +81,15 @@ module.exports = class txProvideUtil {
|
||||
}
|
||||
|
||||
async validateTxParams (txParams) {
|
||||
if (('value' in txParams) && txParams.value.indexOf('-') === 0) {
|
||||
if ('value' in txParams) {
|
||||
const value = txParams.value.toString()
|
||||
if (value.includes('-')) {
|
||||
throw new Error(`Invalid transaction value of ${txParams.value} not a positive number.`)
|
||||
}
|
||||
|
||||
if (value.includes('.')) {
|
||||
throw new Error(`Invalid transaction value of ${txParams.value} number must be in wei`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -571,10 +571,10 @@ button.backup-phrase__confirm-seed-option:hover {
|
||||
text-transform: uppercase;
|
||||
margin: 35px 0 14px;
|
||||
transition: 200ms ease-in-out;
|
||||
background-color: rgba(247, 134, 28, 0.9);
|
||||
}
|
||||
|
||||
button.first-time-flow__button[disabled] {
|
||||
background-color: rgba(247, 134, 28, 0.9);
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
|
@ -247,10 +247,26 @@ SendTransactionScreen.prototype.onSubmit = function () {
|
||||
const recipient = state.recipient || document.querySelector('input[name="address"]').value.replace(/^[.\s]+|[.\s]+$/g, '')
|
||||
const nickname = state.nickname || ' '
|
||||
const input = document.querySelector('input[name="amount"]').value
|
||||
const parts = input.split('')
|
||||
|
||||
let message
|
||||
|
||||
if (isNaN(input) || input === '') {
|
||||
message = 'Invalid ether value.'
|
||||
return this.props.dispatch(actions.displayWarning(message))
|
||||
}
|
||||
|
||||
if (parts[1]) {
|
||||
var decimal = parts[1]
|
||||
if (decimal.length > 18) {
|
||||
message = 'Ether amount is too precise.'
|
||||
return this.props.dispatch(actions.displayWarning(message))
|
||||
}
|
||||
}
|
||||
|
||||
const value = util.normalizeEthStringToWei(input)
|
||||
const txData = document.querySelector('input[name="txData"]').value
|
||||
const balance = this.props.balance
|
||||
let message
|
||||
|
||||
if (value.gt(balance)) {
|
||||
message = 'Insufficient funds.'
|
||||
|
@ -81,7 +81,7 @@
|
||||
"eth-hd-keyring": "^1.2.1",
|
||||
"eth-json-rpc-filters": "^1.2.4",
|
||||
"eth-json-rpc-infura": "^1.0.2",
|
||||
"eth-keyring-controller": "^2.1.2",
|
||||
"eth-keyring-controller": "^2.1.3",
|
||||
"eth-phishing-detect": "^1.1.4",
|
||||
"eth-query": "^2.1.2",
|
||||
"eth-sig-util": "^1.4.0",
|
||||
@ -102,8 +102,8 @@
|
||||
"fast-json-patch": "^2.0.4",
|
||||
"fast-levenshtein": "^2.0.6",
|
||||
"fuse.js": "^3.2.0",
|
||||
"gulp-autoprefixer": "^4.0.0",
|
||||
"gulp": "github:gulpjs/gulp#4.0",
|
||||
"gulp-autoprefixer": "^4.0.0",
|
||||
"gulp-eslint": "^4.0.0",
|
||||
"gulp-sass": "^3.1.0",
|
||||
"hat": "0.0.3",
|
||||
@ -161,8 +161,8 @@
|
||||
"request-promise": "^4.2.1",
|
||||
"sandwich-expando": "^1.1.3",
|
||||
"semaphore": "^1.0.5",
|
||||
"shallow-copy": "0.0.1",
|
||||
"semver": "^5.4.1",
|
||||
"shallow-copy": "0.0.1",
|
||||
"sw-stream": "^2.0.0",
|
||||
"textarea-caret": "^3.0.1",
|
||||
"through2": "^2.0.3",
|
||||
@ -239,7 +239,7 @@
|
||||
"testem": "^1.10.3",
|
||||
"uglifyify": "^4.0.2",
|
||||
"vinyl-buffer": "^1.0.0",
|
||||
"vinyl-source-stream": "^1.1.0",
|
||||
"vinyl-source-stream": "^2.0.0",
|
||||
"watchify": "^3.9.0"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -340,4 +340,63 @@ describe('PendingTransactionTracker', function () {
|
||||
assert.equal(pendingTxTracker.publishTransaction.callCount, 1, 'Should call publish transaction')
|
||||
})
|
||||
})
|
||||
|
||||
describe('#_checkIfNonceIsTaken', function () {
|
||||
beforeEach ( function () {
|
||||
let confirmedTxList = [{
|
||||
id: 1,
|
||||
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||
status: 'confirmed',
|
||||
txParams: {
|
||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||
nonce: '0x1',
|
||||
value: '0xfffff',
|
||||
},
|
||||
rawTx: '0xf86c808504a817c800827b0d940c62bb85faa3311a998d3aba8098c1235c564966880de0b6b3a7640000802aa08ff665feb887a25d4099e40e11f0fef93ee9608f404bd3f853dd9e84ed3317a6a02ec9d3d1d6e176d4d2593dd760e74ccac753e6a0ea0d00cc9789d0d7ff1f471d',
|
||||
}, {
|
||||
id: 2,
|
||||
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||
status: 'confirmed',
|
||||
txParams: {
|
||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||
nonce: '0x2',
|
||||
value: '0xfffff',
|
||||
},
|
||||
rawTx: '0xf86c808504a817c800827b0d940c62bb85faa3311a998d3aba8098c1235c564966880de0b6b3a7640000802aa08ff665feb887a25d4099e40e11f0fef93ee9608f404bd3f853dd9e84ed3317a6a02ec9d3d1d6e176d4d2593dd760e74ccac753e6a0ea0d00cc9789d0d7ff1f471d',
|
||||
}]
|
||||
pendingTxTracker.getCompletedTransactions = (address) => {
|
||||
if (!address) throw new Error('unless behavior has changed #_checkIfNonceIsTaken needs a filtered list of transactions to see if the nonce is taken')
|
||||
return confirmedTxList
|
||||
}
|
||||
})
|
||||
|
||||
it('should return false if nonce has not been taken', function (done) {
|
||||
pendingTxTracker._checkIfNonceIsTaken({
|
||||
txParams: {
|
||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||
nonce: '0x3',
|
||||
value: '0xfffff',
|
||||
},
|
||||
})
|
||||
.then((taken) => {
|
||||
assert.ok(!taken)
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
|
||||
it('should return true if nonce has been taken', function (done) {
|
||||
pendingTxTracker._checkIfNonceIsTaken({
|
||||
txParams: {
|
||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||
nonce: '0x2',
|
||||
value: '0xfffff',
|
||||
},
|
||||
}).then((taken) => {
|
||||
assert.ok(taken)
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -201,6 +201,18 @@ describe('util', function () {
|
||||
var output = util.normalizeEthStringToWei(input)
|
||||
assert.equal(output.toString(10), ethInWei)
|
||||
})
|
||||
|
||||
it('should account for overflow numbers gracefully by dropping extra precision.', function () {
|
||||
var input = '1.11111111111111111111'
|
||||
var output = util.normalizeEthStringToWei(input)
|
||||
assert.equal(output.toString(10), '1111111111111111111')
|
||||
})
|
||||
|
||||
it('should not truncate very exact wei values that do not have extra precision.', function () {
|
||||
var input = '1.100000000000000001'
|
||||
var output = util.normalizeEthStringToWei(input)
|
||||
assert.equal(output.toString(10), '1100000000000000001')
|
||||
})
|
||||
})
|
||||
|
||||
describe('#normalizeNumberToWei', function () {
|
||||
|
@ -360,11 +360,6 @@ App.prototype.renderPrimary = function () {
|
||||
})
|
||||
}
|
||||
|
||||
if (props.seedWords) {
|
||||
log.debug('rendering seed words')
|
||||
return h(HDCreateVaultComplete, {key: 'HDCreateVaultComplete'})
|
||||
}
|
||||
|
||||
// show initialize screen
|
||||
if (!props.isInitialized || props.forgottenPassword) {
|
||||
// show current view
|
||||
@ -389,6 +384,12 @@ App.prototype.renderPrimary = function () {
|
||||
})
|
||||
}
|
||||
|
||||
// show seed words screen
|
||||
if (props.seedWords) {
|
||||
log.debug('rendering seed words')
|
||||
return h(HDCreateVaultComplete, {key: 'HDCreateVaultComplete'})
|
||||
}
|
||||
|
||||
// show current view
|
||||
switch (props.currentView.name) {
|
||||
|
||||
|
@ -211,6 +211,9 @@ function normalizeEthStringToWei (str) {
|
||||
while (decimal.length < 18) {
|
||||
decimal += '0'
|
||||
}
|
||||
if (decimal.length > 18) {
|
||||
decimal = decimal.slice(0, 18)
|
||||
}
|
||||
const decimalBN = new ethUtil.BN(decimal, 10)
|
||||
eth = eth.add(decimalBN)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user